mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
Aftr user edits a group, update the sync related icons based on whether or not user added sync source or removed sync source. This allows a sync to be started immediately (or prevents starting one) without having to first click the refresh button.
This commit is contained in:
parent
9807477944
commit
c55d3e935b
@ -827,7 +827,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
properties: {
|
||||
name: scope.name,
|
||||
description: scope.description,
|
||||
has_inventory_sources: (scope.source) ? true : false
|
||||
has_inventory_sources: (scope.source && scope.source.value) ? true : false,
|
||||
source: (scope.source && scope.source.value) ? scope.source.value : ''
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
*
|
||||
*/
|
||||
angular.module('InventoryGroupsDefinition', [])
|
||||
.value(
|
||||
'InventoryGroups', {
|
||||
.value('InventoryGroups', {
|
||||
|
||||
name: 'groups',
|
||||
iterator: 'group',
|
||||
@ -16,7 +15,7 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
index: false,
|
||||
hover: false,
|
||||
hasChildren: true,
|
||||
filterBy: '\{ show: true \}',
|
||||
filterBy: '{ show: true }',
|
||||
'class': 'table-condensed table-no-border',
|
||||
|
||||
fields: {
|
||||
@ -28,14 +27,14 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
hasChildren: true,
|
||||
columnClass: 'col-lg-9 col-md-9 col-sm-7 col-xs-7',
|
||||
nosort: true,
|
||||
awDroppable: "\{\{ group.isDroppable \}\}",
|
||||
awDraggable: "\{\{ group.isDraggable \}\}",
|
||||
awDroppable: "{{ group.isDroppable }}",
|
||||
awDraggable: "{{ group.isDraggable }}",
|
||||
dataContainment: "#groups_table",
|
||||
dataTreeId: "\{\{ group.id \}\}",
|
||||
dataGroupId: "\{\{ group.group_id \}\}",
|
||||
dataTreeId: "{{ group.id }}",
|
||||
dataGroupId: "{{ group.group_id }}",
|
||||
dataType: "group"
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
@ -45,81 +44,83 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
mode: 'all',
|
||||
ngClick: "createGroup()",
|
||||
awToolTip: "Create a new group"
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
mode: 'all',
|
||||
awToolTip: "Edit inventory properties",
|
||||
ngClick: 'editInventoryProperties()'
|
||||
},
|
||||
},
|
||||
refresh: {
|
||||
mode: 'all',
|
||||
awToolTip: "Refresh the page",
|
||||
ngClick: "refreshGroups()"
|
||||
},
|
||||
},
|
||||
stream: {
|
||||
ngClick: "showGroupActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
mode: 'all'
|
||||
},
|
||||
},
|
||||
help: {
|
||||
mode: 'all',
|
||||
awToolTip: "Get help building your inventory",
|
||||
ngClick: "showGroupHelp()",
|
||||
id: "inventory-summary-help"
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
sync_status: {
|
||||
mode: 'all',
|
||||
ngClick: "viewUpdateStatus(\{\{ group.id + ',' + group.group_id \}\})",
|
||||
ngClick: "viewUpdateStatus(group.id, group.group_id)",
|
||||
ngShow: "group.id > 1", // hide for all hosts
|
||||
awToolTip: "\{\{ group.status_tooltip \}\}",
|
||||
awToolTip: "{{ group.status_tooltip }}",
|
||||
dataTipWatch: "group.launch_tooltip",
|
||||
ngClass: "group.status_class",
|
||||
dataPlacement: "top"
|
||||
},
|
||||
},
|
||||
failed_hosts: {
|
||||
mode: 'all',
|
||||
awToolTip: "\{\{ group.hosts_status_tip \}\}",
|
||||
awToolTip: "{{ group.hosts_status_tip }}",
|
||||
ngShow: "group.id > 1", // hide for all hosts
|
||||
dataPlacement: "top",
|
||||
ngClick: "\{\{ 'showHosts(' + group.id + ',' + group.group_id + ',' + group.show_failures + ')' \}\}",
|
||||
iconClass: "\{\{ 'fa icon-failures-' + group.hosts_status_class \}\}"
|
||||
},
|
||||
ngClick: "showHosts(group.id, group.group_id, group.show_failures)",
|
||||
iconClass: "{{ 'fa icon-failures-' + group.hosts_status_class }}"
|
||||
},
|
||||
group_update: {
|
||||
//label: 'Sync',
|
||||
mode: 'all',
|
||||
ngClick: 'updateGroup(\{\{ group.id \}\})',
|
||||
awToolTip: "\{\{ group.launch_tooltip \}\}",
|
||||
ngClick: 'updateGroup(group.id)',
|
||||
awToolTip: "{{ group.launch_tooltip }}",
|
||||
dataTipWatch: "group.launch_tooltip",
|
||||
ngShow: "group.id > 1 && (group.status !== 'running' && group.status !== 'pending' && group.status !== 'updating')",
|
||||
ngClass: "group.launch_class",
|
||||
dataPlacement: "top"
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
//label: 'Cancel',
|
||||
mode: 'all',
|
||||
ngClick: "cancelUpdate(\{\{ group.id \}\})",
|
||||
ngClick: "cancelUpdate({{ group.id }})",
|
||||
awToolTip: "Cancel sync process",
|
||||
'class': 'red-txt',
|
||||
ngShow: "group.id > 1 && (group.status == 'running' || group.status == 'pending' || group.status == 'updating')",
|
||||
dataPlacement: "top"
|
||||
},
|
||||
},
|
||||
edit: {
|
||||
//label: 'Edit',
|
||||
mode: 'all',
|
||||
ngClick: "editGroup(\{\{ group.group_id + ',' + group.id \}\})",
|
||||
ngClick: "editGroup({{ group.group_id + ',' + group.id }})",
|
||||
awToolTip: 'Edit group',
|
||||
ngShow: "group.id > 1", // hide for all hosts
|
||||
dataPlacement: "top"
|
||||
},
|
||||
},
|
||||
"delete": {
|
||||
//label: 'Delete',
|
||||
mode: 'all',
|
||||
ngClick: "deleteGroup(\{\{ group.id + ',' + group.group_id \}\})",
|
||||
ngClick: "deleteGroup({{ group.id + ',' + group.group_id }})",
|
||||
awToolTip: 'Delete group',
|
||||
ngShow: "group.id != 1", // hide for all hosts
|
||||
dataPlacement: "top"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -174,20 +174,40 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
|
||||
|
||||
|
||||
// Update a group with a set of properties
|
||||
.factory('UpdateGroup', ['ApplyEllipsis', function(ApplyEllipsis) {
|
||||
.factory('UpdateGroup', ['ApplyEllipsis', 'GetSyncStatusMsg', 'Empty',
|
||||
function(ApplyEllipsis, GetSyncStatusMsg, Empty) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
var group_id = params.group_id;
|
||||
var properties = params.properties; // object of key:value pairs to update
|
||||
var old_name;
|
||||
var old_name, stat;
|
||||
for (var i=0; i < scope.groups.length; i++) {
|
||||
if (scope.groups[i].group_id == group_id) {
|
||||
if (scope.groups[i].group_id === group_id) {
|
||||
var grp = scope.groups[i];
|
||||
for (var p in properties) {
|
||||
if (p == 'name') {
|
||||
if (p === 'name') {
|
||||
old_name = scope.groups[i].name;
|
||||
}
|
||||
if (p === 'source') {
|
||||
if (properties[p] !== scope.groups[i][p]) {
|
||||
// User changed source
|
||||
if (!Empty(properties[p]) && (scope.groups[i].status === 'none' || Empty(scope.groups[i].status))) {
|
||||
// We have a source but no status, seed the status with 'never' to enable sync button
|
||||
scope.groups[i].status = 'never updated';
|
||||
}
|
||||
else if (!properties[p]) {
|
||||
// User removed source
|
||||
scope.groups[i].status = 'none';
|
||||
}
|
||||
// Update date sync status links/icons
|
||||
stat = GetSyncStatusMsg({ status: scope.groups[i].status });
|
||||
scope.groups[i].status_class = stat['class'];
|
||||
scope.groups[i].status_tooltip = stat.tooltip;
|
||||
scope.groups[i].launch_tooltip = stat.launch_tip;
|
||||
scope.groups[i].launch_class = stat.launch_class;
|
||||
}
|
||||
}
|
||||
scope.groups[i][p] = properties[p];
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,8 +252,10 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
|
||||
if (attrs.tipWatch) {
|
||||
// Add dataTipWatch: 'variable_name'
|
||||
console.log('adding watch');
|
||||
scope.$watch(attrs.tipWatch, function(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
console.log('switch');
|
||||
// Where did fixTitle come frome?:
|
||||
// http://stackoverflow.com/questions/9501921/change-twitter-bootstrap-tooltip-content-on-click
|
||||
$(element).tooltip('hide').attr('data-original-title', newVal).tooltip('fixTitle');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user