diff options
author | asteroide <thomas.duval@orange.com> | 2017-06-09 16:18:59 +0200 |
---|---|---|
committer | asteroide <thomas.duval@orange.com> | 2017-06-09 16:18:59 +0200 |
commit | 60bb98696ee93f979914d8e88ed4708f59fcff9c (patch) | |
tree | a404880ec261f95c69fa4a6a1edd50ef9a66d160 /moonv4/moon_gui/static/app | |
parent | 8039214d0caedfec5456bd8ee0898a1b9a55629a (diff) |
Stable version
Change-Id: I70001bedbdf1823cb9e8dccd545800387777201b
Diffstat (limited to 'moonv4/moon_gui/static/app')
35 files changed, 1342 insertions, 1344 deletions
diff --git a/moonv4/moon_gui/static/app/authentication/authentication.controller.js b/moonv4/moon_gui/static/app/authentication/authentication.controller.js index d3510fed..ce38bc5f 100644 --- a/moonv4/moon_gui/static/app/authentication/authentication.controller.js +++ b/moonv4/moon_gui/static/app/authentication/authentication.controller.js @@ -37,18 +37,22 @@ } function loginSuccess() { + $translate('moon.login.success').then( function(translatedValue) { alertService.alertSuccess(translatedValue); $state.go('moon.dashboard'); vm.loading = false; }); + } function loginError(reason) { + $translate('moon.login.error', { errorCode: reason.status }).then( function(translatedValue) { alertService.alertError(translatedValue); vm.loading = false; }); + } } })();
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/common/header/header.controller.js b/moonv4/moon_gui/static/app/common/header/header.controller.js index dfab502f..13ef4d6f 100644 --- a/moonv4/moon_gui/static/app/common/header/header.controller.js +++ b/moonv4/moon_gui/static/app/common/header/header.controller.js @@ -27,6 +27,7 @@ header.isModelTabActive = menuService.isModelTabActive; header.changeLocale = changeLocale; header.logout = logout; + header.currentLanguage = $translate.use(); header.getUser = authenticationService.GetUser; @@ -37,17 +38,19 @@ function changeLocale(localeKey, event) { event.preventDefault(); - $translate.use(localeKey); $translate.preferredLanguage(localeKey); + header.currentLanguage = localeKey; } function logout(){ + authenticationService.Logout(); $translate('moon.logout.success').then( function(translatedValue) { alertService.alertSuccess(translatedValue); }); + } } })();
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/common/header/header.tpl.html b/moonv4/moon_gui/static/app/common/header/header.tpl.html index ad7b461d..f703fa79 100644 --- a/moonv4/moon_gui/static/app/common/header/header.tpl.html +++ b/moonv4/moon_gui/static/app/common/header/header.tpl.html @@ -14,13 +14,15 @@ <div class="col-md-3"> <span class="pull-right"> - <a href="" ng-click="header.changeLocale('fr', $event)"><img src="assets/img/arrow-link.gif" alt="fr_" />fr</a> - <a href="" ng-click="header.changeLocale('en', $event)"><img src="assets/img/arrow-link.gif" alt="en_" />en</a> + + <a href="" ng-click="header.changeLocale('fr', $event)" ng-class="{'strong' : header.currentLanguage === 'fr'}"><img src="assets/img/arrow-link.gif" alt="fr_" />fr</a> + <a href="" ng-click="header.changeLocale('en', $event)" ng-class="{'strong' : header.currentLanguage === 'en'}"><img src="assets/img/arrow-link.gif" alt="en_" />en</a> <a href="" ng-if="connected" ng-click="header.logout()" class="left30"> <span class="glyphicon glyphicon-log-out"></span> <span data-translate="moon.logout.title">Logout</span>(<span ng-bind="header.getUser().token.user.name"></span>) </a> + <a href="" ng-if="!connected" class="left30"> <span class="glyphicon glyphicon-log-in"></span> <span data-translate="moon.login.title">Login</span> diff --git a/moonv4/moon_gui/static/app/dashboard/dashboard.tpl.html b/moonv4/moon_gui/static/app/dashboard/dashboard.tpl.html index 03da1b71..67184bcc 100644 --- a/moonv4/moon_gui/static/app/dashboard/dashboard.tpl.html +++ b/moonv4/moon_gui/static/app/dashboard/dashboard.tpl.html @@ -7,7 +7,7 @@ <div class="row"> - <img src="assets/img/et.jpg" alt="ET" class="img-responsive img-center"/> + <img src="assets/img/et.jpg" alt="ET" class="img-responsive img-dashboard"/> </div> diff --git a/moonv4/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html b/moonv4/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html index fde6cdb0..2616be1c 100644 --- a/moonv4/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html +++ b/moonv4/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html @@ -70,7 +70,7 @@ <div class="form-group"> - <label for="description" class="col-sm-3 control-label"data-translate="moon.model.metadata.edit.description">Description</label> + <label for="description" class="col-sm-3 control-label" data-translate="moon.model.metadata.edit.description">Description</label> <div class="col-sm-6"> <textarea id="description" name="description" class="form-control" data-ng-model="edit.metaData.description"></textarea> </div> diff --git a/moonv4/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html b/moonv4/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html index 35b61f57..30a42dbc 100644 --- a/moonv4/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html +++ b/moonv4/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html @@ -1,149 +1,156 @@ <div> - <div class="panel panel-default"> + <!-- + !shortDisplay allow to display more details than shortDisplay. + It will display panels row by row and each panels list have a table with more columns + --> + <div ng-if="!list.shortDisplay"> - <div class="panel-heading"> + <div class="panel panel-default"> - <h4 data-translate="moon.model.metadata.subject.title">List of associated Subject Categories</h4> + <div class="panel-heading"> - </div> + <h4 data-translate="moon.model.metadata.subject.title">List of associated Subject Categories</h4> - <div class="panel-body"> + </div> - <div class="table-responsive"> + <div class="panel-body"> - <table class="table table-striped"> + <div class="table-responsive"> - <thead> - <tr> - <th data-translate="moon.model.metadata.table.id">Id</th> - <th data-translate="moon.model.metadata.table.name">Name</th> - <th data-translate="moon.model.metadata.table.description">Description</th> - <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> - </tr> - </thead> + <table class="table table-striped"> - <moon-loader ng-if="list.loadingCatSub"></moon-loader> + <thead> + <tr> + <th data-translate="moon.model.metadata.table.id">Id</th> + <th data-translate="moon.model.metadata.table.name">Name</th> + <th data-translate="moon.model.metadata.table.description">Description</th> + <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> + </tr> + </thead> - <tbody ng-if="!list.loadingCatSub && list.getSubjectCategories().length > 0"> - <tr ng-repeat="(key, value) in list.catSub"> - <td ng-bind="value.id"></td> - <td ng-bind="value.name"></td> - <td ng-bind="value.description"></td> - <td ng-if="list.editMode"> + <moon-loader ng-if="list.loadingCatSub"></moon-loader> - <a href="" ng-if="!value.loader" ng-click="list.unMapSub(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> - </a> + <tbody ng-if="!list.loadingCatSub && list.getSubjectCategories().length > 0"> + <tr ng-repeat="(key, value) in list.catSub"> + <td ng-bind="value.id"></td> + <td ng-bind="value.name"></td> + <td ng-bind="value.description"></td> + <td ng-if="list.editMode"> - <!--<div ng-if="!value.loader" class="dropdown"> + <a href="" ng-if="!value.loader" ng-click="list.unMapSub(value)"> + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> + </a> - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.model.metadata.table.action.title">Actions</span> - <span class="caret"></span> - </button> + <!--<div ng-if="!value.loader" class="dropdown"> - <ul class="dropdown-menu"> + <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> + <span data-translate="moon.model.metadata.table.action.title">Actions</span> + <span class="caret"></span> + </button> - <li> - <a href="" ng-click="list.unMapSub(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> - </a> - </li> + <ul class="dropdown-menu"> - <li class="divider"></li> + <li> + <a href="" ng-click="list.unMapSub(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> + </a> + </li> - <li> - <a href="" ng-click="list.deleteSub(value)"> - <span class="glyphicon glyphicon-trash"></span> - <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span> - </a> - </li> + <li class="divider"></li> - </ul> + <li> + <a href="" ng-click="list.deleteSub(value)"> + <span class="glyphicon glyphicon-trash"></span> + <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span> + </a> + </li> - </div>--> + </ul> - <div ng-if="value.loader"> + </div>--> - <moon-loader></moon-loader> + <div ng-if="value.loader"> - </div> + <moon-loader></moon-loader> - </td> + </div> - </tr> - </tbody> + </td> + </tr> + </tbody> - <tbody ng-if="!list.loadingCatSub && list.catSub.length === 0"> - <tr> - <td data-translate="moon.model.metadata.subject.notFound">There is no Subjects</td> - <td></td> - <td></td> - <td ng-if="list.editMode"></td> - </tr> - </tbody> - </table> + <tbody ng-if="!list.loadingCatSub && list.catSub.length === 0"> + <tr> + <td data-translate="moon.model.metadata.subject.notFound">There is no Subjects</td> + <td></td> + <td></td> + <td ng-if="list.editMode"></td> + </tr> + </tbody> + + </table> + + </div> </div> </div> - </div> + <div ng-if="list.editMode" class="panel panel-default"> - <div ng-if="list.editMode" class="panel panel-default"> + <div class="panel-heading"> - <div class="panel-heading"> + <h4 data-translate="moon.model.metadata.subject.add.title">Add a Subject Category</h4> - <h4 data-translate="moon.model.metadata.subject.add.title">Add a Subject Category</h4> + </div> - </div> + <div class="panel-body"> - <div class="panel-body"> + <moon-meta-data-edit meta-rule="list.metaRule" + meta-data-type="list.typeOfSubject"></moon-meta-data-edit> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfSubject"></moon-meta-data-edit> + </div> </div> - </div> - - <div class="panel panel-default"> + <div class="panel panel-default"> - <div class="panel-heading"> + <div class="panel-heading"> - <h4 data-translate="moon.model.metadata.object.title">List associated of Object Categories</h4> + <h4 data-translate="moon.model.metadata.object.title">List associated of Object Categories</h4> - </div> + </div> - <div class="panel-body"> + <div class="panel-body"> - <div class="table-responsive"> + <div class="table-responsive"> - <table class="table table-striped"> + <table class="table table-striped"> - <thead> - <tr> - <th data-translate="moon.model.metadata.table.id">Id</th> - <th data-translate="moon.model.metadata.table.name">Name</th> - <th data-translate="moon.model.metadata.table.description">Description</th> - <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> + <thead> + <tr> + <th data-translate="moon.model.metadata.table.id">Id</th> + <th data-translate="moon.model.metadata.table.name">Name</th> + <th data-translate="moon.model.metadata.table.description">Description</th> + <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> - </tr> - </thead> + </tr> + </thead> - <moon-loader ng-if="list.loadingCatObj"></moon-loader> + <moon-loader ng-if="list.loadingCatObj"></moon-loader> - <tbody ng-if="!list.loadingCatObj && list.catObj.length > 0"> + <tbody ng-if="!list.loadingCatObj && list.catObj.length > 0"> <tr ng-repeat="(key, value) in list.catObj"> <td ng-bind="value.id"></td> <td ng-bind="value.name"></td> <td ng-bind="value.description"></td> <td ng-if="list.editMode"> - <a href="" ng-if="!value.loader" ng-click="list.unMapObj(value)" > + <a href="" ng-if="!value.loader" ng-click="list.unMapObj(value)"> <span class="glyphicon glyphicon-transfer"></span> <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> </a> @@ -186,148 +193,299 @@ </td> </tr> - </tbody> + </tbody> - <tbody ng-if="!list.loadingCatObj && list.catObj.length === 0"> + <tbody ng-if="!list.loadingCatObj && list.catObj.length === 0"> <tr> <td data-translate="moon.model.metadata.object.notFound">There is no Objects</td> <td></td> <td></td> <td ng-if="list.editMode"></td> </tr> - </tbody> + </tbody> + + </table> - </table> + </div> </div> </div> - </div> + <div ng-if="list.editMode" class="panel panel-default"> - <div ng-if="list.editMode" class="panel panel-default"> + <div class="panel-heading"> - <div class="panel-heading"> + <h4 data-translate="moon.model.metadata.object.add.title">Add an Object Category</h4> - <h4 data-translate="moon.model.metadata.object.add.title">Add an Object Category</h4> + </div> - </div> + <div class="panel-body"> - <div class="panel-body"> + <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit> + </div> </div> - </div> + <div class="panel panel-default"> - <div class="panel panel-default"> + <div class="panel-heading"> - <div class="panel-heading"> + <h4 data-translate="moon.model.metadata.action.title">List associated of Action Categories</h4> - <h4 data-translate="moon.model.metadata.action.title">List associated of Action Categories</h4> - - </div> + </div> - <div class="panel-body"> + <div class="panel-body"> - <div class="table-responsive"> + <div class="table-responsive"> - <table class="table table-striped"> + <table class="table table-striped"> - <thead> - <tr> - <th data-translate="moon.model.metadata.table.id">Id</th> - <th data-translate="moon.model.metadata.table.name">Name</th> - <th data-translate="moon.model.metadata.table.description">Description</th> - <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> - </tr> - </thead> + <thead> + <tr> + <th data-translate="moon.model.metadata.table.id">Id</th> + <th data-translate="moon.model.metadata.table.name">Name</th> + <th data-translate="moon.model.metadata.table.description">Description</th> + <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th> + </tr> + </thead> - <moon-loader ng-if="list.loadingCatAct"></moon-loader> + <moon-loader ng-if="list.loadingCatAct"></moon-loader> - <tbody ng-if="!list.loadingCatAct && list.catAct.length > 0"> - <tr ng-repeat="(key, value) in list.catAct"> - <td ng-bind="value.id"></td> - <td ng-bind="value.name"></td> - <td ng-bind="value.description"></td> - <td ng-if="list.editMode"> + <tbody ng-if="!list.loadingCatAct && list.catAct.length > 0"> + <tr ng-repeat="(key, value) in list.catAct"> + <td ng-bind="value.id"></td> + <td ng-bind="value.name"></td> + <td ng-bind="value.description"></td> + <td ng-if="list.editMode"> - <a href="" ng-if="!value.loader" ng-click="list.unMapAct(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> - </a> + <a href="" ng-if="!value.loader" ng-click="list.unMapAct(value)"> + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> + </a> - <!--<div ng-if="!value.loader" class="dropdown"> + <!--<div ng-if="!value.loader" class="dropdown"> - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.model.metadata.table.action.title">Actions</span> - <span class="caret"></span> - </button> + <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> + <span data-translate="moon.model.metadata.table.action.title">Actions</span> + <span class="caret"></span> + </button> - <ul class="dropdown-menu"> + <ul class="dropdown-menu"> - <li> - <a href="" ng-click="list.unMapAct(value)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> - </a> - </li> + <li> + <a href="" ng-click="list.unMapAct(value)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span> + </a> + </li> - <li class="divider"></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.model.metadata.table.action.delete">Delete</span> - </a> - </li> + <li> + <a href="" ng-click="list.deleteAct(value)"> + <span class="glyphicon glyphicon-trash"></span> + <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span> + </a> + </li> - </ul> + </ul> - </div>--> + </div>--> - <div ng-if="value.loader"> + <div ng-if="value.loader"> - <moon-loader></moon-loader> + <moon-loader></moon-loader> - </div> + </div> - </td> - </tr> - </tbody> + </td> + </tr> + </tbody> - <tbody ng-if="!list.loadingCatAct && list.catAct.length === 0"> + <tbody ng-if="!list.loadingCatAct && list.catAct.length === 0"> <tr> <td data-translate="moon.model.metadata.action.notFound">There is no Actions</td> <td></td> <td></td> <td ng-if="list.editMode"></td> </tr> - </tbody> + </tbody> - </table> + </table> + + </div> </div> </div> - </div> + <div ng-if="list.editMode" class="panel panel-default"> - <div ng-if="list.editMode" class="panel panel-default"> + <div class="panel-heading"> - <div class="panel-heading"> + <h4 data-translate="moon.model.metadata.action.add.title">Add an Action Category</h4> - <h4 data-translate="moon.model.metadata.action.add.title">Add an Action Category</h4> + </div> - </div> + <div class="panel-body">. - <div class="panel-body">. + <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit> - <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit> + </div> </div> </div> + <!-- + !shortDisplay allow to display less details than shortDisplay. + It will display 3 panels on the same row, each panels have a table with on columns (name) + --> + <div ng-if="list.shortDisplay"> + + <div class="row"> + + <div class="col-md-4"> + + <div class="panel panel-default"> + + <div class="panel-heading"> + + <h4 data-translate="moon.model.metadata.subject.title">List of associated Subject Categories</h4> + + </div> + + <div class="panel-body"> + + <div class="table-responsive"> + + <table class="table table-striped"> + + <thead> + <tr> + <th data-translate="moon.model.metadata.table.name">Name</th> + </tr> + </thead> + + <moon-loader ng-if="list.loadingCatSub"></moon-loader> + + <tbody ng-if="!list.loadingCatSub && list.getSubjectCategories().length > 0"> + <tr ng-repeat="(key, value) in list.catSub"> + <td ng-bind="value.name"></td> + </tr> + </tbody> + + + <tbody ng-if="!list.loadingCatSub && list.catSub.length === 0"> + <tr> + <td data-translate="moon.model.metadata.subject.notFound">There is no Subjects</td> + </tr> + </tbody> + + </table> + + </div> + + </div> + + </div> + + </div> + + <div class="col-md-4"> + + <div class="panel panel-default"> + + <div class="panel-heading"> + + <h4 data-translate="moon.model.metadata.object.title">List associated of Object Categories</h4> + + </div> + + <div class="panel-body"> + + <div class="table-responsive"> + + <table class="table table-striped"> + + <thead> + <tr> + <th data-translate="moon.model.metadata.table.name">Name</th> + </tr> + </thead> + + <moon-loader ng-if="list.loadingCatObj"></moon-loader> + + <tbody ng-if="!list.loadingCatObj && list.catObj.length > 0"> + <tr ng-repeat="(key, value) in list.catObj"> + <td ng-bind="value.name"></td> + </tr> + </tbody> + + <tbody ng-if="!list.loadingCatObj && list.catObj.length === 0"> + <tr> + <td data-translate="moon.model.metadata.object.notFound">There is no Objects</td> + </tr> + </tbody> + + </table> + + </div> + + </div> + + </div> + + </div> + + <div class="col-md-4"> + + <div class="panel panel-default"> + + <div class="panel-heading"> + + <h4 data-translate="moon.model.metadata.action.title">List associated of Action Categories</h4> + + </div> + + <div class="panel-body"> + + <div class="table-responsive"> + + <table class="table table-striped"> + + <thead> + <tr> + <th data-translate="moon.model.metadata.table.name">Name</th> + </tr> + </thead> + + <moon-loader ng-if="list.loadingCatAct"></moon-loader> + + <tbody ng-if="!list.loadingCatAct && list.catAct.length > 0"> + <tr ng-repeat="(key, value) in list.catAct"> + <td ng-bind="value.name"></td> + </tr> + </tbody> + + <tbody ng-if="!list.loadingCatAct && list.catAct.length === 0"> + <tr> + <td data-translate="moon.model.metadata.action.notFound">There is no Actions</td> + </tr> + </tbody> + + </table> + + </div> + + </div> + + </div> + + </div> + + </div> + </div> </div>
\ No newline at end of file diff --git a/moonv4/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js b/moonv4/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js index 2e927c44..10df83b0 100644 --- a/moonv4/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js +++ b/moonv4/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js @@ -29,9 +29,11 @@ .module('moon') .controller('moonMetaDataEditController', moonMetaDataEditController); - moonMetaDataEditController.$inject = ['$scope', 'metaDataService', 'META_DATA_CST', 'alertService', '$translate', 'formService', 'metaRuleService', 'utilService']; + moonMetaDataEditController.$inject = ['$scope', 'metaDataService', 'META_DATA_CST', 'alertService', + '$translate', 'formService', 'metaRuleService', 'utilService']; - function moonMetaDataEditController($scope, metaDataService, META_DATA_CST, alertService, $translate, formService, metaRuleService, utilService) { + function moonMetaDataEditController($scope, metaDataService, META_DATA_CST, alertService, + $translate, formService, metaRuleService, utilService) { var edit = this; @@ -86,7 +88,7 @@ function callBackList(list){ - edit.list = list + edit.list = list; } diff --git a/moonv4/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js b/moonv4/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js index c4654be1..beb2ed86 100644 --- a/moonv4/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js +++ b/moonv4/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js @@ -17,7 +17,9 @@ controllerAs : 'list', scope : { metaRule: '=', - editMode : '=' + editMode: '=', + // shortDisplay : boolean value + shortDisplay: '=' }, restrict : 'E', replace : true @@ -36,6 +38,7 @@ list.metaRule = $scope.list.metaRule; list.editMode = $scope.list.editMode; + list.shortDisplay = $scope.list.shortDisplay; list.typeOfSubject = META_DATA_CST.TYPE.SUBJECT; list.typeOfObject = META_DATA_CST.TYPE.OBJECT; @@ -45,9 +48,9 @@ list.unMapObj = unMapObj; list.unMapAct = unMapAct; - list.deleteSub = deleteSub; - list.deleteObj = deleteObj; - list.deleteAct = deleteAct; + // list.deleteSub = deleteSub; + // list.deleteObj = deleteObj; + // list.deleteAct = deleteAct; list.getSubjectCategories = getSubjectCategories; list.getObjectCategories = getObjectCategories; @@ -82,7 +85,7 @@ list.loadingCatSub = true; - metaDataService.subject.findSomeWithCallback(list.metaRule.subject_categories, function(categories){ + metaDataService.subject.findSomeWithCallback(list.metaRule.subject_categories, function(categories){ list.catSub = categories; list.loadingCatSub = false; @@ -229,97 +232,99 @@ } - /** - * Delete - */ - - function deleteSub(subject){ - - subject.loader = true; - - metaDataService.subject.delete(subject, deleteSubSuccess, deleteSubError); - - function deleteSubSuccess(data){ - - $translate('moon.model.metadata.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeSubFromSubList(subject); - - subject.loader = false; - - } - - function deleteSubError(reason){ - - $translate('moon.model.metadata.subject.delete.error', { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - subject.loader = false; - - } - } - - function deleteObj(object){ - - object.loader = true; - - metaDataService.object.delete(object, deleteObjSuccess, deleteObjError); - - function deleteObjSuccess(data){ - - $translate('moon.model.metadata.object.delete.success', { objectName: object.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeObjFromObjList(object); - list.catSub = metaDataService.subject.findSome(metaRule.subject_categories); - list.catObj = metaDataService.object.findSome(metaRule.object_categories); - list.catAct = metaDataService.action.findSome(metaRule.action_categories); - object.loader = false; - - } - - function deleteObjError(reason){ - - $translate('moon.model.metadata.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { - alertService.alertError(translatedValue); - }); - - object.loader = false; - } - } - - function deleteAct(action){ - - action.loader = true; - - metaDataService.action.delete(action, deleteActSuccess, deleteActError); - - function deleteActSuccess(data){ - - $translate('moon.model.metadata.action.delete.success', { actionName: action.name }).then( function(translatedValue) { - alertService.alertSuccess(translatedValue); - }); - - removeActFromActList(action); - - action.loader = false; - - } - - function deleteActError(reason){ - - $translate('moon.model.metadata.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; + // + // metaDataService.subject.delete(subject, deleteSubSuccess, deleteSubError); + // + // function deleteSubSuccess(data){ + // + // $translate('moon.model.metadata.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) { + // alertService.alertSuccess(translatedValue); + // }); + // + // removeSubFromSubList(subject); + // + // subject.loader = false; + // + // } + // + // function deleteSubError(reason){ + // + // $translate('moon.model.metadata.subject.delete.error', + // { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // subject.loader = false; + // + // } + // } + // + // function deleteObj(object){ + // + // object.loader = true; + // + // metaDataService.object.delete(object, deleteObjSuccess, deleteObjError); + // + // function deleteObjSuccess(data){ + // + // $translate('moon.model.metadata.object.delete.success', { objectName: object.name }).then( function(translatedValue) { + // alertService.alertSuccess(translatedValue); + // }); + // + // removeObjFromObjList(object); + // /*list.catSub = metaDataService.subject.findSome(list.metaRule.subject_categories); + // list.catObj = metaDataService.object.findSome(list.metaRule.object_categories); + // list.catAct = metaDataService.action.findSome(list.metaRule.action_categories);*/ + // + // object.loader = false; + // + // } + // + // function deleteObjError(reason){ + // + // $translate('moon.model.metadata.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // object.loader = false; + // } + // } + // + // function deleteAct(action){ + // + // action.loader = true; + // + // metaDataService.action.delete(action, deleteActSuccess, deleteActError); + // + // function deleteActSuccess(data){ + // + // $translate('moon.model.metadata.action.delete.success', { actionName: action.name }).then( function(translatedValue) { + // alertService.alertSuccess(translatedValue); + // }); + // + // removeActFromActList(action); + // + // action.loader = false; + // + // } + // + // function deleteActError(reason){ + // + // $translate('moon.model.metadata.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // action.loader = false; + // + // } + // } function getSubjectCategories(){ return list.catSub ? list.catSub : []; @@ -333,17 +338,17 @@ return list.catAct ? list.catAct : []; } - function removeSubFromSubList(subject){ - list.catSub = _.without(list.catSub, subject); - } - - function removeObjFromObjList(object){ - list.catObj = _.without(list.catObj, object); - } - - function removeActFromActList(action){ - list.catAct = _.without(list.catAct, action); - } + // function removeSubFromSubList(subject){ + // list.catSub = _.without(list.catSub, subject); + // } + // + // function removeObjFromObjList(object){ + // list.catObj = _.without(list.catObj, object); + // } + // + // function removeActFromActList(action){ + // list.catAct = _.without(list.catAct, action); + // } function updateMetaRuleCategories( event, metaRule){ diff --git a/moonv4/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html b/moonv4/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html index c36700ff..ebe307c3 100644 --- a/moonv4/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html +++ b/moonv4/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html @@ -1,149 +1,138 @@ <div> - <div class="row"> - <div><h4 data-translate="moon.model.metarules.title">List of Meta Rules</h4></div> + <div><h4 data-translate="moon.model.metarules.title">List of Meta Rules</h4></div> - </div> - - <div class="row"> - - <div class="table-responsive" data-role="table"> - <table class="table table-striped table-hover" ng-table="list.table"> - - <colgroup> - <col class="col-md-2" /> - <col class="col-md-2" /> - <col class="col-md-1" /> - <col class="col-md-1" /> - <col class="col-md-1" /> - <col class="col-md-2" /> - </colgroup> + <div class="table-responsive" data-role="table"> + <table class="table table-striped table-hover" ng-table="list.table"> - <thead> + <colgroup> + <col class="col-md-2" /> + <col class="col-md-2" /> + <col class="col-md-1" /> + <col class="col-md-1" /> + <col class="col-md-1" /> + <col class="col-md-2" /> + </colgroup> - <tr> + <thead> - <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.model.metarules.table.name">Name</div> - </th> + <tr> - <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.model.metarules.table.description">Description</div> - </th> + <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.model.metarules.table.name">Name</div> + </th> - <th class="customTables sortable"> - <div data-translate="moon.model.metarules.table.metadata.subject.number">Number of Subjects</div> - </th> + <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.model.metarules.table.description">Description</div> + </th> - <th class="customTables sortable"> - <div data-translate="moon.model.metarules.table.metadata.object.number">Number of Subjects</div> - </th> + <th class="customTables sortable"> + <div data-translate="moon.model.metarules.table.metadata.subject.number">Number of Subjects</div> + </th> - <th class="customTables sortable"> - <div data-translate="moon.model.metarules.table.metadata.action.number">Number of Actions</div> - </th> + <th class="customTables sortable"> + <div data-translate="moon.model.metarules.table.metadata.object.number">Number of Subjects</div> + </th> - <th class="customTables"> - <div data-translate="moon.model.metarules.action.title">Actions</div> - </th> - </tr> + <th class="customTables sortable"> + <div data-translate="moon.model.metarules.table.metadata.action.number">Number of Actions</div> + </th> - </thead> + <th class="customTables"> + <div data-translate="moon.model.metarules.action.title">Actions</div> + </th> + </tr> - <tbody ng-if="!list.hasMetaRules()"> - <tr> - <td colspan="2"><span data-translate="moon.model.metarules.table.notFound">There is no Meta Rules</span></td> - </tr> - </tbody> + </thead> - <tbody ng-if="list.hasMetaRules()"> + <tbody ng-if="!list.hasMetaRules()"> + <tr> + <td colspan="2"><span data-translate="moon.model.metarules.table.notFound">There is no Meta Rules</span></td> + </tr> + </tbody> - <tr ng-repeat="aMetaRules in $data | filter:list.search.find | orderBy:sort:reverse"> - <td ng-bind="aMetaRules.name"></td> - <td ng-bind="aMetaRules.description"></td> - <td ng-bind="aMetaRules.subject_categories.length"></td> - <td ng-bind="aMetaRules.object_categories.length"></td> - <td ng-bind="aMetaRules.action_categories.length"></td> - <td> + <tbody ng-if="list.hasMetaRules()"> - <div ng-if="list.editMode"> + <tr ng-repeat="aMetaRules in $data | filter:list.search.find | orderBy:sort:reverse"> + <td ng-bind="aMetaRules.name"></td> + <td ng-bind="aMetaRules.description"></td> + <td ng-bind="aMetaRules.subject_categories.length"></td> + <td ng-bind="aMetaRules.object_categories.length"></td> + <td ng-bind="aMetaRules.action_categories.length"></td> + <td> - <div ng-if="!value.loader" class="dropdown"> + <div ng-if="list.editMode"> - <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> - <span data-translate="moon.model.metadata.table.action.title">Actions</span> - <span class="caret"></span> - </button> + <div ng-if="!value.loader" class="dropdown"> - <ul class="dropdown-menu"> + <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"> + <span data-translate="moon.model.metadata.table.action.title">Actions</span> + <span class="caret"></span> + </button> - <li> - <a href="" ng-click="list.unmap.showModal(aMetaRules)" > - <span class="glyphicon glyphicon-transfer"></span> - <span class="control-label" data-translate="moon.model.metarules.action.remove">Remove</span> - </a> - </li> + <ul class="dropdown-menu"> - <li> - <a href="" ng-click="list.edit.showModal(aMetaRules)"> - <span class="glyphicon glyphicon-cog"></span> - <span class="control-label" data-translate="moon.model.metarules.action.edit">Edit</span> - </a> - </li> + <li> + <a href="" ng-click="list.unmap.showModal(aMetaRules)" > + <span class="glyphicon glyphicon-transfer"></span> + <span class="control-label" data-translate="moon.model.metarules.action.remove">Remove</span> + </a> + </li> - </ul> + <li> + <a href="" ng-click="list.edit.showModal(aMetaRules)"> + <span class="glyphicon glyphicon-cog"></span> + <span class="control-label" data-translate="moon.model.metarules.action.edit">Edit</span> + </a> + </li> - </div> + </ul> </div> - <div ng-if="!list.editMode"> + </div> - <a href="" ng-click="list.showDetail(aMetaRules)"> + <div ng-if="!list.editMode"> - <span ng-if="aMetaRules.id !== list.getShowDetailValue().id"> - <span class="glyphicon glyphicon-eye-open"></span> - <span class="control-label" data-translate="moon.model.metarules.action.detail.open">Consult</span> - </span> + <a href="" ng-click="list.showDetail(aMetaRules)"> - <span ng-if="aMetaRules.id === list.getShowDetailValue().id"> - <span class="glyphicon glyphicon-eye-close"></span> - <span class="control-label" data-translate="moon.model.metarules.action.detail.close">Close</span> - </span> + <span ng-if="aMetaRules.id !== list.getShowDetailValue().id"> + <span class="glyphicon glyphicon-eye-open"></span> + <span class="control-label" data-translate="moon.model.metarules.action.detail.open">Consult</span> + </span> - </a> + <span ng-if="aMetaRules.id === list.getShowDetailValue().id"> + <span class="glyphicon glyphicon-eye-close"></span> + <span class="control-label" data-translate="moon.model.metarules.action.detail.close">Close</span> + </span> - </div> + </a> - </td> - </tr> + </div> - </tbody> + </td> + </tr> - </table> + </tbody> - <div ng-if="list.showDetailValue"> - <moon-meta-data-list edit-mode="list.editMode" meta-rule="list.getShowDetailValue()"></moon-meta-data-list> - </div> + </table> + <div ng-if="list.showDetailValue"> + <moon-meta-data-list edit-mode="list.editMode" meta-rule="list.getShowDetailValue()"></moon-meta-data-list> </div> </div> - <div class="row" ng-if="list.editMode"> - - <div class="form-group"> - <a href="" ng-click="list.map.showModal()" class="btn btn-default"> - <span class="glyphicon glyphicon-link"></span> - <span data-translate="moon.model.metarules.action.settings">Settings</span> - </a> - </div> - + <div class="form-group" ng-if="list.editMode"> + <a href="" ng-click="list.map.showModal()" class="btn btn-default"> + <span class="glyphicon glyphicon-link"></span> + <span data-translate="moon.model.metarules.action.settings">Settings</span> + </a> </div> </div> diff --git a/moonv4/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js b/moonv4/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js index 8fba0266..120b6a8b 100644 --- a/moonv4/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js +++ b/moonv4/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js @@ -59,6 +59,11 @@ list.edit = { modal: $modal({ template: 'html/model/edit/metarules/action/metarules-edit.tpl.html', show: false }), showModal: showEditModal }; + /*list.edit.modal.result.finally(function(){ + console.log('CATCHING'); + });*/ + + list.map = { modal: $modal({ template: 'html/model/edit/metarules/action/mapping/metarules-map.tpl.html', show: false }), showModal: showMapModal }; @@ -224,8 +229,6 @@ }); - - } function modelUnmappedError(event) { diff --git a/moonv4/moon_gui/static/app/model/edit/model-edit.tpl.html b/moonv4/moon_gui/static/app/model/edit/model-edit.tpl.html index c86d05ec..4955f441 100644 --- a/moonv4/moon_gui/static/app/model/edit/model-edit.tpl.html +++ b/moonv4/moon_gui/static/app/model/edit/model-edit.tpl.html @@ -53,7 +53,11 @@ </div> <div class="panel-body" ng-if="edit.model.meta_rules_values"> - <moon-meta-rules-list mapped-model="edit.model" edit-mode="edit.editMetaRules"></moon-meta-rules-list> + <div class=""> + + <moon-meta-rules-list mapped-model="edit.model" edit-mode="edit.editMetaRules"></moon-meta-rules-list> + + </div> </div> <div class="panel-body" ng-if="!edit.model.meta_rules_values"> diff --git a/moonv4/moon_gui/static/app/model/edit/model.controller.edit.js b/moonv4/moon_gui/static/app/model/edit/model.controller.edit.js index f5972052..3e10a533 100644 --- a/moonv4/moon_gui/static/app/model/edit/model.controller.edit.js +++ b/moonv4/moon_gui/static/app/model/edit/model.controller.edit.js @@ -6,9 +6,9 @@ .module('moon') .controller('ModelEditController', ModelEditController); - ModelEditController.$inject = ['$scope', '$rootScope', 'model', '$stateParams']; + ModelEditController.$inject = ['$scope', '$rootScope', 'model', 'metaRuleService']; - function ModelEditController($scope, $rootScope, model, $stateParams) { + function ModelEditController($scope, $rootScope, model, metaRuleService) { var edit = this; @@ -48,6 +48,12 @@ edit.model = model; + metaRuleService.findSomeWithCallback(model.meta_rules, function(metaRules){ + + edit.model.meta_rules_values = metaRules; + + }); + } } diff --git a/moonv4/moon_gui/static/app/moon.constants.js b/moonv4/moon_gui/static/app/moon.constants.js index e3fd7595..ffe60f94 100644 --- a/moonv4/moon_gui/static/app/moon.constants.js +++ b/moonv4/moon_gui/static/app/moon.constants.js @@ -58,29 +58,22 @@ ACTION: 'ACTION' } }) - .constant('RULES_CST', { - TYPE: { - SUBJECT: 'SUBJECT', - OBJECT: 'OBJECT', - ACTION: 'ACTION' - } - }) .constant('REST_URI', { - PDP : 'http://172.18.0.11:38001/pdp/', - MODELS : 'http://172.18.0.11:38001/models/', - METARULES: 'http://172.18.0.11:38001/meta_rules/', - RULES: 'http://172.18.0.11:38001/rules/', - POLICIES: 'http://172.18.0.11:38001/policies/', + PDP : 'http://192.168.102.118:38001/pdp/', + MODELS : 'http://192.168.102.118:38001/models/', + METARULES: 'http://192.168.102.118:38001/meta_rules/', + RULES: 'http://192.168.102.118:38001/rules/', + POLICIES: 'http://192.168.102.118:38001/policies/', METADATA: { - subject : 'http://172.18.0.11:38001/subject_categories/', - object : 'http://172.18.0.11:38001/object_categories/', - action : 'http://172.18.0.11:38001/action_categories/' + subject : 'http://192.168.102.118:38001/subject_categories/', + object : 'http://192.168.102.118:38001/object_categories/', + action : 'http://192.168.102.118:38001/action_categories/' }, PERIMETERS :{ - subject : 'http://172.18.0.11:38001/subjects/', - object : 'http://172.18.0.11:38001/objects/', - action : 'http://172.18.0.11:38001/actions/' + subject : 'http://192.168.102.118:38001/subjects/', + object : 'http://192.168.102.118:38001/objects/', + action : 'http://192.168.102.118:38001/actions/' }, - KEYSTONE : 'http://keystone:5000/v3/' + KEYSTONE : 'http://192.168.102.118:5000/v3/' }); })(); diff --git a/moonv4/moon_gui/static/app/pdp/edit/pdp-edit.tpl.html b/moonv4/moon_gui/static/app/pdp/edit/pdp-edit.tpl.html index bc4582ce..1fbd555a 100644 --- a/moonv4/moon_gui/static/app/pdp/edit/pdp-edit.tpl.html +++ b/moonv4/moon_gui/static/app/pdp/edit/pdp-edit.tpl.html @@ -48,7 +48,15 @@ </div> - <moon-policy-mapped-list pdp="edit.pdp"></moon-policy-mapped-list> + <div class="panel-body"> + + <div class="row"> + + <moon-policy-mapped-list pdp="edit.pdp"></moon-policy-mapped-list> + + </div> + + </div> </div> </div> diff --git a/moonv4/moon_gui/static/app/pdp/pdp-list.tpl.html b/moonv4/moon_gui/static/app/pdp/pdp-list.tpl.html index 6716ebba..8aa4e653 100644 --- a/moonv4/moon_gui/static/app/pdp/pdp-list.tpl.html +++ b/moonv4/moon_gui/static/app/pdp/pdp-list.tpl.html @@ -21,49 +21,49 @@ <div> </div> <div class="row" > - + <div class="table-responsive" data-role="table"> - + <table class="table table-striped table-hover" ng-table="list.table"> <thead> - + <tr> - + <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.pdp.list.table.name">Name</div> </th> - - <th class="customTables sortable" + + <th class="customTables sortable" ng-class="{ 'sort-asc': list.table.isSortBy('security_pipeline', 'asc'), 'sort-desc': list.table.isSortBy('security_pipeline', 'desc') }" ng-click="list.table.sorting('security_pipeline', list.table.isSortBy('policy', 'asc') ? 'desc' : 'asc')"> <div data-translate="moon.pdp.list.table.security_pipeline.number">Number of Securities</div> </th> - + <th class="customTables" ng-class="{ 'sort-asc': list.table.isSortBy('project', 'asc'), 'sort-desc': list.table.isSortBy('project', 'desc') }" ng-click="list.table.sorting('project', list.table.isSortBy('project', 'asc') ? 'desc' : 'asc')"> <div data-translate="moon.pdp.list.table.project">Project</div> </th> - + <th class="customTables"> <div data-translate="moon.pdp.list.action.title">Actions</div> </th> - + </tr> - + </thead> - + <tbody ng-if="!list.hasPDPs()"> <tr> <td colspan="12"><span data-translate="moon.pdp.list.table.notFound">There is no PDP</span></td> </tr> </tbody> - + <tbody ng-if="list.hasPDPs()"> - + <tr ng-repeat="pdp in $data | filter:list.search.find | orderBy:sort:reverse"> <td ng-bind="list.getPDPName(pdp)"></td> <td ng-bind="list.getSecPipelineFromPdp(pdp).length"></td> @@ -111,15 +111,15 @@ </ul> </div> </td> - + </tr> - + </tbody> - + </table> - + </div> - + <div class="container"> <div class="form-inline form-group"> <a href="" ng-click="list.add.showModal()" class="btn btn-default"> diff --git a/moonv4/moon_gui/static/app/pdp/pdp.controller.list.js b/moonv4/moon_gui/static/app/pdp/pdp.controller.list.js index 07c9aa2a..a831cfe3 100644 --- a/moonv4/moon_gui/static/app/pdp/pdp.controller.list.js +++ b/moonv4/moon_gui/static/app/pdp/pdp.controller.list.js @@ -15,7 +15,7 @@ '$scope', '$filter', '$modal', - 'ngTableParams', + 'NgTableParams', 'pdps', 'projectService']; @@ -23,7 +23,7 @@ $scope, $filter, $modal, - ngTableParams, + NgTableParams, pdps, projectService) { @@ -79,11 +79,11 @@ 'event:pdpDeletedError': $rootScope.$on('event:pdpDeletedError', pdpDeletedError), }; - - for (var unbind in rootListeners) { - $scope.$on('$destroy', rootListeners[unbind]); - } - + + _.each(rootListeners, function(unbind){ + $scope.$on('$destroy', rootListeners[unbind]); + }); + /* * */ @@ -189,13 +189,10 @@ */ function newPDPsTable() { - list.table = new ngTableParams({ + list.table = new NgTableParams({ page: 1, // show first page count: 10, // count per page - sorting: { - name: 'asc' // initial sorting - } }, { 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 }, { diff --git a/moonv4/moon_gui/static/app/services/gui/form.service.js b/moonv4/moon_gui/static/app/services/gui/form.service.js index bc137943..e436593c 100644 --- a/moonv4/moon_gui/static/app/services/gui/form.service.js +++ b/moonv4/moon_gui/static/app/services/gui/form.service.js @@ -41,7 +41,7 @@ }); } - + } - + })(); diff --git a/moonv4/moon_gui/static/app/services/moon/policy/parameters/assignements.service.js b/moonv4/moon_gui/static/app/services/moon/policy/parameters/assignements.service.js index ad7d8e8b..ca138b45 100644 --- a/moonv4/moon_gui/static/app/services/moon/policy/parameters/assignements.service.js +++ b/moonv4/moon_gui/static/app/services/moon/policy/parameters/assignements.service.js @@ -8,17 +8,17 @@ angular .module('moon') - .factory('assignmentService', assignmentService); + .factory('assignmentsService', assignmentsService); - assignmentService.$inject = ['$resource', 'REST_URI', 'utilService']; + assignmentsService.$inject = ['$resource', 'REST_URI', 'utilService']; - function assignmentService($resource, REST_URI, utilService) { + function assignmentsService($resource, REST_URI, utilService) { var data = { subject: { - policy: $resource(REST_URI.POLICIES + ':policy_id/subject_assignments/:subject_id', {}, { + policy: $resource(REST_URI.POLICIES + ':policy_id/subject_assignments/:perimeter_id/:category_id/:data_id', {}, { get: {method: 'GET'}, create: {method: 'POST'}, remove: {method: 'DELETE'} @@ -29,8 +29,8 @@ object: { - policy: $resource(REST_URI.POLICIES + ':policy_id/object_assignments/:object_id', {}, { - get: {method: 'GET', isArray: false}, + policy: $resource(REST_URI.POLICIES + ':policy_id/object_assignments/:perimeter_id/:category_id/:data_id', {}, { + get: {method: 'GET'}, create: {method: 'POST'}, remove: {method: 'DELETE'} }) @@ -39,8 +39,8 @@ action: { - policy: $resource(REST_URI.POLICIES + ':policy_id/action_assignments/:action_id', {}, { - get: {method: 'GET', isArray: false}, + policy: $resource(REST_URI.POLICIES + ':policy_id/action_assignments/:perimeter_id/:category_id/:data_id', {}, { + get: {method: 'GET'}, create: {method: 'POST'}, remove: {method: 'DELETE'} }) @@ -53,6 +53,18 @@ subject : { + delete: function (policyId, perimeterId, categoryId, dataId, callbackSuccess, callbackError ) { + + data.subject.policy.remove({policy_id: policyId, perimeter_id: perimeterId, category_id: categoryId, data_id: dataId}, {}, callbackSuccess, callbackError); + + }, + + add:function (subject, policyId, callbackSuccess, callbackError ) { + + data.subject.policy.create({policy_id: policyId}, subject, callbackSuccess, callbackError); + + }, + findAllFromPolicyWithCallback: function(policyId, callback){ data.subject.policy.get({policy_id: policyId}).$promise.then(function(data) { @@ -66,6 +78,19 @@ object : { + + delete: function (policyId, perimeterId, categoryId, dataId, callbackSuccess, callbackError ) { + + data.object.policy.remove({policy_id: policyId, perimeter_id: perimeterId, category_id: categoryId, data_id: dataId}, {}, callbackSuccess, callbackError); + + }, + + add:function (object, policyId, callbackSuccess, callbackError ) { + + data.object.policy.create({policy_id: policyId}, object, callbackSuccess, callbackError); + + }, + findAllFromPolicyWithCallback: function(policyId, callback){ data.object.policy.get({policy_id: policyId}).$promise.then(function(data) { @@ -79,6 +104,18 @@ action : { + delete: function (policyId, perimeterId, categoryId, dataId, callbackSuccess, callbackError ) { + + data.action.policy.remove({policy_id: policyId, perimeter_id: perimeterId, category_id: categoryId, data_id: dataId}, {}, callbackSuccess, callbackError); + + }, + + add:function (action, policyId, callbackSuccess, callbackError ) { + + data.action.policy.create({policy_id: policyId}, action, callbackSuccess, callbackError); + + }, + findAllFromPolicyWithCallback: function(policyId, callback){ data.action.policy.get({policy_id: policyId}).$promise.then(function(data) { diff --git a/moonv4/moon_gui/static/app/services/moon/policy/parameters/data.service.js b/moonv4/moon_gui/static/app/services/moon/policy/parameters/data.service.js index 22f35e45..1bbd3b24 100644 --- a/moonv4/moon_gui/static/app/services/moon/policy/parameters/data.service.js +++ b/moonv4/moon_gui/static/app/services/moon/policy/parameters/data.service.js @@ -18,7 +18,7 @@ subject: { - policy: $resource(REST_URI.POLICIES + ':policy_id/subject_data/:subject_id/:data_id', {}, { + policy: $resource(REST_URI.POLICIES + ':policy_id/subject_data/:subject_id/:category_id/:data_id', {}, { get: {method: 'GET'}, create: {method: 'POST'}, remove: {method: 'DELETE'} @@ -28,7 +28,7 @@ object: { - policy: $resource(REST_URI.POLICIES + ':policy_id/object_data/:object_id/:data_id', {}, { + policy: $resource(REST_URI.POLICIES + ':policy_id/object_data/:object_id/:category_id/:data_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, remove: {method: 'DELETE'} @@ -38,7 +38,7 @@ action: { - policy: $resource(REST_URI.POLICIES + ':policy_id/action_data/:action_id/:data_id', {}, { + policy: $resource(REST_URI.POLICIES + ':policy_id/action_data/:action_id/:category_id/:data_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, remove: {method: 'DELETE'} @@ -62,15 +62,33 @@ }, - delete: function (subject, callbackSuccess, callbackError ) { + findAllFromCategoriesWithCallback: function(policyId, categoryId, callback){ - data.subject.perimeter.remove({subject_id: subject.id}, subject, callbackSuccess, callbackError); + data.subject.policy.get({policy_id: policyId, category_id: categoryId}).$promise.then(function(data) { + + if(data['subject_data'][0]) { + + callback(utilService.transform(data['subject_data'][0], 'data')); + + }else{ + + callback([]) + + } + + }); }, - add: function (subject, callbackSuccess, callbackError ) { + delete: function (subject, policyId, categoryId, callbackSuccess, callbackError ) { - data.subject.perimeter.create({}, subject, callbackSuccess, callbackError); + data.subject.policy.remove({policy_id: policyId, category_id: categoryId, data_id: subject.id}, subject, callbackSuccess, callbackError); + + }, + + add: function (subject, policyId, categoryId, callbackSuccess, callbackError ) { + + data.subject.policy.create({policy_id: policyId, category_id: categoryId}, subject, callbackSuccess, callbackError); }, @@ -108,15 +126,33 @@ }, - delete: function (object, callbackSuccess, callbackError ) { + findAllFromCategoriesWithCallback: function(policyId, categoryId, callback){ + + data.object.policy.get({policy_id: policyId, category_id: categoryId}).$promise.then(function(data) { + + if(data['object_data'][0]) { + + callback(utilService.transform(data['object_data'][0], 'data')); + + }else{ + + callback([]) + + } + + }); + + }, + + delete: function (object, policyId, categoryId, callbackSuccess, callbackError ) { - data.object.perimeter.remove({object_id: object.id}, object, callbackSuccess, callbackError); + data.object.policy.remove({policy_id: policyId, category_id: categoryId, data_id: object.id}, object, callbackSuccess, callbackError); }, - add:function (object, callbackSuccess, callbackError ) { + add:function (object, policyId, categoryId, callbackSuccess, callbackError ) { - data.object.perimeter.create({}, object, callbackSuccess, callbackError); + data.object.policy.create({policy_id: policyId, category_id: categoryId}, object, callbackSuccess, callbackError); }, @@ -126,7 +162,6 @@ data.object.policy.get({policy_id: policyId, object_id: objectId, data_id : dataId}).$promise.then(function(data) { - if(data['object_data'][0]){ callback(utilService.transformOne(data['object_data'][0], 'data')); @@ -155,15 +190,33 @@ }, - delete: function (action, callbackSuccess, callbackError ) { + findAllFromCategoriesWithCallback: function(policyId, categoryId, callback){ + + data.action.policy.get({policy_id: policyId, category_id: categoryId}).$promise.then(function(data) { + + if(data['action_data'][0]) { + + callback(utilService.transform(data['action_data'][0], 'data')); + + }else{ + + callback([]) + + } + + }); + + }, + + delete: function (action, policyId, categoryId, callbackSuccess, callbackError ) { - data.action.perimeter.remove({action_id: action.id}, action, callbackSuccess, callbackError); + data.action.policy.remove({policy_id: policyId, category_id: categoryId, data_id: action.id}, action, callbackSuccess, callbackError); }, - add:function (action, callbackSuccess, callbackError ) { + add:function (action, policyId, categoryId, callbackSuccess, callbackError ) { - data.action.perimeter.create({}, action, callbackSuccess, callbackError); + data.action.policy.create({policy_id: policyId, category_id: categoryId}, action, callbackSuccess, callbackError); }, diff --git a/moonv4/moon_gui/static/app/services/moon/policy/parameters/perimeter.service.js b/moonv4/moon_gui/static/app/services/moon/policy/parameters/perimeter.service.js index 6e929aba..42e7288a 100644 --- a/moonv4/moon_gui/static/app/services/moon/policy/parameters/perimeter.service.js +++ b/moonv4/moon_gui/static/app/services/moon/policy/parameters/perimeter.service.js @@ -21,30 +21,33 @@ perimeter: $resource(REST_URI.PERIMETERS.subject + ':subject_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }), policy: $resource(REST_URI.POLICIES + ':policy_id/subjects/:subject_id', {}, { get: {method: 'GET'}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }) }, - object: { perimeter: $resource(REST_URI.PERIMETERS.object + ':object_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }), policy: $resource(REST_URI.POLICIES + ':policy_id/objects/:object_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }) }, @@ -54,13 +57,15 @@ perimeter: $resource(REST_URI.PERIMETERS.action + ':action_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }), policy: $resource(REST_URI.POLICIES + ':policy_id/actions/:action_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, - remove: {method: 'DELETE'} + remove: {method: 'DELETE'}, + update: { method: 'PATCH' } }) } @@ -113,6 +118,12 @@ }, + unMapPerimeterFromPolicy: function(policyId, subjectId, callbackSuccess, callbackError ){ + + data.subject.policy.remove({policy_id: policyId, subject_id: subjectId}, {}, callbackSuccess, callbackError); + + }, + findAllFromPolicyWithCallback: function(policyId, callback){ data.subject.policy.get({policy_id: policyId}).$promise.then(function(data) { @@ -162,6 +173,12 @@ data.subject.perimeter.create({}, subject, callbackSuccess, callbackError); + }, + + update: function(subject, callbackSuccess, callbackError){ + + data.subject.perimeter.update({subject_id: subject.id}, subject, callbackSuccess, callbackError); + } }, @@ -173,7 +190,7 @@ callback(utilService.transformOne(data, 'objects')); - }) + }); }, @@ -210,6 +227,12 @@ }, + unMapPerimeterFromPolicy: function(policyId, objectId, callbackSuccess, callbackError ){ + + data.object.policy.remove({policy_id: policyId, object_id: objectId}, {}, callbackSuccess, callbackError); + + }, + findSomeWithCallback: function(objectListId, callback){ var _self = this; @@ -287,6 +310,12 @@ data.object.perimeter.create({}, object, callbackSuccess, callbackError); + }, + + update: function(object, callbackSuccess, callbackError){ + + data.object.perimeter.update({object_id: object.id}, object, callbackSuccess, callbackError); + } }, @@ -334,6 +363,12 @@ }, + unMapPerimeterFromPolicy: function(policyId, actionId, callbackSuccess, callbackError){ + + data.action.policy.remove({policy_id: policyId, action_id: actionId}, {}, callbackSuccess, callbackError); + + }, + findSomeWithCallback: function(actionListId, callback){ var _self = this; @@ -410,6 +445,12 @@ data.action.perimeter.create({}, action, callbackSuccess, callbackError); + }, + + update: function(action, callbackSuccess, callbackError){ + + data.action.perimeter.update({action_id: action.id}, action, callbackSuccess, callbackError); + } } diff --git a/moonv4/moon_gui/static/app/services/moon/policy/policy.service.js b/moonv4/moon_gui/static/app/services/moon/policy/policy.service.js index 5c8ad4f5..5ad31421 100644 --- a/moonv4/moon_gui/static/app/services/moon/policy/policy.service.js +++ b/moonv4/moon_gui/static/app/services/moon/policy/policy.service.js @@ -82,7 +82,7 @@ findOne: function (policyId) { - return this.data.policy.get({policy_id: policyId}).$promise.then(function (data) { + return this.data.policy.get({policy_id: policyId}).$promise.then(function (data) { return utilService.transformOne(data, 'policies'); diff --git a/moonv4/moon_gui/static/app/services/moon/rule/metadata.service.js b/moonv4/moon_gui/static/app/services/moon/rule/metadata.service.js index 659e0b30..8c68b2ef 100644 --- a/moonv4/moon_gui/static/app/services/moon/rule/metadata.service.js +++ b/moonv4/moon_gui/static/app/services/moon/rule/metadata.service.js @@ -29,7 +29,7 @@ remove: {method: 'DELETE'} }), - action: $resource(REST_URI.METADATA.action + ':action_id', {}, { + action: $resource(REST_URI.METADATA.action + ':action_id', {}, { get: {method: 'GET', isArray: false}, create: {method: 'POST'}, remove: {method: 'DELETE'} @@ -194,9 +194,9 @@ callback([]); } - var promises = _(objectListId).map( function(subjectId) { + var promises = _(objectListId).map( function(objectId) { - return _self.findOneReturningPromise(subjectId); + return _self.findOneReturningPromise(objectId); }); @@ -249,7 +249,7 @@ findOne: function(actionId, callback){ - data.action.get({actionId: actionId}).$promise.then(function(data) { + data.action.get({action_id: actionId}).$promise.then(function(data) { callback(utilService.transformOne(data, 'action_categories')); @@ -259,7 +259,7 @@ findOneReturningPromise: function(actionId){ - return data.action.get({actionId: actionId}).$promise; + return data.action.get({action_id: actionId}).$promise; }, @@ -297,9 +297,9 @@ callback([]); } - var promises = _(actionListId).map( function(subjectId) { + var promises = _(actionListId).map( function(actionId) { - return _self.findOneReturningPromise(subjectId); + return _self.findOneReturningPromise(actionId); }); diff --git a/moonv4/moon_gui/static/app/services/moon/rule/metarule.service.js b/moonv4/moon_gui/static/app/services/moon/rule/metarule.service.js index 71a36c50..2679fc5b 100644 --- a/moonv4/moon_gui/static/app/services/moon/rule/metarule.service.js +++ b/moonv4/moon_gui/static/app/services/moon/rule/metarule.service.js @@ -115,7 +115,7 @@ return utilService.transformOne(data, 'meta_rules'); - }) + }); }, @@ -141,7 +141,7 @@ return metaRule; - }) + }); }, |