-
+
@@ -42,18 +43,35 @@ import TopologyConfig from "./configuration/Topology.vue";
import WidgetConfig from "./configuration/Widget.vue";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
+import { EntityType } from "./data";
+/*global defineEmits */
+const emit = defineEmits(["update"]);
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
const { t } = useI18n();
const p = useRoute().params;
const layoutKey = ref(`${p.layerId}_${p.entity}_${p.name}`);
-
+dashboardStore.setCurrentDashboard({});
setTemplate();
async function setTemplate() {
await dashboardStore.setDashboards();
if (!p.entity) {
+ const index = dashboardStore.dashboards.findIndex(
+ (d: { name: string; isRoot: boolean; layer: string; entity: string }) =>
+ d.layer === dashboardStore.layerId &&
+ d.entity === EntityType[1].value &&
+ d.isRoot
+ );
+ if (index < 0) {
+ appStore.setPageTitle(dashboardStore.layer);
+ dashboardStore.setCurrentDashboard(null);
+ emit("update", false);
+ return;
+ }
+ const item = dashboardStore.dashboards[index];
+ dashboardStore.setCurrentDashboard(item);
const { layer, entity, name } = dashboardStore.currentDashboard;
layoutKey.value = `${layer}_${entity}_${name}`;
}
@@ -64,16 +82,18 @@ async function setTemplate() {
dashboardStore.setLayout(layout.children || []);
appStore.setPageTitle(layout.name);
- if (!dashboardStore.currentDashboard) {
+ if (p.entity) {
dashboardStore.setCurrentDashboard({
layer: p.layerId,
entity: p.entity,
- name: String(p.name).split("-").join(" "),
+ name: p.name,
id: c.id,
isRoot: layout.isRoot,
});
}
+ emit("update", true);
}
+
function handleClick(e: any) {
e.stopPropagation();
if (e.target.className === "ds-main") {
diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue
index 310cc08d..4d61a90d 100644
--- a/src/views/dashboard/graphs/EndpointList.vue
+++ b/src/views/dashboard/graphs/EndpointList.vue
@@ -167,8 +167,6 @@ function clickEndpoint(scope: any) {
ElMessage.error("No this dashboard");
return;
}
- dashboardStore.setEntity(EntityType[2].value);
- dashboardStore.setCurrentDashboard(d);
router.push(
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${scope.row.id}/${d.name}`
);
diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue
index 1f4152b8..a0fd8b89 100644
--- a/src/views/dashboard/graphs/InstanceList.vue
+++ b/src/views/dashboard/graphs/InstanceList.vue
@@ -168,24 +168,16 @@ function clickInstance(scope: any) {
layer: dashboardStore.layerId,
entity: EntityType[3].value,
});
- if (!d) {
- ElMessage.error("No this dashboard");
- return;
- }
- dashboardStore.setCurrentDashboard(d);
- dashboardStore.setEntity(d.entity);
router.push(
- `/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${scope.row.id}/${d.name}`
+ `/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${
+ scope.row.id
+ }/${d.name.split(" ").join("-")}`
);
}
function changePage(pageIndex: number) {
- instances.value = searchInstances.value.splice(
- (pageIndex - 1 || 0) * pageSize,
- pageSize * (pageIndex || 1)
- );
+ instances.value = searchInstances.value.splice(pageIndex - 1, pageSize);
}
-
function searchList() {
searchInstances.value = selectorStore.pods.filter((d: { label: string }) =>
d.label.includes(searchText.value)
@@ -201,12 +193,6 @@ watch(
}
}
);
-watch(
- () => [selectorStore.currentService],
- () => {
- queryInstance();
- }
-);