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}`);
setTemplate();
async function setTemplate() {
await dashboardStore.setDashboards();
if (dashboardStore.currentDashboard) {
if (!p.entity) {
const { layer, entity, name } = dashboardStore.currentDashboard;
layoutKey.value = `${layer}_${entity}_${name.split(" ").join("-")}`;
}
@ -83,8 +83,6 @@ async function setTemplate() {
isRoot: layout.isRoot,
});
}
dashboardStore.setLayer(dashboardStore.currentDashboard.layer);
dashboardStore.setEntity(dashboardStore.currentDashboard.entity);
}
function handleClick(e: any) {
e.stopPropagation();

View File

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

View File

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

View File

@ -173,6 +173,12 @@ export default defineComponent({
function deleteTabItem(e: Event, idx: number) {
e.stopPropagation();
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() {
dashboardStore.addTabItem(props.data);

View File

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

View File

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

View File

@ -47,7 +47,9 @@ limitations under the License. -->
<template #default="scope">
<router-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"
:style="{ fontSize: `${config.fontSize}px` }"
>
@ -115,6 +117,7 @@ const props = defineProps({
i: string;
metrics: string[];
metricTypes: string[];
isEdit: boolean;
}
>,
default: () => ({ dashboardName: "", fontSize: 12 }),
@ -165,7 +168,9 @@ async function queryServices() {
}
groups.value[s.group] = obj[s.group];
}
if (props.config.isEdit) {
return;
}
queryServiceMetrics(services.value);
}
async function queryServiceMetrics(currentServices: Service[]) {

View File

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