This commit is contained in:
Qiuxia Fan 2022-03-23 15:30:22 +08:00
parent 93161b6ec9
commit 5bdc31012c
3 changed files with 22 additions and 6 deletions

View File

@ -66,6 +66,7 @@ limitations under the License. -->
i: data.i, i: data.i,
}" }"
:standard="data.standard" :standard="data.standard"
:needQuery="needQuery"
/> />
</div> </div>
<div v-else class="no-data">{{ t("noData") }}</div> <div v-else class="no-data">{{ t("noData") }}</div>
@ -112,6 +113,7 @@ export default defineComponent({
} }
async function queryMetrics() { async function queryMetrics() {
console.log(props.data);
const params = await useQueryProcessor(props.data); const params = await useQueryProcessor(props.data);
if (!params) { if (!params) {
@ -153,6 +155,7 @@ export default defineComponent({
if (props.data.i !== dashboardStore.selectedGrid.i) { if (props.data.i !== dashboardStore.selectedGrid.i) {
return; return;
} }
const isList = ListChartTypes.includes(props.data.graph.type || "");
if ( if (
ListChartTypes.includes(dashboardStore.selectedGrid.graph.type) || ListChartTypes.includes(dashboardStore.selectedGrid.graph.type) ||
isList isList
@ -165,6 +168,7 @@ export default defineComponent({
watch( watch(
() => [selectorStore.currentService, selectorStore.currentDestService], () => [selectorStore.currentService, selectorStore.currentDestService],
() => { () => {
const isList = ListChartTypes.includes(props.data.graph.type || "");
if (isList) { if (isList) {
return; return;
} }

View File

@ -110,6 +110,7 @@ const props = defineProps({
default: () => ({ dashboardName: "", fontSize: 12, i: "" }), default: () => ({ dashboardName: "", fontSize: 12, i: "" }),
}, },
intervalTime: { type: Array as PropType<string[]>, default: () => [] }, intervalTime: { type: Array as PropType<string[]>, default: () => [] },
needQuery: { type: Boolean, default: false },
}); });
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
@ -119,8 +120,9 @@ const searchEndpoints = ref<Endpoint[]>([]);
const pageSize = 5; const pageSize = 5;
const searchText = ref<string>(""); const searchText = ref<string>("");
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();
@ -193,7 +195,7 @@ watch(
} }
); );
watch( watch(
() => [selectorStore.currentService], () => selectorStore.currentService,
() => { () => {
queryEndpoints(); queryEndpoints();
} }

View File

@ -113,6 +113,7 @@ const props = defineProps({
}), }),
}, },
intervalTime: { type: Array as PropType<string[]>, default: () => [] }, intervalTime: { type: Array as PropType<string[]>, default: () => [] },
needQuery: { type: Boolean, default: false },
}); });
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
@ -122,15 +123,18 @@ const searchInstances = ref<Instance[]>([]); // all instances
const pageSize = 5; const pageSize = 5;
const searchText = ref<string>(""); const searchText = ref<string>("");
queryInstance(); if (props.needQuery) {
queryInstance();
}
async function queryInstance() { async function queryInstance() {
chartLoading.value = true; chartLoading.value = true;
const resp = await selectorStore.getServiceInstances(); const resp = await selectorStore.getServiceInstances();
chartLoading.value = false; chartLoading.value = false;
if (resp.errors) { if (resp && resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
searchInstances.value = [];
instances.value = [];
return; return;
} }
searchInstances.value = selectorStore.pods; searchInstances.value = selectorStore.pods;
@ -193,6 +197,12 @@ watch(
} }
} }
); );
watch(
() => selectorStore.currentService,
() => {
queryInstance();
}
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./style.scss"; @import "./style.scss";