You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/04/12 08:29:37 UTC

[skywalking-booster-ui] branch main updated: fix: refresh dashboards with current selectors (#64)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-booster-ui.git


The following commit(s) were added to refs/heads/main by this push:
     new 2dd9df1  fix: refresh dashboards with current selectors (#64)
2dd9df1 is described below

commit 2dd9df19d71c94097f3e3b6a976878e7405e597d
Author: Fine0830 <fi...@outlook.com>
AuthorDate: Tue Apr 12 16:29:33 2022 +0800

    fix: refresh dashboards with current selectors (#64)
---
 src/views/Settings.vue               |   4 +-
 src/views/dashboard/panel/Layout.vue |   4 +-
 src/views/dashboard/panel/Tool.vue   | 109 +++++++++++++++++++++++++----------
 3 files changed, 83 insertions(+), 34 deletions(-)

diff --git a/src/views/Settings.vue b/src/views/Settings.vue
index 53ccb04..79c2fbd 100644
--- a/src/views/Settings.vue
+++ b/src/views/Settings.vue
@@ -77,13 +77,13 @@ import { Languages } from "@/constants/data";
 import Selector from "@/components/Selector.vue";
 
 const { t, locale } = useI18n();
+const appStore = useAppStoreWithOut();
 const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({
   timer: null,
 });
 const lang = ref<string>(locale.value || "en");
 const autoTime = ref<number>(6);
-const auto = ref<boolean>(false);
-const appStore = useAppStoreWithOut();
+const auto = ref<boolean>(appStore.autoRefresh || false);
 const utcArr = appStore.utc.split(":");
 const utcHour = ref<number>(isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]));
 const utcMin = ref<number>(isNaN(Number(utcArr[1])) ? 0 : Number(utcArr[1]));
diff --git a/src/views/dashboard/panel/Layout.vue b/src/views/dashboard/panel/Layout.vue
index 6bb9a0b..409df42 100644
--- a/src/views/dashboard/panel/Layout.vue
+++ b/src/views/dashboard/panel/Layout.vue
@@ -53,9 +53,7 @@ export default defineComponent({
     const { t } = useI18n();
     const dashboardStore = useDashboardStore();
     const selectorStore = useSelectorStore();
-    // function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
-    //   dashboardStore.setLayout(newLayout);
-    // }
+
     function clickGrid(item: LayoutConfig) {
       dashboardStore.activeGridItem(item.i);
       dashboardStore.selectWidget(item);
diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue
index b5b9864..2c079d7 100644
--- a/src/views/dashboard/panel/Tool.vue
+++ b/src/views/dashboard/panel/Tool.vue
@@ -217,12 +217,23 @@ async function setSelector() {
     return;
   }
   let currentService, currentDestService;
-  for (const d of selectorStore.services) {
-    if (d.id === String(params.serviceId)) {
-      currentService = d;
+  if (states.currentService) {
+    for (const d of selectorStore.services) {
+      if (d.value === states.currentService) {
+        currentService = d;
+      }
+      if (d.value === states.currentDestService) {
+        currentDestService = d;
+      }
     }
-    if (d.id === String(params.destServiceId)) {
-      currentDestService = d;
+  } else {
+    for (const d of selectorStore.services) {
+      if (d.id === String(params.serviceId)) {
+        currentService = d;
+      }
+      if (d.id === String(params.destServiceId)) {
+        currentDestService = d;
+      }
     }
   }
   selectorStore.setCurrentService(currentService);
@@ -244,9 +255,14 @@ async function setSourceSelector() {
     return;
   }
   const pod = params.podId || selectorStore.pods[0].id;
-  const currentPod = selectorStore.pods.find(
-    (d: { id: string }) => d.id === pod
-  );
+  let currentPod;
+  if (states.currentPod) {
+    currentPod = selectorStore.pods.find(
+      (d: { id: string }) => d.label === states.currentPod
+    );
+  } else {
+    currentPod = selectorStore.pods.find((d: { id: string }) => d.id === pod);
+  }
   if (currentPod) {
     selectorStore.setCurrentPod(currentPod);
     states.currentPod = currentPod.label;
@@ -267,9 +283,16 @@ async function setDestSelector() {
     return;
   }
   const destPod = params.destPodId || selectorStore.destPods[0].id;
-  const currentDestPod = selectorStore.destPods.find(
-    (d: { id: string }) => d.id === destPod
-  );
+  let currentDestPod = "";
+  if (states.currentDestPod) {
+    currentDestPod = selectorStore.pods.find(
+      (d: { id: string }) => d.label === states.currentDestPod
+    );
+  } else {
+    currentDestPod = selectorStore.destPods.find(
+      (d: { id: string }) => d.id === destPod
+    );
+  }
   if (currentDestPod) {
     selectorStore.setCurrentDestPod(currentDestPod);
     states.currentDestPod = currentDestPod.label;
@@ -291,12 +314,24 @@ async function getServices() {
     ElMessage.error(json.errors);
     return;
   }
-  selectorStore.setCurrentService(
-    selectorStore.services.length ? selectorStore.services[0] : null
-  );
-  selectorStore.setCurrentDestService(
-    selectorStore.services.length ? selectorStore.services[1] : null
-  );
+  let s;
+  if (states.currentService) {
+    s = (selectorStore.services || []).find(
+      (d) => d.label === states.currentService
+    );
+  } else {
+    s = (selectorStore.services || []).find((d, index) => index === 0);
+  }
+  selectorStore.setCurrentService(s || null);
+  let d;
+  if (states.currentService) {
+    d = (selectorStore.services || []).find(
+      (d) => d.label === states.currentDestService
+    );
+  } else {
+    d = (selectorStore.services || []).find((d, index) => index === 1);
+  }
+  selectorStore.setCurrentDestService(d || null);
   if (!selectorStore.currentService) {
     return;
   }
@@ -447,18 +482,26 @@ async function fetchPods(
     case EntityType[2].value:
       resp = await selectorStore.getEndpoints({ serviceId, ...param });
       if (setPod) {
-        selectorStore.setCurrentPod(
-          selectorStore.pods.length ? selectorStore.pods[0] : null
-        );
+        let p;
+        if (states.currentPod) {
+          p = selectorStore.pods.find((d) => d.label === states.currentPod);
+        } else {
+          p = selectorStore.pods.find((d, index) => index === 0);
+        }
+        selectorStore.setCurrentPod(p || null);
         states.currentPod = selectorStore.currentPod.label;
       }
       break;
     case EntityType[3].value:
       resp = await selectorStore.getServiceInstances({ serviceId });
       if (setPod) {
-        selectorStore.setCurrentPod(
-          selectorStore.pods.length ? selectorStore.pods[0] : null
-        );
+        let p;
+        if (states.currentPod) {
+          p = selectorStore.pods.find((d) => d.label === states.currentPod);
+        } else {
+          p = selectorStore.pods.find((d, index) => index === 0);
+        }
+        selectorStore.setCurrentPod(p || null);
         states.currentPod = selectorStore.currentPod.label;
       }
       break;
@@ -469,9 +512,13 @@ async function fetchPods(
         ...param,
       });
       if (setPod) {
-        selectorStore.setCurrentDestPod(
-          selectorStore.destPods.length ? selectorStore.destPods[0] : null
-        );
+        let p;
+        if (states.currentDestPod) {
+          p = selectorStore.pods.find((d) => d.label === states.currentDestPod);
+        } else {
+          p = selectorStore.pods.find((d, index) => index === 0);
+        }
+        selectorStore.setCurrentDestPod(p || null);
         states.currentDestPod = selectorStore.currentDestPod.label;
       }
       break;
@@ -481,9 +528,13 @@ async function fetchPods(
         isRelation: true,
       });
       if (setPod) {
-        selectorStore.setCurrentDestPod(
-          selectorStore.destPods.length ? selectorStore.destPods[0] : null
-        );
+        let p;
+        if (states.currentDestPod) {
+          p = selectorStore.pods.find((d) => d.label === states.currentDestPod);
+        } else {
+          p = selectorStore.pods.find((d, index) => index === 0);
+        }
+        selectorStore.setCurrentDestPod(p || null);
         states.currentDestPod = selectorStore.currentDestPod.label;
       }
       break;