You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2019/12/08 14:28:13 UTC
[skywalking-rocketbot-ui] branch master updated: Sync timezone with
oap server (#219)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git
The following commit(s) were added to refs/heads/master by this push:
new 662eaae Sync timezone with oap server (#219)
662eaae is described below
commit 662eaaef3bcd0cc81980025c8515786b476bc649
Author: Kdump <ro...@gmail.com>
AuthorDate: Sun Dec 8 22:28:05 2019 +0800
Sync timezone with oap server (#219)
* Sync timezone with oap server
https://github.com/apache/skywalking-rocketbot-ui/issues/213
* Sync_timezone_with_oap_server
* Sync_timezone_with_oap_server
---
package-lock.json | 91 +++++++++++----------------------------
src/graph/fragments/option.ts | 8 ++++
src/graph/query/option.ts | 5 ++-
src/main.ts | 17 +++++---
src/store/modules/global/index.ts | 6 ---
src/utils/localtime.ts | 22 ++++++++++
6 files changed, 70 insertions(+), 79 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 af4c833..63d0e49 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -39,6 +39,7 @@ import VModal from 'vue-js-modal';
import './assets';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
+import { queryOAPTimeInfo } from './utils/localtime';
Vue.use(eventBus);
Vue.use(VueI18n);
@@ -69,9 +70,13 @@ 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..b7e8b62 100644
--- a/src/utils/localtime.ts
+++ b/src/utils/localtime.ts
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+import graph from '@/graph';
+import { AxiosResponse } from 'axios';
+
const getLocalTime = (i: number, t: Date | number) => {
const d = new Date(t);
const len = d.getTime();
@@ -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;