aboutsummaryrefslogtreecommitdiffstats
path: root/moon_gui/static/app/project/action/mapping
diff options
context:
space:
mode:
Diffstat (limited to 'moon_gui/static/app/project/action/mapping')
-rwxr-xr-xmoon_gui/static/app/project/action/mapping/project-map.tpl.html62
-rwxr-xr-xmoon_gui/static/app/project/action/mapping/project-unmap.tpl.html33
-rwxr-xr-xmoon_gui/static/app/project/action/mapping/project.controller.map.js107
-rwxr-xr-xmoon_gui/static/app/project/action/mapping/project.controller.unmap.js74
4 files changed, 276 insertions, 0 deletions
diff --git a/moon_gui/static/app/project/action/mapping/project-map.tpl.html b/moon_gui/static/app/project/action/mapping/project-map.tpl.html
new file mode 100755
index 00000000..5ffd98e2
--- /dev/null
+++ b/moon_gui/static/app/project/action/mapping/project-map.tpl.html
@@ -0,0 +1,62 @@
+<div ng-controller="ProjectMapController as map" class="modal" tabindex="-1" data-role="modalMappingProject">
+
+ <div class="modal-dialog">
+
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="$hide()">&times;</button>
+ <h4 class="modal-title" data-translate="moon.project.map.title" data-translate-values="{projectName: map.project.name}"></h4>
+ </div>
+
+ <div class="modal-body">
+
+ <form class="form-horizontal" role="form" name="map.form">
+
+ <div class="form-group" ng-class="{'has-error': map.form.pdp.$dirty && (map.form.pdp.$invalid || !map.selectedPDP)}">
+
+ <label class="col-sm-3 control-label" data-translate="moon.project.map.form.pdp">PDP</label>
+
+ <div class="col-sm-6">
+
+ <ui-select ng-model="map.selectedPDP" name="pdp" required>
+ <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match>
+ <ui-select-choices repeat="pdp in map.pdps">
+ <div ng-bind="pdp.name" ng-value="pdp"></div>
+ </ui-select-choices>
+ </ui-select>
+
+ <img ng-if="map.pdpsLoading" src="assets/img/ajax-loader.gif" />
+
+ <div class="help-block" ng-show="map.form.pdp.$dirty && (map.form.pdp.$invalid || !map.selectedPDP)">
+ <small class="error" ng-show="map.form.pdp.$error.required" data-translate="moon.project.map.check.pdp.required">PDP is required</small>
+ </div>
+
+ </div>
+
+ </div>
+
+ </form>
+
+ </div>
+
+ <div class="modal-footer">
+ <div class="btn-toolbar" style="float: right;">
+ <a href="" ng-click="$hide()" class="btn btn-default">
+ <span data-translate="moon.project.map.action.cancel">Cancel</span>
+ </a>
+ <a href="" ng-disabled="map.mappingLoading" ng-click="map.map()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-link"></span>
+ <span data-translate="moon.project.map.action.map">Map</span>
+ </a>
+
+ <img ng-if="map.mappingLoading" src="assets/img/ajax-loader.gif" />
+
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+</div>
diff --git a/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html b/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html
new file mode 100755
index 00000000..5cc5c6dd
--- /dev/null
+++ b/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html
@@ -0,0 +1,33 @@
+<div ng-controller="ProjectUnMapController as unmap" class="modal" tabindex="-1" data-role="modalUnmapProject">
+
+ <div class="modal-dialog">
+
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="$hide()">&times;</button>
+ <h4 class="modal-title" data-translate="moon.project.unmap.title"></h4>
+ </div>
+
+ <div class="modal-body">
+ <span data-translate="moon.project.unmap.content" data-translate-values="{ projectName: unmap.project.name, pdpName: unmap.project.mapping.authz.pdp.name }"></span>
+ </div>
+
+ <div class="modal-footer">
+ <div class="btn-toolbar" style="float: right;">
+ <a href="" ng-click="$hide()" class="btn btn-default">
+ <span data-translate="moon.project.unmap.action.cancel">Cancel</span>
+ </a>
+ <a href="" ng-disabled="unmap.unMappingLoading" ng-click="unmap.unmap()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span data-translate="moon.project.unmap.action.unmap">Unmap</span>
+ </a>
+ <img ng-if="unmap.unMappingLoading" src="assets/img/ajax-loader.gif" />
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+</div> \ No newline at end of file
diff --git a/moon_gui/static/app/project/action/mapping/project.controller.map.js b/moon_gui/static/app/project/action/mapping/project.controller.map.js
new file mode 100755
index 00000000..afa2bfc0
--- /dev/null
+++ b/moon_gui/static/app/project/action/mapping/project.controller.map.js
@@ -0,0 +1,107 @@
+/**
+ * @author arnaud marhin<arnaud.marhin@orange.com>
+ */
+
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .controller('ProjectMapController', ProjectMapController);
+
+ ProjectMapController.$inject = ['$scope', '$translate', 'alertService', 'formService', 'pdpService'];
+
+ function ProjectMapController($scope, $translate, alertService, formService, pdpService) {
+
+ var map = this;
+
+ /*
+ *
+ */
+
+ map.form = {};
+
+ map.project = $scope.project;
+
+ map.pdps = [];
+
+ map.pdpsLoading = true;
+
+ map.selectedPDP = null;
+
+ map.map = mapProject;
+
+ activate();
+
+ function activate(){
+
+ resolvePDPs();
+
+ }
+
+ /*
+ *
+ */
+
+ function resolvePDPs() {
+
+ pdpService.findAllWithCallBack(resolveMappedProjects);
+
+ }
+
+ function resolveMappedProjects(pdps) {
+
+ map.pdps = _.filter(pdps, function(pdp){
+ return _.isNull(pdp.keystone_project_id);
+ });
+
+ map.pdpsLoading = false;
+
+ }
+
+ function mapProject() {
+
+ if(formService.isInvalid(map.form)) {
+
+ formService.checkFieldsValidity(map.form);
+
+ } else {
+
+ map.mappingLoading = true;
+
+ pdpService.map( map.selectedPDP, map.project.id, mapSuccess, mapError);
+
+ }
+
+ function mapSuccess(data) {
+
+ map.project.pdp = map.selectedPDP;
+
+ $translate('moon.project.map.success', { projectName: map.project.name, pdpName: map.selectedPDP.name }).then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ map.mappingLoading = false;
+
+ $scope.$emit('event:projectMappedSuccess', map.project);
+
+ }
+
+ function mapError(response) {
+
+ $translate('moon.project.map.error', { projectName: map.project.name, pdpName: map.selectedPDP.name }).then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ map.mappingLoading = false;
+
+ $scope.$emit('event:projectMappedError', map.project);
+
+ }
+
+ }
+
+ }
+
+})();
diff --git a/moon_gui/static/app/project/action/mapping/project.controller.unmap.js b/moon_gui/static/app/project/action/mapping/project.controller.unmap.js
new file mode 100755
index 00000000..911b30ff
--- /dev/null
+++ b/moon_gui/static/app/project/action/mapping/project.controller.unmap.js
@@ -0,0 +1,74 @@
+/**
+ * @author arnaud marhin<arnaud.marhin@orange.com>
+ */
+
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .controller('ProjectUnMapController', ProjectUnMapController);
+
+ ProjectUnMapController.$inject = ['$scope', '$translate', 'alertService', 'pdpService'];
+
+ function ProjectUnMapController($scope, $translate, alertService, pdpService) {
+
+ var unmap = this;
+
+ /*
+ *
+ */
+
+ unmap.project = $scope.project;
+ unmap.unMappingLoading = false;
+
+ unmap.unmap = unMapProject;
+
+ /*
+ *
+ */
+
+ function unMapProject() {
+
+
+ unmap.unMappingLoading = true;
+
+ var pdpName = unmap.project.pdp.name;
+
+ pdpService.unMap(unmap.project.pdp, unMapSuccess, unMapError);
+
+ function unMapSuccess(data) {
+
+ $translate('moon.project.unmap.success', { projectName: unmap.project.name, pdpName: pdpName })
+ .then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ unmap.unMappingLoading = false;
+
+ delete unmap.project.mapping;
+ delete unmap.project.pdp;
+
+ $scope.$emit('event:projectUnmappedSuccess', unmap.project);
+
+ }
+
+ function unMapError(reason) {
+
+ $translate('moon.project.unmap.error', { projectName: unmap.project.name, pdpName: pdpName })
+ .then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ unmap.unMappingLoading = false;
+
+ $scope.$emit('event:projectUnmappedError', unmap.project);
+
+ }
+
+ }
+
+ }
+
+})();