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:
Chris Houseknecht
2014-02-06 17:05:22 -05:00
parent 9807477944
commit c55d3e935b
4 changed files with 60 additions and 36 deletions

View File

@@ -827,7 +827,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
properties: { properties: {
name: scope.name, name: scope.name,
description: scope.description, 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 : ''
} }
}); });
} }

View File

@@ -5,8 +5,7 @@
* *
*/ */
angular.module('InventoryGroupsDefinition', []) angular.module('InventoryGroupsDefinition', [])
.value( .value('InventoryGroups', {
'InventoryGroups', {
name: 'groups', name: 'groups',
iterator: 'group', iterator: 'group',
@@ -16,7 +15,7 @@ angular.module('InventoryGroupsDefinition', [])
index: false, index: false,
hover: false, hover: false,
hasChildren: true, hasChildren: true,
filterBy: '\{ show: true \}', filterBy: '{ show: true }',
'class': 'table-condensed table-no-border', 'class': 'table-condensed table-no-border',
fields: { fields: {
@@ -28,14 +27,14 @@ angular.module('InventoryGroupsDefinition', [])
hasChildren: true, hasChildren: true,
columnClass: 'col-lg-9 col-md-9 col-sm-7 col-xs-7', columnClass: 'col-lg-9 col-md-9 col-sm-7 col-xs-7',
nosort: true, nosort: true,
awDroppable: "\{\{ group.isDroppable \}\}", awDroppable: "{{ group.isDroppable }}",
awDraggable: "\{\{ group.isDraggable \}\}", awDraggable: "{{ group.isDraggable }}",
dataContainment: "#groups_table", dataContainment: "#groups_table",
dataTreeId: "\{\{ group.id \}\}", dataTreeId: "{{ group.id }}",
dataGroupId: "\{\{ group.group_id \}\}", dataGroupId: "{{ group.group_id }}",
dataType: "group" dataType: "group"
} }
}, },
actions: { actions: {
@@ -45,81 +44,83 @@ angular.module('InventoryGroupsDefinition', [])
mode: 'all', mode: 'all',
ngClick: "createGroup()", ngClick: "createGroup()",
awToolTip: "Create a new group" awToolTip: "Create a new group"
}, },
properties: { properties: {
mode: 'all', mode: 'all',
awToolTip: "Edit inventory properties", awToolTip: "Edit inventory properties",
ngClick: 'editInventoryProperties()' ngClick: 'editInventoryProperties()'
}, },
refresh: { refresh: {
mode: 'all', mode: 'all',
awToolTip: "Refresh the page", awToolTip: "Refresh the page",
ngClick: "refreshGroups()" ngClick: "refreshGroups()"
}, },
stream: { stream: {
ngClick: "showGroupActivity()", ngClick: "showGroupActivity()",
awToolTip: "View Activity Stream", awToolTip: "View Activity Stream",
mode: 'all' mode: 'all'
}, },
help: { help: {
mode: 'all', mode: 'all',
awToolTip: "Get help building your inventory", awToolTip: "Get help building your inventory",
ngClick: "showGroupHelp()", ngClick: "showGroupHelp()",
id: "inventory-summary-help" id: "inventory-summary-help"
} }
}, },
fieldActions: { fieldActions: {
sync_status: { sync_status: {
mode: 'all', mode: 'all',
ngClick: "viewUpdateStatus(\{\{ group.id + ',' + group.group_id \}\})", ngClick: "viewUpdateStatus(group.id, group.group_id)",
ngShow: "group.id > 1", // hide for all hosts ngShow: "group.id > 1", // hide for all hosts
awToolTip: "\{\{ group.status_tooltip \}\}", awToolTip: "{{ group.status_tooltip }}",
dataTipWatch: "group.launch_tooltip",
ngClass: "group.status_class", ngClass: "group.status_class",
dataPlacement: "top" dataPlacement: "top"
}, },
failed_hosts: { failed_hosts: {
mode: 'all', mode: 'all',
awToolTip: "\{\{ group.hosts_status_tip \}\}", awToolTip: "{{ group.hosts_status_tip }}",
ngShow: "group.id > 1", // hide for all hosts ngShow: "group.id > 1", // hide for all hosts
dataPlacement: "top", dataPlacement: "top",
ngClick: "\{\{ 'showHosts(' + group.id + ',' + group.group_id + ',' + group.show_failures + ')' \}\}", ngClick: "showHosts(group.id, group.group_id, group.show_failures)",
iconClass: "\{\{ 'fa icon-failures-' + group.hosts_status_class \}\}" iconClass: "{{ 'fa icon-failures-' + group.hosts_status_class }}"
}, },
group_update: { group_update: {
//label: 'Sync', //label: 'Sync',
mode: 'all', mode: 'all',
ngClick: 'updateGroup(\{\{ group.id \}\})', ngClick: 'updateGroup(group.id)',
awToolTip: "\{\{ group.launch_tooltip \}\}", awToolTip: "{{ group.launch_tooltip }}",
dataTipWatch: "group.launch_tooltip",
ngShow: "group.id > 1 && (group.status !== 'running' && group.status !== 'pending' && group.status !== 'updating')", ngShow: "group.id > 1 && (group.status !== 'running' && group.status !== 'pending' && group.status !== 'updating')",
ngClass: "group.launch_class", ngClass: "group.launch_class",
dataPlacement: "top" dataPlacement: "top"
}, },
cancel: { cancel: {
//label: 'Cancel', //label: 'Cancel',
mode: 'all', mode: 'all',
ngClick: "cancelUpdate(\{\{ group.id \}\})", ngClick: "cancelUpdate({{ group.id }})",
awToolTip: "Cancel sync process", awToolTip: "Cancel sync process",
'class': 'red-txt', 'class': 'red-txt',
ngShow: "group.id > 1 && (group.status == 'running' || group.status == 'pending' || group.status == 'updating')", ngShow: "group.id > 1 && (group.status == 'running' || group.status == 'pending' || group.status == 'updating')",
dataPlacement: "top" dataPlacement: "top"
}, },
edit: { edit: {
//label: 'Edit', //label: 'Edit',
mode: 'all', mode: 'all',
ngClick: "editGroup(\{\{ group.group_id + ',' + group.id \}\})", ngClick: "editGroup({{ group.group_id + ',' + group.id }})",
awToolTip: 'Edit group', awToolTip: 'Edit group',
ngShow: "group.id > 1", // hide for all hosts ngShow: "group.id > 1", // hide for all hosts
dataPlacement: "top" dataPlacement: "top"
}, },
"delete": { "delete": {
//label: 'Delete', //label: 'Delete',
mode: 'all', mode: 'all',
ngClick: "deleteGroup(\{\{ group.id + ',' + group.group_id \}\})", ngClick: "deleteGroup({{ group.id + ',' + group.group_id }})",
awToolTip: 'Delete group', awToolTip: 'Delete group',
ngShow: "group.id != 1", // hide for all hosts ngShow: "group.id != 1", // hide for all hosts
dataPlacement: "top" dataPlacement: "top"
}
} }
}
}); });

View File

@@ -174,20 +174,40 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
// Update a group with a set of properties // 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) { return function(params) {
var scope = params.scope; var scope = params.scope;
var group_id = params.group_id; var group_id = params.group_id;
var properties = params.properties; // object of key:value pairs to update 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++) { 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]; var grp = scope.groups[i];
for (var p in properties) { for (var p in properties) {
if (p == 'name') { if (p === 'name') {
old_name = scope.groups[i].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]; scope.groups[i][p] = properties[p];
} }
} }

View File

@@ -252,8 +252,10 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
if (attrs.tipWatch) { if (attrs.tipWatch) {
// Add dataTipWatch: 'variable_name' // Add dataTipWatch: 'variable_name'
console.log('adding watch');
scope.$watch(attrs.tipWatch, function(newVal, oldVal) { scope.$watch(attrs.tipWatch, function(newVal, oldVal) {
if (newVal !== oldVal) { if (newVal !== oldVal) {
console.log('switch');
// Where did fixTitle come frome?: // Where did fixTitle come frome?:
// http://stackoverflow.com/questions/9501921/change-twitter-bootstrap-tooltip-content-on-click // http://stackoverflow.com/questions/9501921/change-twitter-bootstrap-tooltip-content-on-click
$(element).tooltip('hide').attr('data-original-title', newVal).tooltip('fixTitle'); $(element).tooltip('hide').attr('data-original-title', newVal).tooltip('fixTitle');