disabled mithril redraw for each status request
the goal is to allow each page to finely manage how to update with minimum CPU usage
This commit is contained in:
parent
f8c2a28c47
commit
71b87437c7
@ -45,11 +45,21 @@ export class MonitorApi {
|
||||
t: Math.random() * 400 - 100,
|
||||
alt: Math.random() * 4500000 - 200000
|
||||
}
|
||||
setTimeout(() => m.redraw(), 0);
|
||||
} else {
|
||||
apiStatus = await m.request({
|
||||
method: "GET",
|
||||
url: "/api/status"
|
||||
apiStatus = await new Promise<ApiStatus>((resolve, error) => {
|
||||
let request = new XMLHttpRequest();
|
||||
request.onreadystatechange = () => {
|
||||
if(request.readyState == 4) {
|
||||
if(request.status == 200) {
|
||||
resolve(JSON.parse(request.response));
|
||||
}
|
||||
else {
|
||||
error();
|
||||
}
|
||||
}
|
||||
};
|
||||
request.open('GET', '/api/status', true);
|
||||
request.send();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ export class DashboardPage extends Page {
|
||||
|
||||
async refresh() {
|
||||
this.status = await MonitorApi.get().fetchStatus();
|
||||
// todo: update widgets (avoiding to use m.redraw which is a bit costly on CPU)
|
||||
if(this.autoRefresh)
|
||||
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ export class RawDataPage extends Page {
|
||||
|
||||
async refresh() {
|
||||
this.status = await MonitorApi.get().fetchStatus();
|
||||
m.redraw();
|
||||
if(this.autoRefresh)
|
||||
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user