aboutsummaryrefslogtreecommitdiffstats
path: root/moon_gui/static/app/policy
diff options
context:
space:
mode:
authorGourdin Jonathan <jonathan.gourdin@orange.com>2018-01-12 11:35:19 +0100
committerGourdin Jonathan <jonathan.gourdin@orange.com>2018-01-12 15:22:42 +0100
commit414a03af7951dc69703d57e43f3f91d2aca0a005 (patch)
tree7a73011be99f4555d232f293e6bf9f2346b6739d /moon_gui/static/app/policy
parent5d325dfc5d666b345b6555ea9dc4ab3af853be67 (diff)
Fix GUI
Change-Id: I909038e8d00c97b9e19c97b13836407649b5dc96
Diffstat (limited to 'moon_gui/static/app/policy')
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html27
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js98
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/perimeter/perimeter.edit.dir.js2
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html2
-rwxr-xr-xmoon_gui/static/app/policy/edit/policy-edit.tpl.html8
-rwxr-xr-xmoon_gui/static/app/policy/edit/policy.controller.edit.js14
6 files changed, 68 insertions, 83 deletions
diff --git a/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html b/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
index 3f11a641..fae647e3 100755
--- a/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
+++ b/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
@@ -36,33 +36,6 @@
</div>
<div class="form-group"
- ng-class="{'has-error': edit.form.policyList.$invalid && edit.form.policyList.$dirty}">
-
- <label for="policyList" class="col-sm-3 control-label" data-translate="moon.policy.data.edit.policies">Policy
- List </label>
-
- <div class="col-sm-6">
-
- <ui-select ng-model="edit.selectedPolicy" name="policyList" id="policyList" required>
-
- <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match>
- <ui-select-choices repeat="aPolicy in edit.policyList">
- <div ng-value="aPolicy" ng-bind="aPolicy.name"></div>
- </ui-select-choices>
-
- </ui-select>
-
- <div class="help-block" ng-show="edit.form.policyList.$dirty && edit.form.policyList.$invalid">
- <small class="error" ng-show="edit.form.policyList.$error.required"
- data-translate="moon.policy.data.edit.check.policy.required">Policy is required
- </small>
- </div>
-
- </div>
-
- </div>
-
- <div class="form-group"
ng-class="{'has-error': edit.form.categoryList.$invalid && edit.form.categoryList.$dirty}">
<label for="categoryList" class="col-sm-3 control-label"
diff --git a/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js b/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
index 57ad0c9b..2ae08177 100755
--- a/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
+++ b/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
@@ -31,10 +31,10 @@
.controller('moonDataEditController', moonDataEditController);
moonDataEditController.$inject = ['$scope', 'dataService', 'DATA_CST', 'alertService', '$translate',
- 'formService', 'policyService', 'utilService', 'metaDataService'];
+ 'formService', 'policyService', 'utilService', 'metaDataService', 'modelService', 'metaRuleService'];
function moonDataEditController($scope, dataService, DATA_CST, alertService, $translate,
- formService, policyService, utilService, metaDataService) {
+ formService, policyService, utilService, metaDataService, modelService, metaRuleService) {
var edit = this;
@@ -50,7 +50,6 @@
edit.data = { name: null, description: null};
edit.list = [];
- edit.policyList = [];
edit.categoriesToBeSelected = [];
edit.create = createData;
@@ -64,7 +63,6 @@
function activate(){
loadAllCategories();
- loadAllPolicies();
switch(edit.dataType){
@@ -105,58 +103,54 @@
}
- function loadAllCategories(){
-
- switch(edit.dataType){
-
- case DATA_CST.TYPE.SUBJECT:
-
- metaDataService.subject.findAllWithCallback(callBackList);
- break;
-
- case DATA_CST.TYPE.OBJECT:
-
- metaDataService.object.findAllWithCallback(callBackList);
- break;
-
- case DATA_CST.TYPE.ACTION:
-
- metaDataService.action.findAllWithCallback(callBackList);
- break;
-
- default :
-
- edit.categoriesToBeSelected = [];
- break;
-
- }
-
- function callBackList(list){
-
- edit.categoriesToBeSelected = list;
-
- }
- }
- function loadAllPolicies() {
-
- edit.policyList = [];
-
- policyService.findAllWithCallback( function(data) {
-
- _.each(data, function(element){
+ function loadAllCategories(){
- if(element.id === edit.policy.id){
- edit.selectedPolicy = element;
+ modelService.findOneWithCallback(edit.policy.model_id, function(model){
+
+ metaRuleService.findSomeWithCallback(model.meta_rules, function(metaRules){
+
+ switch(edit.dataType){
+
+ case DATA_CST.TYPE.SUBJECT:
+ var subjectCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.subject_categories);
+ }, [])
+ metaDataService.subject.findSomeWithCallback(subjectCategoryList, callBackList);
+ break;
+
+ case DATA_CST.TYPE.OBJECT:
+ var objectCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.object_categories);
+ }, [])
+ metaDataService.object.findSomeWithCallback(objectCategoryList, callBackList);
+ break;
+
+ case DATA_CST.TYPE.ACTION:
+ var actionCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.action_categories);
+ }, [])
+ metaDataService.action.findSomeWithCallback(actionCategoryList, callBackList);
+ break;
+
+ default :
+
+ edit.categoriesToBeSelected = [];
+ break;
+
+ }
+
+ function callBackList(list){
+
+ edit.categoriesToBeSelected = list;
+
}
-
});
- edit.policyList = data;
-
});
- }
+
+ }
/**
* Create
@@ -200,26 +194,30 @@
function createSuccess(data) {
var created = {};
+ var name = '';
switch(edit.dataType){
case DATA_CST.TYPE.SUBJECT:
created = utilService.transformOne(data['subject_data'], 'data');
+ name = created.name;
break;
case DATA_CST.TYPE.OBJECT:
created = utilService.transformOne(data['object_data'], 'data');
+ name = created.value.name;
break;
case DATA_CST.TYPE.ACTION:
created = utilService.transformOne(data['action_data'], 'data');
+ name = created.value.name;
break;
}
- $translate('moon.policy.data.edit.create.success', { name: created.name }).then(function (translatedValue) {
+ $translate('moon.policy.data.edit.create.success', { name: name }).then(function (translatedValue) {
alertService.alertSuccess(translatedValue);
});
diff --git a/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.edit.dir.js b/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.edit.dir.js
index a96741fe..d72e23b7 100755
--- a/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.edit.dir.js
+++ b/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.edit.dir.js
@@ -394,7 +394,7 @@
}
function cleanSelectedValue() {
-
+ edit.list = _.without(edit.list, edit.selectedPerimeter);
delete edit.selectedPerimeter;
}
diff --git a/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html b/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html
index 76ac4365..7f556f93 100755
--- a/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html
+++ b/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html
@@ -119,7 +119,7 @@
<div class="panel-heading">
- <h4 data-translate="moon.policy.rules.edit.action.add.title">Add a Rules</h4>
+ <h4 data-translate="moon.policy.rules.edit.action.add.title">Add a Rule</h4>
</div>
diff --git a/moon_gui/static/app/policy/edit/policy-edit.tpl.html b/moon_gui/static/app/policy/edit/policy-edit.tpl.html
index a1a6a54a..60841168 100755
--- a/moon_gui/static/app/policy/edit/policy-edit.tpl.html
+++ b/moon_gui/static/app/policy/edit/policy-edit.tpl.html
@@ -64,7 +64,7 @@
<span data-translate="moon.policy.edit.perimeter.title" >Perimeters</span>
- <a href="" ng-click="edit.showPerimeters = !edit.showPerimeters">
+ <a href="" ng-click="edit.showPart('showPerimeters')">
<span ng-if="!edit.showPerimeters">
<span data-translate="moon.policy.edit.show.open">Show</span>
@@ -99,7 +99,7 @@
<span data-translate="moon.policy.edit.data.title" >Data</span>
- <a href="" ng-click="edit.showData = !edit.showData">
+ <a href="" ng-click="edit.showPart('showData')">
<span ng-if="!edit.showData">
<span data-translate="moon.policy.edit.show.open">Show</span>
@@ -134,7 +134,7 @@
<span data-translate="moon.policy.edit.rules.title" >Rules</span>
- <a href="" ng-click="edit.showRules = !edit.showRules">
+ <a href="" ng-click="edit.showPart('showRules')">
<span ng-if="!edit.showRules">
<span data-translate="moon.policy.edit.show.open">Show</span>
@@ -170,7 +170,7 @@
<span data-translate="moon.policy.edit.assignments.title" >Assignments</span>
- <a href="" ng-click="edit.showAssignments = !edit.showAssignments">
+ <a href="" ng-click="edit.showPart('showAssignments')">
<span ng-if="!edit.showAssignments">
<span data-translate="moon.policy.edit.show.open">Show</span>
diff --git a/moon_gui/static/app/policy/edit/policy.controller.edit.js b/moon_gui/static/app/policy/edit/policy.controller.edit.js
index 123ee58b..cd6e429b 100755
--- a/moon_gui/static/app/policy/edit/policy.controller.edit.js
+++ b/moon_gui/static/app/policy/edit/policy.controller.edit.js
@@ -21,9 +21,23 @@
edit.showRules = false;
edit.showAssignments = false;
+ edit.showPart = showPart;
+
activate();
+ function showPart(partName) {
+ var state = edit[partName];
+
+ edit.showPerimeters = false;
+ edit.showData = false;
+ edit.showRules = false;
+ edit.showAssignments = false;
+
+ edit[partName] = !state;
+ }
+
+
function activate(){
manageModel();