diff options
Diffstat (limited to 'src/views/_sila/Power/Dynamic/VoltInput.vue')
-rw-r--r-- | src/views/_sila/Power/Dynamic/VoltInput.vue | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/views/_sila/Power/Dynamic/VoltInput.vue b/src/views/_sila/Power/Dynamic/VoltInput.vue index 7012f11b..794ca0d2 100644 --- a/src/views/_sila/Power/Dynamic/VoltInput.vue +++ b/src/views/_sila/Power/Dynamic/VoltInput.vue @@ -1,7 +1,7 @@ <template> <collapse id="collapse_InputVolt" - :class="{ disabledDiv: loading && opened }" + :class="{ disabledDiv: (loading || isPageLoading) && opened }" :title="$t('pagePowerSup.InputVolt')" @opened="onOpened" > @@ -55,7 +55,9 @@ variant="primary" style="height: 35px" :disabled=" - loading || $store.getters['authentication/role'] === 'ReadOnly' + loading || + isPageLoading || + $store.getters['authentication/role'] === 'ReadOnly' " @click="saveLimit" > @@ -72,6 +74,7 @@ :warning="warningLimit" :critical="criticalLimit" :max="maxLimit" + :opened="opened" ></chart> <b-table responsive="md" @@ -147,7 +150,7 @@ export default { loading, warning: null, critical: null, - isBusy: true, + isBusy: false, opened: false, fields: [ { @@ -205,6 +208,10 @@ export default { return this.$store.getters['powerSupply/limitsVol']; }, + isPageLoading() { + return this.$store.getters['powerSupply/isLoadingVol']; + }, + warningLimit() { return this.limits.find((limit) => { return ( @@ -247,6 +254,13 @@ export default { }, }, watch: { + limits() { + if (this.limits && this.limits.length > 0) { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + } + }, + timeScale() { if (!this.opened) { return; @@ -270,30 +284,47 @@ export default { .catch(({ message }) => this.errorToast(message)) .finally(() => this.endLoader()); }, + onOpened(state) { if (state) { this.loadData(); } this.opened = state; }, + loadData() { + if (this.isPageLoading) { + return; + } + let payload = { metricsName: 'psu_voltage', lastHour: false }; if (this.timeScale === 'hour') { payload.lastHour = true; } - this.$root.$emit('psu-volt-input', true); - this.startLoader(); + this.start(); this.$store.dispatch('powerSupply/getPsu', payload).finally(() => { this.$store.dispatch('powerSupply/getLimitsVol').finally(() => { this.warning = this.warningLimit; this.critical = this.criticalLimit; - this.$root.$emit('psu-volt-input', false); - this.endLoader(); - this.isBusy = false; + this.end(); }); }); }, + + start() { + this.startLoader(); + this.isBusy = true; + this.$store.commit('powerSupply/setIsLoadingVol', true); + this.$root.$emit('psu-volt-input', true); + }, + + end() { + this.endLoader(); + this.isBusy = false; + this.$store.commit('powerSupply/setIsLoadingVol', false); + this.$root.$emit('psu-volt-input', false); + }, }, }; </script> |