You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by kd...@apache.org on 2019/12/08 07:51:40 UTC

[skywalking-rocketbot-ui] branch Sync_timezone_with_oap_server created (now c82c4ef)

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

kdump pushed a change to branch Sync_timezone_with_oap_server
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git.


      at c82c4ef  Sync timezone with oap server

This branch includes the following new commits:

     new c82c4ef  Sync timezone with oap server

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-rocketbot-ui] 01/01: Sync timezone with oap server

Posted by kd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kdump pushed a commit to branch Sync_timezone_with_oap_server
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git

commit c82c4ef27a1439a1fe165372f99bd3b12c5b625c
Author: x22x22 <ro...@gmail.com>
AuthorDate: Sun Dec 8 15:51:20 2019 +0800

    Sync timezone with oap server
    
    https://github.com/apache/skywalking-rocketbot-ui/issues/213
---
 package-lock.json                 | 91 +++++++++++----------------------------
 src/graph/fragments/option.ts     |  8 ++++
 src/graph/query/option.ts         |  5 ++-
 src/main.ts                       | 51 ++++++++++++----------
 src/store/modules/global/index.ts |  6 ---
 src/utils/localtime.ts            | 22 ++++++++++
 6 files changed, 88 insertions(+), 95 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 004298d..8262f15 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1679,14 +1679,6 @@
       "integrity": "sha1-ePrtjD0HSrgfIrTphdeehzj3IPg=",
       "dev": true
     },
-    "async-validator": {
-      "version": "1.8.5",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/async-validator/-/async-validator-1.8.5.tgz",
-      "integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=",
-      "requires": {
-        "babel-runtime": "6.x"
-      }
-    },
     "asynckit": {
       "version": "0.4.0",
       "resolved": "http://registry.npm.taobao.org/asynckit/download/asynckit-0.4.0.tgz",
@@ -1793,11 +1785,6 @@
         }
       }
     },
-    "babel-helper-vue-jsx-merge-props": {
-      "version": "2.0.3",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
-      "integrity": "sha1-Iq69OzOQIyjlEyk6jkmSs4T58bY="
-    },
     "babel-loader": {
       "version": "8.0.5",
       "resolved": "http://registry.npm.taobao.org/babel-loader/download/babel-loader-8.0.5.tgz",
@@ -1819,22 +1806,6 @@
         "object.assign": "^4.1.0"
       }
     },
-    "babel-runtime": {
-      "version": "6.26.0",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/babel-runtime/-/babel-runtime-6.26.0.tgz",
-      "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
-      "requires": {
-        "core-js": "^2.4.0",
-        "regenerator-runtime": "^0.11.0"
-      },
-      "dependencies": {
-        "regenerator-runtime": {
-          "version": "0.11.1",
-          "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
-          "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk="
-        }
-      }
-    },
     "balanced-match": {
       "version": "1.0.0",
       "resolved": "http://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz",
@@ -3007,7 +2978,8 @@
     "core-js": {
       "version": "2.6.5",
       "resolved": "http://registry.npm.taobao.org/core-js/download/core-js-2.6.5.tgz",
-      "integrity": "sha1-RLyNJJ5/sv9dAOA0Gn/7lPv2eJU="
+      "integrity": "sha1-RLyNJJ5/sv9dAOA0Gn/7lPv2eJU=",
+      "dev": true
     },
     "core-util-is": {
       "version": "1.0.2",
@@ -3700,7 +3672,8 @@
     "deepmerge": {
       "version": "1.5.2",
       "resolved": "http://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz",
-      "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M="
+      "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M=",
+      "dev": true
     },
     "default-gateway": {
       "version": "4.1.2",
@@ -4030,19 +4003,6 @@
       "integrity": "sha1-scz2Gd9yla6he8aVHcaJYyYp5Kk=",
       "dev": true
     },
-    "element-ui": {
-      "version": "2.12.0",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/element-ui/-/element-ui-2.12.0.tgz",
-      "integrity": "sha1-qJO8Ea5Pfbt+nVQWBvI+ZD8THuQ=",
-      "requires": {
-        "async-validator": "~1.8.1",
-        "babel-helper-vue-jsx-merge-props": "^2.0.0",
-        "deepmerge": "^1.2.0",
-        "normalize-wheel": "^1.0.1",
-        "resize-observer-polyfill": "^1.5.0",
-        "throttle-debounce": "^1.0.1"
-      }
-    },
     "elliptic": {
       "version": "6.4.1",
       "resolved": "http://registry.npm.taobao.org/elliptic/download/elliptic-6.4.1.tgz",
@@ -4784,12 +4744,14 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -4804,17 +4766,20 @@
         "code-point-at": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "concat-map": {
           "version": "0.0.1",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -4931,7 +4896,8 @@
         "inherits": {
           "version": "2.0.3",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "ini": {
           "version": "1.3.5",
@@ -4943,6 +4909,7 @@
           "version": "1.0.0",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -4957,6 +4924,7 @@
           "version": "3.0.4",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -4964,12 +4932,14 @@
         "minimist": {
           "version": "0.0.8",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -4988,6 +4958,7 @@
           "version": "0.5.1",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -5068,7 +5039,8 @@
         "number-is-nan": {
           "version": "1.0.1",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -5080,6 +5052,7 @@
           "version": "1.4.0",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -5201,6 +5174,7 @@
           "version": "1.0.2",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -7388,11 +7362,6 @@
       "integrity": "sha1-suHE3E98bVd0PfczpPWXjRhlBVk=",
       "dev": true
     },
-    "normalize-wheel": {
-      "version": "1.0.1",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/normalize-wheel/-/normalize-wheel-1.0.1.tgz",
-      "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU="
-    },
     "noty": {
       "version": "3.2.0-beta",
       "resolved": "https://registry.npmjs.org/noty/-/noty-3.2.0-beta.tgz",
@@ -9071,11 +9040,6 @@
       "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
       "dev": true
     },
-    "resize-observer-polyfill": {
-      "version": "1.5.1",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
-      "integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
-    },
     "resolve": {
       "version": "1.10.0",
       "resolved": "http://registry.npm.taobao.org/resolve/download/resolve-1.10.0.tgz",
@@ -10515,11 +10479,6 @@
         "neo-async": "^2.6.0"
       }
     },
-    "throttle-debounce": {
-      "version": "1.1.0",
-      "resolved": "http://nexus.yfb.sunline.cn:8099/nexus3/repository/npm-sunline/throttle-debounce/-/throttle-debounce-1.1.0.tgz",
-      "integrity": "sha1-UYU9o3vmihVctugns1FKPEIuic0="
-    },
     "through2": {
       "version": "2.0.5",
       "resolved": "http://registry.npm.taobao.org/through2/download/through2-2.0.5.tgz",
diff --git a/src/graph/fragments/option.ts b/src/graph/fragments/option.ts
index e64b73e..9eb0d67 100644
--- a/src/graph/fragments/option.ts
+++ b/src/graph/fragments/option.ts
@@ -55,3 +55,11 @@ export const Instances = {
       }
     }
   `};
+
+export const OAPTimeInfo = {
+  query: `
+    getTimeInfo {
+      timezone
+      currentTimestamp
+    }
+  `};
diff --git a/src/graph/query/option.ts b/src/graph/query/option.ts
index 209befe..11e436e 100644
--- a/src/graph/query/option.ts
+++ b/src/graph/query/option.ts
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-import { Services, Endpoints, Instances, Database } from '../fragments/option';
+import { Services, Endpoints, Instances, Database, OAPTimeInfo } from '../fragments/option';
 
 export const queryServices =
   `query queryServices(${Services.variable}) {${Services.query}}`;
@@ -28,3 +28,6 @@ export const queryEndpoints =
 
 export const queryInstances =
   `query queryInstances(${Instances.variable}) {${Instances.query}}`;
+
+export const queryOAPTimeInfo =
+  `query queryOAPTimeInfo {${OAPTimeInfo.query}}`;
diff --git a/src/main.ts b/src/main.ts
index db06627..ab370f1 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -15,28 +15,29 @@
  * limitations under the License.
  */
 
-import Vue from 'vue';
-import moment from 'dayjs';
+import en from '@/assets/lang/en';
+import zh from '@/assets/lang/zh';
 import clickout from '@/utils/clickout';
+import { queryOAPTimeInfo } from '@/utils/localtime';
 import tooltip from '@/utils/tooltip';
-import zh from '@/assets/lang/zh';
-import en from '@/assets/lang/en';
-import VueI18n from 'vue-i18n';
-import eventBus from './event-bus';
-import App from './App.vue';
-import router from './router';
-import store from './store';
-import components from './components';
-import 'echarts/lib/chart/line';
-import 'echarts/lib/chart/graph';
+import moment from 'dayjs';
 import 'echarts/lib/chart/bar';
-import 'echarts/lib/chart/scatter';
+import 'echarts/lib/chart/graph';
 import 'echarts/lib/chart/heatmap';
+import 'echarts/lib/chart/line';
 import 'echarts/lib/chart/sankey';
+import 'echarts/lib/chart/scatter';
 import 'echarts/lib/component/legend';
 import 'echarts/lib/component/tooltip';
+import Vue from 'vue';
+import VueI18n from 'vue-i18n';
 import VModal from 'vue-js-modal';
+import App from './App.vue';
 import './assets';
+import components from './components';
+import eventBus from './event-bus';
+import router from './router';
+import store from './store';
 
 Vue.use(eventBus);
 Vue.use(VueI18n);
@@ -58,17 +59,23 @@ const i18n = new VueI18n({
   locale: language,
   messages: {
     zh,
-    en,
-  },
+    en
+  }
 });
 
-if (!window.Promise) { window.Promise = Promise; }
+if (!window.Promise) {
+  window.Promise = Promise;
+}
 
 Vue.config.productionTip = false;
 
-new Vue({
-  i18n,
-  router,
-  store,
-  render: (h) => h(App),
-}).$mount('#app');
+queryOAPTimeInfo().then(() => {
+  new Vue({
+    i18n,
+    router,
+    store,
+    render: (h) => h(App)
+  }).$mount('#app');
+});
+
+
diff --git a/src/store/modules/global/index.ts b/src/store/modules/global/index.ts
index 9dd0eb4..d903534 100644
--- a/src/store/modules/global/index.ts
+++ b/src/store/modules/global/index.ts
@@ -97,12 +97,6 @@ const dateFormatTime = (date: Date, step: string): string => {
   return '';
 };
 
-let utc = window.localStorage.getItem('utc');
-if (!utc) {
-  utc = (-(new Date().getTimezoneOffset() / 60)).toString();
-  window.localStorage.setItem('utc', utc);
-}
-
 export interface State {
   durationRow: Duration;
   eventStack: any;
diff --git a/src/utils/localtime.ts b/src/utils/localtime.ts
index 8d5b9e9..1359471 100644
--- a/src/utils/localtime.ts
+++ b/src/utils/localtime.ts
@@ -1,3 +1,6 @@
+import graph from '@/graph';
+import { AxiosResponse } from 'axios';
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -23,4 +26,23 @@ const getLocalTime = (i: number, t: Date | number) => {
   return new Date(utcTime + (3600000 * i));
 };
 
+const setTimezoneOffset = () => {
+  window.localStorage.setItem('utc', -(new Date().getTimezoneOffset() / 60) + '');
+};
+
+export const queryOAPTimeInfo = async () => {
+  let utc = window.localStorage.getItem('utc');
+  if (!utc) {
+    const res: AxiosResponse = await graph
+      .query('queryOAPTimeInfo')
+      .params({});
+    if (!res.data) {
+      debugger
+      setTimezoneOffset();
+    }
+    utc = (res.data.data.getTimeInfo.timezone / 100) + '';
+    window.localStorage.setItem('utc', utc);
+  }
+};
+
 export default getLocalTime;