Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements for resource page in Sentinel Dashboard #209

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
<java.target.version>1.6</java.target.version>
<java.encoding>UTF-8</java.encoding>
<maven.compiler.version>3.8.0</maven.compiler.version>
<maven.surefire.version>2.22.1</maven.surefire.version>
<maven.source.version>3.0.1</maven.source.version>
<maven.javadoc.version>3.0.1</maven.javadoc.version>
<maven.deploy.version>2.8.2</maven.deploy.version>
<maven.gpg.version>1.6</maven.gpg.version>
<maven.jacoco.version>0.8.1</maven.jacoco.version>
<maven.jacoco.version>0.8.2</maven.jacoco.version>
<maven.jar.version>3.1.0</maven.jar.version>
</properties>

Expand Down Expand Up @@ -163,6 +164,15 @@
<encoding>${java.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- CircleCI build workaround -->
<argLine>-Xms1024m -Xmx2048m</argLine>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -185,6 +195,11 @@
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String getResource() {
}

@JsonIgnore
public int getBlockGrade() {
public int getGrade() {
return rule.getGrade();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private <R> Result<R> checkEntityInternal(ParamFlowRuleEntity entity) {
if (entity.getCount() < 0) {
return Result.ofFail(-1, "count should be valid");
}
if (entity.getBlockGrade() != RuleConstant.FLOW_GRADE_QPS) {
if (entity.getGrade() != RuleConstant.FLOW_GRADE_QPS) {
return Result.ofFail(-1, "Unknown mode (blockGrade) for parameter flow control");
}
if (entity.getParamIdx() == null || entity.getParamIdx() < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,8 @@ angular.module('sentinelDashboardApp').controller('AuthorityRuleController', ['$
});
};

function checkRuleValid(rule) {
if (rule.resource === undefined || rule.resource === '') {
alert('资源名称不能为空');
return false;
}
if (rule.limitApp === undefined || rule.limitApp === '') {
alert('流控针对应用不能为空');
return false;
}
if (rule.strategy === undefined) {
alert('必须选择黑白名单模式');
return false;
}
return true;
}

$scope.saveRule = function () {
if (!checkRuleValid($scope.currentRule.rule)) {
if (!AuthorityRuleService.checkRuleValid($scope.currentRule.rule)) {
return;
}
if ($scope.authorityRuleDialog.type === 'add') {
Expand All @@ -136,7 +120,7 @@ angular.module('sentinelDashboardApp').controller('AuthorityRuleController', ['$
alert("添加规则失败:未知错误");
}
});
};
}

function saveRuleAndPush(rule, edit) {
AuthorityRuleService.saveRule(rule).success(function (data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,8 @@ app.controller('DegradeCtl', ['$scope', '$stateParams', 'DegradeService', 'ngDia
});
};

function checkRuleValid(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('降级时间窗口必须大于 0');
return false;
}
// 异常比率类型.
if (rule.grade == 1 && rule.count > 1) {
alert('异常比率超出范围:[0.0 - 1.0]');
return false;
}
return true;
}

$scope.saveRule = function () {
if (!checkRuleValid($scope.currentRule)) {
if (!DegradeService.checkRuleValid($scope.currentRule)) {
return;
}
if ($scope.degradeRuleDialog.type === 'add') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,50 +88,8 @@ app.controller('FlowCtl', ['$scope', '$stateParams', 'FlowService', 'ngDialog',
});
};

function notNumberAtLeastZero(num) {
return num === undefined || num === '' || isNaN(num) || num < 0;
}

function notNumberGreaterThanZero(num) {
return num === undefined || num === '' || isNaN(num) || num <= 0;
}

function checkRuleValid(rule) {
if (rule.resource === undefined || rule.resource === '') {
alert('资源名称不能为空');
return false;
}
if (rule.count === undefined || rule.count < 0) {
alert('限流阈值必须大于等于 0');
return false;
}
if (rule.strategy === undefined || rule.strategy < 0) {
alert('无效的流控模式');
return false;
}
if (rule.strategy == 1 || rule.strategy == 2) {
if (rule.refResource === undefined || rule.refResource === '') {
alert('请填写关联资源或入口');
return false;
}
}
if (rule.controlBehavior === undefined || rule.controlBehavior < 0) {
alert('无效的流控整形方式');
return false;
}
if (rule.controlBehavior == 1 && notNumberGreaterThanZero(rule.warmUpPeriodSec)) {
alert('预热时长必须大于 0');
return false;
}
if (rule.controlBehavior == 2 && notNumberGreaterThanZero(rule.maxQueueingTimeMs)) {
alert('排队超时时间必须大于 0');
return false;
}
return true;
}

$scope.saveRule = function () {
if (!checkRuleValid($scope.currentRule)) {
if (!FlowService.checkRuleValid($scope.currentRule)) {
return;
}
if ($scope.flowRuleDialog.type === 'add') {
Expand Down
Loading