diff options
Diffstat (limited to 'moonv4/moon_gui/static/app/policy')
12 files changed, 554 insertions, 861 deletions
diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments-list.tpl.html b/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments-list.tpl.html index 0f919a4a..34bbc7a8 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments-list.tpl.html +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments-list.tpl.html @@ -17,9 +17,7 @@ <tr> <th data-translate="moon.policy.assignments.table.perimeter.name">Perimeter name</th> <th data-translate="moon.policy.assignments.table.category.name">Category name</th> - <th data-translate="moon.policy.assignments.table.data.name">Data name</th> - <!--<th data-translate="moon.policy.assignments.table.action.title"></th>--> - </tr> + <th data-translate="moon.policy.assignments.table.data.name">Data name</th></tr> </thead> <moon-loader ng-if="list.loadingSub"></moon-loader> @@ -29,13 +27,14 @@ <tr ng-repeat="(key, value) in list.subjects"> <td> + <div ng-if="!list.getPerimeterFromAssignment(value, list.typeOfSubject)"> <moon-loader ng-if="!list.getPerimeterFromAssignment(value)" ></moon-loader> <em data-translate="moon.policy.assignments.table.loading.perimeter">Loading </em> </div> <div ng-if="list.getPerimeterFromAssignment(value)"> - <span ng-bind="value.category.name"></span> + <span ng-bind="value.perimeter.name"></span> </div> </td> @@ -63,14 +62,26 @@ <span ng-if="list.getDataFromAssignmentsIndex(index, value, list.typeOfSubject)"> <span ng-bind="value.assignments_value[index].data.name"></span> - - <span ng-if="index < value.assignments.length-1">,</span> + <a href="" ng-if="!value.loader" ng-click="list.deleteSub(value, value.assignments_value[index].data.id)" > + <span>(</span><span class="glyphicon glyphicon-transfer"></span><span>)</span> + </a> + <span ng-if="index < value.assignments.length-1">, </span> </span> </span> </td> + <td> + + <div ng-if="value.loader"> + + <moon-loader></moon-loader> + + </div> + + </td> + </tr> </tbody> @@ -101,7 +112,7 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfSubject"></moon-meta-data-edit> + <moon-assignments-edit policy="list.policy" assignments-type="list.typeOfSubject"></moon-assignments-edit> </div> @@ -122,13 +133,11 @@ <table class="table table-striped"> <thead> - <tr> - <th data-translate="moon.policy.assignments.table.perimeter.name">Perimeter name</th> - <th data-translate="moon.policy.assignments.table.category.name">Category name</th> - <th data-translate="moon.policy.assignments.table.data.name">Data name</th> - - <!--<th data-translate="moon.policy.assignments.table.action.title"></th>--> - </tr> + <tr> + <th data-translate="moon.policy.assignments.table.perimeter.name">Perimeter name</th> + <th data-translate="moon.policy.assignments.table.category.name">Category name</th> + <th data-translate="moon.policy.assignments.table.data.name">Data name</th> + </tr> </thead> <moon-loader ng-if="list.loadingObj"></moon-loader> @@ -143,7 +152,7 @@ </div> <div ng-if="list.getPerimeterFromAssignment(value)"> - <span ng-bind="value.category.name"></span> + <span ng-bind="value.perimeter.name"></span> </div> </td> @@ -169,10 +178,13 @@ </span> <span ng-if="list.getDataFromAssignmentsIndex(index, value, list.typeOfObject)"> + <span ng-if="value.assignments_value[index].data.name" ng-bind="value.assignments_value[index].data.name"></span> <span ng-if="value.assignments_value[index].data.value.name" ng-bind="value.assignments_value[index].data.value.name"></span> - - <span ng-if="index < value.assignments.length-1">,</span> + <a href="" ng-if="!value.loader" ng-click="list.deleteObj(value, value.assignments_value[index].data.id)" > + <span>(</span><span class="glyphicon glyphicon-transfer"></span><span>)</span> + </a> + <span ng-if="index < value.assignments.length-1">, </span> </span> </span> @@ -207,7 +219,7 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit> + <moon-assignments-edit policy="list.policy" assignments-type="list.typeOfObject"></moon-assignments-edit> </div> @@ -228,13 +240,11 @@ <table class="table table-striped"> <thead> - <tr> - <th data-translate="moon.policy.assignments.table.perimeter.name">Perimeter name</th> - <th data-translate="moon.policy.assignments.table.category.name">Category name</th> - <th data-translate="moon.policy.assignments.table.data.name">Data name</th> - - <!--<th data-translate="moon.policy.assignments.table.action.title"></th>--> - </tr> + <tr> + <th data-translate="moon.policy.assignments.table.perimeter.name">Perimeter name</th> + <th data-translate="moon.policy.assignments.table.category.name">Category name</th> + <th data-translate="moon.policy.assignments.table.data.name">Data name</th> + </tr> </thead> <moon-loader ng-if="list.loadingAct"></moon-loader> @@ -277,8 +287,10 @@ <span ng-if="list.getDataFromAssignmentsIndex(index, value, list.typeOfAction)"> <span ng-if="value.assignments_value[index].data.name" ng-bind="value.assignments_value[index].data.name"></span> <span ng-if="value.assignments_value[index].data.value.name" ng-bind="value.assignments_value[index].data.value.name"></span> - - <span ng-if="index < value.assignments.length-1">,</span> + <a href="" ng-if="!value.loader" ng-click="list.deleteAct(value, value.assignments_value[index].data.id)" > + <span>(</span><span class="glyphicon glyphicon-transfer"></span><span>)</span> + </a> + <span ng-if="index < value.assignments.length-1">, </span> </span> </span> @@ -314,7 +326,7 @@ <div class="panel-body">. - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit> + <moon-assignments-edit policy="list.policy" assignments-type="list.typeOfAction"></moon-assignments-edit> </div> diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments.list.dir.js b/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments.list.dir.js index 747fd487..22931e4d 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments.list.dir.js +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/assignments/assignments.list.dir.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; @@ -11,16 +11,16 @@ function moonAssignmentsList() { return { - templateUrl : 'html/policy/edit/parameter/assignments/assignments-list.tpl.html', - bindToController : true, - controller : moonAssignmentsListController, - controllerAs : 'list', - scope : { + templateUrl: 'html/policy/edit/parameter/assignments/assignments-list.tpl.html', + bindToController: true, + controller: moonAssignmentsListController, + controllerAs: 'list', + scope: { policy: '=', - editMode : '=' + editMode: '=' }, - restrict : 'E', - replace : true + restrict: 'E', + replace: true }; } @@ -28,9 +28,11 @@ .module('moon') .controller('moonAssignmentsListController', moonAssignmentsListController); - moonAssignmentsListController.$inject = ['$scope', '$rootScope', 'assignmentService', '$translate', 'alertService', 'policyService', 'ASSIGNMENTS_CST', 'utilService', 'metaDataService', 'perimeterService', 'dataService']; + moonAssignmentsListController.$inject = ['$scope', '$rootScope', 'assignmentsService', '$translate', 'alertService', + 'policyService', 'ASSIGNMENTS_CST', 'utilService', 'metaDataService', 'perimeterService', 'dataService']; - function moonAssignmentsListController($scope, $rootScope, assignmentService, $translate, alertService, policyService, ASSIGNMENTS_CST, utilService, metaDataService, perimeterService, dataService){ + function moonAssignmentsListController($scope, $rootScope, assignmentsService, $translate, alertService, + policyService, ASSIGNMENTS_CST, utilService, metaDataService, perimeterService, dataService) { var list = this; @@ -41,10 +43,6 @@ list.typeOfObject = ASSIGNMENTS_CST.TYPE.OBJECT; list.typeOfAction = ASSIGNMENTS_CST.TYPE.ACTION; - list.unMapSub = unMapSub; - list.unMapObj = unMapObj; - list.unMapAct = unMapAct; - list.deleteSub = deleteSub; list.deleteObj = deleteObj; list.deleteAct = deleteAct; @@ -59,7 +57,7 @@ activate(); - function activate(){ + function activate() { manageSubjects(); @@ -71,37 +69,32 @@ var rootListeners = { - 'event:deleteDataFromDataAddSuccess': $rootScope.$on('event:deleteDataFromDataAddSuccess', deletePolicy) + 'event:createAssignmentsFromAssignmentsEditSuccess': $rootScope.$on('event:createAssignmentsFromAssignmentsEditSuccess', updateList) }; - for (var unbind in rootListeners) { + _.each(rootListeners, function(unbind){ $scope.$on('$destroy', rootListeners[unbind]); - } - + }); - function manageSubjects(){ + function manageSubjects() { list.loadingSub = true; - assignmentService.subject.findAllFromPolicyWithCallback(list.policy.id, function(data){ + assignmentsService.subject.findAllFromPolicyWithCallback(list.policy.id, function (data) { - console.log('subjects'); - console.log(data); list.subjects = data; list.loadingSub = false; }); } - function manageObjects(){ + function manageObjects() { list.loadingObj = true; - assignmentService.object.findAllFromPolicyWithCallback(list.policy.id, function(data){ + assignmentsService.object.findAllFromPolicyWithCallback(list.policy.id, function (data) { - console.log('objects'); - console.log(data); list.objects = data; list.loadingObj = false; @@ -109,14 +102,12 @@ } - function manageActions(){ + function manageActions() { list.loadingAct = true; - assignmentService.action.findAllFromPolicyWithCallback(list.policy.id, function(data){ + assignmentsService.action.findAllFromPolicyWithCallback(list.policy.id, function (data) { - console.log('actions'); - console.log(data); list.actions = data; list.loadingAct = false; @@ -126,16 +117,16 @@ function getPerimeterFromAssignment(assignment, type) { - if(_.has(assignment, 'perimeter')){ + if (_.has(assignment, 'perimeter')) { return assignment.perimeter; } // if the call has not been made - if(!_.has(assignment, 'callPerimeterInProgress')){ + if (!_.has(assignment, 'callPerimeterInProgress')) { assignment.callPerimeterInProgress = true; - switch(type){ + switch (type) { case ASSIGNMENTS_CST.TYPE.SUBJECT: perimeterService.subject.findOneFromPolicyWithCallback(list.policy.id, assignment.subject_id, setPerimeterToAssignment); @@ -156,7 +147,7 @@ // if the call is in progress return false return false; - function setPerimeterToAssignment(perimeter){ + function setPerimeterToAssignment(perimeter) { assignment.callPerimeterInProgress = false; assignment.perimeter = perimeter; @@ -166,16 +157,16 @@ function getCategoryFromAssignment(data, type) { - if(_.has(data, 'category')){ + if (_.has(data, 'category')) { return data.category; } // if the call has not been made - if(!_.has(data, 'callCategoryInProgress')){ + if (!_.has(data, 'callCategoryInProgress')) { data.callCategoryInProgress = true; - switch(type){ + switch (type) { case ASSIGNMENTS_CST.TYPE.SUBJECT: metaDataService.subject.findOne(data.subject_cat_id, setCategoryToData); @@ -196,7 +187,7 @@ // if the call is in progress return false return false; - function setCategoryToData(category){ + function setCategoryToData(category) { data.callCategoryInProgress = false; data.category = category; @@ -205,32 +196,31 @@ } /** - * Prerequisite : meta Rule should be completely loaded * @param index * @param assignment * @param type */ - function getDataFromAssignmentsIndex(index, assignment, type){ + function getDataFromAssignmentsIndex(index, assignment, type) { - if(!_.has(assignment, 'assignments_value')){ + if (!_.has(assignment, 'assignments_value')) { // setting an array which will contains every value of the category - assignment.assignments_value = Array.apply(null, new Array(assignment.assignments.length)).map(function(){ + assignment.assignments_value = Array.apply(null, new Array(assignment.assignments.length)).map(function () { return { data: {} - } + }; }); } - if(_.has(assignment.assignments_value[index], 'callDataInProgress') && !assignment.assignments_value[index].callDataInProgress ){ + if (_.has(assignment.assignments_value[index], 'callDataInProgress') && !assignment.assignments_value[index].callDataInProgress) { return assignment.assignments_value[index].data; } // if the call has not been made - if(!_.has(assignment.assignments_value[index], 'callDataInProgress')){ + if (!_.has(assignment.assignments_value[index], 'callDataInProgress')) { assignment.assignments_value[index].callDataInProgress = true; - switch(type){ + switch (type) { case ASSIGNMENTS_CST.TYPE.SUBJECT: dataService.subject.data.findOne(list.policy.id, assignment.category_id, assignment.assignments[index], setDataToAssignment); @@ -251,7 +241,7 @@ // if the call is in progress return false return false; - function setDataToAssignment(data){ + function setDataToAssignment(data) { assignment.assignments_value[index].callDataInProgress = false; assignment.assignments_value[index].data = data; @@ -259,239 +249,142 @@ } } - - /** - * UnMap + * Delete */ - function unMapSub(subject){ + function deleteSub(subject, dataId) { subject.loader = true; - var policyToSend = angular.copy(list.policy); + assignmentsService.subject.delete(list.policy.id, subject.subject_id, subject.subject_cat_id, dataId, deleteSubSuccess, deleteSubError); - policyToSend.subject_categories = _.without(policyToSend.subject_categories, subject.id); + function deleteSubSuccess(data) { - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); - - function updatePolicySuccess(data){ - - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.assignments.subject.delete.success').then(function (translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); + manageSubjects(); subject.loader = false; } - function updatePolicyError(reason){ + function deleteSubError(reason) { - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.assignments.subject.delete.error', { + subjectName: subject.name, + reason: reason.message + }).then(function (translatedValue) { alertService.alertError(translatedValue); }); subject.loader = false; } - } - function unMapObj(object){ + function deleteObj(object, dataId) { object.loader = true; - var policyToSend = angular.copy(list.policy); - - policyToSend.object_categories = _.without(policyToSend.object_categories, object.id); - - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); + assignmentsService.object.delete(list.policy.id, object.object_id, object.object_cat_id, dataId, deleteObjSuccess, deleteObjError); - function updatePolicySuccess(data){ + function deleteObjSuccess(data) { - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.assignments.object.delete.success').then(function (translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); + manageObjects(); object.loader = false; } - function updatePolicyError(reason){ + function deleteObjError(reason) { - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.assignments.object.delete.error', { + objectName: object.name, + reason: reason.message + }).then(function (translatedValue) { alertService.alertError(translatedValue); }); object.loader = false; - } - } - function unMapAct(action){ + function deleteAct(action, dataId) { action.loader = true; - var policyToSend = angular.copy(list.policy); + assignmentsService.action.delete(list.policy.id, action.action_id, action.action_cat_id, dataId, deleteActSuccess, deleteActError); - policyToSend.action_categories = _.without(policyToSend.action_categories, action.id); + function deleteActSuccess(data) { - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); - - function updatePolicySuccess(data){ - - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.assignments.action.delete.success').then(function (translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); + manageActions(); action.loader = false; } - function updatePolicyError(reason){ + function deleteActError(reason) { - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.assignments.action.delete.error', { + actionName: action.name, + reason: reason.message + }).then(function (translatedValue) { alertService.alertError(translatedValue); }); action.loader = false; } - } - /** - * Delete - */ - - function deleteSub(subject){ - - subject.loader = true; - - assignmentService.subject.delete(subject, deleteSubSuccess, deleteSubError); - - function deleteSubSuccess(data){ - - $translate('moon.policy.perimeter.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeSubFromSubList(subject); - - subject.loader = false; - - } - - function deleteSubError(reason){ - - $translate('moon.policy.perimeter.subject.delete.error', { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - subject.loader = false; - - } + function getSubjects() { + return list.subjects ? list.subjects : []; } - function deleteObj(object){ - - object.loader = true; - - assignmentService.object.delete(object, deleteObjSuccess, deleteObjError); - - function deleteObjSuccess(data){ - - $translate('moon.policy.perimeter.object.delete.success', { objectName: object.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeObjFromObjList(object); - - object.loader = false; - - } - - function deleteObjError(reason){ - - $translate('moon.policy.perimeter.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - object.loader = false; - } + function getObjects() { + return list.objects ? list.objects : []; } - function deleteAct(action){ + function getActions() { + return list.actions ? list.actions : []; + } - action.loader = true; + function updateList(event, type) { - assignmentService.action.delete(action, deleteActSuccess, deleteActError); + switch(type){ - function deleteActSuccess(data){ + case ASSIGNMENTS_CST.TYPE.SUBJECT: - $translate('moon.policy.perimeter.action.delete.success', { actionName: action.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); + manageSubjects(); + break; - removeActFromActList(action); + case ASSIGNMENTS_CST.TYPE.OBJECT: - action.loader = false; + manageObjects(); + break; - } + case ASSIGNMENTS_CST.TYPE.ACTION: - function deleteActError(reason){ + manageActions(); + break; - $translate('moon.policy.perimeter.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); + default : - action.loader = false; + activate(); + break; } - } - - function getSubjects(){ - return list.subjects ? list.subjects : []; - } - - function getObjects(){ - return list.objects ? list.objects : []; - } - - function getActions(){ - return list.actions ? list.actions : []; - } - - function removeSubFromSubList(subject){ - list.subjects = _.without(list.subjects, subject); - } - - function removeObjFromObjList(object){ - list.objects = _.without(list.objects, object); - } - - function removeActFromActList(action){ - list.actions = _.without(list.actions, action); - } - - function deletePolicy( event, policy){ - - list.policy = policy; - - activate(); } diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data-list.tpl.html b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data-list.tpl.html index b2bac597..b69a4eed 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data-list.tpl.html +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data-list.tpl.html @@ -18,7 +18,7 @@ <th data-translate="moon.policy.data.table.name">Name</th> <th data-translate="moon.policy.data.table.description">Description</th> <th data-translate="moon.policy.data.table.category.name">Category</th> - <!--<th data-translate="moon.policy.data.table.action.title"></th>--> + <th data-translate="moon.policy.data.table.action.title"></th> </tr> </thead> @@ -40,6 +40,23 @@ </div> </td> + + <td> + + <a href="" ng-if="!value.loader" ng-click="list.deleteSub(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.data.table.action.delete">Delete</span> + </a> + + <div ng-if="value.loader"> + + <moon-loader></moon-loader> + + </div> + + </td> + + <!--<td> <div class="dropdown"> @@ -85,9 +102,7 @@ <tbody ng-if="!list.loadingSub && list.getSubjects().length === 0"> <tr> - <td data-translate="moon.policy.data.subject.notFound">There is no Subjects</td> - <td></td> - <td></td> + <td colspan="4" data-translate="moon.policy.data.subject.notFound">There is no Subjects</td> </tr> </tbody> @@ -109,7 +124,7 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfSubject"></moon-meta-data-edit> + <moon-data-edit policy="list.policy" mn-data-type="list.typeOfSubject"></moon-data-edit> </div> @@ -134,8 +149,7 @@ <th data-translate="moon.policy.data.table.name">Name</th> <th data-translate="moon.policy.data.table.description">Description</th> <th data-translate="moon.policy.data.table.category.name">Category</th> - - <!--<th data-translate="moon.policy.data.table.action.title"></th>--> + <th data-translate="moon.policy.data.table.action.title">Actions</th> </tr> </thead> @@ -157,6 +171,21 @@ </div> </td> + + <td> + + <a href="" ng-if="!value.loader" ng-click="list.deleteObj(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.data.table.action.delete">Delete</span> + </a> + + <div ng-if="value.loader"> + + <moon-loader></moon-loader> + + </div> + + </td> <!--<td> <div class="dropdown"> @@ -200,9 +229,9 @@ <tbody ng-if="!list.loadingObj && list.getObjects().length === 0"> <tr> - <td data-translate="moon.policy.data.object.notFound">There is no Objects</td> - <td></td> - <td></td> + + <td colspan="4" data-translate="moon.policy.data.object.notFound">There is no Objects</td> + </tr> </tbody> @@ -224,7 +253,7 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit> + <moon-data-edit policy="list.policy" mn-data-type="list.typeOfObject"></moon-data-edit> </div> @@ -249,8 +278,7 @@ <th data-translate="moon.policy.data.table.name">Name</th> <th data-translate="moon.policy.data.table.description">Description</th> <th data-translate="moon.policy.data.table.category.name">Category</th> - - <!--<th data-translate="moon.policy.data.table.action.title"></th>--> + <th data-translate="moon.policy.data.table.action.title">Actions</th> </tr> </thead> @@ -272,6 +300,21 @@ </div> </td> + + <td> + + <a href="" ng-if="!value.loader" ng-click="list.deleteSub(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.data.table.action.delete">Delete</span> + </a> + + <div ng-if="value.loader"> + + <moon-loader></moon-loader> + + </div> + + </td> <!--<td> <div class="dropdown"> @@ -315,9 +358,7 @@ <tbody ng-if="!list.loadingAct && list.getActions().length === 0"> <tr> - <td data-translate="moon.policy.data.action.notFound">There is no Actions</td> - <td></td> - <td></td> + <td colspan="4" data-translate="moon.policy.data.action.notFound">There is no Actions</td> </tr> </tbody> @@ -340,7 +381,7 @@ <div class="panel-body">. - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit> + <moon-data-edit policy="list.policy" mn-data-type="list.typeOfAction"></moon-data-edit> </div> diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js index 11f0d480..57ad0c9b 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js @@ -17,40 +17,43 @@ controllerAs : 'edit', scope : { //Type can be 'ACTION', 'OBJECT', 'SUBJECT' - metaDataType: '=', - metaRule : '=' + mnDataType: '=', + policy : '=' }, restrict : 'E', replace : true }; + } angular .module('moon') .controller('moonDataEditController', moonDataEditController); - moonDataEditController.$inject = ['$scope', 'metaDataService', 'DATA_CST', 'alertService', '$translate', 'formService', 'policyService', 'utilService']; + moonDataEditController.$inject = ['$scope', 'dataService', 'DATA_CST', 'alertService', '$translate', + 'formService', 'policyService', 'utilService', 'metaDataService']; - function moonDataEditController($scope, metaDataService, DATA_CST, alertService, $translate, formService, policyService, utilService) { + function moonDataEditController($scope, dataService, DATA_CST, alertService, $translate, + formService, policyService, utilService, metaDataService) { var edit = this; - edit.metaDataType = $scope.edit.metaDataType; - edit.metaRule = $scope.edit.metaRule; + edit.dataType = $scope.edit.mnDataType; + edit.policy = $scope.edit.policy; - edit.fromList = true; + edit.fromList = false; - edit.laoading = false; + edit.loading = false; edit.form = {}; - edit.metaData = { name: null, description: null}; + edit.data = { name: null, description: null}; edit.list = []; + edit.policyList = []; + edit.categoriesToBeSelected = []; - edit.create = createMetaData; - edit.addToMetaRule = addToMetaRule; - edit.deleteMetaData = deleteMetaData; + edit.create = createData; activate(); @@ -60,21 +63,24 @@ function activate(){ - switch(edit.metaDataType){ + loadAllCategories(); + loadAllPolicies(); + + switch(edit.dataType){ case DATA_CST.TYPE.SUBJECT: - metaDataService.subject.findAllWithCallback(callBackList); + dataService.subject.findAllFromPolicyWithCallback(edit.policy.id, callBackList); break; case DATA_CST.TYPE.OBJECT: - metaDataService.object.findAllWithCallback(callBackList); + dataService.object.findAllFromPolicyWithCallback(edit.policy.id, callBackList); break; case DATA_CST.TYPE.ACTION: - metaDataService.action.findAllWithCallback(callBackList); + dataService.action.findAllFromPolicyWithCallback(edit.policy.id, callBackList); break; default : @@ -86,81 +92,77 @@ function callBackList(list){ - edit.list = list - - } - - } - - /** - * Add - */ + // For each Data, there is a check about the mapping between the Data and the policy + _.each(list, function (element) { + if (element.policy_id !== edit.policy.id) { - function addToMetaRule(){ + edit.list.push(element); - if(!edit.selectedMetaData){ - - return; + } + }); } - var metaRuleToSend = edit.metaRule; + } + + function loadAllCategories(){ - switch(edit.metaDataType){ + switch(edit.dataType){ case DATA_CST.TYPE.SUBJECT: - metaRuleToSend.subject_categories.push(edit.selectedMetaData.id); + metaDataService.subject.findAllWithCallback(callBackList); break; case DATA_CST.TYPE.OBJECT: - metaRuleToSend.object_categories.push(edit.selectedMetaData.id); + metaDataService.object.findAllWithCallback(callBackList); break; case DATA_CST.TYPE.ACTION: - metaRuleToSend.action_categories.push(edit.selectedMetaData.id); + metaDataService.action.findAllWithCallback(callBackList); break; - } - - policyService.update(metaRuleToSend, updateMetaRuleSuccess, updateMetaRuleError); - function updateMetaRuleSuccess(data){ + default : - $translate('moon.model.metarules.update.success', { metaRuleName: metaRuleToSend.name }).then( function(translatedValue) { + edit.categoriesToBeSelected = []; + break; - alertService.alertSuccess(translatedValue); + } - }); + function callBackList(list){ - metaRuleToSend = utilService.transformOne(data, 'meta_rules'); + edit.categoriesToBeSelected = list; - $scope.$emit('event:updateMetaRuleFromMetaDataAddSuccess', metaRuleToSend); + } + } - stopLoading(); + function loadAllPolicies() { - } + edit.policyList = []; - function updateMetaRuleError(reason){ + policyService.findAllWithCallback( function(data) { - $translate('moon.model.metarules.update.error', { metaRuleName: metaRuleToSend.name, reason: reason.message}).then( function(translatedValue) { + _.each(data, function(element){ - alertService.alertError(translatedValue); + if(element.id === edit.policy.id){ + edit.selectedPolicy = element; + } }); - stopLoading(); - - } + edit.policyList = data; + }); } + /** * Create */ - function createMetaData() { + function createData() { if(formService.isInvalid(edit.form)) { @@ -170,140 +172,74 @@ startLoading(); - var metaDataToSend = angular.copy(edit.metaData); + var dataToSend = angular.copy(edit.data); - switch(edit.metaDataType){ + switch(edit.dataType){ case DATA_CST.TYPE.SUBJECT: - metaDataService.subject.add(metaDataToSend, createSuccess, createError); + dataService.subject.add(dataToSend, edit.policy.id, edit.selectedCategory.id, createSuccess, createError); break; case DATA_CST.TYPE.OBJECT: - metaDataService.object.add(metaDataToSend, createSuccess, createError); + dataService.object.add(dataToSend, edit.policy.id, edit.selectedCategory.id, createSuccess, createError); break; case DATA_CST.TYPE.ACTION: - metaDataService.action.add(metaDataToSend, createSuccess, createError); + dataService.action.add(dataToSend, edit.policy.id, edit.selectedCategory.id, createSuccess, createError); break; } } + /** + * @param data + */ function createSuccess(data) { var created = {}; - switch(edit.metaDataType){ + switch(edit.dataType){ case DATA_CST.TYPE.SUBJECT: - created = utilService.transformOne(data, 'subject_categories'); + created = utilService.transformOne(data['subject_data'], 'data'); break; case DATA_CST.TYPE.OBJECT: - created = utilService.transformOne(data, 'object_categories'); + created = utilService.transformOne(data['object_data'], 'data'); break; case DATA_CST.TYPE.ACTION: - created = utilService.transformOne(data, 'action_categories'); + created = utilService.transformOne(data['action_data'], 'data'); break; } - $translate('moon.model.metadata.edit.create.success', { name: created.name }).then(function (translatedValue) { + $translate('moon.policy.data.edit.create.success', { name: created.name }).then(function (translatedValue) { alertService.alertSuccess(translatedValue); }); + $scope.$emit('event:createDataFromDataEditSuccess', created, edit.dataType); + stopLoading(); edit.list.push(created); - displayList(); - } function createError(reason) { - $translate('moon.model.metadata.edit.create.error', { name: metaDataToSend.name }).then(function (translatedValue) { - alertService.alertError(translatedValue); - }); - - stopLoading(); - - } - - } - - function deleteMetaData(){ - - if(!edit.selectedMetaData){ - - return; - - } - - startLoading(); - - var metaDataToDelete = angular.copy(edit.selectedMetaData); - - switch(edit.metaDataType){ - case DATA_CST.TYPE.SUBJECT: - - metaDataService.subject.delete(metaDataToDelete, deleteSuccess, deleteError); - break; - - case DATA_CST.TYPE.OBJECT: - - metaDataService.object.delete(metaDataToDelete, deleteSuccess, deleteError); - break; - - case DATA_CST.TYPE.ACTION: - - metaDataService.action.delete(metaDataToDelete, deleteSuccess, deleteError); - break; - } - - - function deleteSuccess(data) { - - $translate('moon.model.metadata.edit.delete.success', { name: metaDataToDelete.name }).then(function (translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - policyService.findOneWithMetaData(edit.metaRule.id).then( function(metaRule){ - - edit.metaRule = metaRule; - - cleanSelectedValue(); - - activate(); - - stopLoading(); - - $scope.$emit('event:deleteMetaDataFromMetaDataAddSuccess', edit.metaRule); - - }); - - } - - function deleteError(reason) { - - $translate('moon.model.metadata.edit.delete.error', { name: metaDataToDelete.name }).then(function (translatedValue) { + $translate('moon.policy.data.edit.create.error', { name: dataToSend.name }).then(function (translatedValue) { alertService.alertError(translatedValue); }); stopLoading(); } - } - - function cleanSelectedValue(){ - - delete edit.selectedMetaData; } @@ -319,12 +255,6 @@ } - function displayList(){ - - edit.fromList = true; - - } - } })();
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.list.dir.js b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.list.dir.js index 07afd1b9..23a7e535 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.list.dir.js +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/data/data.list.dir.js @@ -28,9 +28,9 @@ .module('moon') .controller('moonDataListController', moonDataListController); - moonDataListController.$inject = ['$scope', '$rootScope', 'dataService', '$translate', 'alertService', 'policyService', 'DATA_CST', 'utilService', 'metaDataService']; + moonDataListController.$inject = ['$scope', '$rootScope', 'dataService', '$translate', 'alertService', 'DATA_CST', 'metaDataService']; - function moonDataListController($scope, $rootScope, dataService, $translate, alertService, policyService, DATA_CST, utilService, metaDataService){ + function moonDataListController($scope, $rootScope, dataService, $translate, alertService, DATA_CST, metaDataService){ var list = this; @@ -41,10 +41,6 @@ list.typeOfObject = DATA_CST.TYPE.OBJECT; list.typeOfAction = DATA_CST.TYPE.ACTION; - list.unMapSub = unMapSub; - list.unMapObj = unMapObj; - list.unMapAct = unMapAct; - list.deleteSub = deleteSub; list.deleteObj = deleteObj; list.deleteAct = deleteAct; @@ -69,13 +65,13 @@ var rootListeners = { - 'event:deleteDataFromDataAddSuccess': $rootScope.$on('event:deleteDataFromDataAddSuccess', deletePolicy) + 'event:createDataFromDataEditSuccess': $rootScope.$on('event:createDataFromDataEditSuccess', addDataToList) }; - for (var unbind in rootListeners) { + _.each(rootListeners, function(unbind){ $scope.$on('$destroy', rootListeners[unbind]); - } + }); function manageSubjects(){ @@ -84,8 +80,6 @@ dataService.subject.findAllFromPolicyWithCallback(list.policy.id, function(data){ - console.log('subjects'); - console.log(data); list.subjects = data; list.loadingSub = false; @@ -98,8 +92,6 @@ dataService.object.findAllFromPolicyWithCallback(list.policy.id, function(data){ - console.log('objects'); - console.log(data); list.objects = data; list.loadingObj = false; @@ -113,8 +105,6 @@ dataService.action.findAllFromPolicyWithCallback(list.policy.id, function(data){ - console.log('actions'); - console.log(data); list.actions = data; list.loadingAct = false; @@ -163,118 +153,6 @@ } /** - * UnMap - */ - - function unMapSub(subject){ - - subject.loader = true; - - var policyToSend = angular.copy(list.policy); - - policyToSend.subject_categories = _.without(policyToSend.subject_categories, subject.id); - - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); - - function updatePolicySuccess(data){ - - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); - - subject.loader = false; - - } - - function updatePolicyError(reason){ - - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - subject.loader = false; - - } - - } - - function unMapObj(object){ - - object.loader = true; - - var policyToSend = angular.copy(list.policy); - - policyToSend.object_categories = _.without(policyToSend.object_categories, object.id); - - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); - - function updatePolicySuccess(data){ - - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); - - object.loader = false; - - } - - function updatePolicyError(reason){ - - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - object.loader = false; - - } - - } - - function unMapAct(action){ - - action.loader = true; - - var policyToSend = angular.copy(list.policy); - - policyToSend.action_categories = _.without(policyToSend.action_categories, action.id); - - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); - - function updatePolicySuccess(data){ - - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - list.policy = policyService.findDataFromPolicy(utilService.transformOne(data, 'meta_rules')); - - activate(); - - action.loader = false; - - } - - function updatePolicyError(reason){ - - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - action.loader = false; - - } - - } - - /** * Delete */ @@ -282,11 +160,11 @@ subject.loader = true; - dataService.subject.delete(subject, deleteSubSuccess, deleteSubError); + dataService.subject.delete(subject, list.policy.id, subject.category_id, deleteSubSuccess, deleteSubError); function deleteSubSuccess(data){ - $translate('moon.policy.perimeter.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { + $translate('moon.policy.data.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); @@ -298,7 +176,7 @@ function deleteSubError(reason){ - $translate('moon.policy.perimeter.subject.delete.error', { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.data.subject.delete.error', { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); @@ -311,11 +189,11 @@ object.loader = true; - dataService.object.delete(object, deleteObjSuccess, deleteObjError); + dataService.object.delete(object, list.policy.id, object.category_id, deleteObjSuccess, deleteObjError); function deleteObjSuccess(data){ - $translate('moon.policy.perimeter.object.delete.success', { objectName: object.name }).then( function(translatedValue) { + $translate('moon.policy.data.object.delete.success', { objectName: object.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); @@ -327,7 +205,7 @@ function deleteObjError(reason){ - $translate('moon.policy.perimeter.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.data.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); @@ -339,11 +217,11 @@ action.loader = true; - dataService.action.delete(action, deleteActSuccess, deleteActError); + dataService.action.delete(action, list.policy.id, action.category_id, deleteActSuccess, deleteActError); function deleteActSuccess(data){ - $translate('moon.policy.perimeter.action.delete.success', { actionName: action.name }).then( function(translatedValue) { + $translate('moon.policy.data.action.delete.success', { actionName: action.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); @@ -355,7 +233,7 @@ function deleteActError(reason){ - $translate('moon.policy.perimeter.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.data.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); @@ -388,11 +266,25 @@ list.actions = _.without(list.actions, action); } - function deletePolicy( event, policy){ + function addDataToList( event, data, typeOfData){ + + switch(typeOfData){ - list.policy = policy; + case DATA_CST.TYPE.SUBJECT: - activate(); + list.subjects.push(data); + break; + + case DATA_CST.TYPE.OBJECT: + + list.objects.push(data); + break; + + case DATA_CST.TYPE.ACTION: + + list.actions.push(data); + break; + } } diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter-list.tpl.html b/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter-list.tpl.html index 6111888a..a94d663e 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter-list.tpl.html +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter-list.tpl.html @@ -15,11 +15,10 @@ <thead> <tr> - <th data-translate="moon.policy.perimeter.table.partner.id">Id</th> <th data-translate="moon.policy.perimeter.table.name">Name</th> <th data-translate="moon.policy.perimeter.table.description">Description</th> <th data-translate="moon.policy.perimeter.table.email">Email</th> - <!--<th data-translate="moon.policy.perimeter.table.action.title"></th>--> + <th data-translate="moon.policy.perimeter.table.action.title"></th> </tr> </thead> @@ -27,40 +26,15 @@ <tbody ng-if="!list.loadingSub && list.getSubjects().length > 0"> <tr ng-repeat="(key, value) in list.subjects"> - <td ng-bind="value.partner_id"></td> <td ng-bind="value.name"></td> <td ng-bind="value.description"></td> <td ng-bind="value.email"></td> - <!--<td> + <td> - <div class="dropdown"> - - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.policy.perimeter.table.action.title">Actions</span> - <span class="caret"></span> - </button> - - <ul class="dropdown-menu"> - - <li> - <a href="" ng-click="list.unMapSub(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metarules.action.unmap">Unmap</span> - </a> - </li> - - <li class="divider"></li> - - <li> - <a href="" ng-click="list.deleteSub(value)"> - <span class="glyphicon glyphicon-trash"></span> - <span class="control-label" data-translate="moon.policy.perimeter.table.action.delete">Delete</span> - </a> - </li> - - </ul> - - </div> + <a href="" ng-if="!value.loader" ng-click="list.unMapSub(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.perimeter.table.action.unmap">Unmap</span> + </a> <div ng-if="value.loader"> @@ -68,7 +42,7 @@ </div> - </td>--> + </td> </tr> </tbody> @@ -80,7 +54,6 @@ <td></td> <td></td> <td></td> - <td></td> </tr> </tbody> @@ -102,12 +75,13 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfSubject"></moon-meta-data-edit> + <moon-perimeter-edit policy="list.policy" perimeter-type="list.typeOfSubject"></moon-perimeter-edit> </div> </div> + <div class="panel panel-default"> <div class="panel-heading"> @@ -124,10 +98,9 @@ <thead> <tr> - <th data-translate="moon.policy.perimeter.table.partner.id">Id</th> <th data-translate="moon.policy.perimeter.table.name">Name</th> <th data-translate="moon.policy.perimeter.table.description">Description</th> - <!--<th data-translate="moon.policy.perimeter.table.action.title"></th>--> + <th data-translate="moon.policy.perimeter.table.action.title"></th> </tr> </thead> @@ -135,39 +108,14 @@ <tbody ng-if="!list.loadingObj && list.getObjects().length > 0"> <tr ng-repeat="(key, value) in list.objects"> - <td ng-bind="value.partner_id"></td> <td ng-bind="value.name"></td> <td ng-bind="value.description"></td> - <!--<td> - - <div class="dropdown"> - - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.policy.perimeter.table.action.title">Actions</span> - <span class="caret"></span> - </button> - - <ul class="dropdown-menu"> - - <li> - <a href="" ng-click="list.unMapObj(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metarules.action.unmap">Unmap</span> - </a> - </li> - - <li class="divider"></li> + <td> - <li> - <a href="" ng-click="list.deleteObj(value)"> - <span class="glyphicon glyphicon-trash"></span> - <span class="control-label" data-translate="moon.policy.perimeter.table.action.delete">Delete</span> - </a> - </li> - - </ul> - - </div> + <a href="" ng-if="!value.loader" ng-click="list.unMapObj(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.perimeter.table.action.unmap">Unmap</span> + </a> <div ng-if="value.loader"> @@ -176,7 +124,7 @@ </div> </td> - </tr>--> + </tr> </tbody> <tbody ng-if="!list.loadingObj && list.getObjects().length === 0"> @@ -184,7 +132,6 @@ <td data-translate="moon.policy.perimeter.object.notFound">There is no Objects</td> <td></td> <td></td> - <td></td> </tr> </tbody> @@ -206,7 +153,7 @@ <div class="panel-body"> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit> + <moon-perimeter-edit policy="list.policy" perimeter-type="list.typeOfObject"></moon-perimeter-edit> </div> @@ -228,10 +175,9 @@ <thead> <tr> - <th data-translate="moon.policy.perimeter.table.partner.id">Id</th> <th data-translate="moon.policy.perimeter.table.name">Name</th> <th data-translate="moon.policy.perimeter.table.description">Description</th> - <!--<th data-translate="moon.policy.perimeter.table.action.title"></th>--> + <th data-translate="moon.policy.perimeter.table.action.title"></th> </tr> </thead> @@ -239,39 +185,14 @@ <tbody ng-if="!list.loadingAct && list.getActions().length > 0"> <tr ng-repeat="(key, value) in list.actions"> - <td ng-bind="value.partner_id"></td> <td ng-bind="value.name"></td> <td ng-bind="value.description"></td> - <!--<td> - - <div class="dropdown"> - - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.policy.perimeter.table.action.title">Actions</span> - <span class="caret"></span> - </button> - - <ul class="dropdown-menu"> + <td> - <li> - <a href="" ng-click="list.unMapAct(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metarules.action.unmap">Unmap</span> - </a> - </li> - - <li class="divider"></li> - - <li> - <a href="" ng-click="list.deleteAct(value)"> - <span class="glyphicon glyphicon-trash"></span> - <span class="control-label" data-translate="moon.policy.perimeter.table.action.delete">Delete</span> - </a> - </li> - - </ul> - - </div> + <a href="" ng-if="!value.loader" ng-click="list.unMapAct(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.perimeter.table.action.unmap">Unmap</span> + </a> <div ng-if="value.loader"> @@ -280,7 +201,7 @@ </div> </td> - </tr>--> + </tr> </tbody> <tbody ng-if="!list.loadingAct && list.getActions().length === 0"> @@ -288,7 +209,6 @@ <td data-translate="moon.policy.perimeter.action.notFound">There is no Actions</td> <td></td> <td></td> - <td></td> </tr> </tbody> @@ -311,7 +231,7 @@ <div class="panel-body">. - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit> + <moon-perimeter-edit policy="list.policy" perimeter-type="list.typeOfAction"></moon-perimeter-edit> </div> diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.list.dir.js b/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.list.dir.js index 8c50b22e..dffa7783 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.list.dir.js +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/perimeter/perimeter.list.dir.js @@ -22,15 +22,16 @@ restrict : 'E', replace : true }; + } angular .module('moon') .controller('moonPerimeterListController', moonPerimeterListController); - moonPerimeterListController.$inject = ['$scope', '$rootScope', 'perimeterService', '$translate', 'alertService', 'policyService', 'PERIMETER_CST', 'utilService']; + moonPerimeterListController.$inject = ['$scope', '$rootScope', 'perimeterService', '$translate', 'alertService', 'PERIMETER_CST']; - function moonPerimeterListController($scope, $rootScope, perimeterService, $translate, alertService, policyService, PERIMETER_CST, utilService){ + function moonPerimeterListController($scope, $rootScope, perimeterService, $translate, alertService, PERIMETER_CST){ var list = this; @@ -45,10 +46,6 @@ list.unMapObj = unMapObj; list.unMapAct = unMapAct; - list.deleteSub = deleteSub; - list.deleteObj = deleteObj; - list.deleteAct = deleteAct; - list.getSubjects = getSubjects; list.getObjects = getObjects; list.getActions = getActions; @@ -67,13 +64,14 @@ var rootListeners = { - 'event:deletePerimeterFromPerimeterAddSuccess': $rootScope.$on('event:deletePerimeterFromPerimeterAddSuccess', deletePolicy) + 'event:deletePerimeterFromPerimeterAddSuccess': $rootScope.$on('event:deletePerimeterFromPerimeterAddSuccess', deletePolicy), + 'event:createAssignmentsFromAssignmentsEditSuccess': $rootScope.$on('event:createAssignmentsFromAssignmentsEditSuccess', addAssignmentsToPolicy) }; - for (var unbind in rootListeners) { + _.each(rootListeners, function(unbind){ $scope.$on('$destroy', rootListeners[unbind]); - } + }); function manageSubjects(){ @@ -94,8 +92,6 @@ perimeterService.object.findAllFromPolicyWithCallback(list.policy.id, function(perimeters){ - console.log('objects'); - console.log(perimeters); list.objects = perimeters; list.loadingObj = false; @@ -109,8 +105,6 @@ perimeterService.action.findAllFromPolicyWithCallback(list.policy.id, function(perimeters){ - console.log('actions'); - console.log(perimeters); list.actions = perimeters; list.loadingAct = false; @@ -118,207 +112,113 @@ } - /** * UnMap */ - function unMapSub(subject){ + function unMapSub(perimeter){ - subject.loader = true; + perimeter.policy_list = _.without(perimeter.policy_list, list.policy.id); - var policyToSend = angular.copy(list.policy); + perimeter.loader = true; - policyToSend.subject_categories = _.without(policyToSend.subject_categories, subject.id); + var perimeterToSend = angular.copy(perimeter); - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); + perimeterService.subject.unMapPerimeterFromPolicy(list.policy.id , perimeter.id, updatePerimeterSuccess, updatePerimeterError); - function updatePolicySuccess(data){ + function updatePerimeterSuccess(data){ - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.success', { perimeterName: perimeterToSend.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findPerimeterFromPolicy(utilService.transformOne(data, 'meta_rules')); + $scope.$emit('event:unMapPerimeterFromPerimeterList', perimeter, PERIMETER_CST.TYPE.SUBJECT); activate(); - subject.loader = false; - + perimeter.loader = false; } - function updatePolicyError(reason){ + function updatePerimeterError(reason){ - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.error', { perimeterName: perimeter.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); - subject.loader = false; + perimeter.loader = false; } } - function unMapObj(object){ + function unMapObj(perimeter){ - object.loader = true; + perimeter.policy_list = _.without(perimeter.policy_list, list.policy.id); - var policyToSend = angular.copy(list.policy); + perimeter.loader = true; - policyToSend.object_categories = _.without(policyToSend.object_categories, object.id); + var perimeterToSend = angular.copy(perimeter); - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); + perimeterService.object.unMapPerimeterFromPolicy(list.policy.id , perimeter.id, updatePerimeterSuccess, updatePerimeterError); - function updatePolicySuccess(data){ + function updatePerimeterSuccess(data){ - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.success', { perimeterName: perimeterToSend.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findPerimeterFromPolicy(utilService.transformOne(data, 'meta_rules')); + $scope.$emit('event:unMapPerimeterFromPerimeterList', perimeter, PERIMETER_CST.TYPE.OBJECT); activate(); - object.loader = false; - + perimeter.loader = false; } - function updatePolicyError(reason){ + function updatePerimeterError(reason){ - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.error', { perimeterName: perimeter.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); - object.loader = false; + perimeter.loader = false; } } - function unMapAct(action){ + function unMapAct(perimeter){ - action.loader = true; + perimeter.policy_list = _.without(perimeter.policy_list, list.policy.id); - var policyToSend = angular.copy(list.policy); + perimeter.loader = true; - policyToSend.action_categories = _.without(policyToSend.action_categories, action.id); + var perimeterToSend = angular.copy(perimeter); - policyService.update(policyToSend, updatePolicySuccess, updatePolicyError); + perimeterService.action.unMapPerimeterFromPolicy(list.policy.id , perimeter.id, updatePerimeterSuccess, updatePerimeterError); - function updatePolicySuccess(data){ + function updatePerimeterSuccess(data){ - $translate('moon.policy.metarules.update.success', { policyName: list.policy.name }).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.success', { perimeterName: perimeterToSend.name }).then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); - list.policy = policyService.findPerimeterFromPolicy(utilService.transformOne(data, 'meta_rules')); + $scope.$emit('event:unMapPerimeterFromPerimeterList', perimeter, PERIMETER_CST.TYPE.ACTION); activate(); - action.loader = false; - + perimeter.loader = false; } - function updatePolicyError(reason){ + function updatePerimeterError(reason){ - $translate('moon.policy.metarules.update.error', { policyName: list.policy.name, reason: reason.message}).then( function(translatedValue) { + $translate('moon.policy.perimeter.update.error', { perimeterName: perimeter.name, reason: reason.message}).then( function(translatedValue) { alertService.alertError(translatedValue); }); - action.loader = false; - - } - - } - - /** - * Delete - */ - - function deleteSub(subject){ - - subject.loader = true; - - perimeterService.subject.delete(subject, deleteSubSuccess, deleteSubError); - - function deleteSubSuccess(data){ - - $translate('moon.policy.perimeter.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeSubFromSubList(subject); - - subject.loader = false; + perimeter.loader = false; } - function deleteSubError(reason){ - - $translate('moon.policy.perimeter.subject.delete.error', { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - subject.loader = false; - - } - } - - function deleteObj(object){ - - object.loader = true; - - perimeterService.object.delete(object, deleteObjSuccess, deleteObjError); - - function deleteObjSuccess(data){ - - $translate('moon.policy.perimeter.object.delete.success', { objectName: object.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeObjFromObjList(object); - - object.loader = false; - - } - - function deleteObjError(reason){ - - $translate('moon.policy.perimeter.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - object.loader = false; - } - } - - function deleteAct(action){ - - action.loader = true; - - perimeterService.action.delete(action, deleteActSuccess, deleteActError); - - function deleteActSuccess(data){ - - $translate('moon.policy.perimeter.action.delete.success', { actionName: action.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeActFromActList(action); - - action.loader = false; - - } - - function deleteActError(reason){ - - $translate('moon.policy.perimeter.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - action.loader = false; - - } } function getSubjects(){ @@ -353,6 +253,32 @@ } + function addAssignmentsToPolicy( event, assignments, type){ + + switch (type) { + + case PERIMETER_CST.TYPE.SUBJECT: + + list.subjects.push(assignments); + break; + + case PERIMETER_CST.TYPE.OBJECT: + + list.objects.push(assignments); + break; + + case PERIMETER_CST.TYPE.ACTION: + + list.actions.push(assignments); + break; + + default : + break; + + } + + } + } })();
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html b/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html index 3ec54239..76ac4365 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules-list.tpl.html @@ -1,79 +1,74 @@ <div> - <div class="row"> - <div class="table-responsive" data-role="table"> + <div class="panel panel-default"> - <table class="table table-striped table-hover" ng-table="list.table"> + <div class="panel-heading"> - <thead> + <h4 data-translate="moon.policy.rules.edit.title">List of associated Subjects</h4> - <tr> + </div> + + <div class="panel-body"> - <th class="customTables sortable" - ng-class="{ 'sort-asc': list.table.isSortBy('name', 'asc'), 'sort-desc': list.table.isSortBy('name', 'desc') }" - ng-click="list.table.sorting('name', list.table.isSortBy('name', 'asc') ? 'desc' : 'asc')"> - <div data-translate="moon.policy.rules.list.table.id">Id</div> - </th> + <div class="table-responsive" data-role="table"> - <th class="customTables sortable" - ng-class="{ 'sort-asc': list.table.isSortBy('description', 'asc'), 'sort-desc': list.table.isSortBy('description', 'desc') }" - ng-click="list.table.sorting('description', list.table.isSortBy('description', 'asc') ? 'desc' : 'asc')"> - <div data-translate="moon.policy.rules.list.table.metaRule">Meta Rule</div> - </th> + <table class="table table-striped table-hover" ng-table="list.table"> - <th class="customTables sortable" - ng-class="{ 'sort-asc': list.table.isSortBy('enabled', 'asc'), 'sort-desc': list.table.isSortBy('enabled', 'desc') }" - ng-click="list.table.sorting('enabled', list.table.isSortBy('enabled', 'asc') ? 'desc' : 'asc')"> - <div data-translate="moon.policy.rules.list.table.enabled">Enabled</div> - </th> + <thead> - <th class="customTables sortable" - ng-class="{ 'sort-asc': list.table.isSortBy('enabled', 'asc'), 'sort-desc': list.table.isSortBy('enabled', 'desc') }" - ng-click="list.table.sorting('enabled', list.table.isSortBy('enabled', 'asc') ? 'desc' : 'asc')"> - <div data-translate="moon.policy.rules.list.table.rule">Rule</div> - </th> - </tr> + <tr> - </thead> + <th class="customTables sortable" + ng-class="{ 'sort-asc': list.table.isSortBy('description', 'asc'), 'sort-desc': list.table.isSortBy('description', 'desc') }" + ng-click="list.table.sorting('description', list.table.isSortBy('description', 'asc') ? 'desc' : 'asc')"> + <div data-translate="moon.policy.rules.list.table.metaRule">Meta Rule</div> + </th> - <moon-loader ng-if="list.loadingRules"></moon-loader> + <th class="customTables sortable"> + <div data-translate="moon.policy.rules.list.table.rule">Rule</div> + </th> - <tbody ng-if="!list.loadingRules && !list.hasRules()"> - <tr> - <td colspan="2"><span data-translate="moon.policy.rules.list.table.notFound">There is no Rules</span></td> + <th class="customTables sortable"> + <div data-translate="moon.policy.rules.list.table.instructions">Instruction</div> + </th> + + <th class="customTables sortable"> + <div data-translate="moon.policy.rules.list.table.action.title">Actions</div> + </th> </tr> - </tbody> - <tbody ng-if="!list.loadingRules && list.hasRules()"> + </thead> - <tr ng-repeat="aRule in $data | filter:list.search.find | orderBy:sort:reverse"> - <td ng-bind="aRule.id"></td> + <moon-loader ng-if="list.loadingRules"></moon-loader> - <td> - <span ng-if="!list.getMetaRuleFromRule(aRule)"> - <moon-loader ng-if="!list.getMetaRuleFromRule(aRule)" ></moon-loader> - <em data-translate="moon.policy.rules.list.table.loading.metaRule">Loading </em> - </span> + <tbody ng-if="!list.loadingRules && !list.hasRules()"> + <tr> + <td colspan="4"><span data-translate="moon.policy.rules.list.table.notFound">There is no Rules</span></td> + </tr> + </tbody> - <span ng-if="list.getMetaRuleFromRule(aRule)"> - <span ng-bind="aRule.meta_rule.name"></span> - </span> - </td> + <tbody ng-if="!list.loadingRules && list.hasRules()"> - <td> - <span ng-if="aRule.enabled" class="glyphicon glyphicon-ok"></span> - <span ng-if="!aRule.enabled" class="glyphicon glyphicon-remove"></span> - </td> + <tr ng-repeat="aRule in $data | filter:list.search.find | orderBy:sort:reverse"> + <td> + <span ng-if="!list.getMetaRuleFromRule(aRule)"> + <moon-loader ng-if="!list.getMetaRuleFromRule(aRule)" ></moon-loader> + <em data-translate="moon.policy.rules.list.table.loading.metaRule">Loading </em> + </span> - <td > + <span ng-if="list.getMetaRuleFromRule(aRule)"> + <span ng-bind="aRule.meta_rule.name"></span> + </span> + </td> - <span ng-if="!list.getMetaRuleFromRule(aRule)"> - <moon-loader ng-if="!list.getMetaRuleFromRule(aRule)" ></moon-loader> - <em data-translate="moon.policy.rules.list.table.loading.metaRule">Loading </em> - </span> + <td> + <span ng-if="!list.getMetaRuleFromRule(aRule)"> + <moon-loader ng-if="!list.getMetaRuleFromRule(aRule)" ></moon-loader> + <em data-translate="moon.policy.rules.list.table.loading.metaRule">Loading </em> + </span> - <span ng-if="list.getMetaRuleFromRule(aRule)" ng-repeat="(key, value) in aRule.rule"> + <span ng-if="list.getMetaRuleFromRule(aRule)" ng-repeat="(key, value) in aRule.rule"> <span ng-if="!list.getCategoryFromRuleIndex(key, aRule)"> <moon-loader ng-if="!list.getCategoryFromRuleIndex(key, aRule)" ></moon-loader> @@ -87,13 +82,50 @@ </span> - </td> + </td> + + <td> + <pre ng-bind="aRule.instructions | json "></pre> + </td> + + <td> + + <a href="" ng-if="!aRule.loader" ng-click="list.deleteRules(aRule)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.policy.rules.list.table.action.delete">Delete</span> + </a> + + <div ng-if="aRule.loader"> + + <moon-loader></moon-loader> - </tr> + </div> + + </td> + + </tr> + + </tbody> + + </table> + + </div> + + </div> + + </div> + + <div ng-if="list.editMode" class="panel panel-default"> + + <div class="panel-heading"> + + <h4 data-translate="moon.policy.rules.edit.action.add.title">Add a Rules</h4> + + </div> - </tbody> + <div class="panel-body">. - </table> + <moon-rules-edit policy="list.policy"></moon-rules-edit> </div> diff --git a/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules.list.dir.js b/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules.list.dir.js index 98e1d62b..5c3e7457 100644 --- a/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules.list.dir.js +++ b/moonv4/moon_gui/static/app/policy/edit/parameter/rules/rules.list.dir.js @@ -28,13 +28,14 @@ .module('moon') .controller('moonRulesListController', moonRulesListController); - moonRulesListController.$inject = [ 'NgTableParams', '$filter', 'metaRuleService', 'ruleService', 'dataService']; + moonRulesListController.$inject = [ '$scope', '$rootScope', 'NgTableParams', '$filter', 'metaRuleService', 'rulesService', 'dataService', '$translate', 'alertService' ]; - function moonRulesListController( NgTableParams, $filter, metaRuleService, ruleService, dataService) { + function moonRulesListController( $scope, $rootScope, NgTableParams, $filter, metaRuleService, rulesService, dataService, $translate, alertService ) { var list = this; list.rules = []; + list.editMode = $scope.list.editMode; list.loadingRules = true; @@ -43,6 +44,7 @@ list.getRules = getRules; list.hasRules = hasRules; list.refreshRules = refreshRules; + list.deleteRules = deleteRules; list.getMetaRuleFromRule = getMetaRuleFromRule; list.getCategoryFromRuleIndex = getCategoryFromRuleIndex; @@ -55,41 +57,40 @@ function activate(){ - newRulesTable(); manageRules(); + } + var rootListeners = { + 'event:createRulesFromDataRulesSuccess': $rootScope.$on('event:createRulesFromDataRulesSuccess', addRulesToList) - function manageRules(){ + }; + + _.each(rootListeners, function(unbind){ + $scope.$on('$destroy', rootListeners[unbind]); + }); - ruleService.findAllFromPolicyWithCallback(list.policy.id, function(data){ + function manageRules(){ - console.log('rules'); - console.log(data); + rulesService.findAllFromPolicyWithCallback(list.policy.id, function(data){ list.rules = data; list.loadingRules = false; refreshRules(); + }); } - - - - function newRulesTable() { list.table = new NgTableParams({ page: 1, // show first page - count: 10, // count per page - sorting: { - name: 'asc' // initial sorting - } + count: 10 // count per page }, { @@ -134,7 +135,12 @@ /** - * Prerequisite : meta Rule should be completely loaded + * Prerequisite : meta Rule must be completely loader + * Depending on the meta_rule, the rule array will be filled by subject(s), object(s) or an action(s) + * the only way to know if rule[i] contains a subject/object/action is to check + * how many subject/object/action are associated to a MetaRule + * For example if the associated MetaRule contains 2 subjects, 1 object and 2 actions + * then the 2 first elements of rule array are 2 subject, the third one will be an object, and the 2 last will be action * @param index * @param rule */ @@ -145,7 +151,7 @@ rule.rule_value = Array.apply(null, new Array(rule.rule.length)).map(function(){ return { category: {} - } + }; }); } @@ -200,10 +206,11 @@ rule.rule_value[index].callCategoryInProgress = false; rule.rule_value[index].category = { name : 'ERROR' - } + }; } } + // if the call is in progress return false return false; } @@ -220,7 +227,7 @@ var ind = index + 1; - return rule.meta_rule.subject_categories.length < ind && ind <= ( rule.meta_rule.object_categories.length + rule.meta_rule.subject_categories.length ); + return rule.meta_rule.subject_categories.length < ind && ind <= ( rule.meta_rule.object_categories.length + rule.meta_rule.subject_categories.length ); } @@ -240,7 +247,6 @@ return list.getRules().length > 0; } - /** * Refresh the table */ @@ -249,6 +255,48 @@ list.table.reload(); } + function addRulesToList(event, rules){ + list.rules.push(rules); + refreshRules(); + } + + /** + * Delete + */ + function deleteRules(rules){ + + rules.loader = true; + + rulesService.delete(rules.id, list.policy.id, deleteRulesSuccess, deleteRulesError ); + + function deleteRulesSuccess(){ + + $translate('moon.policy.rules.edit.action.add.delete.success').then( function(translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + removeRulesFromList(rules); + refreshRules(); + + rules.loader = false; + + } + + function deleteRulesError(reason){ + + $translate('moon.policy.rules.edit.action.add.delete.success', {reason: reason.message}).then( function(translatedValue) { + alertService.alertError(translatedValue); + }); + + rules.loader = false; + + } + + } + + function removeRulesFromList(rules){ + list.rules = _.without(list.rules, rules); + } } })();
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/policy/edit/policy-edit.tpl.html b/moonv4/moon_gui/static/app/policy/edit/policy-edit.tpl.html index 550d1e4c..a1a6a54a 100644 --- a/moonv4/moon_gui/static/app/policy/edit/policy-edit.tpl.html +++ b/moonv4/moon_gui/static/app/policy/edit/policy-edit.tpl.html @@ -87,7 +87,7 @@ <div class="panel-body" ng-if="edit.showPerimeters"> - <moon-perimeter-list edit-mode="false" policy="edit.policy" ></moon-perimeter-list> + <moon-perimeter-list edit-mode="true" policy="edit.policy" ></moon-perimeter-list> </div> @@ -120,9 +120,9 @@ </div> - <div class="panel-body" ng-if="edit.showData"> + <div class="panel-body" ng-if="edit.showData" > <!-- --> - <moon-data-list edit-mode="false" policy="edit.policy" ></moon-data-list> + <moon-data-list edit-mode="true" policy="edit.policy" ></moon-data-list> </div> @@ -157,7 +157,7 @@ <div class="panel-body" ng-if="edit.showRules"> - <moon-rules-list edit-mode="false" policy="edit.policy" ></moon-rules-list> + <moon-rules-list edit-mode="true" policy="edit.policy" ></moon-rules-list> </div> @@ -193,7 +193,7 @@ <div class="panel-body" ng-if="edit.showAssignments"> - <moon-assignments-list edit-mode="false" policy="edit.policy" ></moon-assignments-list> + <moon-assignments-list edit-mode="true" policy="edit.policy" ></moon-assignments-list> </div> diff --git a/moonv4/moon_gui/static/app/policy/policy.controller.list.js b/moonv4/moon_gui/static/app/policy/policy.controller.list.js index dc2db2cc..fc2c6503 100644 --- a/moonv4/moon_gui/static/app/policy/policy.controller.list.js +++ b/moonv4/moon_gui/static/app/policy/policy.controller.list.js @@ -6,9 +6,9 @@ .module('moon') .controller('PolicyListController', PolicyListController); - PolicyListController.$inject = ['$scope', 'policies', 'ngTableParams', '$filter', '$modal', '$rootScope']; + PolicyListController.$inject = ['$scope', 'policies', 'NgTableParams', '$filter', '$modal', '$rootScope']; - function PolicyListController($scope, policies, ngTableParams, $filter, $modal, $rootScope) { + function PolicyListController($scope, policies, NgTableParams, $filter, $modal, $rootScope) { var list = this; @@ -69,7 +69,7 @@ function newPoliciesTable() { - list.table = new ngTableParams({ + list.table = new NgTableParams({ page: 1, // show first page count: 10, // count per page diff --git a/moonv4/moon_gui/static/app/policy/policy.mapped.list.dir.js b/moonv4/moon_gui/static/app/policy/policy.mapped.list.dir.js index b3becde9..78bb3b8d 100644 --- a/moonv4/moon_gui/static/app/policy/policy.mapped.list.dir.js +++ b/moonv4/moon_gui/static/app/policy/policy.mapped.list.dir.js @@ -61,11 +61,13 @@ */ function loadPolicices(refresh){ + if(_.isUndefined( list.pdp.security_pipeline)){ + return; + } list.policiesId = list.pdp.security_pipeline; policyService.findSomeWithCallback(list.policiesId, function(policies){ - list.policies = policies; list.loadingPolicies = false; @@ -114,10 +116,7 @@ list.table = new NgTableParams({ page: 1, // show first page - count: 10, // count per page - sorting: { - name: 'asc' // initial sorting - } + count: 10 // count per page }, { |