Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
[EAGLE-909] UI Policy definition require siteID
Browse files Browse the repository at this point in the history
add siteId in def page.
check submit if not siteId config

Author: zombieJ <smith3816@gmail.com>

Closes #814 from zombieJ/EAGLE-909.
  • Loading branch information
zombieJ authored and haoch committed Feb 17, 2017
1 parent 255f00f commit 71522d9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ <h3 class="box-title">
</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()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -105,25 +104,32 @@
// = Input Stream =
// ==============================================================
$scope.getSearchApplication = function() {
if(cacheSearchSourceKey !== $scope.searchSourceKey.toUpperCase() || cacheSearchType !== $scope.searchType) {
var siteId = $scope.policy.siteId;

if(cacheSearchSourceKey !== $scope.searchSourceKey.toUpperCase() || cacheSiteId !== siteId) {
var match = false;
cacheSearchSourceKey = $scope.searchSourceKey.toUpperCase();
cacheSearchType = $scope.searchType;

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 (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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 71522d9

Please sign in to comment.