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,
|
t: Math.random() * 400 - 100,
|
||||||
alt: Math.random() * 4500000 - 200000
|
alt: Math.random() * 4500000 - 200000
|
||||||
}
|
}
|
||||||
setTimeout(() => m.redraw(), 0);
|
|
||||||
} else {
|
} else {
|
||||||
apiStatus = await m.request({
|
apiStatus = await new Promise<ApiStatus>((resolve, error) => {
|
||||||
method: "GET",
|
let request = new XMLHttpRequest();
|
||||||
url: "/api/status"
|
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() {
|
async refresh() {
|
||||||
this.status = await MonitorApi.get().fetchStatus();
|
this.status = await MonitorApi.get().fetchStatus();
|
||||||
|
// todo: update widgets (avoiding to use m.redraw which is a bit costly on CPU)
|
||||||
if(this.autoRefresh)
|
if(this.autoRefresh)
|
||||||
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ export class RawDataPage extends Page {
|
|||||||
|
|
||||||
async refresh() {
|
async refresh() {
|
||||||
this.status = await MonitorApi.get().fetchStatus();
|
this.status = await MonitorApi.get().fetchStatus();
|
||||||
|
m.redraw();
|
||||||
if(this.autoRefresh)
|
if(this.autoRefresh)
|
||||||
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user