fix dashboards

This commit is contained in:
Qiuxia Fan 2022-03-18 22:56:20 +08:00
parent 846aada0e2
commit 47f09ff1dd
8 changed files with 31 additions and 8 deletions

View File

@ -60,10 +60,10 @@ const p = useRoute().params;
const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`); const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`);
setTemplate(); setTemplate();
async function setTemplate() { async function setTemplate() {
await dashboardStore.setDashboards(); await dashboardStore.setDashboards();
if (dashboardStore.currentDashboard) {
if (!p.entity) {
const { layer, entity, name } = dashboardStore.currentDashboard; const { layer, entity, name } = dashboardStore.currentDashboard;
layoutKey.value = `${layer}_${entity}_${name.split(" ").join("-")}`; layoutKey.value = `${layer}_${entity}_${name.split(" ").join("-")}`;
} }
@ -83,8 +83,6 @@ async function setTemplate() {
isRoot: layout.isRoot, isRoot: layout.isRoot,
}); });
} }
dashboardStore.setLayer(dashboardStore.currentDashboard.layer);
dashboardStore.setEntity(dashboardStore.currentDashboard.entity);
} }
function handleClick(e: any) { function handleClick(e: any) {
e.stopPropagation(); e.stopPropagation();

View File

@ -37,6 +37,7 @@ limitations under the License. -->
metrics: dashboardStore.selectedGrid.metrics, metrics: dashboardStore.selectedGrid.metrics,
metricTypes: dashboardStore.selectedGrid.metricTypes, metricTypes: dashboardStore.selectedGrid.metricTypes,
standard: dashboardStore.selectedGrid.standard, standard: dashboardStore.selectedGrid.standard,
isEdit: true,
}" }"
/> />
<div v-show="!dashboardStore.selectedGrid.graph.type" class="no-data"> <div v-show="!dashboardStore.selectedGrid.graph.type" class="no-data">

View File

@ -179,8 +179,8 @@ async function setMetricType(catalog?: string) {
} }
dashboardStore.selectWidget({ dashboardStore.selectWidget({
...dashboardStore.selectedGrid, ...dashboardStore.selectedGrid,
metrics, metrics: states.metrics,
metricTypes, metricTypes: states.metricTypes,
}); });
states.metricTypeList = []; states.metricTypeList = [];
for (const metric of metrics) { for (const metric of metrics) {
@ -321,6 +321,9 @@ function changeMetricType(index: number, opt: Option[] | any) {
queryMetrics(); queryMetrics();
} }
async function queryMetrics() { async function queryMetrics() {
if (states.isList) {
return;
}
const { standard } = dashboardStore.selectedGrid; const { standard } = dashboardStore.selectedGrid;
const params = useQueryProcessor({ ...states, standard }); const params = useQueryProcessor({ ...states, standard });
if (!params) { if (!params) {

View File

@ -173,6 +173,12 @@ export default defineComponent({
function deleteTabItem(e: Event, idx: number) { function deleteTabItem(e: Event, idx: number) {
e.stopPropagation(); e.stopPropagation();
dashboardStore.removeTabItem(props.data, idx); dashboardStore.removeTabItem(props.data, idx);
const kids = dashboardStore.layout[l].children[0];
const arr = (kids && kids.children) || [];
dashboardStore.setCurrentTabItems(arr);
dashboardStore.activeGridItem(0);
activeTabIndex.value = 0;
needQuery.value = true;
} }
function addTabItem() { function addTabItem() {
dashboardStore.addTabItem(props.data); dashboardStore.addTabItem(props.data);

View File

@ -102,6 +102,7 @@ const props = defineProps({
i: string; i: string;
metrics: string[]; metrics: string[];
metricTypes: string[]; metricTypes: string[];
isEdit: boolean;
} }
>, >,
default: () => ({ dashboardName: "", fontSize: 12, i: "" }), default: () => ({ dashboardName: "", fontSize: 12, i: "" }),
@ -129,6 +130,9 @@ async function queryEndpoints() {
} }
searchEndpoints.value = selectorStore.pods; searchEndpoints.value = selectorStore.pods;
endpoints.value = selectorStore.pods.splice(0, pageSize); endpoints.value = selectorStore.pods.splice(0, pageSize);
if (props.config.isEdit) {
return;
}
queryEndpointMetrics(endpoints.value); queryEndpointMetrics(endpoints.value);
} }
async function queryEndpointMetrics(currentPods: Endpoint[]) { async function queryEndpointMetrics(currentPods: Endpoint[]) {

View File

@ -99,6 +99,7 @@ const props = defineProps({
i: string; i: string;
metrics: string[]; metrics: string[];
metricTypes: string[]; metricTypes: string[];
isEdit: boolean;
} }
>, >,
default: () => ({ default: () => ({
@ -132,6 +133,9 @@ async function queryInstance() {
} }
searchInstances.value = selectorStore.pods; searchInstances.value = selectorStore.pods;
instances.value = searchInstances.value.splice(0, pageSize); instances.value = searchInstances.value.splice(0, pageSize);
if (props.config.isEdit) {
return;
}
queryInstanceMetrics(instances.value); queryInstanceMetrics(instances.value);
} }

View File

@ -47,7 +47,9 @@ limitations under the License. -->
<template #default="scope"> <template #default="scope">
<router-link <router-link
class="link" class="link"
:to="`/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${scope.row.id}/${config.dashboardName}`" :to="`/dashboard/${dashboardStore.layerId}/${
EntityType[0].value
}/${scope.row.id}/${config.dashboardName.split(' ').join('-')}`"
:key="1" :key="1"
:style="{ fontSize: `${config.fontSize}px` }" :style="{ fontSize: `${config.fontSize}px` }"
> >
@ -115,6 +117,7 @@ const props = defineProps({
i: string; i: string;
metrics: string[]; metrics: string[];
metricTypes: string[]; metricTypes: string[];
isEdit: boolean;
} }
>, >,
default: () => ({ dashboardName: "", fontSize: 12 }), default: () => ({ dashboardName: "", fontSize: 12 }),
@ -165,7 +168,9 @@ async function queryServices() {
} }
groups.value[s.group] = obj[s.group]; groups.value[s.group] = obj[s.group];
} }
if (props.config.isEdit) {
return;
}
queryServiceMetrics(services.value); queryServiceMetrics(services.value);
} }
async function queryServiceMetrics(currentServices: Service[]) { async function queryServiceMetrics(currentServices: Service[]) {

View File

@ -128,6 +128,8 @@ const states = reactive<{
currentDestPod: "", currentDestPod: "",
}); });
dashboardStore.setLayer(params.layerId);
dashboardStore.setEntity(params.entity);
appStore.setEventStack([initSelector]); appStore.setEventStack([initSelector]);
initSelector(); initSelector();