From 66bd37a47bcb5767455dfddb37fc4faa11b94a84 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 28 Apr 2020 10:39:09 +0200 Subject: [PATCH] Add System Control to dashboard --- modules/base/src/components/Dashboard.vue | 62 ++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/modules/base/src/components/Dashboard.vue b/modules/base/src/components/Dashboard.vue index 37bea40f..7e764c80 100644 --- a/modules/base/src/components/Dashboard.vue +++ b/modules/base/src/components/Dashboard.vue @@ -42,6 +42,10 @@ loading...

+ +

+ There are disabled subsystems. +

@@ -197,6 +201,35 @@
+

System Control

+
+
+
+
+ + + + +
+ + loading... + + + Success + : {{ controlOp.record.Message }} + + + Control Error: {{ controlOp.record.Message }} + + + + Communication Error: {{ controlOp.error }} + + +
+
+
+

Work in Progress

@@ -212,6 +245,7 @@ export default { components: {}, data() { return { + controlOp: null, StatusDead: 0, // not prepared, not started StatusPreparing: 1, StatusOffline: 2, // prepared, not started @@ -230,7 +264,7 @@ export default { }, subsystems() { var all = []; - for (const [key, record] of Object.entries(this.$parent.statusDB.records)) { + for (var [key, record] of Object.entries(this.$parent.statusDB.records)) { if (key.startsWith("core:status/subsystems/")) { all.push(record); } @@ -245,6 +279,14 @@ export default { } } return worstStatus; + }, + allSubsystemsEnabled() { + for (var subsystem of this.subsystems) { + if (!subsystem.Modules[0].Enabled) { + return false; + } + } + return true; } }, methods: { @@ -278,7 +320,24 @@ export default { return "green"; } } + }, + control(value) { + this.controlOp = this.$api.get("control:" + value); + }, + reloadUI() { + this.beforeOnUnload(); + // add an extra second, in case waiting is broken on a client + setTimeout(function(){ + location.reload(); + }, 1000); + }, + beforeOnUnload() { + this.controlOp = this.$api.get("control:module/ui/trigger/reload"); + this.controlOp.wait(); } + }, + beforeMount() { + window.addEventListener("beforeunload", this.beforeOnUnload) } }; @@ -327,6 +386,7 @@ export default { .module-msg { margin-top: 28px; color: #000; + white-space: pre-wrap; // respect \n } } .module-item.segment {