AC-423, AC-424, AC-425, AC-426 resolved issues.

This commit is contained in:
chouseknecht
2013-09-10 02:39:58 -04:00
parent eff8a6426a
commit de9c8a258c
12 changed files with 163 additions and 42 deletions

View File

@@ -144,12 +144,48 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
}
}
};
// Detect and alert user to potential SCM status issues
var checkSCMStatus = function(oldValue, newValue) {
if (oldValue !== newValue) {
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
Rest.get()
.success( function(data, status, headers, config) {
var msg;
switch(data.status) {
case 'failed':
msg = "The selected project has a <em>failed</em> status. Review the project's SCM settings" +
" and run an update before adding it to a template.";
break;
case 'never updated':
msg = 'The selected project has a <em>never updated</em> status. You will need to run a successful' +
' update in order to selected a playbook. Without a valid playbook you will not be able ' +
' to save this template.';
break;
case 'missing':
msg = 'The selected project has a status of <em>missing</em>. Please check the server and make sure ' +
' the directory exists and file permissions are set correctly.';
break;
}
if (msg) {
Alert('Waning', msg, 'alert-info');
}
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to get project ' + scope.project +'. GET returned status: ' + status });
});
}
}
// Register a watcher on project_name
if (scope.selectPlaybookUnregister) {
scope.selectPlaybookUnregister();
}
scope.selectPlaybookUnregister = scope.$watch('project_name', selectPlaybook);
scope.selectPlaybookUnregister = scope.$watch('project_name', function(oldval, newval) {
selectPlaybook(oldval, newval);
checkSCMStatus(oldval, newval);
});
LookUpInit({
scope: scope,
@@ -272,6 +308,39 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
});
}
}
// Detect and alert user to potential SCM status issues
var checkSCMStatus = function() {
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
Rest.get()
.success( function(data, status, headers, config) {
var msg;
switch(data.status) {
case 'failed':
msg = "The selected project has a <em>failed</em> status. Review the project's SCM settings" +
" and run an update before adding it to a template.";
break;
case 'never updated':
msg = 'The selected project has a <em>never updated</em> status. You will need to run a successful' +
' update in order to selected a playbook. Without a valid playbook you will not be able ' +
' to save this template.';
break;
case 'missing':
msg = 'The selected project has a status of <em>missing</em>. Please check the server and make sure ' +
' the directory exists and file permissions are set correctly.';
break;
}
if (msg) {
Alert('Waning', msg, 'alert-info');
}
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to get project ' + scope.project +'. GET returned status: ' + status });
});
}
// Register a watcher on project_name. Refresh the playbook list on change.
if (scope.selectPlaybookUnregister) {
@@ -281,6 +350,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
if (oldValue !== newValue && newValue !== '' && newValue !== null && newValue !== undefined) {
scope.playbook = null;
getPlaybooks(scope.project);
checkSCMStatus();
}
});

View File

@@ -13,7 +13,7 @@
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList,
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate, ProjectStatus,
FormatDate)
FormatDate)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@@ -34,11 +34,17 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
scope.projectsPostRefresh = scope.$on('PostRefresh', function() {
for (var i=0; i < scope.projects.length; i++) {
if (scope.projects[i].scm_type == null) {
// override the last_update_failed on manual projects- it should be false so we get a
// green badge. if projet scm_type changed from something to manual, last_update_failed
// will contain status of last update, which is not what we want.
scope.projects[i].last_update_failed = false;
switch(scope.projects[i].status) {
case 'updating':
case 'successful':
case 'ok':
scope.projects[i].badge = 'false';
break;
case 'never updated':
case 'failed':
case 'missing':
scope.projects[i].badge = 'true';
break;
}
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
FormatDate(new Date(scope.projects[i].last_updated)) : null;
@@ -89,7 +95,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
statusCheckRemove();
});
// Refresh the project list so we're looking at the latest data
// Refresh the project list so we're looking at the latest data
scope.search(list.iterator);
}
@@ -124,7 +130,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
scope.SCMUpdate = function(project_id) {
for (var i=0; i < scope.projects.length; i++) {
if (scope.projects[i].id == project_id) {
if (scope.projects[i].scm_type == "") {
if (scope.projects[i].scm_type == "" || scope.projects[i].scm_type == null ) {
Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
}
else if (scope.projects[i].status == 'updating') {
@@ -140,7 +146,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
ProjectsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'ProjectList', 'GenerateList',
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
'GetBasePath', 'SelectionInit', 'ProjectUpdate', 'ProjectStatus', 'FormatDate'];
'GetBasePath', 'SelectionInit', 'ProjectUpdate', 'ProjectStatus', 'FormatDate' ];
function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
@@ -162,7 +168,6 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
generator.reset();
LoadBreadCrumbs();
GetProjectPath({ scope: scope, master: master });
//console.log(scope.)
scope.scm_type = null;
master.scm_type = null;