You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by mi...@apache.org on 2018/10/18 03:13:02 UTC

[incubator-dubbo-ops] branch develop updated: add enable/disable to override rule

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

min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1c9211d  add enable/disable to override rule
1c9211d is described below

commit 1c9211d835388d0d7a8b8efc7e43361797572476
Author: nzomkxia <z8...@gmail.com>
AuthorDate: Thu Oct 18 11:12:51 2018 +0800

    add enable/disable to override rule
---
 .../admin/controller/OverridesController.java      | 14 ++++++
 dubbo-admin-frontend/src/api/operation.js          | 38 ++++++++++++++++
 .../src/components/governance/Overrides.vue        | 53 +++++++++++++++-------
 .../src/components/governance/RoutingRule.vue      | 52 ++++-----------------
 4 files changed, 99 insertions(+), 58 deletions(-)

diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
index 4673601..cfd5e6a 100644
--- a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
@@ -112,6 +112,20 @@ public class OverridesController {
         return true;
     }
 
+    @RequestMapping(value = "/enable/{id}", method = RequestMethod.PUT)
+    public boolean enableRoute(@PathVariable String id, @PathVariable String env) {
+
+        overrideService.enableOverride(id);
+        return true;
+    }
+
+    @RequestMapping(value = "/disable/{id}", method = RequestMethod.PUT)
+    public boolean disableRoute(@PathVariable String id, @PathVariable String env) {
+
+        overrideService.disableOverride(id);
+        return true;
+    }
+
     private void overrideDTOToParams(Override override, OverrideDTO overrideDTO) {
         Map<Object, String>[] mocks = overrideDTO.getMock();
         Map<String, Object>[] parameters = overrideDTO.getParameters();
diff --git a/dubbo-admin-frontend/src/api/operation.js b/dubbo-admin-frontend/src/api/operation.js
new file mode 100644
index 0000000..3645b9b
--- /dev/null
+++ b/dubbo-admin-frontend/src/api/operation.js
@@ -0,0 +1,38 @@
+const Operations = [
+  {id: 0,
+    icon: function (item) {
+      return 'visibility'
+    },
+    tooltip: function (item) {
+      return 'View'
+    }},
+  {id: 1,
+    icon: function (item) {
+      return 'edit'
+    },
+    tooltip: function (item) {
+      return 'Edit'
+    }},
+  {id: 2,
+    icon: function (item) {
+      if (item.enabled) {
+        return 'block'
+      }
+      return 'check_circle_outline'
+    },
+    tooltip: function (item) {
+      if (item.enabled === true) {
+        return 'Disable'
+      }
+      return 'Enable'
+    }},
+  {id: 3,
+    icon: function (item) {
+      return 'delete'
+    },
+    tooltip: function (item) {
+      return 'Delete'
+    }}
+]
+
+export default Operations
diff --git a/dubbo-admin-frontend/src/components/governance/Overrides.vue b/dubbo-admin-frontend/src/components/governance/Overrides.vue
index cb01061..f8df9dc 100644
--- a/dubbo-admin-frontend/src/components/governance/Overrides.vue
+++ b/dubbo-admin-frontend/src/components/governance/Overrides.vue
@@ -47,10 +47,10 @@
               <td class="text-xs-left">{{ props.item.service }}</td>
               <td class="justify-center px-0">
                 <v-tooltip bottom v-for="op in operations" :key="op.id">
-                  <v-icon small class="mr-2" slot="activator" @click="itemOperation(op.icon, props.item)">
-                    {{op.icon}}
+                  <v-icon small class="mr-2" slot="activator" @click="itemOperation(op.icon(props.item), props.item)">
+                    {{op.icon(props.item)}}
                   </v-icon>
-                  <span>{{op.tooltip}}</span>
+                  <span>{{op.tooltip(props.item)}}</span>
                 </v-tooltip>
               </td>
             </template>
@@ -103,6 +103,7 @@
   import yaml from 'js-yaml'
   import {AXIOS} from '../http-common'
   import Search from '@/components/public/Search'
+  import operations from '@/api/operation'
   export default {
     components: {
       AceEditor,
@@ -121,18 +122,14 @@
       warnText: '',
       warnStatus: {},
       height: 0,
-      operations: [
-        {id: 0, icon: 'visibility', tooltip: 'View'},
-        {id: 1, icon: 'edit', tooltip: 'Edit'},
-        {id: 3, icon: 'delete', tooltip: 'Delete'}
-      ],
+      operations: operations,
       configs: [
       ],
       template:
         'application:  # consumer\'s application name, empty for all \n' +
         'address: 192.168.0.1 # consumer\'s ip address, empty for all consumers\n' +
         'dynamic: false\n' +
-        'enabled: false # enable this rule\n' +
+        'enabled: true # enable this rule\n' +
         'parameters:\n' +
         '  - timeout: 100\n' +
         '\n' +
@@ -233,6 +230,16 @@
                 this.updateId = item.id
               })
             break
+          case 'block':
+            this.openWarn(' Are you sure to block Dynamic Config', 'service: ' + item.service)
+            this.warnStatus.operation = 'disable'
+            this.warnStatus.id = item.id
+            break
+          case 'check_circle_outline':
+            this.openWarn(' Are you sure to enable Dynamic Config', 'service: ' + item.service)
+            this.warnStatus.operation = 'enable'
+            this.warnStatus.id = item.id
+            break
           case 'delete':
             this.openWarn(' Are you sure to Delete Dynamic Config', 'service: ' + item.service)
             this.warnStatus.operation = 'delete'
@@ -250,13 +257,27 @@
         this.height = window.innerHeight * 0.5
       },
       deleteItem: function (warnStatus) {
-        let id = {}
-        id.id = warnStatus.id
-        AXIOS.delete('/rules/override/' + id)
-          .then(response => {
-            this.warn = false
-            this.search(this.filter, false)
-          })
+        let id = warnStatus.id
+        let operation = warnStatus.operation
+        if (operation === 'delete') {
+          AXIOS.delete('/rules/override/' + id)
+            .then(response => {
+              this.warn = false
+              this.search(this.filter, false)
+            })
+        } else if (operation === 'disable') {
+          AXIOS.put('/rules/override/disable/' + id)
+            .then(response => {
+              this.warn = false
+              this.search(this.filter, false)
+            })
+        } else if (operation === 'enable') {
+          AXIOS.put('/rules/override/enable/' + id)
+            .then(response => {
+              this.warn = false
+              this.search(this.filter, false)
+            })
+        }
       }
     },
     created () {
diff --git a/dubbo-admin-frontend/src/components/governance/RoutingRule.vue b/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
index c614c88..bb45a64 100644
--- a/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
+++ b/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
@@ -113,6 +113,7 @@
   import AceEditor from '@/components/public/AceEditor'
   import Search from '@/components/public/Search'
   import {AXIOS} from '../http-common'
+  import operations from '@/api/operation'
   export default {
     components: {
       AceEditor,
@@ -132,42 +133,7 @@
       warnText: '',
       warnStatus: {},
       height: 0,
-      operations: [
-        {id: 0,
-          icon: function (item) {
-            return 'visibility'
-          },
-          tooltip: function (item) {
-            return 'View'
-          }},
-        {id: 1,
-          icon: function (item) {
-            return 'edit'
-          },
-          tooltip: function (item) {
-            return 'Edit'
-          }},
-        {id: 2,
-          icon: function (item) {
-            if (item.enabled) {
-              return 'block'
-            }
-            return 'check_circle_outline'
-          },
-          tooltip: function (item) {
-            if (item.enabled === true) {
-              return 'Disable'
-            }
-            return 'Enable'
-          }},
-        {id: 3,
-          icon: function (item) {
-            return 'delete'
-          },
-          tooltip: function (item) {
-            return 'Delete'
-          }}
-      ],
+      operations: operations,
       routingRules: [
       ],
       template:
@@ -326,20 +292,22 @@
         this.height = window.innerHeight * 0.5
       },
       deleteItem: function (warnStatus) {
-        if (warnStatus.operation === 'delete') {
-          AXIOS.delete('/rules/route/' + warnStatus.id)
+        let id = warnStatus.id
+        let operation = warnStatus.operation
+        if (operation === 'delete') {
+          AXIOS.delete('/rules/route/' + id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)
             })
-        } else if (warnStatus.operation === 'disable') {
-          AXIOS.put('/rules/route/disable/' + warnStatus.id)
+        } else if (operation === 'disable') {
+          AXIOS.put('/rules/route/disable/' + id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)
             })
-        } else if (warnStatus.operation === 'enable') {
-          AXIOS.put('/rules/route/enable/' + warnStatus.id)
+        } else if (operation === 'enable') {
+          AXIOS.put('/rules/route/enable/' + id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)