mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-17 14:55:25 +00:00
verificate dashboard names
This commit is contained in:
parent
ecd046c663
commit
83496dc4b5
@ -296,7 +296,7 @@ export const dashboardStore = defineStore({
|
||||
const list = [];
|
||||
for (const t of data) {
|
||||
const c = JSON.parse(t.configuration);
|
||||
const key = [c.layer, c.entity, c.name.split(" ").join("-")].join("_");
|
||||
const key = [c.layer, c.entity, c.name].join("_");
|
||||
|
||||
list.push({
|
||||
id: t.id,
|
||||
@ -404,7 +404,7 @@ export const dashboardStore = defineStore({
|
||||
const key = [
|
||||
this.currentDashboard.layer,
|
||||
this.currentDashboard.entity,
|
||||
this.currentDashboard.name.split(" ").join("-"),
|
||||
this.currentDashboard.name,
|
||||
].join("_");
|
||||
if (this.currentDashboard.id) {
|
||||
sessionStorage.removeItem(key);
|
||||
@ -441,7 +441,7 @@ export const dashboardStore = defineStore({
|
||||
const key = [
|
||||
this.currentDashboard.layer,
|
||||
this.currentDashboard.entity,
|
||||
this.currentDashboard.name.split(" ").join("-"),
|
||||
this.currentDashboard.name,
|
||||
].join("_");
|
||||
sessionStorage.removeItem(key);
|
||||
},
|
||||
|
@ -55,7 +55,7 @@ async function setTemplate() {
|
||||
|
||||
if (!p.entity) {
|
||||
const { layer, entity, name } = dashboardStore.currentDashboard;
|
||||
layoutKey.value = `${layer}_${entity}_${name.split(" ").join("-")}`;
|
||||
layoutKey.value = `${layer}_${entity}_${name}`;
|
||||
}
|
||||
const c: { configuration: string; id: string } = JSON.parse(
|
||||
sessionStorage.getItem(layoutKey.value) || "{}"
|
||||
|
@ -172,7 +172,7 @@ async function importTemplates(event: any) {
|
||||
(d: DashboardItem) => d.id === item.id
|
||||
);
|
||||
const p: DashboardItem = {
|
||||
name: name,
|
||||
name: name.split(" ").join("-"),
|
||||
layer: layer,
|
||||
entity: entity,
|
||||
isRoot: false,
|
||||
@ -196,7 +196,7 @@ function exportTemplates() {
|
||||
}
|
||||
);
|
||||
const templates = arr.map((d: DashboardItem) => {
|
||||
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
||||
const key = [d.layer, d.entity, d.name].join("_");
|
||||
const layout = JSON.parse(sessionStorage.getItem(key) || "{}");
|
||||
return layout;
|
||||
});
|
||||
@ -211,9 +211,7 @@ function handleEdit(row: DashboardItem) {
|
||||
dashboardStore.setEntity(row.entity);
|
||||
dashboardStore.setLayer(row.layer);
|
||||
dashboardStore.setCurrentDashboard(row);
|
||||
router.push(
|
||||
`/dashboard/${row.layer}/${row.entity}/${row.name.split(" ").join("-")}`
|
||||
);
|
||||
router.push(`/dashboard/${row.layer}/${row.entity}/${row.name}`);
|
||||
}
|
||||
|
||||
function handleView(row: DashboardItem) {
|
||||
@ -221,9 +219,7 @@ function handleView(row: DashboardItem) {
|
||||
dashboardStore.setEntity(row.entity);
|
||||
dashboardStore.setLayer(row.layer);
|
||||
dashboardStore.setCurrentDashboard(row);
|
||||
router.push(
|
||||
`/dashboard/${row.layer}/${row.entity}/${row.name.split(" ").join("-")}`
|
||||
);
|
||||
router.push(`/dashboard/${row.layer}/${row.entity}/${row.name}`);
|
||||
}
|
||||
|
||||
async function setRoot(row: DashboardItem) {
|
||||
@ -232,7 +228,7 @@ async function setRoot(row: DashboardItem) {
|
||||
for (const d of dashboardStore.dashboards) {
|
||||
if (d.id === row.id) {
|
||||
d.isRoot = !row.isRoot;
|
||||
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
||||
const key = [d.layer, d.entity, d.name].join("_");
|
||||
const layout = sessionStorage.getItem(key) || "{}";
|
||||
const c = {
|
||||
...JSON.parse(layout).configuration,
|
||||
@ -262,7 +258,7 @@ async function setRoot(row: DashboardItem) {
|
||||
d.isRoot === true
|
||||
) {
|
||||
d.isRoot = false;
|
||||
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
||||
const key = [d.layer, d.entity, d.name].join("_");
|
||||
const layout = sessionStorage.getItem(key) || "{}";
|
||||
const c = {
|
||||
...JSON.parse(layout).configuration,
|
||||
@ -307,7 +303,11 @@ function handleRename(row: DashboardItem) {
|
||||
});
|
||||
}
|
||||
async function updateName(d: DashboardItem, value: string) {
|
||||
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
||||
if (new RegExp(/\s/).test(value)) {
|
||||
ElMessage.error("The name cannot contain spaces, carriage returns, etc");
|
||||
return;
|
||||
}
|
||||
const key = [d.layer, d.entity, d.name].join("_");
|
||||
const layout = sessionStorage.getItem(key) || "{}";
|
||||
const c = {
|
||||
...JSON.parse(layout).configuration,
|
||||
@ -341,7 +341,7 @@ async function updateName(d: DashboardItem, value: string) {
|
||||
const str = [
|
||||
dashboardStore.currentDashboard.layer,
|
||||
dashboardStore.currentDashboard.entity,
|
||||
dashboardStore.currentDashboard.name.split(" ").join("-"),
|
||||
dashboardStore.currentDashboard.name,
|
||||
].join("_");
|
||||
sessionStorage.setItem(
|
||||
str,
|
||||
@ -359,9 +359,7 @@ async function handleDelete(row: DashboardItem) {
|
||||
dashboards.value = dashboardStore.dashboards;
|
||||
loading.value = false;
|
||||
sessionStorage.setItem("dashboards", JSON.stringify(dashboards.value));
|
||||
sessionStorage.removeItem(
|
||||
`${row.layer}_${row.entity}_${row.name.split(" ").join("-")}`
|
||||
);
|
||||
sessionStorage.removeItem(`${row.layer}_${row.entity}_${row.name}`);
|
||||
}
|
||||
function searchDashboards() {
|
||||
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
||||
|
@ -90,7 +90,7 @@ const onCreate = () => {
|
||||
entity: states.entity,
|
||||
layer: states.selectedLayer,
|
||||
});
|
||||
const name = states.name.split(" ").join("-");
|
||||
const name = states.name;
|
||||
const path = `/dashboard/${states.selectedLayer}/${states.entity}/${name}`;
|
||||
router.push(path);
|
||||
};
|
||||
|
@ -170,9 +170,7 @@ function clickEndpoint(scope: any) {
|
||||
dashboardStore.setEntity(EntityType[2].value);
|
||||
dashboardStore.setCurrentDashboard(d);
|
||||
router.push(
|
||||
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${
|
||||
scope.row.id
|
||||
}/${d.name.split(" ").join("-")}`
|
||||
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${scope.row.id}/${d.name}`
|
||||
);
|
||||
}
|
||||
function changePage(pageIndex: number) {
|
||||
|
@ -175,9 +175,7 @@ function clickInstance(scope: any) {
|
||||
dashboardStore.setCurrentDashboard(d);
|
||||
dashboardStore.setEntity(d.entity);
|
||||
router.push(
|
||||
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${
|
||||
scope.row.id
|
||||
}/${d.name.split(" ").join("-")}`
|
||||
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${scope.row.id}/${d.name}`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -254,9 +254,7 @@ function handleLinkClick(event: any, d: Call) {
|
||||
entity: `${e}Relation`,
|
||||
});
|
||||
dashboardStore.setEntity(p.entity);
|
||||
const path = `/dashboard/${p.layer}/${e}Relation/${d.source.id}/${
|
||||
d.target.id
|
||||
}/${p.name.split(" ").join("-")}`;
|
||||
const path = `/dashboard/${p.layer}/${e}Relation/${d.source.id}/${d.target.id}/${p.name}`;
|
||||
const routeUrl = router.resolve({ path });
|
||||
window.open(routeUrl.href, "_blank");
|
||||
dashboardStore.setEntity(origin);
|
||||
@ -412,9 +410,7 @@ function handleGoInstance(name: string) {
|
||||
entity: EntityType[3].value,
|
||||
});
|
||||
dashboardStore.setEntity(p.entity);
|
||||
const path = `/dashboard/${p.layer}/ServiceInstance/${
|
||||
topologyStore.node.id
|
||||
}/${name.split(" ").join("-")}`;
|
||||
const path = `/dashboard/${p.layer}/ServiceInstance/${topologyStore.node.id}/${name}`;
|
||||
const routeUrl = router.resolve({ path });
|
||||
|
||||
window.open(routeUrl.href, "_blank");
|
||||
|
@ -176,9 +176,7 @@ function goDashboard() {
|
||||
});
|
||||
dashboardStore.setEntity(entity);
|
||||
dashboardStore.setCurrentDashboard(d);
|
||||
const path = `/dashboard/${d.layer}/${entity}/${
|
||||
topologyStore.node.serviceId
|
||||
}/${topologyStore.node.id}/${d.name.split(" ").join("-")}`;
|
||||
const path = `/dashboard/${d.layer}/${entity}/${topologyStore.node.serviceId}/${topologyStore.node.id}/${d.name}`;
|
||||
const routeUrl = router.resolve({ path });
|
||||
window.open(routeUrl.href, "_blank");
|
||||
topologyStore.setNode(null);
|
||||
@ -217,9 +215,7 @@ function selectNodeLink(d: any) {
|
||||
entity,
|
||||
});
|
||||
dashboardStore.setEntity(entity);
|
||||
const path = `/dashboard/${p.layer}/${entity}/${sourceObj.serviceId}/${
|
||||
sourceObj.id
|
||||
}/${targetObj.serviceId}/${targetObj.id}/${p.name.split(" ").join("-")}`;
|
||||
const path = `/dashboard/${p.layer}/${entity}/${sourceObj.serviceId}/${sourceObj.id}/${targetObj.serviceId}/${targetObj.id}/${p.name}`;
|
||||
const routeUrl = router.resolve({ path });
|
||||
window.open(routeUrl.href, "_blank");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user