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,
metricConfig: dashboardStore.selectedGrid.metricConfig,
}"
:needQuery="true"
/>
<div v-show="!graph.type" class="no-data">
{{ t("noData") }}

View File

@ -111,6 +111,7 @@ const props = defineProps({
i: "",
}),
},
needQuery: { type: Boolean, default: false },
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
});
// const emit = defineEmits(["changeOpt"]);
@ -121,8 +122,9 @@ const endpoints = ref<Endpoint[]>([]);
const searchText = ref<string>("");
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
if (props.needQuery) {
queryEndpoints();
}
async function queryEndpoints() {
chartLoading.value = true;
const resp = await selectorStore.getEndpoints({

View File

@ -142,7 +142,6 @@ const props = defineProps({
},
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
needQuery: { type: Boolean, default: false },
isEdit: { type: Boolean, default: false },
});
const { t } = useI18n();
const selectorStore = useSelectorStore();
@ -152,8 +151,10 @@ const instances = ref<Instance[]>([]); // current instances
const pageSize = 10;
const searchText = ref<string>("");
const colMetrics = computed(() => props.config.metrics.map((d: string) => d));
if (props.needQuery) {
queryInstance();
}
async function queryInstance() {
chartLoading.value = true;
const resp = await selectorStore.getServiceInstances();

View File

@ -120,7 +120,7 @@ limitations under the License. -->
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, computed } from "vue";
import { reactive, ref, computed, watch } from "vue";
import { useRoute } from "vue-router";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
@ -277,20 +277,20 @@ async function setDestSelector() {
}
async function getServices() {
if (key.value === 10) {
if (!dashboardStore.entity) {
return;
}
if (!dashboardStore.layerId) {
return;
}
if (dashboardStore.entity === EntityType[1].value) {
return;
}
const json = await selectorStore.fetchServices(dashboardStore.layerId);
if (json.errors) {
ElMessage.error(json.errors);
return;
}
if (dashboardStore.entity === EntityType[1].value) {
return;
}
selectorStore.setCurrentService(
selectorStore.services.length ? selectorStore.services[0] : null
);
@ -538,6 +538,15 @@ function searchDestPods(query: string) {
param
);
}
watch(
() => dashboardStore.entity,
(newVal, oldVal) => {
if (newVal === oldVal) {
return;
}
getServices();
}
);
</script>
<style lang="scss" scoped>
.dashboard-tool {