Rewrite instances page

Render the table in the instances page using an antd Table component
directly and feed it the data via an automatically updating list of
instances.
This commit is contained in:
Hornwitser committed 2021-06-10 10:26:40 +02:00
1 parent 0e9893fcb6
commit 82c3d27bff
4 files changed
+136 -36

No files matched your search

+8 -5
View File
@@ -154,14 +154,17 @@ export class Control extends libLink.Link {
}
async instanceUpdateEventHandler(message) {
let handlers = this.instanceUpdateHandlers.get(message.data.id);
for (let handler of handlers || []) {
let handlers = [].concat(
this.instanceUpdateHandlers.get(null) || [],
this.instanceUpdateHandlers.get(message.data.id) || [],
);
for (let handler of handlers) {
handler(message.data);
}
};
async onInstanceUpdate(id, handler) {
if (!Number.isInteger(id)) {
if (id !== null && !Number.isInteger(id)) {
throw new Error("Invalid instance id");
}
@@ -202,8 +205,8 @@ export class Control extends libLink.Link {
}
await libLink.messages.setInstanceSubscriptions.send(this, {
all: false,
instance_ids: [...this.instanceUpdateHandlers.keys()],
all: this.instanceUpdateHandlers.has(null),
instance_ids: [...this.instanceUpdateHandlers.keys()].filter(e => e !== null),
});
}