Skip to content

Commit 055ee8f

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 055ee8f

3 files changed

Lines changed: 41 additions & 34 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: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
:report-count="reportCount"
1313
:refresh-filter="refreshFilterState"
1414
:hidden-filters="hiddenFilters"
15-
@refresh="refresh"
15+
@refresh="refreshByReportFilter"
1616
@set-refresh-filter-state="setRefreshFilterState"
1717
/>
1818
</div>
@@ -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,10 +170,6 @@ 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
178175
const currentTab = tabs[tab.value];
@@ -183,30 +180,44 @@ watch(() => tab.value, async () => {
183180
...currentTab.hiddenFiltersByTab
184181
];
185182
183+
if (!reportFiltersReady.value) return;
184+
186185
await nextTick();
187-
refreshCurrentTab();
186+
emitRefresh();
188187
});
189188
190-
function refresh() {
191-
ccService.getClient().getRunResultCount(
192-
runIds.value,
193-
reportFilter.value,
194-
null,
195-
handleThriftError(_res => {
196-
reportCount.value = _res.toNumber();
197-
}));
198-
199-
tabs.forEach(_tab => {
200-
const _resolve = router.resolve(_tab.to);
201-
if (_resolve.route?.name) {
202-
refreshTabs[_resolve.route.name] = true;
203-
}
204-
});
205-
206-
refreshCurrentTab();
189+
function refreshByReportFilter(reason) {
190+
if (reason === "filter-change" && !reportFiltersReady.value) {
191+
return;
192+
}
193+
194+
if (reportFiltersReady.value) {
195+
ccService.getClient().getRunResultCount(
196+
runIds.value,
197+
reportFilter.value,
198+
null,
199+
handleThriftError(_res => {
200+
reportCount.value = _res.toNumber();
201+
}));
202+
203+
tabs.forEach(_tab => {
204+
const _resolve = router.resolve(_tab.to);
205+
if (_resolve.route?.name) {
206+
refreshTabs[_resolve.route.name] = true;
207+
}
208+
});
209+
}
210+
211+
if (reason === "filter-init") {
212+
reportFiltersReady.value = true;
213+
emitRefreshStatistics();
214+
return;
215+
}
216+
217+
emitRefreshStatistics();
207218
}
208219
209-
function refreshCurrentTab() {
220+
function emitRefreshStatistics() {
210221
bus.emit("refresh");
211222
212223
if (tab.value == null) return;

0 commit comments

Comments
 (0)