From 414a03af7951dc69703d57e43f3f91d2aca0a005 Mon Sep 17 00:00:00 2001 From: Gourdin Jonathan Date: Fri, 12 Jan 2018 11:35:19 +0100 Subject: Fix GUI Change-Id: I909038e8d00c97b9e19c97b13836407649b5dc96 --- .../policy/edit/parameter/data/data-edit.tpl.html | 27 ------ .../policy/edit/parameter/data/data.edit.dir.js | 98 +++++++++++----------- .../edit/parameter/perimeter/perimeter.edit.dir.js | 2 +- .../edit/parameter/rules/rules-list.tpl.html | 2 +- .../static/app/policy/edit/policy-edit.tpl.html | 8 +- .../app/policy/edit/policy.controller.edit.js | 14 ++++ 6 files changed, 68 insertions(+), 83 deletions(-) (limited to 'moon_gui/static/app/policy') 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 @@ -35,33 +35,6 @@ -
- - - -
- - - - - -
-
- -
- -
- Policy is required - -
- -
- -
-
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 @@
-

Add a Rules

+

Add a Rule

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 @@ Perimeters - + Show @@ -99,7 +99,7 @@ Data - + Show @@ -134,7 +134,7 @@ Rules - + Show @@ -170,7 +170,7 @@ Assignments - + Show 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(); -- cgit 1.2.3-korg