[EAGLE-909] UI Policy definition require siteID
add siteId in def page.
check submit if not siteId config
Author: zombieJ <smith3816@gmail.com>
Closes #814 from zombieJ/EAGLE-909.
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
index 995a8a5..a2c09f1 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
@@ -36,17 +36,21 @@
</div>
</div>
<div class="box-body">
+ <div class="form-group">
+ <label>* Site</label>
+ <select class="form-control" ng-model="policy.siteId">
+ <option ng-repeat="site in Site.list track by $index" value="{{site.siteId}}">
+ {{site.siteName || site.siteId}}
+ </option>
+ </select>
+ </div>
+ <hr />
+
<div ng-show="sourceTab === 'all'">
<div class="input-with-icon">
- <input type="text" class="form-control" placeholder="Search..." ng-model="searchSourceKey" />
+ <input type="text" class="form-control" placeholder="Filter..." ng-model="searchSourceKey" />
<span class="fa fa-search"></span>
</div>
- <p>
- Group Type:
- <a ng-class="{'text-bold': searchType === 'app'}" ng-click="searchType = 'app'">Application</a>
- /
- <a ng-class="{'text-bold': searchType === 'site'}" ng-click="searchType = 'site'">Site</a>
- </p>
<p ng-hide="getSearchApplication()" class="text-warning">No stream match</p>
<div ng-show="getSearchApplication()">
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
index c866efb..d464858 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertCtrl.js
@@ -150,7 +150,7 @@
if ($scope.siteFilter) {
$scope.policyList = $.grep(originPolicyList, function (policy) {
- return policy.definition.siteId === $scope.siteFilter;
+ return policy.siteId === $scope.siteFilter;
});
} else {
$scope.policyList = originPolicyList;
diff --git a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
index f079e76..9b62f6a 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
@@ -78,11 +78,10 @@
}, $scope.policy);
console.log("[Policy]", $scope.policy);
- var cacheSearchType;
+ var cacheSiteId;
var cacheSearchSourceKey;
var searchApplications;
- $scope.searchType = "app";
$scope.searchSourceKey = "";
$scope.applications = {};
$scope.newPolicy = !$scope.policy.name;
@@ -105,25 +104,32 @@
// = Input Stream =
// ==============================================================
$scope.getSearchApplication = function() {
- if(cacheSearchSourceKey !== $scope.searchSourceKey.toUpperCase() || cacheSearchType !== $scope.searchType) {
- var match = false;
- cacheSearchSourceKey = $scope.searchSourceKey.toUpperCase();
- cacheSearchType = $scope.searchType;
+ var siteId = $scope.policy.siteId;
- searchApplications = {};
- $.each($scope.applications, function (appName, streams) {
- $.each(streams, function (i, stream) {
- var groupName = cacheSearchType === "app" ? stream.dataSource : stream.siteId;
- if(
- groupName.toUpperCase().indexOf(cacheSearchSourceKey) >= 0 ||
- stream.streamId.toUpperCase().indexOf(cacheSearchSourceKey) >= 0
- ) {
- match = true;
- var group = searchApplications[groupName] = searchApplications[groupName] || [];
- group.push(stream);
- }
+ if(cacheSearchSourceKey !== $scope.searchSourceKey.toUpperCase() || cacheSiteId !== siteId) {
+ var match = false;
+
+ if (siteId) {
+ cacheSearchSourceKey = $scope.searchSourceKey.toUpperCase();
+ cacheSiteId = siteId;
+
+ searchApplications = {};
+ $.each($scope.applications, function (appName, streams) {
+ $.each(streams, function (i, stream) {
+ var groupName = stream.dataSource;
+ if(
+ stream.siteId === siteId && (
+ groupName.toUpperCase().indexOf(cacheSearchSourceKey) >= 0 ||
+ stream.streamId.toUpperCase().indexOf(cacheSearchSourceKey) >= 0
+ )
+ ) {
+ match = true;
+ var group = searchApplications[groupName] = searchApplications[groupName] || [];
+ group.push(stream);
+ }
+ });
});
- });
+ }
if(!match) {
searchApplications = null;
@@ -336,6 +342,7 @@
$scope.policy.name &&
!$scope.checkPolicyName() &&
common.number.parse($scope.policy.parallelismHint) > 0 &&
+ $scope.policy.siteId &&
$scope.policy.definition.value &&
$scope.policy.outputStreams.length &&
$scope.policyPublisherList.length