mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 14:39:30 -02:30
Added variable data fied to Host detail page. Save/edit work -made changes in the Hosts controller for this. Still need to validate text blob is valid JSON.
This commit is contained in:
@@ -197,6 +197,15 @@ angular.module('ansible', [
|
|||||||
Authorization.restoreUserInfo(); //user must have hit browser refresh
|
Authorization.restoreUserInfo(); //user must have hit browser refresh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Make the correct tab active
|
||||||
|
var base = ($location.path().replace(/^\//,'').split('/')[0]);
|
||||||
|
if (base == '') {
|
||||||
|
$('.nav-tabs a[href="#' + 'organizations' + '"]').tab('show');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
base.replace(/\_/g,' ');
|
||||||
|
$('.nav-tabs a[href="#' + base + '"]').tab('show');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (! Authorization.isTokenValid() ) {
|
if (! Authorization.isTokenValid() ) {
|
||||||
|
|||||||
@@ -168,18 +168,33 @@ function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
var data = {}
|
var data = {}
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
data[fld] = scope[fld];
|
if (fld != 'varaibles') {
|
||||||
|
data[fld] = scope[fld];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($routeParams.inventory_id) {
|
if ($routeParams.inventory_id) {
|
||||||
data['inventory'] = $routeParams.inventory_id;
|
data['inventory'] = $routeParams.inventory_id;
|
||||||
}
|
}
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
ReturnToCaller(1);
|
if (scope.variables) {
|
||||||
|
Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/');
|
||||||
|
Rest.post({data: scope.variables})
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to add host varaibles. POST returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new host. Post returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to add new host. POST returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -217,6 +232,21 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
if (scope.variable_url) {
|
||||||
|
Rest.setUrl(scope.variable_url);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
scope.variables = data.data;
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
scope.variables = null;
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to retrieve host variables. GET returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.variables = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -236,6 +266,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scope.variable_url = data.related.variable_data;
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
@@ -255,7 +286,20 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
}
|
}
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
if (scope.variables) {
|
||||||
|
Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/');
|
||||||
|
Rest.put({data: scope.variables})
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to update host varaibles. PUT returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -357,23 +357,26 @@ function JobEvents ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.PostRefreshRemove();
|
scope.PostRefreshRemove();
|
||||||
}
|
}
|
||||||
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||||
var results = scope[form.items.event.set][0];
|
|
||||||
// Disable Next/Prev buttons when we rich the end/beginning of array
|
// Disable Next/Prev buttons when we reach the end/beginning of array
|
||||||
scope[form.items.event.iterator + 'NextUrlDisable'] = (scope[form.items.event.iterator + 'NextUrl']) ? "" : "disabled";
|
scope[form.items.event.iterator + 'NextUrlDisable'] = (scope[form.items.event.iterator + 'NextUrl'] !== null) ? "" : "disabled";
|
||||||
scope[form.items.event.iterator + 'PrevUrlDisable'] = (scope[form.items.event.iterator + 'PrevUrl']) ? "" : "disabled";
|
scope[form.items.event.iterator + 'PrevUrlDisable'] = (scope[form.items.event.iterator + 'PrevUrl'] !== null) ? "" : "disabled";
|
||||||
|
|
||||||
// Set the scope input field values
|
// Set the scope input field values
|
||||||
for (var fld in form.items.event.fields) {
|
if (scope[form.items.event.set] && scope[form.items.event.set].length > 0) {
|
||||||
if (fld == 'event_data') {
|
var results = scope[form.items.event.set][0];
|
||||||
scope.event_data = JSON.stringify(results[fld]);
|
for (var fld in form.items.event.fields) {
|
||||||
}
|
if (fld == 'event_data') {
|
||||||
else {
|
scope.event_data = JSON.stringify(results[fld]);
|
||||||
if (results[fld]) {
|
}
|
||||||
scope[fld] = results[fld];
|
else {
|
||||||
|
if (results[fld]) {
|
||||||
|
scope[fld] = results[fld];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
scope['event_status'] = (results.failed) ? 'failed' : 'success';
|
||||||
scope['event_status'] = (results.failed) ? 'failed' : 'success';
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
|
|||||||
@@ -32,16 +32,15 @@ angular.module('HostFormDefinition', [])
|
|||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
includeOnEdit: true,
|
includeOnEdit: true,
|
||||||
includeOnAdd: true
|
includeOnAdd: true
|
||||||
|
},
|
||||||
|
variables: {
|
||||||
|
label: 'Variables',
|
||||||
|
type: 'textarea',
|
||||||
|
addRequired: false,
|
||||||
|
editRequird: false,
|
||||||
|
rows: 10,
|
||||||
|
class: 'span12'
|
||||||
}
|
}
|
||||||
// inventory: {
|
|
||||||
// label: 'Inventory',
|
|
||||||
// type: 'lookup',
|
|
||||||
// sourceModel: 'inventory',
|
|
||||||
// sourceField: 'name',
|
|
||||||
// addRequired: true,
|
|
||||||
// editRequired: true,
|
|
||||||
// ngClick: 'lookUpInventory()'
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: { //for now always generates <button> tags
|
buttons: { //for now always generates <button> tags
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition' ])
|
angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition' ])
|
||||||
.factory('PromptPasswords',['CredentialForm', '$compile', 'Rest', function(JobTemplateForm, $compile, Rest) {
|
.factory('PromptPasswords',['CredentialForm', '$compile', 'Rest', '$location', function(JobTemplateForm, $compile, Rest, $location) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
|||||||
if (scope[form.name + '_form'] && form.fields[field] && form.fields[field].sourceModel) {
|
if (scope[form.name + '_form'] && form.fields[field] && form.fields[field].sourceModel) {
|
||||||
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField] =
|
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField] =
|
||||||
listScope[list.name][i][form.fields[field].sourceField];
|
listScope[list.name][i][form.fields[field].sourceField];
|
||||||
scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]
|
if (scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]) {
|
||||||
.$setValidity('awlookup',true);
|
scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]
|
||||||
|
.$setValidity('awlookup',true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (scope[form.name + '_form']) {
|
if (scope[form.name + '_form']) {
|
||||||
scope[form.name + '_form'].$setDirty();
|
scope[form.name + '_form'].$setDirty();
|
||||||
@@ -64,6 +66,7 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
|||||||
'and then click the Select button.');
|
'and then click the Select button.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
console.log('found!');
|
||||||
if (postAction) {
|
if (postAction) {
|
||||||
postAction();
|
postAction();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user