mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 22:43:09 +00:00
feat: update selectors
This commit is contained in:
parent
8cd5dbc74d
commit
829ae69f0f
@ -48,7 +48,6 @@ export const selectorStore = defineStore({
|
|||||||
this.currentService = service;
|
this.currentService = service;
|
||||||
},
|
},
|
||||||
setCurrentPod(pod: Nullable<Instance | Endpoint>) {
|
setCurrentPod(pod: Nullable<Instance | Endpoint>) {
|
||||||
console.log(pod);
|
|
||||||
this.currentPod = pod;
|
this.currentPod = pod;
|
||||||
},
|
},
|
||||||
async fetchLayers(): Promise<AxiosResponse> {
|
async fetchLayers(): Promise<AxiosResponse> {
|
||||||
@ -115,6 +114,7 @@ export const selectorStore = defineStore({
|
|||||||
});
|
});
|
||||||
if (!res.data.errors) {
|
if (!res.data.errors) {
|
||||||
this.currentService = res.data.data.service || {};
|
this.currentService = res.data.data.service || {};
|
||||||
|
this.services = [res.data.data.service];
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="dashboard-tool flex-h">
|
<div class="dashboard-tool flex-h">
|
||||||
<div v-if="params.serviceId"></div>
|
<div class="flex-h">
|
||||||
<div v-else class="flex-h">
|
|
||||||
<div class="selectors-item" v-if="states.key !== 10">
|
<div class="selectors-item" v-if="states.key !== 10">
|
||||||
<span class="label">$Service</span>
|
<span class="label">$Service</span>
|
||||||
<Selector
|
<Selector
|
||||||
v-model="states.currentService"
|
v-model="states.currentService"
|
||||||
:options="selectorStore.services"
|
:options="selectorStore.services"
|
||||||
|
:disabled="states.disableService"
|
||||||
size="mini"
|
size="mini"
|
||||||
placeholder="Select a service"
|
placeholder="Select a service"
|
||||||
@change="changeService"
|
@change="changeService"
|
||||||
@ -104,12 +104,14 @@ const states = reactive<{
|
|||||||
key: number;
|
key: number;
|
||||||
currentService: string;
|
currentService: string;
|
||||||
currentPod: string;
|
currentPod: string;
|
||||||
|
disableService: boolean;
|
||||||
}>({
|
}>({
|
||||||
destService: "",
|
destService: "",
|
||||||
destPod: "",
|
destPod: "",
|
||||||
key: (type && type.key) || 0,
|
key: (type && type.key) || 0,
|
||||||
currentService: "",
|
currentService: "",
|
||||||
currentPod: "",
|
currentPod: "",
|
||||||
|
disableService: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
dashboardStore.setLayer(String(params.layerId));
|
dashboardStore.setLayer(String(params.layerId));
|
||||||
@ -122,17 +124,29 @@ if (params.serviceId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setSelector() {
|
async function setSelector() {
|
||||||
await selectorStore.getService(String(params.serviceId));
|
|
||||||
states.currentService = selectorStore.currentService.value;
|
|
||||||
if (params.podId) {
|
if (params.podId) {
|
||||||
if (String(params.entity) === EntityType[2].value) {
|
await selectorStore.getService(String(params.serviceId));
|
||||||
await selectorStore.getEndpoint(String(params.podId));
|
states.currentService = selectorStore.currentService.value;
|
||||||
}
|
await fetchPods(String(params.entity), false);
|
||||||
if (String(params.entity) === EntityType[3].value) {
|
const currentPod = selectorStore.pods.filter(
|
||||||
await selectorStore.getInstance(String(params.podId));
|
(d: { id: string }) => d.id === String(params.podId)
|
||||||
}
|
)[0];
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
selectorStore.setCurrentPod(currentPod);
|
||||||
|
states.currentPod = currentPod.label;
|
||||||
|
states.disableService = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// entity=Service with serviceId
|
||||||
|
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
||||||
|
if (json.errors) {
|
||||||
|
ElMessage.error(json.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentService = selectorStore.services.filter(
|
||||||
|
(d: { id: string }) => d.id === String(params.serviceId)
|
||||||
|
)[0];
|
||||||
|
selectorStore.setCurrentService(currentService);
|
||||||
|
states.currentService = selectorStore.currentService.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getServices() {
|
async function getServices() {
|
||||||
@ -148,14 +162,14 @@ async function getServices() {
|
|||||||
selectorStore.services.length ? selectorStore.services[0] : null
|
selectorStore.services.length ? selectorStore.services[0] : null
|
||||||
);
|
);
|
||||||
states.currentService = selectorStore.currentService.value;
|
states.currentService = selectorStore.currentService.value;
|
||||||
fetchPods(dashboardStore.entity);
|
fetchPods(dashboardStore.entity, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeService(service: Service[]) {
|
async function changeService(service: Service[]) {
|
||||||
if (service[0]) {
|
if (service[0]) {
|
||||||
states.currentService = service[0].value;
|
states.currentService = service[0].value;
|
||||||
selectorStore.setCurrentService(service[0]);
|
selectorStore.setCurrentService(service[0]);
|
||||||
fetchPods(dashboardStore.entity);
|
fetchPods(dashboardStore.entity, true);
|
||||||
} else {
|
} else {
|
||||||
selectorStore.setCurrentService("");
|
selectorStore.setCurrentService("");
|
||||||
}
|
}
|
||||||
@ -188,22 +202,26 @@ function clickIcons(t: { id: string; content: string; name: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchPods(type: string) {
|
async function fetchPods(type: string, setPod: boolean) {
|
||||||
let resp;
|
let resp;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Endpoint":
|
case "Endpoint":
|
||||||
resp = await selectorStore.getEndpoints();
|
resp = await selectorStore.getEndpoints();
|
||||||
selectorStore.setCurrentPod(
|
if (setPod) {
|
||||||
selectorStore.pods.length ? selectorStore.pods[0] : null
|
selectorStore.setCurrentPod(
|
||||||
);
|
selectorStore.pods.length ? selectorStore.pods[0] : null
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
);
|
||||||
|
states.currentPod = selectorStore.currentPod.label;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ServiceInstance":
|
case "ServiceInstance":
|
||||||
resp = await selectorStore.getServiceInstances();
|
resp = await selectorStore.getServiceInstances();
|
||||||
selectorStore.setCurrentPod(
|
if (setPod) {
|
||||||
selectorStore.pods.length ? selectorStore.pods[0] : null
|
selectorStore.setCurrentPod(
|
||||||
);
|
selectorStore.pods.length ? selectorStore.pods[0] : null
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
);
|
||||||
|
states.currentPod = selectorStore.currentPod.label;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
resp = {};
|
resp = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user