From 0d9937963ae7a4fe6739a3af5a15c9fc13631a57 Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Sun, 11 Jan 2015 12:49:14 +0800 Subject: [PATCH] Add warning to host wildcard conditions containing some invalid host chars. --- omega-web/src/omega/controllers/switch_profile.coffee | 6 ++++++ omega-web/src/partials/profile_switch.jade | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/omega-web/src/omega/controllers/switch_profile.coffee b/omega-web/src/omega/controllers/switch_profile.coffee index f231662..a76e6f4 100644 --- a/omega-web/src/omega/controllers/switch_profile.coffee +++ b/omega-web/src/omega/controllers/switch_profile.coffee @@ -145,6 +145,12 @@ angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $location, return false return true + $scope.conditionHasWarning = (condition) -> + if condition.conditionType == 'HostWildcardCondition' + pattern = condition.pattern + return pattern.indexOf(':') >= 0 || pattern.indexOf('/') >= 0 + return false + $scope.removeRule = (index) -> removeForReal = -> $scope.profile.rules.splice index, 1 diff --git a/omega-web/src/partials/profile_switch.jade b/omega-web/src/partials/profile_switch.jade index 7efdabf..9d5e90e 100644 --- a/omega-web/src/partials/profile_switch.jade +++ b/omega-web/src/partials/profile_switch.jade @@ -38,7 +38,7 @@ div(ng-controller='SwitchProfileCtrl') td select.form-control(ng-model='rule.condition.conditionType' ng-options='type.type as ("condition_" + type.type | tr) group by (type.group | tr) for type in conditionTypes') - td(ng-switch='rule.condition.conditionType') + td(ng-switch='rule.condition.conditionType' ng-class='{"has-warning": conditionHasWarning(rule.condition)}') span(ng-switch-when='FalseCondition') span(ng-show='!!rule.condition.pattern') input.form-control(ng-model='rule.condition.pattern' disabled title="{{'condition_details_FalseCondition' | tr}}")