diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-29 17:45:10 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-29 17:45:10 +0300 |
commit | 214d4d58742478b1e9ad3d0549568a92114179b8 (patch) | |
tree | f239785783a317ef36497356b13a07b02f3e1eac | |
parent | 10f5207c77b16b46f637f77520964c82226d27fb (diff) | |
download | webui-vue-214d4d58742478b1e9ad3d0549568a92114179b8.tar.xz |
one req for fans, dynamic
-rw-r--r-- | src/components/_sila/Mixins/LoadingBarMixin.js | 2 | ||||
-rw-r--r-- | src/store/modules/HardwareStatus/FanStore.js | 52 | ||||
-rw-r--r-- | src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue | 43 | ||||
-rw-r--r-- | src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue | 25 | ||||
-rw-r--r-- | src/views/_sila/Fans/Dynamic/FansDynamicPage.vue | 1 |
5 files changed, 66 insertions, 57 deletions
diff --git a/src/components/_sila/Mixins/LoadingBarMixin.js b/src/components/_sila/Mixins/LoadingBarMixin.js index d1152703..912f284c 100644 --- a/src/components/_sila/Mixins/LoadingBarMixin.js +++ b/src/components/_sila/Mixins/LoadingBarMixin.js @@ -1,4 +1,4 @@ -export const loading = true; +export const loading = false; const LoadingBarMixin = { methods: { diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 98dfb5be..43baf6b1 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -4,18 +4,16 @@ import i18n from '@/i18n'; const FanStore = { namespaced: true, state: { - fansCpu: [], - fansCpuLastHour: [], - fansSystem: [], - fansSystemLastHour: [], + fans: [], + fansLastHour: [], limits: [], + isLoading: false, }, getters: { - fansCpu: (state) => state.fansCpu, - fansCpuLastHour: (state) => state.fansCpuLastHour, - fansSystem: (state) => state.fansCpu, - fansSystemLastHour: (state) => state.fansCpuLastHour, + fans: (state) => state.fansCpu, + fansLastHour: (state) => state.fansCpuLastHour, limits: (state) => state.limits, + isLoading: (state) => state.isLoading, }, mutations: { setFanInfo: (state, data) => { @@ -47,21 +45,18 @@ const FanStore = { }); }, - setFansCpu: (state, data) => { + setFans: (state, data) => { state.fansCpu = data; }, - setFansCpuLastHour: (state, data) => { + setFansLastHour: (state, data) => { state.fansCpuLastHour = data; }, - setFansSystem: (state, data) => { - state.fansSystem = data; - }, - setFansSystemLastHour: (state, data) => { - state.fansSystemLastHour = data; - }, setLimits: (state, data) => { state.limits = data; }, + setIsLoading: (state, data) => { + state.isLoading = data; + }, }, actions: { async patchLimits({ dispatch }, { warning, critical, groups }) { @@ -98,26 +93,7 @@ const FanStore = { }) .catch((error) => console.log(error)); }, - async getFansCpu({ commit }, { lastHour }) { - let url = null; - if (lastHour) { - url = - '/redfish/v1/TelemetryService/MetricReports/fans&period=last_hour'; - } else { - url = '/redfish/v1/TelemetryService/MetricReports/fans'; - } - return await api - .get(url) - .then(({ data: { MetricValues = [] } }) => { - if (lastHour) { - commit('setFansCpuLastHour', MetricValues); - } else { - commit('setFansCpu', MetricValues); - } - }) - .catch((error) => console.log(error)); - }, - async getFansSystem({ commit }, { lastHour }) { + async getFans({ commit }, { lastHour }) { let url = null; if (lastHour) { url = @@ -129,9 +105,9 @@ const FanStore = { .get(url) .then(({ data: { MetricValues = [] } }) => { if (lastHour) { - commit('setFansSystemLastHour', MetricValues); + commit('setFansLastHour', MetricValues); } else { - commit('setFansSystem', MetricValues); + commit('setFans', MetricValues); } }) .catch((error) => console.log(error)); diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue index b4c5dfdd..fe7b2509 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue @@ -1,7 +1,7 @@ <template> <collapse id="collapse_FansCpu" - :class="{ disabledDiv: loading && opened }" + :class="{ disabledDiv: (loading || isPageLoading) && opened }" :title="$t('pageFans.speed')" :opened="true" @opened="onOpened" @@ -56,7 +56,9 @@ variant="primary" style="height: 35px" :disabled=" - loading || $store.getters['authentication/role'] === 'ReadOnly' + loading || + isPageLoading || + $store.getters['authentication/role'] === 'ReadOnly' " @click="saveLimit" > @@ -154,7 +156,7 @@ export default { loading, warning: null, critical: null, - isBusy: true, + isBusy: false, opened: false, fields: [ { @@ -236,6 +238,10 @@ export default { return this.$store.getters['fan/limits']; }, + isPageLoading() { + return this.$store.getters['fan/isLoading']; + }, + warningLimit() { return this.limits.find((limit) => { return ( @@ -261,8 +267,8 @@ export default { allSensors() { return this.timeScale === 'hour' - ? this.$store.getters['fan/fansCpuLastHour'] - : this.$store.getters['fan/fansCpu']; + ? this.$store.getters['fan/fansLastHour'] + : this.$store.getters['fan/fans']; }, preFiltered() { @@ -333,23 +339,38 @@ export default { }, loadData() { + if (this.isPageLoading) { + return; + } + let payload = { lastHour: false }; if (this.timeScale === 'hour') { payload = { lastHour: true }; } - this.$root.$emit('fan-cpu', true); - this.startLoader(); - this.$store.dispatch('fan/getFansCpu', payload).finally(() => { + this.start(); + this.$store.dispatch('fan/getFans', payload).finally(() => { this.$store.dispatch('fan/getLimits').finally(() => { this.warning = this.warningLimit; this.critical = this.criticalLimit; - this.$root.$emit('fan-cpu', false); - this.endLoader(); - this.isBusy = false; + this.end(); }); }); }, + + start() { + this.startLoader(); + this.isBusy = true; + this.$store.commit('fan/setIsLoading', true); + this.$root.$emit('fan-cpu', true); + }, + + end() { + this.endLoader(); + this.isBusy = false; + this.$store.commit('fan/setIsLoading', false); + this.$root.$emit('fan-cpu', false); + }, }, }; </script> diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue index b86e1672..a499a08d 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue @@ -1,7 +1,7 @@ <template> <collapse id="collapse_FansSystem" - :class="{ disabledDiv: loading && opened }" + :class="{ disabledDiv: (loading || isPageLoading) && opened }" :title="$t('pageFans.speedSystem')" :opened="true" @opened="onOpened" @@ -56,7 +56,9 @@ variant="primary" style="height: 35px" :disabled=" - loading || $store.getters['authentication/role'] === 'ReadOnly' + loading || + isPageLoading || + $store.getters['authentication/role'] === 'ReadOnly' " @click="saveLimit" > @@ -154,7 +156,7 @@ export default { loading, warning: null, critical: null, - isBusy: true, + isBusy: false, opened: false, fields: [ { @@ -236,6 +238,10 @@ export default { return this.$store.getters['fan/limits']; }, + isPageLoading() { + return this.$store.getters['fan/isLoading']; + }, + warningLimit() { return this.limits.find((limit) => { return ( @@ -261,8 +267,8 @@ export default { allSensors() { return this.timeScale === 'hour' - ? this.$store.getters['fan/fansSystemLastHour'] - : this.$store.getters['fan/fansSystem']; + ? this.$store.getters['fan/fansLastHour'] + : this.$store.getters['fan/fans']; }, preFiltered() { @@ -335,6 +341,10 @@ export default { }, loadData() { + if (this.isPageLoading) { + return; + } + let payload = { lastHour: false }; if (this.timeScale === 'hour') { payload = { lastHour: true }; @@ -342,13 +352,16 @@ export default { this.$root.$emit('fan-system', true); this.startLoader(); - this.$store.dispatch('fan/getFansSystem', payload).finally(() => { + this.isBusy = true; + this.$store.commit('fan/setIsLoading', true); + this.$store.dispatch('fan/getFans', payload).finally(() => { this.$store.dispatch('fan/getLimits').finally(() => { this.warning = this.warningLimit; this.critical = this.criticalLimit; this.$root.$emit('fan-system', false); this.endLoader(); this.isBusy = false; + this.$store.commit('fan/setIsLoading', false); }); }); }, diff --git a/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue index eaf3777c..ca9de7ff 100644 --- a/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue +++ b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue @@ -47,7 +47,6 @@ export default { }, onChangePeriod(period) { this.timeScale = period; - this.startProgress(); this.resetZoom(); }, startProgress() { |