mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Latest UI changes
This commit is contained in:
@@ -38,12 +38,16 @@ angular.module('ansible', [
|
|||||||
'TeamsListDefinition',
|
'TeamsListDefinition',
|
||||||
'TeamFormDefinition',
|
'TeamFormDefinition',
|
||||||
'TeamHelper',
|
'TeamHelper',
|
||||||
'CredentialListDefinition',
|
'CredentialsListDefinition',
|
||||||
'CredentialFormDefinition',
|
'CredentialFormDefinition',
|
||||||
'LookUpHelper'
|
'LookUpHelper',
|
||||||
|
'JobTemplatesListDefinition'
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
|
when('/job_templates', { templateUrl: urlPrefix + 'partials/job_templates.html',
|
||||||
|
controller: JobTemplatesList }).
|
||||||
|
|
||||||
when('/inventories', { templateUrl: urlPrefix + 'partials/inventories.html',
|
when('/inventories', { templateUrl: urlPrefix + 'partials/inventories.html',
|
||||||
controller: InventoriesList }).
|
controller: InventoriesList }).
|
||||||
|
|
||||||
@@ -181,8 +185,10 @@ angular.module('ansible', [
|
|||||||
if (base == '') {
|
if (base == '') {
|
||||||
base = 'organizations';
|
base = 'organizations';
|
||||||
$location.path('/organizations');
|
$location.path('/organizations');
|
||||||
|
$('.nav-tabs a[href="#' + base + '"]').tab('show');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
base.replace(/\_/g,' ');
|
||||||
$('.nav-tabs a[href="#' + base + '"]').tab('show');
|
$('.nav-tabs a[href="#' + base + '"]').tab('show');
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
if (scope.selected.length > 0 ) {
|
if (scope.selected.length > 0 ) {
|
||||||
var credential = null;
|
var credential = null;
|
||||||
for (var i=0; i < scope.selected.length; i++) {
|
for (var i=0; i < scope.selected.length; i++) {
|
||||||
for (var j=0; j < scope.Credentials.length; j++) {
|
for (var j=0; j < scope.credentials.length; j++) {
|
||||||
if (scope.credentials[j].id == scope.selected[i]) {
|
if (scope.credentials[j].id == scope.selected[i]) {
|
||||||
credential = scope.credentials[j];
|
credential = scope.credentials[j];
|
||||||
}
|
}
|
||||||
|
|||||||
132
lib/ui/static/js/controllers/JobTemplates.js
Normal file
132
lib/ui/static/js/controllers/JobTemplates.js
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/************************************
|
||||||
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* JobTemplates.js
|
||||||
|
*
|
||||||
|
* Controller functions for the Job Template model.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobTemplateList,
|
||||||
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||||
|
ClearScope, ProcessErrors, GetBasePath)
|
||||||
|
{
|
||||||
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
|
//scope.
|
||||||
|
var list = JobTemplateList;
|
||||||
|
var defaultUrl = GetBasePath('job_templates');
|
||||||
|
var view = GenerateList;
|
||||||
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
|
var mode = (base == 'job_templates') ? 'edit' : 'select'; // if base path 'credentials', we're here to add/edit
|
||||||
|
console.log(base);
|
||||||
|
var scope = view.inject(list, { mode: mode }); // Inject our view
|
||||||
|
scope.selected = [];
|
||||||
|
|
||||||
|
SearchInit({ scope: scope, set: 'job_templates', list: list, url: defaultUrl });
|
||||||
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
scope.addCredential = function() {
|
||||||
|
$location.path($location.path() + '/add');
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.editCredential = function(id) {
|
||||||
|
$location.path($location.path() + '/' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.deleteCredential = function(id, name) {
|
||||||
|
|
||||||
|
var action = function() {
|
||||||
|
var url = defaultUrl + id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.delete()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(list.iterator);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({ hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.finishSelection = function() {
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
scope.queue = [];
|
||||||
|
|
||||||
|
if (scope.callFinishedRemove) {
|
||||||
|
scope.callFinishedRemove();
|
||||||
|
}
|
||||||
|
scope.callFinishedRemove = scope.$on('callFinished', function() {
|
||||||
|
// We call the API for each selected user. We need to hang out until all the api
|
||||||
|
// calls are finished.
|
||||||
|
if (scope.queue.length == scope.selected.length) {
|
||||||
|
// All the api calls finished
|
||||||
|
$('input[type="checkbox"]').prop("checked",false);
|
||||||
|
scope.selected = [];
|
||||||
|
var errors = 0;
|
||||||
|
for (var i=0; i < scope.queue.length; i++) {
|
||||||
|
if (scope.queue[i].result == 'error') {
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errors > 0) {
|
||||||
|
Alert('Error', 'There was an error while adding one or more of the selected templates.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scope.selected.length > 0 ) {
|
||||||
|
var template = null;
|
||||||
|
for (var i=0; i < scope.selected.length; i++) {
|
||||||
|
for (var j=0; j < scope.job_templates.length; j++) {
|
||||||
|
if (scope.job_templates[j].id == scope.selected[i]) {
|
||||||
|
template = scope.job_templates[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (template !== null) {
|
||||||
|
Rest.post(template)
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
scope.queue.push({ result: 'success', data: data, status: status });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
scope.queue.push({ result: 'error', data: data, status: status, headers: headers });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.toggle_credential = function(idx) {
|
||||||
|
if (scope.selected.indexOf(idx) > -1) {
|
||||||
|
scope.selected.splice(scope.selected.indexOf(idx),1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.selected.push(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JobTemplatesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobTemplateList',
|
||||||
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
|
'ProcessErrors','GetBasePath' ];
|
||||||
@@ -70,7 +70,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
|||||||
},
|
},
|
||||||
headers: { 'Authorization': 'Token ' + Authorization.getToken() },
|
headers: { 'Authorization': 'Token ' + Authorization.getToken() },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log(data);
|
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
if (console) {
|
if (console) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
angular.module('CredentialListDefinition', [])
|
angular.module('CredentialsListDefinition', [])
|
||||||
.value(
|
.value(
|
||||||
'CredentialList', {
|
'CredentialList', {
|
||||||
|
|
||||||
|
|||||||
54
lib/ui/static/js/lists/JobTemplates.js
Normal file
54
lib/ui/static/js/lists/JobTemplates.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*********************************************
|
||||||
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
|
*
|
||||||
|
* JobTemplates.js
|
||||||
|
* List view object for Job Templates data model.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular.module('JobTemplatesListDefinition', [])
|
||||||
|
.value(
|
||||||
|
'JobTemplateList', {
|
||||||
|
|
||||||
|
name: 'job_templates',
|
||||||
|
iterator: 'job_template',
|
||||||
|
selectTitle: 'Add Job Template',
|
||||||
|
editTitle: 'Job Templates',
|
||||||
|
selectInstructions: 'Check the Select checkbox next to each template to be added, and click Finished when done. Use the green <i class=\"icon-plus\"></i> button to create a new template.',
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
key: true,
|
||||||
|
label: 'Name'
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
label: 'Description'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
add: {
|
||||||
|
icon: 'icon-plus',
|
||||||
|
mode: 'all', // One of: edit, select, all
|
||||||
|
ngClick: 'addJobTemplate()',
|
||||||
|
class: 'btn btn-mini btn-success',
|
||||||
|
basePaths: ['job_templates'],
|
||||||
|
awToolTip: 'Create a new template'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
fieldActions: {
|
||||||
|
edit: {
|
||||||
|
ngClick: "editJobTemplate(\{\{ job_template.id \}\})",
|
||||||
|
icon: 'icon-edit',
|
||||||
|
awToolTip: 'Edit user'
|
||||||
|
},
|
||||||
|
|
||||||
|
delete: {
|
||||||
|
ngClick: "deleteJobTemplate(\{\{ job_template.id \}\},'\{\{ job_template.name \}\}')",
|
||||||
|
icon: 'icon-remove',
|
||||||
|
class: 'btn-danger',
|
||||||
|
awToolTip: 'Delete template'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
3
lib/ui/static/partials/job_templates.html
Normal file
3
lib/ui/static/partials/job_templates.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="tab-pane" id="job_templates">
|
||||||
|
<div id="htmlTemplate"></div>
|
||||||
|
</div>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/controllers/Credentials.js"></script>
|
<script src="{{ STATIC_URL }}js/controllers/Credentials.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/controllers/Hosts.js"></script>
|
<script src="{{ STATIC_URL }}js/controllers/Hosts.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/controllers/Groups.js"></script>
|
<script src="{{ STATIC_URL }}js/controllers/Groups.js"></script>
|
||||||
|
<script src="{{ STATIC_URL }}js/controllers/JobTemplates.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/forms/Users.js"></script>
|
<script src="{{ STATIC_URL }}js/forms/Users.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/forms/Organizations.js"></script>
|
<script src="{{ STATIC_URL }}js/forms/Organizations.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/forms/Inventories.js"></script>
|
<script src="{{ STATIC_URL }}js/forms/Inventories.js"></script>
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/lists/Hosts.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Hosts.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/Groups.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Groups.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/Credentials.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Credentials.js"></script>
|
||||||
|
<script src="{{ STATIC_URL }}js/lists/JobTemplates.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||||
@@ -97,6 +99,7 @@
|
|||||||
<li><a href="#users" data-toggle="tab">Users</a></li>
|
<li><a href="#users" data-toggle="tab">Users</a></li>
|
||||||
<li><a href="#credentials" data-toggle="tab">Credentials</a></li>
|
<li><a href="#credentials" data-toggle="tab">Credentials</a></li>
|
||||||
<li><a href="#inventories" data-toggle="tab">Inventories</a></li>
|
<li><a href="#inventories" data-toggle="tab">Inventories</a></li>
|
||||||
|
<li><a href="#job_templates" data-toggle="tab">Job Templates</a></li>
|
||||||
<li><a href="#jobs" data-toggle="tab">Jobs</a></li>
|
<li><a href="#jobs" data-toggle="tab">Jobs</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -176,7 +179,7 @@
|
|||||||
<script>
|
<script>
|
||||||
$('a[data-toggle="tab"]').on('show', function (e) {
|
$('a[data-toggle="tab"]').on('show', function (e) {
|
||||||
var url = $(e.target).text();
|
var url = $(e.target).text();
|
||||||
window.location = '#/' + url.toLowerCase();
|
window.location = '#/' + url.toLowerCase().replace(/ /g,'_');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user