fix dashboards

This commit is contained in:
Qiuxia Fan 2022-04-02 11:20:41 +08:00
parent f3c8a3a9db
commit f6642c0dda
4 changed files with 22 additions and 9 deletions

View File

@ -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") }}

View File

@ -111,6 +111,7 @@ 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 emit = defineEmits(["changeOpt"]);
@ -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({

View File

@ -142,7 +142,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 +151,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();

View File

@ -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";
@ -277,20 +277,20 @@ async function setDestSelector() {
} }
async function getServices() { async function getServices() {
if (key.value === 10) { 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
); );
@ -538,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 {