mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 20:45:24 +00:00
update selectors
This commit is contained in:
parent
fde0111f28
commit
2bf9b6bead
@ -288,36 +288,6 @@ async function setSourceSelector() {
|
|||||||
states.currentService = selectorStore.currentService.value;
|
states.currentService = selectorStore.currentService.value;
|
||||||
const e = String(params.entity).split("Relation")[0];
|
const e = String(params.entity).split("Relation")[0];
|
||||||
await fetchPods(e, selectorStore.currentService.id, true);
|
await fetchPods(e, selectorStore.currentService.id, true);
|
||||||
if (!(selectorStore.pods.length && selectorStore.pods[0])) {
|
|
||||||
selectorStore.setCurrentPod(null);
|
|
||||||
states.currentPod = "";
|
|
||||||
states.currentProcess = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pod = params.podId || selectorStore.pods[0].id;
|
|
||||||
const currentPod = selectorStore.pods.find(
|
|
||||||
(d: { id: string }) => d.id === pod
|
|
||||||
);
|
|
||||||
if (!currentPod) {
|
|
||||||
selectorStore.setCurrentProcess(null);
|
|
||||||
states.currentProcess = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentPod(currentPod);
|
|
||||||
states.currentPod = currentPod.label;
|
|
||||||
if (!(selectorStore.processes.length && selectorStore.processes[0])) {
|
|
||||||
selectorStore.setCurrentProcess(null);
|
|
||||||
states.currentProcess = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const process = params.processId || selectorStore.processes[0].id;
|
|
||||||
const currentProcess = selectorStore.processes.find(
|
|
||||||
(d: { id: string }) => d.id === process
|
|
||||||
);
|
|
||||||
if (currentProcess) {
|
|
||||||
selectorStore.setCurrentProcess(currentProcess);
|
|
||||||
states.currentProcess = currentProcess.label;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setDestSelector() {
|
async function setDestSelector() {
|
||||||
@ -328,33 +298,6 @@ async function setDestSelector() {
|
|||||||
selectorStore.currentDestService.id,
|
selectorStore.currentDestService.id,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
if (!(selectorStore.destPods.length && selectorStore.destPods[0])) {
|
|
||||||
selectorStore.setCurrentDestPod(null);
|
|
||||||
states.currentDestPod = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const destPod = params.destPodId || selectorStore.destPods[0].id;
|
|
||||||
const currentDestPod = selectorStore.destPods.find(
|
|
||||||
(d: { id: string }) => d.id === destPod
|
|
||||||
);
|
|
||||||
if (!currentDestPod) {
|
|
||||||
states.currentDestProcess = "";
|
|
||||||
selectorStore.setCurrentProcess(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentDestPod(currentDestPod);
|
|
||||||
states.currentDestPod = currentDestPod.label;
|
|
||||||
const destProcess = params.destProcessId || selectorStore.destProcesses[0].id;
|
|
||||||
const currentDestProcess = selectorStore.destProcesses.find(
|
|
||||||
(d: { id: string }) => d.id === destProcess
|
|
||||||
);
|
|
||||||
if (!currentDestProcess) {
|
|
||||||
states.currentDestProcess = "";
|
|
||||||
selectorStore.setCurrentProcess(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentProcess(currentDestProcess);
|
|
||||||
states.currentDestProcess = currentDestProcess.label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getServices() {
|
async function getServices() {
|
||||||
@ -482,10 +425,12 @@ function changeDestPods(pod: Option[]) {
|
|||||||
|
|
||||||
function changeDestProcess(pod: Option[]) {
|
function changeDestProcess(pod: Option[]) {
|
||||||
selectorStore.setCurrentDestProcess(pod[0] || null);
|
selectorStore.setCurrentDestProcess(pod[0] || null);
|
||||||
|
states.currentDestProcess = pod[0].label || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeProcess(pod: Option[]) {
|
function changeProcess(pod: Option[]) {
|
||||||
selectorStore.setCurrentProcess(pod[0] || null);
|
selectorStore.setCurrentProcess(pod[0] || null);
|
||||||
|
states.currentProcess = pod[0].label || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeMode() {
|
function changeMode() {
|
||||||
@ -612,35 +557,13 @@ async function fetchPods(
|
|||||||
case EntityType[2].value:
|
case EntityType[2].value:
|
||||||
resp = await selectorStore.getEndpoints({ serviceId, ...param });
|
resp = await selectorStore.getEndpoints({ serviceId, ...param });
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let p;
|
updateCurrentPod();
|
||||||
if (states.currentPod) {
|
|
||||||
p = selectorStore.pods.find(
|
|
||||||
(d: { label: unknown }) => d.label === states.currentPod
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
p = selectorStore.pods.find(
|
|
||||||
(d: unknown, index: number) => index === 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentPod(p || null);
|
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EntityType[3].value:
|
case EntityType[3].value:
|
||||||
resp = await selectorStore.getServiceInstances({ serviceId });
|
resp = await selectorStore.getServiceInstances({ serviceId });
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let p;
|
updateCurrentPod();
|
||||||
if (states.currentPod) {
|
|
||||||
p = selectorStore.pods.find(
|
|
||||||
(d: { label: string }) => d.label === states.currentPod
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
p = selectorStore.pods.find(
|
|
||||||
(d: { label: string }, index: number) => index === 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentPod(p || null);
|
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EntityType[6].value:
|
case EntityType[6].value:
|
||||||
@ -650,18 +573,7 @@ async function fetchPods(
|
|||||||
...param,
|
...param,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let p;
|
updateCurrentDestPod();
|
||||||
if (states.currentDestPod) {
|
|
||||||
p = selectorStore.destPods.find(
|
|
||||||
(d: { label: string }) => d.label === states.currentDestPod
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
p = selectorStore.destPods.find(
|
|
||||||
(d: { label: string }, index: number) => index === 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentDestPod(p || null);
|
|
||||||
states.currentDestPod = selectorStore.currentDestPod.label;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EntityType[5].value:
|
case EntityType[5].value:
|
||||||
@ -670,18 +582,7 @@ async function fetchPods(
|
|||||||
isRelation: true,
|
isRelation: true,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let p;
|
updateCurrentDestPod();
|
||||||
if (states.currentDestPod) {
|
|
||||||
p = selectorStore.destPods.find(
|
|
||||||
(d: { label: string }) => d.label === states.currentDestPod
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
p = selectorStore.destPods.find(
|
|
||||||
(d: { label: string }, index: number) => index === 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentDestPod(p || null);
|
|
||||||
states.currentDestPod = selectorStore.currentDestPod.label;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EntityType[7].value:
|
case EntityType[7].value:
|
||||||
@ -705,18 +606,14 @@ async function fetchProcess(setPod: boolean) {
|
|||||||
instanceId: selectorStore.currentPod.id,
|
instanceId: selectorStore.currentPod.id,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let m;
|
const process = params.processId || selectorStore.processes[0].id;
|
||||||
if (states.currentProcess) {
|
const currentProcess = selectorStore.processes.find(
|
||||||
m = selectorStore.processes.find(
|
(d: { id: string }) => d.id === process
|
||||||
(d: { label: string }) => d.label === states.currentProcess
|
);
|
||||||
);
|
if (currentProcess) {
|
||||||
} else {
|
selectorStore.setCurrentProcess(currentProcess);
|
||||||
m = selectorStore.processes.find(
|
states.currentProcess = currentProcess.label;
|
||||||
(d: { label: string }, index: number) => index === 0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
selectorStore.setCurrentProcess(m || null);
|
|
||||||
states.currentProcess = m && m.label;
|
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
@ -726,21 +623,58 @@ async function fetchDestProcess(setPod: boolean) {
|
|||||||
isRelation: true,
|
isRelation: true,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
let m;
|
const destProcess =
|
||||||
if (states.currentDestProcess) {
|
params.destProcessId || selectorStore.destProcesses[0].id;
|
||||||
m = selectorStore.destProcesses.find(
|
const currentDestProcess = selectorStore.destProcesses.find(
|
||||||
(d: { label: string }) => d.label === states.currentDestProcess
|
(d: { id: string }) => d.id === destProcess
|
||||||
);
|
);
|
||||||
} else {
|
if (!currentDestProcess) {
|
||||||
m = selectorStore.destProcesses.find(
|
states.currentDestProcess = "";
|
||||||
(d: { label: string }, index: number) => index === 1
|
selectorStore.setCurrentDestProcess(null);
|
||||||
);
|
return;
|
||||||
}
|
}
|
||||||
selectorStore.setCurrentDestProcess(m || null);
|
selectorStore.setCurrentDestProcess(currentDestProcess);
|
||||||
states.currentDestProcess = m && m.label;
|
states.currentDestProcess = currentDestProcess.label;
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCurrentDestPod() {
|
||||||
|
if (!(selectorStore.destPods.length && selectorStore.destPods[0])) {
|
||||||
|
selectorStore.setCurrentDestPod(null);
|
||||||
|
states.currentDestPod = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const destPod = params.destPodId || selectorStore.destPods[0].id;
|
||||||
|
const currentDestPod = selectorStore.destPods.find(
|
||||||
|
(d: { id: string }) => d.id === destPod
|
||||||
|
);
|
||||||
|
if (!currentDestPod) {
|
||||||
|
states.currentDestPod = "";
|
||||||
|
selectorStore.setCurrentDestPod(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentDestPod(currentDestPod);
|
||||||
|
states.currentDestPod = currentDestPod.label;
|
||||||
|
}
|
||||||
|
function updateCurrentPod() {
|
||||||
|
if (!(selectorStore.pods.length && selectorStore.pods[0])) {
|
||||||
|
selectorStore.setCurrentPod(null);
|
||||||
|
states.currentPod = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const pod = params.podId || selectorStore.pods[0].id;
|
||||||
|
const currentPod = selectorStore.pods.find(
|
||||||
|
(d: { id: string }) => d.id === pod
|
||||||
|
);
|
||||||
|
if (!currentPod) {
|
||||||
|
selectorStore.setCurrentPod(null);
|
||||||
|
states.currentPod = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentPod(currentPod);
|
||||||
|
states.currentPod = currentPod.label;
|
||||||
|
}
|
||||||
function getTools() {
|
function getTools() {
|
||||||
switch (params.entity) {
|
switch (params.entity) {
|
||||||
case EntityType[1].value:
|
case EntityType[1].value:
|
||||||
|
Loading…
Reference in New Issue
Block a user