This is an automated email from the ASF dual-hosted git repository.
qiuxiafan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git
The following commit(s) were added to refs/heads/master by this push:
new eb7c54b Bugfix: Handle the case where the service returns an empty
array (#328)
eb7c54b is described below
commit eb7c54b2f44a7f14b43f8a6724f652bcb2e33597
Author: Juntao Zhang <[email protected]>
AuthorDate: Tue Jul 14 10:09:41 2020 +0800
Bugfix: Handle the case where the service returns an empty array (#328)
* Fix: handle the case where the service returns an empty array
* fix: duplicate requests
---
src/store/modules/dashboard/dashboard-option.ts | 26 ++++++++++---------------
src/store/modules/dashboard/mutation-types.ts | 1 +
src/views/components/dashboard/tool-bar.vue | 10 ++++++++--
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/store/modules/dashboard/dashboard-option.ts
b/src/store/modules/dashboard/dashboard-option.ts
index d9ec445..960a3b8 100644
--- a/src/store/modules/dashboard/dashboard-option.ts
+++ b/src/store/modules/dashboard/dashboard-option.ts
@@ -29,7 +29,7 @@ export interface State {
currentEndpoint: any;
instances: any[];
currentInstance: any;
- updateDashboard: string;
+ updateDashboard: object;
}
const initState: State = {
@@ -41,7 +41,7 @@ const initState: State = {
currentInstance: {},
databases: [],
currentDatabase: {},
- updateDashboard: '',
+ updateDashboard: {},
};
// getters
@@ -50,18 +50,18 @@ const getters = {};
// mutations
const mutations: MutationTree<State> = {
[types.SET_SERVICES](state: State, data: any) {
- if (!data.length) {
- return;
- }
state.services = data;
- if (!state.currentService.key && data.length) {
- state.currentService = data[0];
- }
+ state.currentService = data[0] || {};
},
[types.SET_CURRENT_SERVICE](state: State, service: any) {
state.currentService = service;
state.updateDashboard = service;
},
+
+ [types.UPDATE_DASHBOARD](state: State) {
+ state.updateDashboard = { _: +new Date() };
+ },
+
[types.SET_ENDPOINTS](state: State, data: any) {
state.endpoints = data;
if (!data.length) {
@@ -119,15 +119,12 @@ const actions: ActionTree<State, any> = {
});
},
GET_SERVICE_ENDPOINTS(context: { commit: Commit; state: any }, params: {
keyword: string }) {
- if (!context.state.currentService.key) {
- return new Promise((resolve) => resolve());
- }
if (!params.keyword) {
params.keyword = '';
}
return graph
.query('queryEndpoints')
- .params({ serviceId: context.state.currentService.key, ...params })
+ .params({ serviceId: context.state.currentService.key || '', ...params })
.then((res: AxiosResponse) => {
context.commit(types.SET_ENDPOINTS, res.data.data.getEndpoints);
});
@@ -141,12 +138,9 @@ const actions: ActionTree<State, any> = {
});
},
GET_SERVICE_INSTANCES(context: { commit: Commit; state: any }, params: any) {
- if (!context.state.currentService.key) {
- return new Promise((resolve) => resolve());
- }
return graph
.query('queryInstances')
- .params({ serviceId: context.state.currentService.key, ...params })
+ .params({ serviceId: context.state.currentService.key || '', ...params })
.then((res: AxiosResponse) => {
context.commit(types.SET_INSTANCES, res.data.data.getServiceInstances);
});
diff --git a/src/store/modules/dashboard/mutation-types.ts
b/src/store/modules/dashboard/mutation-types.ts
index 9c0c6fa..e3d7509 100644
--- a/src/store/modules/dashboard/mutation-types.ts
+++ b/src/store/modules/dashboard/mutation-types.ts
@@ -34,6 +34,7 @@ export const SET_INSTANCES = 'SET_INSTANCES';
export const SET_CURRENT_INSTANCE = 'SET_CURRENT_INSTANCE';
export const SET_INSTANCE_INFO = 'SET_INSTANCE_INFO';
export const SET_TEMPLATES = 'SET_TEMPLATES';
+export const UPDATE_DASHBOARD = 'UPDATE_DASHBOARD';
// comp
export const SET_CURRENT_GROUP = 'SET_CURRENT_GROUP';
diff --git a/src/views/components/dashboard/tool-bar.vue
b/src/views/components/dashboard/tool-bar.vue
index 91d8762..6f82e11 100644
--- a/src/views/components/dashboard/tool-bar.vue
+++ b/src/views/components/dashboard/tool-bar.vue
@@ -86,12 +86,12 @@ limitations under the License. -->
@State('rocketOption') private rocketOption: any;
@Mutation('ADD_COMP') private ADD_COMP: any;
@Mutation('SET_CURRENT_SERVICE_FILTER') private
SET_CURRENT_SERVICE_FILTER: any;
+ @Mutation('UPDATE_DASHBOARD') private UPDATE_DASHBOARD: any;
@Action('SELECT_SERVICE') private SELECT_SERVICE: any;
@Action('SELECT_DATABASE') private SELECT_DATABASE: any;
@Action('SELECT_ENDPOINT') private SELECT_ENDPOINT: any;
@Action('SELECT_INSTANCE') private SELECT_INSTANCE: any;
@Action('MIXHANDLE_GET_OPTION') private MIXHANDLE_GET_OPTION: any;
- @Action('GET_SERVICES') private GET_SERVICES: any;
private dashboardType = DASHBOARDTYPE;
get lastKey() {
const current =
this.rocketComps.tree[this.rocketComps.group].children[this.rocketComps.current].children;
@@ -110,8 +110,14 @@ limitations under the License. -->
this.SELECT_INSTANCE({ instance: i, duration: this.durationTime });
}
private searchServices(value: string) {
- this.GET_SERVICES({ duration: this.durationTime, keyword: value });
this.SET_CURRENT_SERVICE_FILTER(value);
+ this.MIXHANDLE_GET_OPTION({
+ compType: this.dashboardType.SERVICE,
+ duration: this.durationTime,
+ keywordServiceName: value,
+ }).then(() => {
+ this.UPDATE_DASHBOARD();
+ });
}
}
</script>