diff --git a/src/views/Layer.vue b/src/views/Layer.vue index 3a2f1f69..347f858c 100644 --- a/src/views/Layer.vue +++ b/src/views/Layer.vue @@ -13,8 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> @@ -26,9 +26,11 @@ import { EntityType } from "./dashboard/data"; import { useDashboardStore } from "@/store/modules/dashboard"; import Edit from "./dashboard/Edit.vue"; import { useI18n } from "vue-i18n"; +import { useAppStoreWithOut } from "@/store/modules/app"; const route = useRoute(); const { t } = useI18n(); +const appStore = useAppStoreWithOut(); const dashboardStore = useDashboardStore(); const routeNames = [ "GeneralServices", @@ -43,7 +45,6 @@ const routeNames = [ "Browser", ]; const layer = ref("GENERAL"); -const hasRoot = ref(false); getDashboard(); @@ -52,11 +53,22 @@ async function getDashboard() { dashboardStore.setLayer(layer.value); dashboardStore.setEntity(EntityType[1].value); dashboardStore.setMode(false); + await dashboardStore.setDashboards(); + 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); + return; + } + const item = dashboardStore.dashboards[index]; + dashboardStore.setCurrentDashboard(item); } -function changeStatus(p: boolean) { - hasRoot.value = p; -} function setLayer(n: string) { switch (n) { case routeNames[0]: diff --git a/src/views/dashboard/Edit.vue b/src/views/dashboard/Edit.vue index 85a00091..f884980e 100644 --- a/src/views/dashboard/Edit.vue +++ b/src/views/dashboard/Edit.vue @@ -43,35 +43,18 @@ 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}`; } @@ -81,7 +64,6 @@ async function setTemplate() { const layout: any = c.configuration || {}; dashboardStore.setLayout(layout.children || []); appStore.setPageTitle(layout.name); - if (p.entity) { dashboardStore.setCurrentDashboard({ layer: p.layerId, @@ -91,7 +73,6 @@ async function setTemplate() { isRoot: layout.isRoot, }); } - emit("update", true); } function handleClick(e: any) { diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue index ef7d0f3a..82d38a8d 100644 --- a/src/views/dashboard/panel/Tool.vue +++ b/src/views/dashboard/panel/Tool.vue @@ -165,12 +165,6 @@ function setCurrentDashboard() { if (params.layerId) { dashboardStore.setLayer(params.layerId); dashboardStore.setEntity(params.entity); - const item = getDashboard({ - name: String(params.name), - layer: dashboardStore.layerId, - entity: EntityType[3].value, - }); - dashboardStore.setCurrentDashboard(item || null); } const type = EntityType.filter( (d: Option) => d.value === dashboardStore.entity @@ -213,7 +207,8 @@ async function setSelector() { } selectorStore.setCurrentService(currentService); selectorStore.setCurrentDestService(currentDestService); - states.currentService = selectorStore.currentService.value; + states.currentService = + selectorStore.currentService && selectorStore.currentService.value; states.currentDestService = selectorStore.currentDestService && selectorStore.currentDestService.value; }