Bladeren bron

nacos持久化

master
wangjx 3 jaren geleden
bovenliggende
commit
03f5ab3e84
4 gewijzigde bestanden met toevoegingen van 197 en 2 verwijderingen
  1. +1
    -1
      sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js
  2. +1
    -1
      sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade_v2.js
  3. +97
    -0
      sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degrade_service_v2.js
  4. +98
    -0
      sentinel-dashboard/src/main/webapp/resources/app/views/degrade_v2.html

+ 1
- 1
sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js Bestand weergeven

@@ -263,7 +263,7 @@ angular
return $ocLazyLoad.load({
name: 'sentinelDashboardApp',
files: [
'app/scripts/controllers/degrade.js',
'app/scripts/controllers/degrade_v2.js',
]
});
}]


+ 1
- 1
sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade_v2.js Bestand weergeven

@@ -1,6 +1,6 @@
var app = angular.module('sentinelDashboardApp');

app.controller('DegradeControllerV2', ['$scope', '$stateParams', 'DegradeService', 'ngDialog', 'MachineService',
app.controller('DegradeControllerV2', ['$scope', '$stateParams', 'DegradeServiceV2', 'ngDialog', 'MachineService',
function ($scope, $stateParams, DegradeService, ngDialog, MachineService) {
//初始化
$scope.app = $stateParams.app;


+ 97
- 0
sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degrade_service_v2.js Bestand weergeven

@@ -0,0 +1,97 @@
var app = angular.module('sentinelDashboardApp');

app.service('DegradeServiceV2', ['$http', function ($http) {
this.queryMachineRules = function (app, ip, port) {
var param = {
app: app,
ip: ip,
port: port
};
return $http({
url: '/v2/degrade/rules.json',
params: param,
method: 'GET'
});
};

this.newRule = function (rule) {
return $http({
url: '/v2/degrade/rule',
data: rule,
method: 'POST'
});
};

this.saveRule = function (rule) {
var param = {
id: rule.id,
resource: rule.resource,
limitApp: rule.limitApp,
grade: rule.grade,
count: rule.count,
timeWindow: rule.timeWindow,
statIntervalMs: rule.statIntervalMs,
minRequestAmount: rule.minRequestAmount,
slowRatioThreshold: rule.slowRatioThreshold,
};
return $http({
url: '/v2/degrade/rule/' + rule.id,
data: param,
method: 'PUT'
});
};

this.deleteRule = function (rule) {
return $http({
url: '/v2/degrade/rule/' + rule.id,
method: 'DELETE'
});
};

this.checkRuleValid = function (rule) {
if (rule.resource === undefined || rule.resource === '') {
alert('资源名称不能为空');
return false;
}
if (rule.grade === undefined || rule.grade < 0) {
alert('未知的降级策略');
return false;
}
if (rule.count === undefined || rule.count === '' || rule.count < 0) {
alert('降级阈值不能为空或小于 0');
return false;
}
if (rule.timeWindow == undefined || rule.timeWindow === '' || rule.timeWindow <= 0) {
alert('熔断时长必须大于 0s');
return false;
}
if (rule.minRequestAmount == undefined || rule.minRequestAmount <= 0) {
alert('最小请求数目需大于 0');
return false;
}
if (rule.statIntervalMs == undefined || rule.statIntervalMs <= 0) {
alert('统计窗口时长需大于 0s');
return false;
}
if (rule.statIntervalMs !== undefined && rule.statIntervalMs > 60 * 1000 * 2) {
alert('统计窗口时长不能超过 120 分钟');
return false;
}
// 异常比率类型.
if (rule.grade == 1 && rule.count > 1) {
alert('异常比率超出范围:[0.0 - 1.0]');
return false;
}
if (rule.grade == 0) {
if (rule.slowRatioThreshold == undefined) {
alert('慢调用比率不能为空');
return false;
}
if (rule.slowRatioThreshold < 0 || rule.slowRatioThreshold > 1) {
alert('慢调用比率超出范围:[0.0 - 1.0]');
return false;
}
}
return true;
};
}]);

+ 98
- 0
sentinel-dashboard/src/main/webapp/resources/app/views/degrade_v2.html Bestand weergeven

@@ -0,0 +1,98 @@
<div class="row" style="margin-left: 1px; margin-top:10px; height: 50px;">
<div class="col-md-6" style="margin-bottom: 10px;">
<span style="font-size: 30px;font-weight: bold;">{{app}}</span>
</div>
<div class="col-md-6">
<button class="btn btn-default-inverse" style="float: right; margin-right: 10px;" ng-disabled="!macInputModel" ng-click="addNewRule()">
<i class="fa fa-plus"></i>&nbsp;&nbsp;新增降级规则</button>
</div>
</div>

<div class="separator"></div>

<div class="container-fluid">
<div class="row" style="margin-top: 20px; margin-bottom: 20px;">
<div class="col-md-12">
<div class="card">
<div class="inputs-header">
<span class="brand" style="font-size: 13px;">降级规则</span>
<!--<button class="btn btn-danger" style="float: right;margin-right: 10px;height: 30px;font-size: 12px;" ng-click="disableAll()">全部禁用</button>-->
<button class="btn btn-primary" style="float: right; margin-right: 10px; height: 30px;font-size: 12px;" ng-click="getMachineRules()">刷新</button>
<input class="form-control witdh-200" placeholder="关键字" ng-model="searchKey">
<div class="control-group" style="float:right;margin-right: 10px;margin-bottom: -10px;">
<selectize id="gsInput" class="selectize-input-200" config="macsInputConfig" options="macsInputOptions" ng-model="macInputModel"
placeholder="机器"></selectize>
</div>
</div>

<!--.tools-header -->
<div class="card-body" style="padding: 0px 0px;">
<table class="table" style="border-left: none; border-right:none;margin-top: 10px;">
<thead>
<tr style="background: #F3F5F7;">
<td style="width: 40%">
资源名
</td>
<td style="width: 10%;">
降级策略
</td>
<td style="width: 10%;">
阈值
</td>
<td style="width: 10%;">
熔断时长(s)
</td>
<td style="width: 12%;">
操作
</td>
</tr>
</thead>
<tbody>
<tr dir-paginate="rule in rules | filter : searchKey | itemsPerPage: rulesPageConfig.pageSize " current-page="rulesPageConfig.currentPageIndex"
pagination-id="entriesPagination">
<td style="word-wrap:break-word;word-break:break-all;">{{rule.resource}}</td>
<!--<td style="word-wrap:break-word;word-break:break-all;">{{rule.limitApp }}</td>-->
<td>
<span ng-if="rule.grade == 0">慢调用比例</span>
<span ng-if="rule.grade == 1" title="异常比例">异常比例</span>
<span ng-if="rule.grade == 2" title="异常数">异常数</span>
</td>
<td style="word-wrap:break-word;word-break:break-all;">
{{rule.count}}
</td>
<td style="word-wrap:break-word;word-break:break-all;">
{{rule.timeWindow}}s
</td>

<td>
<button class="btn btn-xs btn-default" type="button" ng-click="editRule(rule)" style="font-size: 12px; height:25px;">编辑</button>
<button class="btn btn-xs btn-default" type="button" ng-click="deleteRule(rule)" style="font-size: 12px; height:25px;">删除</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- .card-body -->
<div class="pagination-footer">
<dir-pagination-controls boundary-links="true" template-url="app/views/pagination.tpl.html" pagination-id="entriesPagination"
on-page-change="">
</dir-pagination-controls>
<div class="tools" style="">
<span>共 {{rulesPageConfig.totalCount}} 条记录, </span>
<span>
每页
<input class="form-control" ng-model="rulesPageConfig.pageSize"> 条记录,
</span>
<span>第 {{rulesPageConfig.currentPageIndex}} / {{rulesPageConfig.totalPage}} 页</span>
</div>
<!-- .tools -->
</div>
<!-- pagination-footer -->
</div>
<!-- .card -->
</div>
<!-- .col-md-12 -->
</div>
<!-- -->
</div>
<!-- .container-fluid -->

Laden…
Annuleren
Opslaan