Skip to content

Commit e06e7e1

Browse files
[gui] Fix refresh page overuse
This change introduces reasons for report filters to why the emit was invoked. Based on this, it can be filtered when a refresh was actually needed and when not.
1 parent e8b55f2 commit e06e7e1

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

web/server/vue-cli/src/components/Report/ReportFilter/ReportFilter.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ function beforeInit() {
702702
}
703703
704704
function afterInit() {
705-
emit("refresh");
705+
emit("refresh", "filter-init");
706706
registerWatchers();
707707
syncGroupPanels();
708708
}
@@ -729,20 +729,20 @@ function registerWatchers() {
729729
reportFilterUnwatch.value = store.watch(
730730
state => state.reportFilter, () => {
731731
if (!isInitializing.value)
732-
emit("refresh");
732+
emit("refresh", "filter-change");
733733
734734
}, { deep: true });
735735
736736
runIdsUnwatch.value = store.watch(
737737
state => state.runIds, () => {
738738
if (!isInitializing.value)
739-
emit("refresh");
739+
emit("refresh", "filter-change");
740740
});
741741
742742
cmpDataUnwatch.value = store.watch(
743743
state => state.cmpData, () => {
744744
if (!isInitializing.value)
745-
emit("refresh");
745+
emit("refresh", "filter-change");
746746
}, { deep: true });
747747
}
748748
@@ -828,7 +828,7 @@ function updateAllFilters() {
828828
if (!_filters?.length) return;
829829
830830
_filters.forEach(filter => filter?.update?.() );
831-
emit("refresh");
831+
emit("refresh", "filter-change");
832832
}
833833
834834
onBeforeUnmount(() => {

web/server/vue-cli/src/components/Statistics/Overview/OutstandingReportsChart.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const chart = ref();
6262
const dates = ref([]);
6363
const filterDateFormat = ref("");
6464
65-
const refreshHandler = () => fetchDataHandler();
65+
const refreshHandler = () => fetchData(dates.value);
6666
6767
const options = ref({
6868
plugins: {
@@ -193,10 +193,6 @@ onDeactivated(function() {
193193
props.bus.off("refresh", refreshHandler);
194194
});
195195
196-
function fetchDataHandler() {
197-
fetchData(dates.value);
198-
}
199-
200196
/* eslint-disable no-unused-vars */
201197
function setChartDataOld() {
202198
const _interval = parseInt(props.interval);

web/server/vue-cli/src/views/Statistics.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const tabs = [
146146
const refreshFilterState = ref(false);
147147
const reportCount = ref(0);
148148
const tab = ref(null);
149+
const reportFiltersReady = ref(false);
149150
150151
const bus = mitt();
151152
@@ -169,12 +170,10 @@ const reportFilter = computed(function() {
169170
});
170171
171172
watch(() => tab.value, async () => {
172-
// FIXME: At page reload, this
173-
// event triggers, but the report filter
174-
// is not ready yet.
175-
176173
if (tab.value == null) return;
177174
175+
if (!reportFiltersReady.value) return;
176+
178177
const currentTab = tabs[tab.value];
179178
if (!currentTab) return;
180179
@@ -184,10 +183,10 @@ watch(() => tab.value, async () => {
184183
];
185184
186185
await nextTick();
187-
refreshCurrentTab();
186+
emitRefresh();
188187
});
189188
190-
function refresh() {
189+
function refresh(reason) {
191190
ccService.getClient().getRunResultCount(
192191
runIds.value,
193192
reportFilter.value,
@@ -203,10 +202,18 @@ function refresh() {
203202
}
204203
});
205204
206-
refreshCurrentTab();
205+
if (reason === "filter-init") {
206+
reportFiltersReady.value = true;
207+
emitRefresh();
208+
return;
209+
}
210+
211+
if (reason === "filter-change" && reportFiltersReady.value) {
212+
emitRefresh();
213+
}
207214
}
208215
209-
function refreshCurrentTab() {
216+
function emitRefresh() {
210217
bus.emit("refresh");
211218
212219
if (tab.value == null) return;

0 commit comments

Comments
 (0)