mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-01 22:24:25 +00:00
fix: import dashboard templates (#363)
This commit is contained in:
parent
5061b19cf7
commit
a46b91d1cf
@ -429,8 +429,7 @@ export const dashboardStore = defineStore({
|
|||||||
d.layer === this.currentDashboard?.layer,
|
d.layer === this.currentDashboard?.layer,
|
||||||
);
|
);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
const { t } = useI18n();
|
ElMessage.error("The dashboard name cannot be duplicate");
|
||||||
ElMessage.error(t("nameError"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res = await graphql.query("addNewTemplate").params({ setting: { configuration: JSON.stringify(c) } });
|
res = await graphql.query("addNewTemplate").params({ setting: { configuration: JSON.stringify(c) } });
|
||||||
|
@ -315,19 +315,19 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
for (const item of arr) {
|
for (const item of arr) {
|
||||||
const { layer, name, entity, isRoot, children, isDefault } = item.configuration;
|
const { layer, name, entity, isRoot, children, isDefault, expressions, expressionsConfig } = item.configuration;
|
||||||
const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id);
|
const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id);
|
||||||
const p: DashboardItem = {
|
const p: DashboardItem = {
|
||||||
name: name.split(" ").join("-"),
|
name: name.split(" ").join("-"),
|
||||||
layer: layer,
|
layer: layer,
|
||||||
entity: entity,
|
entity: entity,
|
||||||
isRoot: false,
|
isRoot: isRoot || false,
|
||||||
isDefault: false,
|
isDefault: isDefault || false,
|
||||||
|
expressions: expressions,
|
||||||
|
expressionsConfig: expressionsConfig,
|
||||||
};
|
};
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
p.id = item.id;
|
p.id = item.id;
|
||||||
p.isRoot = isRoot;
|
|
||||||
p.isDefault = isDefault;
|
|
||||||
}
|
}
|
||||||
dashboardStore.setCurrentDashboard(p);
|
dashboardStore.setCurrentDashboard(p);
|
||||||
dashboardStore.setLayout(children);
|
dashboardStore.setLayout(children);
|
||||||
@ -336,6 +336,7 @@ limitations under the License. -->
|
|||||||
dashboards.value = dashboardStore.dashboards;
|
dashboards.value = dashboardStore.dashboards;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
dashboardFile.value = null;
|
dashboardFile.value = null;
|
||||||
|
searchDashboards(currentPage.value);
|
||||||
}
|
}
|
||||||
function exportTemplates() {
|
function exportTemplates() {
|
||||||
if (!multipleSelection.value.length) {
|
if (!multipleSelection.value.length) {
|
||||||
@ -597,6 +598,7 @@ limitations under the License. -->
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
sessionStorage.setItem("dashboards", JSON.stringify(dashboards.value));
|
sessionStorage.setItem("dashboards", JSON.stringify(dashboards.value));
|
||||||
sessionStorage.removeItem(`${row.layer}_${row.entity}_${row.name}`);
|
sessionStorage.removeItem(`${row.layer}_${row.entity}_${row.name}`);
|
||||||
|
searchDashboards(currentPage.value);
|
||||||
}
|
}
|
||||||
function searchDashboards(pageIndex: number) {
|
function searchDashboards(pageIndex: number) {
|
||||||
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
||||||
|
@ -110,11 +110,6 @@ limitations under the License. -->
|
|||||||
return m.length ? m : [{ label: "", value: "" }];
|
return m.length ? m : [{ label: "", value: "" }];
|
||||||
});
|
});
|
||||||
const currentMetric = ref<string>(metricList.value[0].value);
|
const currentMetric = ref<string>(metricList.value[0].value);
|
||||||
const currentConfig = ref<{ unit: string; calculation: string; label: string }>({
|
|
||||||
unit: "",
|
|
||||||
calculation: "",
|
|
||||||
label: "",
|
|
||||||
});
|
|
||||||
const currentIndex = ref<number>(0);
|
const currentIndex = ref<number>(0);
|
||||||
const getMetricConfig = computed(() => {
|
const getMetricConfig = computed(() => {
|
||||||
if (props.type === "hierarchyServicesConfig") {
|
if (props.type === "hierarchyServicesConfig") {
|
||||||
@ -125,7 +120,12 @@ limitations under the License. -->
|
|||||||
},
|
},
|
||||||
ConfigFieldTypes.ISDEFAULT,
|
ConfigFieldTypes.ISDEFAULT,
|
||||||
);
|
);
|
||||||
return (dashboard && dashboard.expressionsConfig) || [];
|
if (!dashboard) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const config = dashboard.expressionsConfig || [];
|
||||||
|
|
||||||
|
return config || [];
|
||||||
}
|
}
|
||||||
let config = [];
|
let config = [];
|
||||||
|
|
||||||
@ -143,6 +143,14 @@ limitations under the License. -->
|
|||||||
return config || [];
|
return config || [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentConfig = ref<{ unit: string; calculation: string; label: string }>(
|
||||||
|
getMetricConfig.value[0] || {
|
||||||
|
unit: "",
|
||||||
|
calculation: "",
|
||||||
|
label: "",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
function changeConfigs(param: { [key: string]: string }) {
|
function changeConfigs(param: { [key: string]: string }) {
|
||||||
const metricConfig = getMetricConfig.value || [];
|
const metricConfig = getMetricConfig.value || [];
|
||||||
metricConfig[currentIndex.value] = {
|
metricConfig[currentIndex.value] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user