diff options
Diffstat (limited to 'moon_gui/static')
15 files changed, 92 insertions, 102 deletions
diff --git a/moon_gui/static/app/common/header/header.tpl.html b/moon_gui/static/app/common/header/header.tpl.html index f703fa79..7c7633d1 100755 --- a/moon_gui/static/app/common/header/header.tpl.html +++ b/moon_gui/static/app/common/header/header.tpl.html @@ -40,10 +40,10 @@ <div class="row" ng-if="connected"> <ul class="nav nav-tabs"> - <li ng-class="{active: header.isProjectTabActive()}"><a ui-sref="moon.project.list" data-translate="moon.menu.project">Projects</a></li> <li ng-class="{active: header.isModelTabActive()}"><a ui-sref="moon.model.list" data-translate="moon.menu.model">Models</a></li> <li ng-class="{active: header.isPolicyTabActive()}"><a ui-sref="moon.policy.list" data-translate="moon.menu.policy">Policy</a></li> <li ng-class="{active: header.isPDPTabActive()}"><a ui-sref="moon.pdp.list" data-translate="moon.menu.pdp">PDP</a></li> + <li ng-class="{active: header.isProjectTabActive()}"><a ui-sref="moon.project.list" data-translate="moon.menu.project">Projects</a></li> <!--<li ng-class="{active: header.isLogsTabActive()}"><a ui-sref="moon.logs" data-translate="moon.menu.logs">Logs</a></li>--> </ul> diff --git a/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js b/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js index 10df83b0..ab79b5db 100755 --- a/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js +++ b/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js @@ -42,8 +42,6 @@ edit.fromList = true; - edit.laoading = false; - edit.form = {}; edit.metaData = { name: null, description: null}; @@ -106,7 +104,7 @@ } - var metaRuleToSend = edit.metaRule; + var metaRuleToSend = angular.copy(edit.metaRule); switch(edit.metaDataType){ @@ -138,7 +136,9 @@ metaRuleToSend = utilService.transformOne(data, 'meta_rules'); - $scope.$emit('event:updateMetaRuleFromMetaDataAddSuccess', metaRuleToSend); + angular.copy(metaRuleToSend, edit.metaRule) + + $scope.$emit('event:updateMetaRuleFromMetaDataAddSuccess', edit.metaRule); stopLoading(); @@ -278,7 +278,7 @@ metaRuleService.findOneWithMetaData(edit.metaRule.id).then( function(metaRule){ - edit.metaRule = metaRule; + angular.copy(metaRule, edit.metaRule) cleanSelectedValue(); diff --git a/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js b/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js index beb2ed86..305192b6 100755 --- a/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js +++ b/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js @@ -19,7 +19,7 @@ metaRule: '=', editMode: '=', // shortDisplay : boolean value - shortDisplay: '=' + //shortDisplay: '=' }, restrict : 'E', replace : true @@ -80,7 +80,6 @@ $scope.$on('$destroy', rootListeners[unbind]); } - function manageSubjectCategories(){ list.loadingCatSub = true; @@ -140,7 +139,8 @@ alertService.alertSuccess(translatedValue); }); - list.metaRule = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + angular.copy(metaRuleToSend, list.metaRule); activate(); @@ -176,7 +176,8 @@ alertService.alertSuccess(translatedValue); }); - list.metaRule = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + angular.copy(metaRuleToSend, list.metaRule); activate(); @@ -212,7 +213,8 @@ alertService.alertSuccess(translatedValue); }); - list.metaRule = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules')); + angular.copy(metaRuleToSend, list.metaRule); activate(); diff --git a/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js b/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js index b2ebc45d..de6965d0 100755 --- a/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js +++ b/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js @@ -40,7 +40,7 @@ */ function metaRuleUpdatedSuccess(event, metaRule){ - edit.metaRule = metaRule; + angular.copy(metaRule, edit.metaRule); } diff --git a/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js b/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js index 603e7a33..b9dcd19c 100755 --- a/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js +++ b/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js @@ -67,13 +67,15 @@ var updatedMetaRule = utilService.transformOne(data, 'meta_rules'); + angular.copy(updatedMetaRule, edit.metaRule); + $translate('moon.model.metarules.edit.basic.success', { metaRuleName: updatedMetaRule.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); edit.loading = false; - $scope.$emit('event:metaRuleBasicUpdatedSuccess', updatedMetaRule); + $scope.$emit('event:metaRuleBasicUpdatedSuccess', edit.metaRule); } diff --git a/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js b/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js index 120b6a8b..9c1bc72e 100755 --- a/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js +++ b/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js @@ -86,7 +86,8 @@ 'event:metaRuleMapToModelSuccess': $rootScope.$on('event:metaRuleMapToModelSuccess', updateModelFromMapSuccess), 'event:metaRuleUnMappedToModelSuccess': $rootScope.$on('event:metaRuleUnMappedToModelSuccess', modelUnmappedSuccess), - 'event:metaRuleUnMappedToModelError': $rootScope.$on('event:metaRuleUnMappedToModelError', modelUnmappedError) + 'event:metaRuleUnMappedToModelError': $rootScope.$on('event:metaRuleUnMappedToModelError', modelUnmappedError), + }; diff --git a/moon_gui/static/app/moon.module.js b/moon_gui/static/app/moon.module.js index a653f8f3..cc374f24 100755 --- a/moon_gui/static/app/moon.module.js +++ b/moon_gui/static/app/moon.module.js @@ -68,8 +68,8 @@ * routes */ - $urlRouterProvider.when('', '/project'); - $urlRouterProvider.when('/', '/project'); + $urlRouterProvider.when('', '/model'); + $urlRouterProvider.when('/', '/model'); $urlRouterProvider.otherwise('/404'); configureDefaultRoutes($stateProvider); 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(); diff --git a/moon_gui/static/app/services/moon/rule/metarule.service.js b/moon_gui/static/app/services/moon/rule/metarule.service.js index 2679fc5b..05167849 100755 --- a/moon_gui/static/app/services/moon/rule/metarule.service.js +++ b/moon_gui/static/app/services/moon/rule/metarule.service.js @@ -81,7 +81,7 @@ var _self = this; if(metaRuleListId.length === 0){ - return []; + return callback([]); } var promises = _(metaRuleListId).map(function(objectId) { diff --git a/moon_gui/static/i18n/en.json b/moon_gui/static/i18n/en.json index dd54e112..4dc7cea5 100755 --- a/moon_gui/static/i18n/en.json +++ b/moon_gui/static/i18n/en.json @@ -387,7 +387,7 @@ "success": "Rules `{{rulesName}}` successfully deleted" }, "add": { - "title": "Add a Rules", + "title": "Add a Rule", "policies": "Select a policy", "instructions": "Instruction", "metarules" : "Select one of the associated MetaRules", @@ -420,7 +420,7 @@ "required": "{{number}} Object(s) are required" }, "action":{ - "required": "{{number}} a(s) are required" + "required": "{{number}} Action(s) are required" } }, "create":{ |