mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-01 22:04:30 +00:00
fix: update selector params and list graphs (#54)
This commit is contained in:
parent
f57fdf9312
commit
f19bcc856d
@ -53,6 +53,9 @@ const available = computed(
|
|||||||
(Array.isArray(props.option.series.data) && props.option.series.data[0])
|
(Array.isArray(props.option.series.data) && props.option.series.data[0])
|
||||||
);
|
);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
if (!available.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await setOptions(props.option);
|
await setOptions(props.option);
|
||||||
chartRef.value && addResizeListener(unref(chartRef), resize);
|
chartRef.value && addResizeListener(unref(chartRef), resize);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -70,6 +73,9 @@ onMounted(async () => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.option,
|
() => props.option,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
|
if (!available.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (JSON.stringify(newVal) === JSON.stringify(oldVal)) {
|
if (JSON.stringify(newVal) === JSON.stringify(oldVal)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ limitations under the License. -->
|
|||||||
metricTypes: dashboardStore.selectedGrid.metricTypes,
|
metricTypes: dashboardStore.selectedGrid.metricTypes,
|
||||||
metricConfig: dashboardStore.selectedGrid.metricConfig,
|
metricConfig: dashboardStore.selectedGrid.metricConfig,
|
||||||
}"
|
}"
|
||||||
|
:needQuery="true"
|
||||||
/>
|
/>
|
||||||
<div v-show="!graph.type" class="no-data">
|
<div v-show="!graph.type" class="no-data">
|
||||||
{{ t("noData") }}
|
{{ t("noData") }}
|
||||||
|
@ -111,9 +111,10 @@ const props = defineProps({
|
|||||||
i: "",
|
i: "",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
needQuery: { type: Boolean, default: false },
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
});
|
});
|
||||||
// const emit = defineEmits(["changeOpt"]);
|
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const chartLoading = ref<boolean>(false);
|
const chartLoading = ref<boolean>(false);
|
||||||
@ -121,8 +122,9 @@ const endpoints = ref<Endpoint[]>([]);
|
|||||||
const searchText = ref<string>("");
|
const searchText = ref<string>("");
|
||||||
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
|
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
|
||||||
|
|
||||||
queryEndpoints();
|
if (props.needQuery) {
|
||||||
|
queryEndpoints();
|
||||||
|
}
|
||||||
async function queryEndpoints() {
|
async function queryEndpoints() {
|
||||||
chartLoading.value = true;
|
chartLoading.value = true;
|
||||||
const resp = await selectorStore.getEndpoints({
|
const resp = await selectorStore.getEndpoints({
|
||||||
|
@ -48,6 +48,7 @@ limitations under the License. -->
|
|||||||
getLabel(metric, index)
|
getLabel(metric, index)
|
||||||
)} ${decodeURIComponent(getUnit(index))}`"
|
)} ${decodeURIComponent(getUnit(index))}`"
|
||||||
:key="metric + index"
|
:key="metric + index"
|
||||||
|
min-width="120"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="chart">
|
<div class="chart">
|
||||||
@ -70,7 +71,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="Attributes" :width="100">
|
<el-table-column label="Attributes">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-popover placement="left" :width="400" trigger="click">
|
<el-popover placement="left" :width="400" trigger="click">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
@ -142,7 +143,6 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
needQuery: { type: Boolean, default: false },
|
needQuery: { type: Boolean, default: false },
|
||||||
isEdit: { type: Boolean, default: false },
|
|
||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
@ -152,8 +152,10 @@ const instances = ref<Instance[]>([]); // current instances
|
|||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const searchText = ref<string>("");
|
const searchText = ref<string>("");
|
||||||
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
|
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
|
||||||
|
if (props.needQuery) {
|
||||||
|
queryInstance();
|
||||||
|
}
|
||||||
|
|
||||||
queryInstance();
|
|
||||||
async function queryInstance() {
|
async function queryInstance() {
|
||||||
chartLoading.value = true;
|
chartLoading.value = true;
|
||||||
const resp = await selectorStore.getServiceInstances();
|
const resp = await selectorStore.getServiceInstances();
|
||||||
|
@ -120,7 +120,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref, computed } from "vue";
|
import { reactive, ref, computed, watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
@ -169,7 +169,6 @@ const key = computed(() => {
|
|||||||
const type = EntityType.find(
|
const type = EntityType.find(
|
||||||
(d: Option) => d.value === dashboardStore.entity
|
(d: Option) => d.value === dashboardStore.entity
|
||||||
);
|
);
|
||||||
|
|
||||||
return (type && type.key) || 0;
|
return (type && type.key) || 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -268,9 +267,9 @@ 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.filter(
|
const currentDestPod = selectorStore.destPods.find(
|
||||||
(d: { id: string }) => d.id === destPod
|
(d: { id: string }) => d.id === destPod
|
||||||
)[0];
|
);
|
||||||
if (currentDestPod) {
|
if (currentDestPod) {
|
||||||
selectorStore.setCurrentDestPod(currentDestPod);
|
selectorStore.setCurrentDestPod(currentDestPod);
|
||||||
states.currentDestPod = currentDestPod.label;
|
states.currentDestPod = currentDestPod.label;
|
||||||
@ -278,20 +277,20 @@ async function setDestSelector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getServices() {
|
async function getServices() {
|
||||||
if (key.value === 10 || key.value === 0) {
|
if (!dashboardStore.entity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!dashboardStore.layerId) {
|
if (!dashboardStore.layerId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[1].value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dashboardStore.entity === EntityType[1].value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectorStore.setCurrentService(
|
selectorStore.setCurrentService(
|
||||||
selectorStore.services.length ? selectorStore.services[0] : null
|
selectorStore.services.length ? selectorStore.services[0] : null
|
||||||
);
|
);
|
||||||
@ -539,6 +538,15 @@ function searchDestPods(query: string) {
|
|||||||
param
|
param
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
watch(
|
||||||
|
() => dashboardStore.entity,
|
||||||
|
(newVal, oldVal) => {
|
||||||
|
if (newVal === oldVal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getServices();
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.dashboard-tool {
|
.dashboard-tool {
|
||||||
|
Loading…
Reference in New Issue
Block a user