1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-02-15 04:42:05 +00:00
ansible-playable/client/app/designer/roles/new_role/new_role.controller.js
Mumshad Mannambeth c92f737237 Initial Commit
2017-06-07 13:36:45 -04:00

56 lines
1.3 KiB
JavaScript

'use strict';
const angular = require('angular');
/*@ngInject*/
export function newRoleController($scope,$uibModalInstance,ansible,selectedRoleName,copyRole) {
$scope.newRole = {name:null};
$scope.createRoleLoading = false;
$scope.title = 'New Role';
// If copyRole use selectedRoleName to create new role from
// else nullify selectedRoleName
if(!copyRole){
selectedRoleName = null;
}
else {
$scope.title = 'Copy Role';
$scope.newRole.name = 'Copy of ' + selectedRoleName;
}
/**
* Create/Copy Role - Either a new role or copy an existing role
*/
$scope.createRole = function(){
$scope.createRoleLoading = true;
ansible.createRole($scope.newRole.name,
function(response){
$scope.createRoleLoading = false;
$scope.ok();
},
function(response){
$scope.createRoleLoading = false;
$scope.err_msg = response.data;
},
selectedRoleName
)
};
/**
* Close create/copy modal
*/
$scope.ok = function () {
$uibModalInstance.close(null);
};
/**
* Cancel modal
*/
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
}
export default angular.module('webAppApp.new_role', [])
.controller('NewRoleController', newRoleController)
.name;