delete config

This commit is contained in:
Qiuxia Fan 2022-03-26 20:48:49 +08:00
parent a5fe322304
commit cdb776866a
3 changed files with 42 additions and 8 deletions

View File

@ -244,7 +244,7 @@ export enum LegendOpt {
} }
export const DepthList = [1, 2, 3, 4, 5].map((item: number) => ({ export const DepthList = [1, 2, 3, 4, 5].map((item: number) => ({
value: item, value: item,
label: item, label: String(item),
})); }));
export const Status = [ export const Status = [
{ label: "All", value: "ALL" }, { label: "All", value: "ALL" },

View File

@ -119,10 +119,11 @@ function changeMetric(val: string) {
currentIndex.value = index || 0; currentIndex.value = index || 0;
const config = getMetricConfig.value; const config = getMetricConfig.value;
currentConfig.value = config[index] || { currentConfig.value = {
unit: "", unit: "",
label: "", label: "",
calculation: "", calculation: "",
...config[index],
}; };
} }
watch( watch(

View File

@ -416,10 +416,22 @@ function updateSettings(config?: { [key: string]: MetricConfigOpt[] }) {
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, ...param }); dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, ...param });
dashboardStore.setConfigs({ ...dashboardStore.selectedGrid, ...param }); dashboardStore.setConfigs({ ...dashboardStore.selectedGrid, ...param });
emit("update", param); emit("update", param);
console.log(dashboardStore.selectedGrid);
} }
function updateLinkServerMetrics(options: Option[] | any) { function updateLinkServerMetrics(options: Option[] | any) {
states.linkServerMetrics = options.map((d: Option) => d.value); const opt = options.map((d: Option) => d.value);
const index = states.linkServerMetrics.findIndex(
(d: any) => !opt.includes(d)
);
states.linkServerMetrics = opt;
if (index < 0) {
changeLinkServerMetrics(); changeLinkServerMetrics();
return;
}
const config = (
dashboardStore.selectedGrid.linkServerMetricConfig || []
).splice(index, 1);
changeLinkServerMetrics({ linkServerMetricConfig: config });
} }
async function changeLinkServerMetrics(config?: { async function changeLinkServerMetrics(config?: {
[key: string]: MetricConfigOpt[]; [key: string]: MetricConfigOpt[];
@ -432,8 +444,19 @@ async function changeLinkServerMetrics(config?: {
topologyStore.getLinkServerMetrics(states.linkServerMetrics); topologyStore.getLinkServerMetrics(states.linkServerMetrics);
} }
function updateLinkClientMetrics(options: Option[] | any) { function updateLinkClientMetrics(options: Option[] | any) {
states.linkClientMetrics = options.map((d: Option) => d.value); const opt = options.map((d: Option) => d.value);
const index = states.linkClientMetrics.findIndex(
(d: any) => !opt.includes(d)
);
states.linkClientMetrics = opt;
if (index < 0) {
changeLinkClientMetrics(); changeLinkClientMetrics();
return;
}
const config = (
dashboardStore.selectedGrid.linkClientMetricConfig || []
).splice(index, 1);
changeLinkClientMetrics({ linkClientMetricConfig: config });
} }
async function changeLinkClientMetrics(config?: { async function changeLinkClientMetrics(config?: {
[key: string]: MetricConfigOpt[]; [key: string]: MetricConfigOpt[];
@ -446,8 +469,18 @@ async function changeLinkClientMetrics(config?: {
topologyStore.getLinkClientMetrics(states.linkClientMetrics); topologyStore.getLinkClientMetrics(states.linkClientMetrics);
} }
function updateNodeMetrics(options: Option[] | any) { function updateNodeMetrics(options: Option[] | any) {
states.nodeMetrics = options.map((d: Option) => d.value); const opt = options.map((d: Option) => d.value);
const index = states.nodeMetrics.findIndex((d: any) => !opt.includes(d));
states.nodeMetrics = opt;
if (index < 0) {
changeNodeMetrics(); changeNodeMetrics();
return;
}
const config = (dashboardStore.selectedGrid.nodeMetricConfig || []).splice(
index,
1
);
changeNodeMetrics({ nodeMetricConfig: config });
} }
async function changeNodeMetrics(config?: { async function changeNodeMetrics(config?: {
[key: string]: MetricConfigOpt[]; [key: string]: MetricConfigOpt[];