1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #335 from mabashian/7489-edit-smart-inv-host

Edit a host from within the smart inventory tree
This commit is contained in:
Michael Abashian 2017-08-28 15:19:57 -04:00 committed by GitHub
commit 8d6de99a12
7 changed files with 49 additions and 6 deletions

View File

@ -33,7 +33,8 @@ import inventoryHosts from './related/hosts/related-host.route';
import smartInventoryHosts from './smart-inventory/smart-inventory-hosts.route';
import inventoriesList from './inventories.route';
import inventoryHostsAdd from './related/hosts/add/host-add.route';
import inventoryHostsEdit from './related/hosts/edit/host-edit.route';
import inventoryHostsEdit from './related/hosts/edit/standard-host-edit.route';
import smartInventoryHostsEdit from './related/hosts/edit/smart-host-edit.route';
import ansibleFactsRoute from '../shared/ansible-facts/ansible-facts.route';
import insightsRoute from './insights/insights.route';
import inventorySourcesCredentialRoute from './related/sources/lookup/sources-lookup-credential.route';
@ -322,6 +323,7 @@ angular.module('inventory', [
stateExtender.buildDefinition(smartInventoryHosts),
stateExtender.buildDefinition(inventoryHostsAdd),
stateExtender.buildDefinition(inventoryHostsEdit),
stateExtender.buildDefinition(smartInventoryHostsEdit),
stateExtender.buildDefinition(hostNestedGroupsRoute),
stateExtender.buildDefinition(inventorySourceListRoute),
stateExtender.buildDefinition(inventorySourceAddRoute),

View File

@ -0,0 +1,29 @@
export default {
name: "inventories.editSmartInventory.hosts.edit",
url: "/edit/:host_id",
ncyBreadcrumb: {
parent: "inventories.editSmartInventory.hosts",
label: "{{breadcrumb.host_name}}"
},
views: {
'hostForm@inventories': {
templateProvider: function(GenerateForm, RelatedHostsFormDefinition) {
let form = _.cloneDeep(RelatedHostsFormDefinition);
form.stateTree = 'inventories.editSmartInventory.hosts';
delete form.related;
return GenerateForm.buildHTML(form, {
mode: 'edit',
related: false
});
},
controller: 'RelatedHostEditController'
}
},
resolve: {
host: ['$stateParams', 'InventoriesService', function($stateParams, InventoriesService) {
return InventoriesService.getHost($stateParams.smartinventory_id, $stateParams.host_id).then(function(res) {
return res.data.results[0];
});
}]
}
};

View File

@ -89,7 +89,7 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath',
$state.go('inventories.edit.hosts.add');
};
$scope.editHost = function(host){
$state.go('inventories.edit.hosts.edit', {inventory_id: host.inventory_id, host_id: host.id});
$state.go('.edit', {inventory_id: host.inventory_id, host_id: host.id});
};
$scope.goToInsights = function(host){
$state.go('inventories.edit.hosts.edit.insights', {inventory_id: host.inventory_id, host_id:host.id});

View File

@ -37,7 +37,7 @@ function(i18n) {
" set by the inventory sync process.") +
"</p>",
dataTitle: i18n._('Host Enabled'),
ngDisabled: 'host.has_inventory_sources'
ngDisabled: '!host.summary_fields.user_capabilities.edit || host.has_inventory_sources'
}
},
fields: {
@ -78,7 +78,8 @@ function(i18n) {
'<p>' + i18n.sprintf(i18n._('View YAML examples at %s'), '<a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a>') + '</p>',
dataTitle: i18n._('Host Variables'),
dataPlacement: 'right',
dataContainer: 'body'
dataContainer: 'body',
ngDisabled: '!(host.summary_fields.user_capabilities.edit || canAdd)'
}
},

View File

@ -69,6 +69,13 @@
return Rest.get()
.success(this.success.bind(this))
.error(this.error.bind(this));
},
getHost: function(inventoryId, hostId) {
this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId;
Rest.setUrl(this.url);
return Rest.get()
.success(this.success.bind(this))
.error(this.error.bind(this));
}
};
}];

View File

@ -533,9 +533,13 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += (field.ngDisabled) ? ', "ScheduleToggle--disabled": ' + field.ngDisabled : '';
html += "\}' aw-tool-tip='" + field.awToolTip + "' data-placement='" + field.dataPlacement + "' data-tip-watch='" + field.dataTipWatch + "'><button ng-show='" + form.iterator + "." ;
html += (field.flag) ? field.flag : 'enabled';
html += "' class='ScheduleToggle-switch is-on' ng-click='" + field.ngClick + "'>" + i18n._("ON") + "</button><button ng-show='!" + form.iterator + "." ;
html += "' ";
html += (field.ngDisabled) ? `ng-disabled="${field.ngDisabled}" ` : "";
html += " class='ScheduleToggle-switch is-on' ng-click='" + field.ngClick + "'>" + i18n._("ON") + "</button><button ng-show='!" + form.iterator + "." ;
html += (field.flag) ? field.flag : "enabled";
html += "' class='ScheduleToggle-switch' ng-click='" + field.ngClick + "'>" + i18n._("OFF") + "</button></div></div>";
html += "' ";
html += (field.ngDisabled) ? `ng-disabled="${field.ngDisabled}" ` : "";
html += " class='ScheduleToggle-switch' ng-click='" + field.ngClick + "'>" + i18n._("OFF") + "</button></div></div>";
}
return html;
},