From e50be35a9dbfde3531637ea262e57cc762d9b44c Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Tue, 23 Jul 2019 23:16:51 +0800 Subject: [PATCH] dashboard: code and frontend style refinement for #927 and #869 Signed-off-by: Eric Zhao --- .../controller/SystemController.java | 128 +++++++----------- .../entity/rule/SystemRuleEntity.java | 10 -- .../app/scripts/controllers/system.js | 66 +++++---- .../app/scripts/services/systemservice.js | 4 +- .../app/views/dialog/gateway/api-dialog.html | 14 +- .../app/views/dialog/system-rule-dialog.html | 20 +-- .../webapp/resources/app/views/system.html | 10 +- .../src/main/webapp/resources/dist/js/app.js | 5 +- 8 files changed, 101 insertions(+), 156 deletions(-) diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java index ade1692a..66d29f58 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java @@ -23,42 +23,38 @@ import javax.servlet.http.HttpServletRequest; import com.alibaba.csp.sentinel.dashboard.auth.AuthService; import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser; import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; import com.alibaba.csp.sentinel.dashboard.domain.Result; -import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemSystemRuleStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; /** * @author leyou(lihao) */ -@Controller -@RequestMapping(value = "/system", produces = MediaType.APPLICATION_JSON_VALUE) +@RestController +@RequestMapping("/system") public class SystemController { - private static Logger logger = LoggerFactory.getLogger(SystemController.class); + + private final Logger logger = LoggerFactory.getLogger(SystemController.class); @Autowired - private InMemSystemRuleStore repository; + private RuleRepository repository; @Autowired private SentinelApiClient sentinelApiClient; @Autowired private AuthService authService; - @ResponseBody - @RequestMapping("/rules.json") - Result> queryMachineRules(HttpServletRequest request, String app, String ip, Integer port) { - AuthUser authUser = authService.getAuthUser(request); - authUser.authTarget(app, PrivilegeType.READ_RULE); + private Result checkBasicParams(String app, String ip, Integer port) { if (StringUtil.isEmpty(app)) { return Result.ofFail(-1, "app can't be null or empty"); } @@ -68,12 +64,28 @@ public class SystemController { if (port == null) { return Result.ofFail(-1, "port can't be null"); } + if (port <= 0 || port > 65535) { + return Result.ofFail(-1, "port should be in (0, 65535)"); + } + return null; + } + + @GetMapping("/rules.json") + public Result> apiQueryMachineRules(HttpServletRequest request, String app, String ip, + Integer port) { + AuthUser authUser = authService.getAuthUser(request); + authUser.authTarget(app, PrivilegeType.READ_RULE); + + Result> checkResult = checkBasicParams(app, ip, port); + if (checkResult != null) { + return checkResult; + } try { List rules = sentinelApiClient.fetchSystemRuleOfMachine(app, ip, port); rules = repository.saveAll(rules); return Result.ofSuccess(rules); } catch (Throwable throwable) { - logger.error("queryApps error:", throwable); + logger.error("Query machine system rules error", throwable); return Result.ofThrowable(-1, throwable); } } @@ -88,65 +100,38 @@ public class SystemController { return notNullCount; } - /** - * @modify - * 目前代码里做了如下几点修改: - * 1】修改属性名称avgLoad 修改为highestSystemLoad - * 2】修改属性名称avgCpu 修改为highestCpuUsage - * 3】调用countNotNullAndNotNegative非空校验方法里增加参数highestCpuUsage, - * 4】修改notNullCount部分判断错误提示语,因为目前countNotNullAndNotNegative里针对=0的情况也做了限制 - * 5】对于highestSystemLoad、highestCpuUsage增加>1 的这个判断 - * @author tianyang5@yeah.net - * @time 2019年7月17日 18:30:32 - * @modify - * - * @param request - * @param app - * @param ip - * @param port - * @param highestSystemLoad - * @param highestCpuUsage - * @param avgRt - * @param maxThread - * @param qps - * @return - */ - @ResponseBody @RequestMapping("/new.json") - Result add(HttpServletRequest request, - String app, String ip, Integer port, Double highestSystemLoad,Double highestCpuUsage, Long avgRt, Long maxThread, Double qps) { + public Result apiAdd(HttpServletRequest request, String app, String ip, Integer port, + Double highestSystemLoad, Double highestCpuUsage, Long avgRt, + Long maxThread, Double qps) { AuthUser authUser = authService.getAuthUser(request); authUser.authTarget(app, PrivilegeType.WRITE_RULE); - if (StringUtil.isBlank(app)) { - return Result.ofFail(-1, "app can't be null or empty"); - } - if (StringUtil.isBlank(ip)) { - return Result.ofFail(-1, "ip can't be null or empty"); - } - if (port == null) { - return Result.ofFail(-1, "port can't be null"); + + Result checkResult = checkBasicParams(app, ip, port); + if (checkResult != null) { + return checkResult; } - int notNullCount = countNotNullAndNotNegative(highestSystemLoad, avgRt, maxThread, qps,highestCpuUsage); + int notNullCount = countNotNullAndNotNegative(highestSystemLoad, avgRt, maxThread, qps, highestCpuUsage); if (notNullCount != 1) { return Result.ofFail(-1, "only one of [highestSystemLoad, avgRt, maxThread, qps,highestCpuUsage] " + "value must be set > 0, but " + notNullCount + " values get"); } - if ( null!=highestCpuUsage && 1 < highestCpuUsage ) { - return Result.ofFail(-1, "highestCpuUsage must <= 1"); + if (null != highestCpuUsage && highestCpuUsage > 1) { + return Result.ofFail(-1, "highestCpuUsage must between [0.0, 1.0]"); } SystemRuleEntity entity = new SystemRuleEntity(); entity.setApp(app.trim()); entity.setIp(ip.trim()); entity.setPort(port); // -1 is a fake value - if ( null != highestSystemLoad ) { + if (null != highestSystemLoad) { entity.setHighestSystemLoad(highestSystemLoad); } else { entity.setHighestSystemLoad(-1D); } - if ( null != highestCpuUsage ) { + if (null != highestCpuUsage) { entity.setHighestCpuUsage(highestCpuUsage); } else { entity.setHighestCpuUsage(-1D); @@ -173,39 +158,19 @@ public class SystemController { try { entity = repository.save(entity); } catch (Throwable throwable) { - logger.error("add error:", throwable); + logger.error("Add SystemRule error", throwable); return Result.ofThrowable(-1, throwable); } if (!publishRules(app, ip, port)) { - logger.info("publish system rules fail after rule add"); + logger.warn("Publish system rules fail after rule add"); } return Result.ofSuccess(entity); } - /** - * @modify - * 目前代码里做了如下几点修改: - * 1】修改属性名称avgLoad 修改为highestSystemLoad - * 2】修改属性名称avgCpu 修改为highestCpuUsage - * 1】对于highestSystemLoad、highestCpuUsage增加>1 的这个判断,调整原先<0的判断,调整为<=0 等于0的这种规则设置了也没有意义 - * @author tianyang5@yeah.net - * @time 2019年7月17日 18:30:32 - * @modify - * - * @param request - * @param id - * @param app - * @param highestSystemLoad - * @param highestCpuUsage - * @param avgRt - * @param maxThread - * @param qps - * @return - */ - @ResponseBody - @RequestMapping("/save.json") - Result updateIfNotNull(HttpServletRequest request, - Long id, String app, Double highestSystemLoad,Double highestCpuUsage, Long avgRt, Long maxThread, Double qps) { + @GetMapping("/save.json") + public Result apiUpdateIfNotNull(HttpServletRequest request, + Long id, String app, Double highestSystemLoad, Double highestCpuUsage, + Long avgRt, Long maxThread, Double qps) { AuthUser authUser = authService.getAuthUser(request); if (id == null) { return Result.ofFail(-1, "id can't be null"); @@ -219,7 +184,7 @@ public class SystemController { entity.setApp(app.trim()); } if (highestSystemLoad != null) { - if (highestSystemLoad <= 0) { + if (highestSystemLoad < 0) { return Result.ofFail(-1, "highestSystemLoad must >= 0"); } entity.setHighestSystemLoad(highestSystemLoad); @@ -265,9 +230,8 @@ public class SystemController { return Result.ofSuccess(entity); } - @ResponseBody @RequestMapping("/delete.json") - Result delete(HttpServletRequest request, Long id) { + public Result delete(HttpServletRequest request, Long id) { AuthUser authUser = authService.getAuthUser(request); if (id == null) { return Result.ofFail(-1, "id can't be null"); diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java index 22e3d578..483ebcb5 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java @@ -29,20 +29,10 @@ public class SystemRuleEntity implements RuleEntity { private String app; private String ip; private Integer port; - /** - * 对应SystemRule 里的属性highestSystemLoad,这里做下调整 - * @author tianyang5@yeah.net - * @time 2019年7月17日 18:30:32 - */ private Double highestSystemLoad; private Long avgRt; private Long maxThread; private Double qps; - /** - * 对应SystemRule 里的属性highestCpuUsage - * @author tianyang5@yeah.net - * @time 2019年7月17日 18:30:32 - */ private Double highestCpuUsage; private Date gmtCreate; diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js index ae76bd47..5b3107ff 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js @@ -31,13 +31,12 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo if (!$scope.macInputModel) { return; } - var mac = $scope.macInputModel.split(':'); + let mac = $scope.macInputModel.split(':'); SystemService.queryMachineRules($scope.app, mac[0], mac[1]).success( function (data) { - if (data.code == 0 && data.data) { + if (data.code === 0 && data.data) { $scope.rules = data.data; $.each($scope.rules, function (idx, rule) { - // rule.orginEnable = rule.enable; if (rule.highestSystemLoad >= 0) { rule.grade = 0; } else if (rule.avgRt >= 0) { @@ -46,7 +45,7 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo rule.grade = 2; } else if (rule.qps >= 0) { rule.grade = 3; - }else if (rule.highestCpuUsage >= 0) { + } else if (rule.highestCpuUsage >= 0) { rule.grade = 4; } }); @@ -56,7 +55,8 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo $scope.rulesPageConfig.totalCount = 0; } }); - }; + } + $scope.getMachineRules = getMachineRules; var systemRuleDialog; $scope.editRule = function (rule) { @@ -96,13 +96,12 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo }; $scope.saveRule = function () { - if ($scope.systemRuleDialog.type == 'add') { + if ($scope.systemRuleDialog.type === 'add') { addNewRule($scope.currentRule); - } else if ($scope.systemRuleDialog.type == 'edit') { + } else if ($scope.systemRuleDialog.type === 'edit') { saveRule($scope.currentRule, true); } - } - + }; var confirmDialog; $scope.deleteRule = function (rule) { @@ -110,7 +109,7 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo var ruleTypeDesc = ''; var ruleTypeCount = null; if (rule.highestSystemLoad != -1) { - ruleTypeDesc = '系统LOAD'; + ruleTypeDesc = 'LOAD'; ruleTypeCount = rule.highestSystemLoad; } else if (rule.avgRt != -1) { ruleTypeDesc = 'RT'; @@ -142,7 +141,7 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo $scope.confirm = function () { - if ($scope.confirmDialog.type == 'delete_rule') { + if ($scope.confirmDialog.type === 'delete_rule') { deleteRule($scope.currentRule); // } else if ($scope.confirmDialog.type == 'enable_rule') { // $scope.currentRule.enable = true; @@ -161,48 +160,47 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo function deleteRule(rule) { SystemService.deleteRule(rule).success(function (data) { - if (data.code == 0) { + if (data.code === 0) { getMachineRules(); confirmDialog.close(); - } else if(data.msg!=null){ - alert(data.msg); - } else{ - alert('失败!'); + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); } }); - }; + } function addNewRule(rule) { + if (rule.grade == 4 && (rule.highestCpuUsage < 0 || rule.highestCpuUsage > 1)) { + alert('CPU 使用率模式的取值范围应为 [0.0, 1.0],对应 0% - 100%'); + return; + } SystemService.newRule(rule).success(function (data) { - if (data.code == 0) { + if (data.code === 0) { getMachineRules(); systemRuleDialog.close(); - } else if(data.msg!=null){ - alert(data.msg); - }else{ - alert('失败!'); + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); } }); - }; + } function saveRule(rule, edit) { SystemService.saveRule(rule).success(function (data) { - if (data.code == 0) { - // if (rule.enable) { - // rule.orginEnable = true; - // } else { - // rule.orginEnable = false; - // } + if (data.code === 0) { getMachineRules(); if (edit) { systemRuleDialog.close(); } else { confirmDialog.close(); } - } else if(data.msg!=null){ - alert(data.msg); - }else{ - alert('失败!'); + } else if (data.msg != null) { + alert('失败:' + data.msg); + } else { + alert('失败:未知错误'); } }); } @@ -210,7 +208,7 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo function queryAppMachines() { MachineService.getAppMachines($scope.app).success( function (data) { - if (data.code == 0) { + if (data.code === 0) { // $scope.machines = data.data; if (data.data) { $scope.machines = []; diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js index d3ca68ed..8b476793 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js @@ -28,7 +28,7 @@ app.service('SystemService', ['$http', function ($http) { param.maxThread = rule.maxThread; } else if (rule.grade == 3) {// qps param.qps = rule.qps; - }else if (rule.grade == 4) {// cpu + } else if (rule.grade == 4) {// cpu param.highestCpuUsage = rule.highestCpuUsage; } @@ -51,7 +51,7 @@ app.service('SystemService', ['$http', function ($http) { param.maxThread = rule.maxThread; } else if (rule.grade == 3) {// qps param.qps = rule.qps; - }else if (rule.grade == 4) {// cpu + } else if (rule.grade == 4) {// cpu param.highestCpuUsage = rule.highestCpuUsage; } diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html index fb0edb59..8c8d4615 100644 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/gateway/api-dialog.html @@ -2,7 +2,6 @@ {{gatewayApiDialog.title}}
-
@@ -28,19 +27,16 @@
+ align="center" ng-if="currentApi.predicateItems.length > 1">X
-
- +
+
-
diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html index a9fd32b5..3dd9cd97 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html @@ -10,26 +10,26 @@
-  系统LOAD   +  LOAD    RT    线程数   -  入口 QPS +  入口 QPS   -  CPU 使用率   +  CPU 使用率  
-  系统LOAD   +  LOAD    RT    线程数   -  入口 QPS +  入口 QPS    CPU 使用率   @@ -39,11 +39,11 @@
- - - - - + + + + +
diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/system.html b/sentinel-dashboard/src/main/webapp/resources/app/views/system.html index f522dda2..6f4e4b84 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/system.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/system.html @@ -45,11 +45,11 @@ - 系统LOAD - RT - 线程数 - QPS - CPU使用率 + 系统 load + 平均 RT + 并发数 + 入口 QPS + CPU 使用率 {{rule.highestSystemLoad}} diff --git a/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js b/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js index 3326334f..86e17573 100755 --- a/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js +++ b/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js @@ -1,4 +1 @@ -"use strict";var app;angular.module("sentinelDashboardApp",["oc.lazyLoad","ui.router","ui.bootstrap","angular-loading-bar","ngDialog","ui.bootstrap.datetimepicker","ui-notification","rzTable","angular-clipboard","selectize","angularUtils.directives.dirPagination"]).factory("AuthInterceptor",["$window","$state",function(t,r){return{responseError:function(e){return 401===e.status&&(t.localStorage.removeItem("session_sentinel_admin"),r.go("login")),e},response:function(e){return e},request:function(e){return e},requestError:function(e){return e}}}]).config(["$stateProvider","$urlRouterProvider","$ocLazyLoadProvider","$httpProvider",function(e,t,r,a){a.interceptors.push("AuthInterceptor"),r.config({debug:!1,events:!0}),t.otherwise("/dashboard/home"),e.state("login",{url:"/login",templateUrl:"app/views/login.html",controller:"LoginCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/login.js"]})}]}}).state("dashboard",{url:"/dashboard",templateUrl:"app/views/dashboard/main.html",resolve:{loadMyDirectives:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/directives/header/header.js","app/scripts/directives/sidebar/sidebar.js","app/scripts/directives/sidebar/sidebar-search/sidebar-search.js"]})}]}}).state("dashboard.home",{url:"/home",templateUrl:"app/views/dashboard/home.html",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/main.js"]})}]}}).state("dashboard.flowV1",{templateUrl:"app/views/flow_v1.html",url:"/flow/:app",controller:"FlowControllerV1",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/flow_v1.js"]})}]}}).state("dashboard.flow",{templateUrl:"app/views/flow_v2.html",url:"/v2/flow/:app",controller:"FlowControllerV2",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/flow_v2.js"]})}]}}).state("dashboard.paramFlow",{templateUrl:"app/views/param_flow.html",url:"/paramFlow/:app",controller:"ParamFlowController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/param_flow.js"]})}]}}).state("dashboard.clusterAppAssignManage",{templateUrl:"app/views/cluster_app_assign_manage.html",url:"/cluster/assign_manage/:app",controller:"SentinelClusterAppAssignManageController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_assign_manage.js"]})}]}}).state("dashboard.clusterAppServerList",{templateUrl:"app/views/cluster_app_server_list.html",url:"/cluster/server/:app",controller:"SentinelClusterAppServerListController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_server_list.js"]})}]}}).state("dashboard.clusterAppClientList",{templateUrl:"app/views/cluster_app_client_list.html",url:"/cluster/client/:app",controller:"SentinelClusterAppTokenClientListController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_token_client_list.js"]})}]}}).state("dashboard.clusterSingle",{templateUrl:"app/views/cluster_single_config.html",url:"/cluster/single/:app",controller:"SentinelClusterSingleController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_single.js"]})}]}}).state("dashboard.authority",{templateUrl:"app/views/authority.html",url:"/authority/:app",controller:"AuthorityRuleController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/authority.js"]})}]}}).state("dashboard.degrade",{templateUrl:"app/views/degrade.html",url:"/degrade/:app",controller:"DegradeCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/degrade.js"]})}]}}).state("dashboard.system",{templateUrl:"app/views/system.html",url:"/system/:app",controller:"SystemCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/system.js"]})}]}}).state("dashboard.machine",{templateUrl:"app/views/machine.html",url:"/app/:app",controller:"MachineCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/machine.js"]})}]}}).state("dashboard.identity",{templateUrl:"app/views/identity.html",url:"/identity/:app",controller:"IdentityCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/identity.js"]})}]}}).state("dashboard.gatewayIdentity",{templateUrl:"app/views/gateway/identity.html",url:"/gateway/identity/:app",controller:"GatewayIdentityCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/identity.js"]}) - }]}}).state("dashboard.metric",{templateUrl:"app/views/metric.html",url:"/metric/:app",controller:"MetricCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/metric.js"]})}]}}).state("dashboard.gatewayApi",{templateUrl:"app/views/gateway/api.html",url:"/gateway/api/:app",controller:"GatewayApiCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/api.js"]})}]}}).state("dashboard.gatewayFlow",{templateUrl:"app/views/gateway/flow.html",url:"/gateway/flow/:app",controller:"GatewayFlowCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/flow.js"]})}]}})}]),(app=angular.module("sentinelDashboardApp")).filter("range",[function(){return function(e,t){if(isNaN(t)||t<=0){return[]}e=[];for(var r=1;r<=t;r++){e.push(r)}return e}}]),(app=angular.module("sentinelDashboardApp")).service("AuthService",["$http",function(t){this.login=function(e){return t({url:"/auth/login",params:e,method:"POST"})},this.logout=function(){return t({url:"/auth/logout",method:"POST"})}}]),(app=angular.module("sentinelDashboardApp")).service("AppService",["$http",function(e){this.getApps=function(){return e({url:"app/briefinfos.json",method:"GET"})}}]),(app=angular.module("sentinelDashboardApp")).service("FlowServiceV1",["$http",function(a){function t(e){return void 0===e||""===e||isNaN(e)||e<=0}this.queryMachineRules=function(e,t,r){return a({url:"/v1/flow/rules",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){e.resource,e.limitApp,e.grade,e.count,e.strategy,e.refResource,e.controlBehavior,e.warmUpPeriodSec,e.maxQueueingTimeMs,e.app,e.ip,e.port;return a({url:"/v1/flow/rule",data:e,method:"POST"})},this.saveRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,grade:e.grade,count:e.count,strategy:e.strategy,refResource:e.refResource,controlBehavior:e.controlBehavior,warmUpPeriodSec:e.warmUpPeriodSec,maxQueueingTimeMs:e.maxQueueingTimeMs};return a({url:"/v1/flow/save.json",params:t,method:"PUT"})},this.deleteRule=function(e){var t={id:e.id,app:e.app};return a({url:"/v1/flow/delete.json",params:t,method:"DELETE"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.count||e.count<0?(alert("限流阈值必须大于等于 0"),!1):void 0===e.strategy||e.strategy<0?(alert("无效的流控模式"),!1):1!=e.strategy&&2!=e.strategy||void 0!==e.refResource&&""!=e.refResource?void 0===e.controlBehavior||e.controlBehavior<0?(alert("无效的流控整形方式"),!1):1==e.controlBehavior&&t(e.warmUpPeriodSec)?(alert("预热时长必须大于 0"),!1):2==e.controlBehavior&&t(e.maxQueueingTimeMs)?(alert("排队超时时间必须大于 0"),!1):!e.clusterMode||void 0!==e.clusterConfig&&void 0!==e.clusterConfig.thresholdType||(alert("集群限流配置不正确"),!1):(alert("请填写关联资源或入口"),!1)}}]),(app=angular.module("sentinelDashboardApp")).service("FlowServiceV2",["$http",function(a){function t(e){return void 0===e||""===e||isNaN(e)||e<=0}this.queryMachineRules=function(e,t,r){return a({url:"/v2/flow/rules",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){return a({url:"/v2/flow/rule",data:e,method:"POST"})},this.saveRule=function(e){return a({url:"/v2/flow/rule/"+e.id,data:e,method:"PUT"})},this.deleteRule=function(e){return a({url:"/v2/flow/rule/"+e.id,method:"DELETE"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.count||e.count<0?(alert("限流阈值必须大于等于 0"),!1):void 0===e.strategy||e.strategy<0?(alert("无效的流控模式"),!1):1!=e.strategy&&2!=e.strategy||void 0!==e.refResource&&""!=e.refResource?void 0===e.controlBehavior||e.controlBehavior<0?(alert("无效的流控整形方式"),!1):1==e.controlBehavior&&t(e.warmUpPeriodSec)?(alert("预热时长必须大于 0"),!1):2==e.controlBehavior&&t(e.maxQueueingTimeMs)?(alert("排队超时时间必须大于 0"),!1):!e.clusterMode||void 0!==e.clusterConfig&&void 0!==e.clusterConfig.thresholdType||(alert("集群限流配置不正确"),!1):(alert("请填写关联资源或入口"),!1)}}]),(app=angular.module("sentinelDashboardApp")).service("DegradeService",["$http",function(a){this.queryMachineRules=function(e,t,r){return a({url:"degrade/rules.json",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,count:e.count,timeWindow:e.timeWindow,grade:e.grade,app:e.app,ip:e.ip,port:e.port};return a({url:"/degrade/new.json",params:t,method:"GET"})},this.saveRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,grade:e.grade,count:e.count,timeWindow:e.timeWindow};return a({url:"/degrade/save.json",params:t,method:"GET"})},this.deleteRule=function(e){var t={id:e.id,app:e.app};return a({url:"/degrade/delete.json",params:t,method:"GET"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.grade||e.grade<0?(alert("未知的降级策略"),!1):void 0===e.count||""===e.count||e.count<0?(alert("降级阈值不能为空或小于 0"),!1):void 0===e.timeWindow||""===e.timeWindow||e.timeWindow<=0?(alert("降级时间窗口必须大于 0"),!1):!(1==e.grade&&1