mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-07 10:42:56 +00:00
fix: refresh dashboards with current selectors (#64)
This commit is contained in:
parent
5dfbbacd14
commit
2dd9df19d7
@ -77,13 +77,13 @@ import { Languages } from "@/constants/data";
|
|||||||
import Selector from "@/components/Selector.vue";
|
import Selector from "@/components/Selector.vue";
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
|
const appStore = useAppStoreWithOut();
|
||||||
const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({
|
const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({
|
||||||
timer: null,
|
timer: null,
|
||||||
});
|
});
|
||||||
const lang = ref<string>(locale.value || "en");
|
const lang = ref<string>(locale.value || "en");
|
||||||
const autoTime = ref<number>(6);
|
const autoTime = ref<number>(6);
|
||||||
const auto = ref<boolean>(false);
|
const auto = ref<boolean>(appStore.autoRefresh || false);
|
||||||
const appStore = useAppStoreWithOut();
|
|
||||||
const utcArr = appStore.utc.split(":");
|
const utcArr = appStore.utc.split(":");
|
||||||
const utcHour = ref<number>(isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]));
|
const utcHour = ref<number>(isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]));
|
||||||
const utcMin = ref<number>(isNaN(Number(utcArr[1])) ? 0 : Number(utcArr[1]));
|
const utcMin = ref<number>(isNaN(Number(utcArr[1])) ? 0 : Number(utcArr[1]));
|
||||||
|
@ -53,9 +53,7 @@ export default defineComponent({
|
|||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
// function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
|
|
||||||
// dashboardStore.setLayout(newLayout);
|
|
||||||
// }
|
|
||||||
function clickGrid(item: LayoutConfig) {
|
function clickGrid(item: LayoutConfig) {
|
||||||
dashboardStore.activeGridItem(item.i);
|
dashboardStore.activeGridItem(item.i);
|
||||||
dashboardStore.selectWidget(item);
|
dashboardStore.selectWidget(item);
|
||||||
|
@ -217,12 +217,23 @@ async function setSelector() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let currentService, currentDestService;
|
let currentService, currentDestService;
|
||||||
for (const d of selectorStore.services) {
|
if (states.currentService) {
|
||||||
if (d.id === String(params.serviceId)) {
|
for (const d of selectorStore.services) {
|
||||||
currentService = d;
|
if (d.value === states.currentService) {
|
||||||
|
currentService = d;
|
||||||
|
}
|
||||||
|
if (d.value === states.currentDestService) {
|
||||||
|
currentDestService = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (d.id === String(params.destServiceId)) {
|
} else {
|
||||||
currentDestService = d;
|
for (const d of selectorStore.services) {
|
||||||
|
if (d.id === String(params.serviceId)) {
|
||||||
|
currentService = d;
|
||||||
|
}
|
||||||
|
if (d.id === String(params.destServiceId)) {
|
||||||
|
currentDestService = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectorStore.setCurrentService(currentService);
|
selectorStore.setCurrentService(currentService);
|
||||||
@ -244,9 +255,14 @@ async function setSourceSelector() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pod = params.podId || selectorStore.pods[0].id;
|
const pod = params.podId || selectorStore.pods[0].id;
|
||||||
const currentPod = selectorStore.pods.find(
|
let currentPod;
|
||||||
(d: { id: string }) => d.id === pod
|
if (states.currentPod) {
|
||||||
);
|
currentPod = selectorStore.pods.find(
|
||||||
|
(d: { id: string }) => d.label === states.currentPod
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
currentPod = selectorStore.pods.find((d: { id: string }) => d.id === pod);
|
||||||
|
}
|
||||||
if (currentPod) {
|
if (currentPod) {
|
||||||
selectorStore.setCurrentPod(currentPod);
|
selectorStore.setCurrentPod(currentPod);
|
||||||
states.currentPod = currentPod.label;
|
states.currentPod = currentPod.label;
|
||||||
@ -267,9 +283,16 @@ async function setDestSelector() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const destPod = params.destPodId || selectorStore.destPods[0].id;
|
const destPod = params.destPodId || selectorStore.destPods[0].id;
|
||||||
const currentDestPod = selectorStore.destPods.find(
|
let currentDestPod = "";
|
||||||
(d: { id: string }) => d.id === destPod
|
if (states.currentDestPod) {
|
||||||
);
|
currentDestPod = selectorStore.pods.find(
|
||||||
|
(d: { id: string }) => d.label === states.currentDestPod
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
currentDestPod = selectorStore.destPods.find(
|
||||||
|
(d: { id: string }) => d.id === destPod
|
||||||
|
);
|
||||||
|
}
|
||||||
if (currentDestPod) {
|
if (currentDestPod) {
|
||||||
selectorStore.setCurrentDestPod(currentDestPod);
|
selectorStore.setCurrentDestPod(currentDestPod);
|
||||||
states.currentDestPod = currentDestPod.label;
|
states.currentDestPod = currentDestPod.label;
|
||||||
@ -291,12 +314,24 @@ async function getServices() {
|
|||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectorStore.setCurrentService(
|
let s;
|
||||||
selectorStore.services.length ? selectorStore.services[0] : null
|
if (states.currentService) {
|
||||||
);
|
s = (selectorStore.services || []).find(
|
||||||
selectorStore.setCurrentDestService(
|
(d) => d.label === states.currentService
|
||||||
selectorStore.services.length ? selectorStore.services[1] : null
|
);
|
||||||
);
|
} else {
|
||||||
|
s = (selectorStore.services || []).find((d, index) => index === 0);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentService(s || null);
|
||||||
|
let d;
|
||||||
|
if (states.currentService) {
|
||||||
|
d = (selectorStore.services || []).find(
|
||||||
|
(d) => d.label === states.currentDestService
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
d = (selectorStore.services || []).find((d, index) => index === 1);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentDestService(d || null);
|
||||||
if (!selectorStore.currentService) {
|
if (!selectorStore.currentService) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -447,18 +482,26 @@ 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) {
|
||||||
selectorStore.setCurrentPod(
|
let p;
|
||||||
selectorStore.pods.length ? selectorStore.pods[0] : null
|
if (states.currentPod) {
|
||||||
);
|
p = selectorStore.pods.find((d) => d.label === states.currentPod);
|
||||||
|
} else {
|
||||||
|
p = selectorStore.pods.find((d, index) => index === 0);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentPod(p || null);
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
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) {
|
||||||
selectorStore.setCurrentPod(
|
let p;
|
||||||
selectorStore.pods.length ? selectorStore.pods[0] : null
|
if (states.currentPod) {
|
||||||
);
|
p = selectorStore.pods.find((d) => d.label === states.currentPod);
|
||||||
|
} else {
|
||||||
|
p = selectorStore.pods.find((d, index) => index === 0);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentPod(p || null);
|
||||||
states.currentPod = selectorStore.currentPod.label;
|
states.currentPod = selectorStore.currentPod.label;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -469,9 +512,13 @@ async function fetchPods(
|
|||||||
...param,
|
...param,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
selectorStore.setCurrentDestPod(
|
let p;
|
||||||
selectorStore.destPods.length ? selectorStore.destPods[0] : null
|
if (states.currentDestPod) {
|
||||||
);
|
p = selectorStore.pods.find((d) => d.label === states.currentDestPod);
|
||||||
|
} else {
|
||||||
|
p = selectorStore.pods.find((d, index) => index === 0);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentDestPod(p || null);
|
||||||
states.currentDestPod = selectorStore.currentDestPod.label;
|
states.currentDestPod = selectorStore.currentDestPod.label;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -481,9 +528,13 @@ async function fetchPods(
|
|||||||
isRelation: true,
|
isRelation: true,
|
||||||
});
|
});
|
||||||
if (setPod) {
|
if (setPod) {
|
||||||
selectorStore.setCurrentDestPod(
|
let p;
|
||||||
selectorStore.destPods.length ? selectorStore.destPods[0] : null
|
if (states.currentDestPod) {
|
||||||
);
|
p = selectorStore.pods.find((d) => d.label === states.currentDestPod);
|
||||||
|
} else {
|
||||||
|
p = selectorStore.pods.find((d, index) => index === 0);
|
||||||
|
}
|
||||||
|
selectorStore.setCurrentDestPod(p || null);
|
||||||
states.currentDestPod = selectorStore.currentDestPod.label;
|
states.currentDestPod = selectorStore.currentDestPod.label;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user