AC-1144 fixes for inventory group edit modal dialog. Spinner issue fixed. Improved error validation. Improved scope separation. Fixed issues related to home/groups search breaking after dialog closes.

This commit is contained in:
Chris Houseknecht
2014-04-05 18:00:02 -04:00
parent d6237dcfb0
commit ff3ce4f7b4
12 changed files with 134 additions and 113 deletions

View File

@@ -124,7 +124,7 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location',
function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait, GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate) { Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate, Store) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope. //scope.
@@ -134,7 +134,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
defaultUrl = GetBasePath('groups'), defaultUrl = GetBasePath('groups'),
scope = $scope, scope = $scope,
modal_scope = $scope.$new(), modal_scope = $scope.$new(),
opt; opt, PreviousSearchParams;
generator.inject(list, { mode: 'edit', scope: scope }); generator.inject(list, { mode: 'edit', scope: scope });
@@ -173,7 +173,6 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
scope.removePostRefresh = scope.$on('PostRefresh', function () { scope.removePostRefresh = scope.$on('PostRefresh', function () {
var i, hosts_status, stat; var i, hosts_status, stat;
for (i = 0; i < scope.home_groups.length; i++) { for (i = 0; i < scope.home_groups.length; i++) {
scope.home_groups[i].inventory_name = scope.home_groups[i].summary_fields.inventory.name; scope.home_groups[i].inventory_name = scope.home_groups[i].summary_fields.inventory.name;
stat = GetSyncStatusMsg({ stat = GetSyncStatusMsg({
@@ -288,24 +287,30 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
}); });
}; };
if (modal_scope.removeHomeGroupsRefresh) {
modal_scope.removeHomeGroupsRefresh();
}
modal_scope.removeHomeGroupsRefresh = scope.$on('HomeGroupsRefresh', function() {
scope.search(list.iterator);
});
scope.editGroup = function (group_id, inventory_id) { scope.editGroup = function (group_id, inventory_id) {
PreviousSearchParams = Store('CurrentSearchParams');
GroupsEdit({ GroupsEdit({
scope: modal_scope, scope: scope,
group_id: group_id, group_id: group_id,
inventory_id: inventory_id, inventory_id: inventory_id,
groups_reload: false, groups_reload: false,
mode: 'edit', mode: 'edit'
callback: 'HomeGroupsRefresh'
}); });
}; };
scope.restoreSearch = function() {
SearchInit({
scope: scope,
set: PreviousSearchParams.set,
list: PreviousSearchParams.list,
url: PreviousSearchParams.defaultUrl,
iterator: PreviousSearchParams.iterator,
sort_order: PreviousSearchParams.sort_order,
setWidgets: false
});
scope.refresh();
};
scope.viewUpdateStatus = function (id) { scope.viewUpdateStatus = function (id) {
scope.groups = scope.home_groups; scope.groups = scope.home_groups;
ViewUpdateStatus({ ViewUpdateStatus({
@@ -494,7 +499,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus', 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate' 'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate', 'Store'
]; ];

View File

@@ -224,11 +224,20 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
html += "</thead>\n"; html += "</thead>\n";
html += "<tbody>\n"; html += "<tbody>\n";
data.results.forEach( function(row) { data.results.forEach( function(row) {
html += "<tr>"; if (row.related.last_update) {
html += "<td><a href=\"\" ng-click=\"viewJob('" + row.related.last_update + "')\" aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) + ". Click for details\" aw-tip-placement=\"top\"><i class=\"fa icon-job-" + row.status + "\"></i></a></td>"; html += "<tr>";
html += "<td>" + ($filter('date')(row.last_updated,'MM/dd HH:mm:ss')).replace(/ /,'<br />') + "</td>"; html += "<td><a href=\"\" ng-click=\"viewJob('" + row.related.last_update + "')\" aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) + ". Click for details\" aw-tip-placement=\"top\"><i class=\"fa icon-job-" + row.status + "\"></i></a></td>";
html += "<td><a href=\"\" ng-click=\"viewJob('" + row.related.last_update + "')\">" + ellipsis(row.summary_fields.group.name) + "</a></td>"; html += "<td>" + ($filter('date')(row.last_updated,'MM/dd HH:mm:ss')).replace(/ /,'<br />') + "</td>";
html += "</tr>\n"; html += "<td><a href=\"\" ng-click=\"viewJob('" + row.related.last_update + "')\">" + ellipsis(row.summary_fields.group.name) + "</a></td>";
html += "</tr>\n";
}
else {
html += "<tr>";
html += "<td><a href=\"\" aw-tool-tip=\"No sync data\" aw-tip-placement=\"top\"><i class=\"fa icon-job-none\"></i></a></td>";
html += "<td>NA</td>";
html += "<td><a href=\"\">" + ellipsis(row.summary_fields.group.name) + "</a></td>";
html += "</tr>\n";
}
}); });
html += "</tbody>\n"; html += "</tbody>\n";
html += "</table>\n"; html += "</table>\n";

View File

@@ -130,14 +130,14 @@ angular.module('SourceFormDefinition', [])
}] }]
}, },
update_cache_timeout: { update_cache_timeout: {
label: 'Cache Timeout', label: "Cache Timeout <span class=\"small-text\"> (seconds)</span>",
id: 'source-cache-timeout', id: 'source-cache-timeout',
type: 'number', type: 'number',
integer: true, integer: true,
min: 0, min: 0,
ngShow: "update_on_launch", ngShow: "source && source.value !== '' && update_on_launch",
spinner: true, spinner: true,
"default": '0', "default": 0,
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
awPopOver: '<p>Time in seconds to consider an inventory sync to be current. During job runs and callbacks the task system will ' + awPopOver: '<p>Time in seconds to consider an inventory sync to be current. During job runs and callbacks the task system will ' +

View File

@@ -273,25 +273,6 @@ angular.module('UserFormDefinition', [])
actions: {}, actions: {},
fields: {
name: {
key: true,
label: 'Name'
},
description: {
label: 'Description'
}
}
},
projects: {
type: 'collection',
title: 'Projects',
iterator: 'project',
open: false,
actions: {},
fields: { fields: {
name: { name: {
key: true, key: true,
@@ -302,7 +283,6 @@ angular.module('UserFormDefinition', [])
} }
} }
} }
} }
}); //UserForm }); //UserForm

View File

@@ -343,9 +343,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
* Add the list of schedules to the Group Edit modal * Add the list of schedules to the Group Edit modal
* *
*/ */
.factory('ScheduleList', ['ScheduleEdit', 'SchedulesList', 'GenerateList', 'SearchInit', 'PaginateInit', 'Rest', 'PageRangeSetup', .factory('GroupsScheduleList', ['GroupsScheduleEdit', 'SchedulesList', 'GenerateList', 'SearchInit', 'PaginateInit', 'Rest', 'PageRangeSetup',
'Wait', 'ProcessErrors', 'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetBasePath', 'SchedulesListInit', 'Wait', 'ProcessErrors', 'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetBasePath', 'SchedulesListInit',
function(ScheduleEdit, SchedulesList, GenerateList, SearchInit, PaginateInit, Rest, PageRangeSetup, Wait, ProcessErrors, Find, function(GroupsScheduleEdit, SchedulesList, GenerateList, SearchInit, PaginateInit, Rest, PageRangeSetup, Wait, ProcessErrors, Find,
ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) { ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) {
return function(params) { return function(params) {
var parent_scope = params.scope, var parent_scope = params.scope,
@@ -363,7 +363,7 @@ ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) {
$('.popover').each(function () { $('.popover').each(function () {
$(this).remove(); $(this).remove();
}); });
// Add schedules list // Add schedules list
list = angular.copy(SchedulesList); list = angular.copy(SchedulesList);
delete list.fields.dtend; delete list.fields.dtend;
@@ -379,9 +379,10 @@ ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) {
$('#schedules-list').show(); $('#schedules-list').show();
if (schedule_scope.removePostRefresh) { // Removing screws up /home/groups page
schedule_scope.removePostRefresh(); // if (schedule_scope.removePostRefresh) {
} // schedule_scope.removePostRefresh();
//}
schedule_scope.removePostRefresh = schedule_scope.$on('PostRefresh', function() { schedule_scope.removePostRefresh = schedule_scope.$on('PostRefresh', function() {
SchedulesListInit({ SchedulesListInit({
scope: schedule_scope, scope: schedule_scope,
@@ -403,16 +404,16 @@ ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) {
}); });
schedule_scope.search(list.iterator); schedule_scope.search(list.iterator);
parent_scope.refreshSchedule = function() { schedule_scope.refreshSchedules = function() {
schedule_scope.search(list.iterator); schedule_scope.search(list.iterator);
}; };
schedule_scope.editSchedule = function(id) { schedule_scope.editSchedule = function(id) {
ScheduleEdit({ scope: parent_scope, mode: 'edit', url: GetBasePath('schedules') + id + '/' }); GroupsScheduleEdit({ scope: schedule_scope, mode: 'edit', url: GetBasePath('schedules') + id + '/' });
}; };
schedule_scope.addSchedule = function() { schedule_scope.addSchedule = function() {
ScheduleEdit({ scope: parent_scope, mode: 'add', url: url }); GroupsScheduleEdit({ scope: schedule_scope, mode: 'add', url: url });
}; };
if (schedule_scope.removeSchedulesRefresh) { if (schedule_scope.removeSchedulesRefresh) {
@@ -462,11 +463,11 @@ ToggleSchedule, DeleteSchedule, GetBasePath, SchedulesListInit) {
* Remove the schedule list, add the schedule widget and populate it with an rrule * Remove the schedule list, add the schedule widget and populate it with an rrule
* *
*/ */
.factory('ScheduleEdit', ['SchedulerInit', 'Rest', 'Wait', 'SetSchedulesInnerDialogSize', 'SchedulePost', 'ProcessErrors', .factory('GroupsScheduleEdit', ['$compile','SchedulerInit', 'Rest', 'Wait', 'SetSchedulesInnerDialogSize', 'SchedulePost', 'ProcessErrors',
function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, ProcessErrors) { function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, ProcessErrors) {
return function(params) { return function(params) {
var parent_scope = params.scope, var parent_scope = params.scope,
mode = params.mode, // 'create' or 'edit' mode = params.mode, // 'add' or 'edit'
url = params.url, url = params.url,
scope = parent_scope.$new(), scope = parent_scope.$new(),
schedule = {}, schedule = {},
@@ -476,7 +477,8 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
list, list,
detail, detail,
restoreList, restoreList,
container; container,
elem;
Wait('start'); Wait('start');
detail = $('#schedules-detail').hide(); detail = $('#schedules-detail').hide();
@@ -494,6 +496,9 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
$(this).remove(); $(this).remove();
}); });
elem = angular.element(document.getElementById('schedules-form-container'));
$compile(elem)(scope);
if (scope.removeScheduleReady) { if (scope.removeScheduleReady) {
scope.removeScheduleReady(); scope.removeScheduleReady();
} }
@@ -503,8 +508,9 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
scheduler.inject('schedules-form', false); scheduler.inject('schedules-form', false);
scheduler.injectDetail('schedules-detail', false); scheduler.injectDetail('schedules-detail', false);
scheduler.clear(); scheduler.clear();
scope.formShowing = true;
scope.showRRuleDetail = false; scope.showRRuleDetail = false;
parent_scope.schedulesTitle = (mode === 'edit') ? 'Edit Schedule' : 'Create Schedule'; scope.schedulesTitle = (mode === 'edit') ? 'Edit Schedule' : 'Create Schedule';
// display the scheduler widget // display the scheduler widget
showForm = function() { showForm = function() {
@@ -530,22 +536,22 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
$('#group-save-button').prop('disabled', false); $('#group-save-button').prop('disabled', false);
list.show('slide', { direction: 'right' }, 500); list.show('slide', { direction: 'right' }, 500);
$('#schedules-overlay').width($('#schedules-tab').width()).height($('#schedules-tab').height()).hide(); $('#schedules-overlay').width($('#schedules-tab').width()).height($('#schedules-tab').height()).hide();
parent_scope.refreshSchedule(); parent_scope.refreshSchedules();
}; };
parent_scope.showScheduleDetail = function() { scope.showScheduleDetail = function() {
if (parent_scope.formShowing) { if (scope.formShowing) {
if (scheduler.isValid()) { if (scheduler.isValid()) {
detail.width($('#schedules-form').width()).height($('#schedules-form').height()); detail.width($('#schedules-form').width()).height($('#schedules-form').height());
target.hide(); target.hide();
detail.show(); detail.show();
parent_scope.formShowing = false; scope.formShowing = false;
} }
} }
else { else {
detail.hide(); detail.hide();
target.show(); target.show();
parent_scope.formShowing = true; scope.formShowing = true;
} }
}; };
@@ -557,7 +563,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
container.hide('slide', { direction: 'right' }, 500, restoreList); container.hide('slide', { direction: 'right' }, 500, restoreList);
}); });
parent_scope.saveScheduleForm = function() { scope.saveScheduleForm = function() {
if (scheduler.isValid()) { if (scheduler.isValid()) {
scope.schedulerIsValid = true; scope.schedulerIsValid = true;
SchedulePost({ SchedulePost({
@@ -574,7 +580,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
}; };
parent_scope.cancelScheduleForm = function() { scope.cancelScheduleForm = function() {
container.hide('slide', { direction: 'right' }, 500, restoreList); container.hide('slide', { direction: 'right' }, 500, restoreList);
}; };
@@ -603,13 +609,13 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
}]) }])
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm', .factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', '$compile', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate', 'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find','WatchInventoryWindowResize', 'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find','WatchInventoryWindowResize',
'ParseVariableString', 'ToJSON', 'ScheduleList', 'SourceForm', 'SetSchedulesInnerDialogSize', 'BuildTree', 'ParseVariableString', 'ToJSON', 'GroupsScheduleList', 'SourceForm', 'SetSchedulesInnerDialogSize', 'BuildTree',
function ($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors, function ($rootScope, $location, $log, $routeParams, $compile, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait, GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
GetChoices, UpdateGroup, SourceChange, Find, WatchInventoryWindowResize, ParseVariableString, ToJSON, ScheduleList, GetChoices, UpdateGroup, SourceChange, Find, WatchInventoryWindowResize, ParseVariableString, ToJSON, GroupsScheduleList,
SourceForm, SetSchedulesInnerDialogSize, BuildTree) { SourceForm, SetSchedulesInnerDialogSize, BuildTree) {
return function (params) { return function (params) {
@@ -619,15 +625,16 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
mode = params.mode, // 'add' or 'edit' mode = params.mode, // 'add' or 'edit'
inventory_id = params.inventory_id, inventory_id = params.inventory_id,
groups_reload = params.groups_reload, groups_reload = params.groups_reload,
callback = params.callback,
generator = GenerateForm, generator = GenerateForm,
defaultUrl, defaultUrl,
master = {}, master = {},
choicesReady, choicesReady,
base = $location.path().replace(/^\//, '').split('/')[0],
modal_scope = parent_scope.$new(), modal_scope = parent_scope.$new(),
properties_scope = parent_scope.$new(), properties_scope = parent_scope.$new(),
sources_scope = parent_scope.$new(), sources_scope = parent_scope.$new(),
x, y, ww, wh, maxrows, elem, x, y, ww, wh, maxrows,
group,
schedules_url = ''; schedules_url = '';
if (mode === 'edit') { if (mode === 'edit') {
@@ -637,6 +644,15 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
defaultUrl = (group_id !== null) ? GetBasePath('groups') + group_id + '/children/' : defaultUrl = (group_id !== null) ? GetBasePath('groups') + group_id + '/children/' :
GetBasePath('inventory') + inventory_id + '/groups/'; GetBasePath('inventory') + inventory_id + '/groups/';
} }
$('#properties-tab').empty();
$('#sources-tab').empty();
$('#schedules-list').empty();
$('#schedules-form').empty();
$('#schedules-detail').empty();
elem = document.getElementById('group-modal-dialog');
$compile(elem)(modal_scope);
generator.inject(GroupForm, { mode: 'edit', id: 'properties-tab', breadCrumbs: false, related: false, scope: properties_scope }); generator.inject(GroupForm, { mode: 'edit', id: 'properties-tab', breadCrumbs: false, related: false, scope: properties_scope });
generator.inject(SourceForm, { mode: 'edit', id: 'sources-tab', breadCrumbs: false, related: false, scope: sources_scope }); generator.inject(SourceForm, { mode: 'edit', id: 'sources-tab', breadCrumbs: false, related: false, scope: sources_scope });
@@ -647,6 +663,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
sources_scope.source = SourceForm.fields.source['default']; sources_scope.source = SourceForm.fields.source['default'];
sources_scope.sourcePathRequired = false; sources_scope.sourcePathRequired = false;
sources_scope[SourceForm.fields.source_vars.parseTypeName] = 'yaml'; sources_scope[SourceForm.fields.source_vars.parseTypeName] = 'yaml';
sources_scope.update_cache_timeout = 0;
properties_scope.parseType = 'yaml'; properties_scope.parseType = 'yaml';
function waitStop() { Wait('stop'); } function waitStop() { Wait('stop'); }
@@ -772,11 +789,6 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
$('#group-modal-dialog').hide(); $('#group-modal-dialog').hide();
$('#group-modal-dialog').dialog('destroy'); $('#group-modal-dialog').dialog('destroy');
$('#properties-tab').empty();
$('#sources-tab').empty();
$('#schedules-list').empty();
$('#schedules-form').empty();
$('#schedules-detail').empty();
modal_scope.cancelModal(); modal_scope.cancelModal();
}, },
open: function () { open: function () {
@@ -799,8 +811,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
else if ($(e.target).text() === 'Schedule') { else if ($(e.target).text() === 'Schedule') {
$('#schedules-overlay').hide(); $('#schedules-overlay').hide();
parent_scope.formShowing = true; GroupsScheduleList({ scope: modal_scope, url: schedules_url });
ScheduleList({ scope: parent_scope, url: schedules_url });
} }
}); });
@@ -808,6 +819,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
modal_scope.groupVariablesLoadedRemove(); modal_scope.groupVariablesLoadedRemove();
} }
modal_scope.groupVariablesLoadedRemove = modal_scope.$on('groupVariablesLoaded', function () { modal_scope.groupVariablesLoadedRemove = modal_scope.$on('groupVariablesLoaded', function () {
modal_scope.showSourceTab = (mode === 'edit' && group.has_inventory_sources && Empty(group.summary_fields.inventory_source.source)) ? false : true;
$('#group_tabs a:first').tab('show'); $('#group_tabs a:first').tab('show');
Wait('start'); Wait('start');
$('#group-modal-dialog').dialog('open'); $('#group-modal-dialog').dialog('open');
@@ -937,7 +949,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
key: 'value', key: 'value',
val: '' val: ''
}); });
parent_scope.showSourceTab = false; modal_scope.showSchedulesTab = false;
} }
}); });
@@ -949,6 +961,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
group = data;
for (var fld in GroupForm.fields) { for (var fld in GroupForm.fields) {
if (data[fld]) { if (data[fld]) {
properties_scope[fld] = data[fld]; properties_scope[fld] = data[fld];
@@ -1011,6 +1024,14 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
parent_scope.removeAddTreeRefreshed = parent_scope.$on('GroupTreeRefreshed', function() { parent_scope.removeAddTreeRefreshed = parent_scope.$on('GroupTreeRefreshed', function() {
//Clean up //Clean up
// Change the selected group
if (groups_reload && parent_scope.selected_tree_id !== tree_id) {
parent_scope.showHosts(tree_id, group_id, false);
} else {
Wait('stop');
}
WatchInventoryWindowResize();
parent_scope.removeAddTreeRefreshed();
if (modal_scope.searchCleanUp) { if (modal_scope.searchCleanUp) {
modal_scope.searchCleanup(); modal_scope.searchCleanup();
} }
@@ -1020,14 +1041,6 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
catch(e) { catch(e) {
// ignore // ignore
} }
// Change the selected group
if (groups_reload && parent_scope.selected_tree_id !== tree_id) {
parent_scope.showHosts(tree_id, group_id, false);
} else {
Wait('stop');
}
WatchInventoryWindowResize();
parent_scope.removeAddTreeRefreshed();
}); });
if (modal_scope.removeSaveComplete) { if (modal_scope.removeSaveComplete) {
@@ -1035,7 +1048,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
modal_scope.removeSaveComplete = modal_scope.$on('SaveComplete', function (e, error) { modal_scope.removeSaveComplete = modal_scope.$on('SaveComplete', function (e, error) {
if (!error) { if (!error) {
// Update the view with any changes // Update the parent view with any changes
if (groups_reload) { if (groups_reload) {
UpdateGroup({ UpdateGroup({
scope: parent_scope, scope: parent_scope,
@@ -1047,15 +1060,8 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
source: (sources_scope.source && sources_scope.source.value) ? sources_scope.source.value : '' source: (sources_scope.source && sources_scope.source.value) ? sources_scope.source.value : ''
} }
}); });
} else if (callback) { parent_scope.$emit('GroupTreeRefreshed');
try { } else if (base === 'inventories') {
$('#group-modal-dialog').dialog('close');
}
catch(err) {
//ignore
}
parent_scope.$emit(callback);
} else {
if (mode === 'add') { if (mode === 'add') {
BuildTree({ BuildTree({
scope: parent_scope, scope: parent_scope,
@@ -1067,6 +1073,14 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
else { else {
parent_scope.$emit('GroupTreeRefreshed'); parent_scope.$emit('GroupTreeRefreshed');
} }
} else if (base === 'home') {
parent_scope.restoreSearch();
try {
$('#group-modal-dialog').dialog('close');
}
catch(err) {
// ignore
}
} }
} }
}); });
@@ -1112,7 +1126,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
modal_scope.$emit('SaveComplete', false); modal_scope.$emit('SaveComplete', false);
}) })
.error(function (data, status) { .error(function (data, status) {
modal_scope.$emit('SaveComplete', true); $('#group_tabs a:eq(1)').tab('show');
ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!', ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!',
msg: 'Failed to update group inventory source. PUT status: ' + status }); msg: 'Failed to update group inventory source. PUT status: ' + status });
}); });
@@ -1129,6 +1143,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
modal_scope.$emit('formSaveSuccess'); modal_scope.$emit('formSaveSuccess');
}) })
.error(function (data, status) { .error(function (data, status) {
$('#group_tabs a:eq(0)').tab('show');
ProcessErrors(modal_scope, data, status, null, { hdr: 'Error!', ProcessErrors(modal_scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to update group variables. PUT status: ' + status }); msg: 'Failed to update group variables. PUT status: ' + status });
}); });
@@ -1136,19 +1151,18 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
// Cancel // Cancel
modal_scope.cancelModal = function () { modal_scope.cancelModal = function () {
Wait('stop');
try { try {
$('#group-modal-dialog').dialog('close'); $('#group-modal-dialog').dialog('close');
} }
catch(e) { catch(e) {
//ignore //ignore
} }
if (callback) {
parent_scope.$emit(callback); //if (modal_scope.searchCleanup) {
} // modal_scope.searchCleanup();
else { //}
if (modal_scope.searchCleanup) { if (base === 'inventories') {
modal_scope.searchCleanup();
}
WatchInventoryWindowResize(); WatchInventoryWindowResize();
} }
}; };
@@ -1183,7 +1197,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
}) })
.error(function (data, status) { .error(function (data, status) {
Wait('stop'); $('#group_tabs a:eq(0)').tab('show');
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!', ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
}); });
@@ -1192,6 +1206,8 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
else { else {
Rest.post(data) Rest.post(data)
.success(function (data) { .success(function (data) {
mode = 'edit'; // Once the group is saved, we're in edit mode. We may end up re-saving
// the group, if there is an error on the source
if (properties_scope.variables) { if (properties_scope.variables) {
sources_scope.source_url = data.related.inventory_source; sources_scope.source_url = data.related.inventory_source;
modal_scope.$emit('updateVariables', json_data, data.related.variable_data); modal_scope.$emit('updateVariables', json_data, data.related.variable_data);
@@ -1201,6 +1217,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
} }
}) })
.error(function (data, status) { .error(function (data, status) {
$('#group_tabs a:eq(0)').tab('show');
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!', ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
}); });
@@ -1233,7 +1250,7 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, SchedulePost, P
// Change the lookup and regions when the source changes // Change the lookup and regions when the source changes
sources_scope.sourceChange = function () { sources_scope.sourceChange = function () {
parent_scope.showSourceTab = (sources_scope.source && sources_scope.source.value) ? true : false; parent_scope.showSchedulesTab = (mode === 'edit' && sources_scope.source && sources_scope.source.value) ? true : false;
SourceChange({ scope: sources_scope, form: SourceForm }); SourceChange({ scope: sources_scope, form: SourceForm });
}; };

View File

@@ -269,7 +269,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
if (calcOnly) { if (calcOnly) {
scope.$emit('searchParamsReady', url); scope.$emit('searchParamsReady', url);
} }
else { else if (defaultUrl) {
Refresh({ Refresh({
scope: scope, scope: scope,
set: set, set: set,

View File

@@ -55,7 +55,7 @@ angular.module('SchedulesListDefinition', [])
refresh: { refresh: {
mode: 'all', mode: 'all',
awToolTip: "Refresh the page", awToolTip: "Refresh the page",
ngClick: "refreshSchedule()" ngClick: "refreshSchedules()"
}, },
stream: { stream: {
ngClick: "showActivity()", ngClick: "showActivity()",

View File

@@ -59,7 +59,7 @@ body.modal-open {
.pad-left-sm { padding-left: 10px; } .pad-left-sm { padding-left: 10px; }
.pad-left-lg { padding-left: 50px; } .pad-left-lg { padding-left: 50px; }
.normal-weight { font-weight: normal; } .normal-weight { font-weight: normal; }
.small-text { font-size: 12px; } .small-text { font-size: 12px; font-weight: normal; }
.no-bullets { list-style: none; } .no-bullets { list-style: none; }
.nowrap { white-space: nowrap; } .nowrap { white-space: nowrap; }
.capitalize { text-transform: capitalize; } .capitalize { text-transform: capitalize; }

View File

@@ -120,3 +120,7 @@ table.ui-datepicker-calendar {
} }
} }
} }
.ui-spinner a.ui-spinner-button {
border-left: 1px solid #A6C9E2;
}

View File

@@ -426,7 +426,10 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
ctrl.$setValidity('max', true); ctrl.$setValidity('max', true);
ctrl.$dirty = true; ctrl.$dirty = true;
ctrl.$render(); ctrl.$render();
scope.job_templates_form.$dirty = true; if (scope.job_templates_form) {
// need a way to find the parent form and mark it dirty
scope.job_templates_form.$dirty = true;
}
if (!scope.$$phase) { if (!scope.$$phase) {
scope.$digest(); scope.$digest();
} }
@@ -436,6 +439,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
opts.disabled = true; opts.disabled = true;
} }
$(elm).spinner(opts); $(elm).spinner(opts);
$(elm).on("click", function () {
$(elm).select();
});
} }
}; };
}]) }])

View File

@@ -17,9 +17,9 @@
<ul id="group_tabs" class="nav nav-tabs"> <ul id="group_tabs" class="nav nav-tabs">
<li class="active"><a id="properties_link" ng-click="toggleTab($event, 'properties_link', 'group_tabs')" <li class="active"><a id="properties_link" ng-click="toggleTab($event, 'properties_link', 'group_tabs')"
href="#properties-tab" data-toggle="tab">Properties</a></li> href="#properties-tab" data-toggle="tab">Properties</a></li>
<li><a id="source_link" ng-click="toggleTab($event, 'source_link', 'group_tabs')" <li ng-show="showSourceTab"><a id="source_link" ng-click="toggleTab($event, 'source_link', 'group_tabs')"
href="#sources-tab" data-toggle="tab">Source</a></li> href="#sources-tab" data-toggle="tab">Source</a></li>
<li ng-show="showSourceTab"><a id="schedules_link" ng-click="toggleTab($event, 'schedules_link', 'group_tabs')" <li ng-show="showSchedulesTab"><a id="schedules_link" ng-click="toggleTab($event, 'schedules_link', 'group_tabs')"
href="#schedules-tab" data-toggle="tab">Schedule</a></li> href="#schedules-tab" data-toggle="tab">Schedule</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">

View File

@@ -5,9 +5,9 @@
<ul id="group_tabs" class="nav nav-tabs"> <ul id="group_tabs" class="nav nav-tabs">
<li class="active"><a id="properties_link" ng-click="toggleTab($event, 'properties_link', 'group_tabs')" <li class="active"><a id="properties_link" ng-click="toggleTab($event, 'properties_link', 'group_tabs')"
href="#properties-tab" data-toggle="tab">Properties</a></li> href="#properties-tab" data-toggle="tab">Properties</a></li>
<li><a id="source_link" ng-click="toggleTab($event, 'source_link', 'group_tabs')" <li ng-show="showSourceTab"><a id="source_link" ng-click="toggleTab($event, 'source_link', 'group_tabs')"
href="#sources-tab" data-toggle="tab">Source</a></li> href="#sources-tab" data-toggle="tab">Source</a></li>
<li ng-show="showSourceTab"><a id="schedules_link" ng-click="toggleTab($event, 'schedules_link', 'group_tabs')" <li ng-show="showSchedulesTab"><a id="schedules_link" ng-click="toggleTab($event, 'schedules_link', 'group_tabs')"
href="#schedules-tab" data-toggle="tab">Schedule</a></li> href="#schedules-tab" data-toggle="tab">Schedule</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">