1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-03-09 23:38:54 +00:00

Initial Commit

This commit is contained in:
Mumshad Mannambeth 2017-06-07 13:36:44 -04:00
commit c92f737237
273 changed files with 16964 additions and 0 deletions

View file

@ -0,0 +1,134 @@
'use strict';
const angular = require('angular');
/*@ngInject*/
export function newPlayController($scope, $uibModalInstance, ansible, plays, selectedPlayIndex) {
$scope.loading_msg = '';
$scope.title = "Create Play";
$scope.editMode = false;
$scope.editHostMode = false;
var selectedPlay;
if(selectedPlayIndex > -1){
selectedPlay = plays[selectedPlayIndex];
$scope.title = "Edit Play";
$scope.editMode = true;
if(selectedPlay && selectedPlay.tags)$scope.tags = selectedPlay.tags.join(',');
}
$scope.newPlay = selectedPlay || {};
$scope.newPlay_roles = $scope.newPlay.roles;
$scope.createPlayLoading = false;
$scope.createPlay = function () {
$scope.ok($scope.newPlay)
};
$scope.ok = function (newPlay) {
if($scope.tags)
newPlay.tags = $scope.tags.split(',');
if($scope.newPlay_roles && $scope.newPlay_roles.length){
var roles = [];
angular.forEach($scope.newPlay_roles,function(role){
roles.push(role.text)
});
newPlay.roles = roles;
}else if(newPlay.roles){
delete newPlay.roles;
}
$uibModalInstance.close(newPlay);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.getHostsFromInventory = function(){
var hosts = [];
angular.forEach($scope.inventory_data_json.hosts, function(host){
hosts.push({name:host})
});
angular.forEach($scope.inventory_data_json.groups, function(group){
if(group.name !== 'Un grouped')
hosts.push({name:group.name})
});
return hosts;
};
$scope.listOfInventoryFiles = function(){
$scope.loading_msg = 'Loading Inventory Files';
ansible.getInventoryList(function(response){
$scope.loading_msg = '';
$scope.inventoryFiles = response.data;
},
function(response){
$scope.loading_msg = '';
$scope.err_msg = response.data
})
};
$scope.listOfRoles = function(){
$scope.loading_msg = 'Loading Roles';
ansible.getRoleList(function(response){
$scope.loading_msg = '';
$scope.roleList = response.data;
},
function(response){
$scope.loading_msg = '';
$scope.err_msg = response.data
})
};
$scope.inventorySelected = function(selectedInventoryFile){
$scope.loading_msg = 'Loading Hosts';
ansible.readInventory(selectedInventoryFile,
function(response){
$scope.loading_msg = '';
$scope.inventory_data_json = ansible.parseINIString(response.data);
$scope.hosts = $scope.getHostsFromInventory();
},function(response){
$scope.loading_msg = '';
$scope.err_msg = response.data
})
};
$scope.getHostObject = function(hostname){
var result = $scope.hosts.filter(function(host){
return host.name == hostname
});
if(result.length){
return result[0]
}
};
$scope.listOfInventoryFiles();
$scope.listOfRoles();
$scope.loadTags = function(query){
if($scope.roleList){
var tempList = $scope.roleList.filter(function(role){
return role.indexOf(query) > -1
});
return tempList
}
}
}
export default angular.module('webAppApp.new_play', [])
.controller('NewPlayController', newPlayController)
.name;

View file

@ -0,0 +1,17 @@
'use strict';
describe('Controller: NewPlayCtrl', function() {
// load the controller's module
beforeEach(module('webAppApp.new_play'));
var NewPlayCtrl;
// Initialize the controller and a mock scope
beforeEach(inject(function($controller) {
NewPlayCtrl = $controller('NewPlayCtrl', {});
}));
it('should ...', function() {
expect(1).to.equal(1);
});
});

View file

@ -0,0 +1,96 @@
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">{{title}}</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<p class="form-group">
<label>Name</label>
<input ng-model="newPlay.name" type="text" class="form-control" placeholder="Play Name">
</p>
<p class="form-group">
<label>Tags</label>
<input ng-model="tags" type="text" class="form-control" placeholder="Tags separated by comma">
</p>
<p class="form-group" ng-show="!editMode || editHostMode">
<label>Inventory Files</label>
<select class="form-control" ng-disabled="loading_msg" ng-change="inventorySelected(selectedInventoryFile);" ng-model="selectedInventoryFile" ng-options="inventoryFile as inventoryFile for inventoryFile in inventoryFiles">
</select>
</p>
<p class="form-group" ng-show="!editMode || editHostMode">
<label>Hosts</label>
<select class="form-control" ng-disabled="loading_msg" ng-model="newPlay.hosts" ng-options="host.name as host.name for host in hosts">
</select>
</p>
<p class="form-group" ng-show="editMode && !editHostMode">
<label>Hosts </label>
<input ng-model="newPlay.hosts" ng-disabled="true" type="text" class="form-control" placeholder="Host Name">
</p>
<div class="input-group-btn" ng-show="editMode && !editHostMode">
<button class="btn btn-default" ng-click="editHostMode = true"> <span class="fa fa-edit"></span> Edit Hosts </button>
</div>
<label>Roles</label>
<tags-input ng-model="newPlay_roles" add-from-autocomplete-only="true" placeholder="Add roles to play">
<auto-complete source="loadTags($query)" min-length="0" load-on-empty="true" load-on-focus="true" load-on-down-arrow="true" ></auto-complete>
</tags-input>
</div>
<div class="col-md-6">
<h4 ng-if="selectedHostInfo.ip">IP - {{selectedHostInfo.ip}}</h4>
<h4 ng-if="selectedHostInfo.members">Members:</h4>
<ul class="list-group" ng-if="selectedHostInfo.members">
<li class="list-group-item" ng-repeat="member in selectedHostInfo.members.split(',')">{{member}}</li>
</ul>
<div ng-if="hostGroups">
<h4 >Member Of:</h4>
<ul class="list-group">
<li class="list-group-item" ng-repeat="group in hostGroups">{{group.name}}</li>
</ul>
</div>
<!--<div ui-ace="{theme:'twilight',document:'INI',mode:'ini',showGutter:false}" ng-model="hostInfo">
</div>-->
</div>
</div>
<div class="row" ng-if="selectedHostInfo">
<h4>Variables</h4>
<div class="input-group">
<span class="input-group-addon" >Groups</span>
<select class="form-control" ng-change="variableGroupSelected(selectedVariableGroup.value)" ng-model="selectedVariableGroup.value" ng-options="group.name as group.name for group in [selectedHostInfo].concat(hostGroups)">
</select>
</div>
<div ui-ace="{theme:'twilight',document:'INI',mode:'ini'}" ng-model="variableInfo">
</div>
</div>
</div>
<div class="alert alert-danger" ng-if="err_msg">{{err_msg}}</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-3" style="text-align: left">
<span ng-show="loading_msg" class="fa fa-spin fa-spinner"></span> {{loading_msg}}
</div>
<div class="col-md-9" style="text-align: right">
<button class="btn btn-primary" ng-click="createPlay()">Save <span ng-if="createPlayLoading" class="fa fa-spinner fa-spin"></span> </button>
<button class="btn btn-default" type="button" ng-click="cancel()">Close</button>
</div>
</div>
</div>
</div>