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

ywang 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 b79d7f9  Moved magic strings to constants file (#372)
b79d7f9 is described below

commit b79d7f985251c48e0435fc0d6c3e4b2c25113b47
Author: Mateusz Róg <kont...@matrog.pl>
AuthorDate: Wed Nov 25 13:53:56 2020 +0100

    Moved magic strings to constants file (#372)
    
    * Moved constants from views to constants directory and added constants for 
time types
    
    * Updated references in all occurences
    
    Co-authored-by: 吴晟 Wu Sheng <wu.sh...@foxmail.com>
---
 src/{views => constants}/constant.ts                 | 6 ++++++
 src/utils/datetime.ts                                | 3 ++-
 src/utils/timeFormat.ts                              | 9 +++++----
 src/views/components/dashboard/charts/chart-edit.vue | 2 +-
 src/views/components/dashboard/dashboard-item.vue    | 2 +-
 src/views/containers/dashboard.vue                   | 2 +-
 src/views/containers/topology/endpoint/index.vue     | 2 +-
 src/views/containers/topology/instance/index.vue     | 2 +-
 src/views/containers/topology/topology.vue           | 2 +-
 9 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/views/constant.ts b/src/constants/constant.ts
similarity index 91%
rename from src/views/constant.ts
rename to src/constants/constant.ts
index cd9a79e..022719c 100644
--- a/src/views/constant.ts
+++ b/src/constants/constant.ts
@@ -25,3 +25,9 @@ export enum ObjectsType {
   UPDATE_ENDPOINTS = 'UPDATE_ENDPOINTS',
   UPDATE_DASHBOARD = 'UPDATE_DASHBOARD',
 }
+
+export enum TimeType {
+  MINUTE_TIME = 'MINUTE',
+  HOUR_TIME = 'HOUR',
+  DAY_TIME = 'DAY',
+}
diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts
index 8cfdf45..0e47fcf 100644
--- a/src/utils/datetime.ts
+++ b/src/utils/datetime.ts
@@ -16,6 +16,7 @@
  */
 
 import { Duration } from '@/types/global';
+import { TimeType } from '@/constants/constant';
 
 /**
  * init or generate durationRow Obj and save localStorage.
@@ -34,7 +35,7 @@ const getDurationRow = (): Duration => {
     durationRow = {
       start: new Date(new Date().getTime() - 900000),
       end: new Date(),
-      step: 'MINUTE',
+      step: TimeType.MINUTE_TIME,
     };
     localStorage.setItem('durationRow', JSON.stringify(durationRow, null, 0));
   }
diff --git a/src/utils/timeFormat.ts b/src/utils/timeFormat.ts
index 1cdd566..6f33630 100644
--- a/src/utils/timeFormat.ts
+++ b/src/utils/timeFormat.ts
@@ -16,16 +16,17 @@
  */
 
 import { Duration } from '@/types/global';
+import { TimeType } from '@/constants/constant';
 
 const timeFormat = (time: Date[]): Duration => {
-  let step = 'MINUTE';
+  let step: TimeType;
   const unix = Math.round(time[1].getTime()) - Math.round(time[0].getTime());
   if (unix <= 60 * 60 * 1000) {
-    step = 'MINUTE';
+    step = TimeType.MINUTE_TIME;
   } else if (unix <= 24 * 60 * 60 * 1000) {
-    step = 'HOUR';
+    step = TimeType.HOUR_TIME;
   } else {
-    step = 'DAY';
+    step = TimeType.DAY_TIME;
   }
   return { start: time[0], end: time[1], step };
 };
diff --git a/src/views/components/dashboard/charts/chart-edit.vue 
b/src/views/components/dashboard/charts/chart-edit.vue
index 384b365..2fd719a 100755
--- a/src/views/components/dashboard/charts/chart-edit.vue
+++ b/src/views/components/dashboard/charts/chart-edit.vue
@@ -263,7 +263,7 @@ limitations under the License. -->
   import { State, Getter, Mutation, Action } from 'vuex-class';
   import { Component, Prop, Watch } from 'vue-property-decorator';
 
-  import { TopologyType, ObjectsType } from '../../../constant';
+  import { TopologyType, ObjectsType } from '../../../../constants/constant';
   import {
     EntityType,
     BrowserEntityType,
diff --git a/src/views/components/dashboard/dashboard-item.vue 
b/src/views/components/dashboard/dashboard-item.vue
index 5eb582d..209945c 100644
--- a/src/views/components/dashboard/dashboard-item.vue
+++ b/src/views/components/dashboard/dashboard-item.vue
@@ -68,7 +68,7 @@ limitations under the License. -->
   import dayjs from 'dayjs';
 
   import { QueryTypes } from './constant';
-  import { TopologyType, ObjectsType } from '../../constant';
+  import { TopologyType, ObjectsType } from '../../../constants/constant';
   import { MetricsType, CalculationType } from './charts/constant';
   import { uuid } from '@/utils/uuid.ts';
 
diff --git a/src/views/containers/dashboard.vue 
b/src/views/containers/dashboard.vue
index c1daf01..ad25ba3 100644
--- a/src/views/containers/dashboard.vue
+++ b/src/views/containers/dashboard.vue
@@ -50,7 +50,7 @@ limitations under the License. -->
   import ToolGroup from '@/views/components/dashboard/tool-group.vue';
   import ToolNav from '@/views/components/dashboard/tool-nav.vue';
   import DashboardItem from '@/views/components/dashboard/dashboard-item.vue';
-  import { ObjectsType } from '../constant';
+  import { ObjectsType } from '../../constants/constant';
 
   interface ITemplate {
     name: string;
diff --git a/src/views/containers/topology/endpoint/index.vue 
b/src/views/containers/topology/endpoint/index.vue
index 64a8a2d..be3132d 100644
--- a/src/views/containers/topology/endpoint/index.vue
+++ b/src/views/containers/topology/endpoint/index.vue
@@ -67,7 +67,7 @@ limitations under the License. -->
   import ToolBarEndpointSelect from 
'@/views/components/dashboard/tool-bar-endpoint-select.vue';
   import { readFile } from '@/utils/readFile';
   import { saveFile } from '@/utils/saveFile';
-  import { ObjectsType } from '../../../constant';
+  import { ObjectsType } from '../../../../constants/constant';
 
   interface Endpoint {
     label: string;
diff --git a/src/views/containers/topology/instance/index.vue 
b/src/views/containers/topology/instance/index.vue
index 1faff42..b991f6d 100644
--- a/src/views/containers/topology/instance/index.vue
+++ b/src/views/containers/topology/instance/index.vue
@@ -69,7 +69,7 @@ limitations under the License. -->
   import { Action, Getter, State, Mutation } from 'vuex-class';
   import { readFile } from '@/utils/readFile';
   import { saveFile } from '@/utils/saveFile';
-  import { ObjectsType } from '../../../constant';
+  import { ObjectsType } from '../../../../constants/constant';
 
   interface Instance {
     label: string;
diff --git a/src/views/containers/topology/topology.vue 
b/src/views/containers/topology/topology.vue
index 189a306..800e007 100644
--- a/src/views/containers/topology/topology.vue
+++ b/src/views/containers/topology/topology.vue
@@ -54,7 +54,7 @@ limitations under the License. -->
   import { State, Action, Getter, Mutation } from 'vuex-class';
   import { AxiosResponse } from 'axios';
   import { State as topoState } from '@/store/modules/topology';
-  import { TopologyType } from '../../constant';
+  import { TopologyType } from '../../../constants/constant';
   import WindowEndpoint from '@/views/containers/topology/endpoint/index.vue';
   import WindowInstance from '@/views/containers/topology/instance/index.vue';
   import WindowTrace from '@/views/containers/topology/trace/index.vue';

Reply via email to