Add slave update subscriptions

Allow the web interface to listen for updates to the slave list and
apply it live to the places where slaves are shown in the web interface.
This commit is contained in:
Hornwitser committed 2021-06-02 16:19:18 +02:00
1 parent cc438574ff
commit 2be91cbd3a
12 files changed
+275 -29

No files matched your search

+18
View File
@@ -39,6 +39,11 @@ class ControlConnection extends BaseConnection {
*/
this.user = user;
this.slaveSubscriptions = {
all: false,
slave_ids: [],
};
this.instanceSubscriptions = {
all: false,
instance_ids: [],
@@ -107,6 +112,19 @@ class ControlConnection extends BaseConnection {
return { list };
}
async setSlaveSubscriptionsRequestHandler(message) {
this.slaveSubscriptions = message.data;
}
slaveUpdated(slave, update) {
if (
this.slaveSubscriptions.all
|| this.slaveSubscriptions.slave_ids.includes(slave.id)
) {
libLink.messages.slaveUpdate.send(this, update);
}
}
generateSlaveToken(slaveId) {
return jwt.sign({ aud: "slave", slave: slaveId }, this._master.config.get("master.auth_secret"));
}