From 3d3782fcee8f0eb0a2bc213e52a3a0fac30fd7d5 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Mon, 20 May 2013 00:05:26 -0400 Subject: [PATCH] Job Events detail page starting to work. --- lib/ui/static/css/ansible-ui.css | 6 ++ lib/ui/static/js/app.js | 6 +- lib/ui/static/js/controllers/Jobs.js | 57 +++++++++++++- lib/ui/static/js/forms/JobEvents.js | 74 ++++++++++++++++++ lib/ui/static/js/forms/Jobs.js | 5 +- lib/ui/static/js/lists/Credentials.js | 2 +- lib/ui/static/js/lists/Groups.js | 2 +- lib/ui/static/js/lists/Hosts.js | 2 +- lib/ui/static/js/lists/Inventories.js | 2 +- lib/ui/static/js/lists/JobTemplates.js | 4 +- lib/ui/static/js/lists/Jobs.js | 10 +-- lib/ui/static/js/lists/Organizations.js | 4 +- lib/ui/static/js/lists/Projects.js | 2 +- lib/ui/static/js/lists/Teams.js | 2 +- lib/ui/static/js/lists/Users.js | 2 +- lib/ui/static/lib/ansible/form-generator.js | 84 +++++++++++---------- lib/ui/templates/ui/index.html | 1 + 17 files changed, 205 insertions(+), 60 deletions(-) create mode 100644 lib/ui/static/js/forms/JobEvents.js diff --git a/lib/ui/static/css/ansible-ui.css b/lib/ui/static/css/ansible-ui.css index 017c22b754..d0aafec9b5 100644 --- a/lib/ui/static/css/ansible-ui.css +++ b/lib/ui/static/css/ansible-ui.css @@ -267,5 +267,11 @@ .job-pending, .job-running { color: #5bb75b; } + + .job-detail-status { + font-size: 15px; + font-weight: bold; + padding-left: 15px; + } /* End Jobs Page */ diff --git a/lib/ui/static/js/app.js b/lib/ui/static/js/app.js index 53a0a4c275..aab51d05fb 100644 --- a/lib/ui/static/js/app.js +++ b/lib/ui/static/js/app.js @@ -46,7 +46,8 @@ angular.module('ansible', [ 'JobTemplateHelper', 'ProjectsListDefinition', 'JobsListDefinition', - 'JobFormDefinition' + 'JobFormDefinition', + 'JobEventFormDefinition' ]) .config(['$routeProvider', function($routeProvider) { $routeProvider. @@ -55,6 +56,9 @@ angular.module('ansible', [ when('/jobs/:id', { templateUrl: urlPrefix + 'partials/jobs.html', controller: JobsEdit }). + + when('/jobs/:id/job_events', + { templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEvents }). when('/job_templates', { templateUrl: urlPrefix + 'partials/job_templates.html', controller: JobTemplatesList }). diff --git a/lib/ui/static/js/controllers/Jobs.js b/lib/ui/static/js/controllers/Jobs.js index 1dc0b94f1f..7834e718a8 100644 --- a/lib/ui/static/js/controllers/Jobs.js +++ b/lib/ui/static/js/controllers/Jobs.js @@ -31,6 +31,11 @@ function JobsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Aler scope.editJob = function(id) { $location.path($location.path() + '/' + id); } + + scope.viewEvents = function(id) { + console.log('headed to: ' + $location.path() + '/' + id + '/job_events'); + $location.path($location.path() + '/' + id + '/job_events'); + } } @@ -265,4 +270,54 @@ JobsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$ 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit', 'PromptPasswords', 'GetBasePath' - ]; + ]; + + +function JobEvents ($scope, $rootScope, $compile, $location, $log, $routeParams, JobEventForm, + GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath) +{ + ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior + //scope. + + // Inject dynamic view + var form = JobEventForm; + var generator = GenerateForm; + var scope = GenerateForm.inject(form, {mode: 'edit', related: true}); + generator.reset(); + + var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events'; + var base = $location.path().replace(/^\//,'').split('/')[0]; + var master = {}; + var id = $routeParams.id; + var relatedSets = {}; + + + // Retrieve detail record and prepopulate the form + Rest.setUrl(defaultUrl); + Rest.get({ params: {page_size: 1} }) + .success( function(data, status, headers, config) { + LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name }); + for (var fld in form.fields) { + if (data[fld]) { + scope[fld] = data[fld]; + } + } + for (var fld in form.items) { + if (data[fld]) { + scope[fld] = data[fld]; + } + } + scope['event_satus'] = (data.failed) ? 'failed' : 'success'; + scope.next = data.next; + scope.previous = data.previous; + }) + .error( function(data, status, headers, config) { + ProcessErrors(scope, data, status, form, + { hdr: 'Error!', msg: 'Failed to retrieve job event data: ' + $routeParams.id + '. GET status: ' + status }); + }); + +} + +JobEvents.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobEventForm', + 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath' ]; + diff --git a/lib/ui/static/js/forms/JobEvents.js b/lib/ui/static/js/forms/JobEvents.js new file mode 100644 index 0000000000..566bdfbcc5 --- /dev/null +++ b/lib/ui/static/js/forms/JobEvents.js @@ -0,0 +1,74 @@ +/********************************************* + * Copyright (c) 2013 AnsibleWorks, Inc. + * + * JobEvents.js + * Form definition for Job Events model + * + * + */ +angular.module('JobEventFormDefinition', []) + .value( + 'JobEventForm', { + + editTitle: '{{ name }} Events', //Legend in edit mode + name: 'job_events', + well: true, + formInline: true, + + fields: { + job: { + label: 'Job ID', + type: 'text', + readonly: true + }, + name: { + label: 'Name', + type: 'text', + sourceModel: 'job', + sourceField: 'name', + readonly: true + }, + description: { + label: 'Description', + type: 'text', + sourceModel: 'job', + sourceField: 'description', + readonly: true + } + }, + + buttons: { + + }, + + items: { + event: { + label: 'Event', + type: 'text', + readonly: true + }, + created: { + label: 'Event Timestamp', + type: 'text', + readonly: true + }, + event_status: { + label: 'Event Status \{\{ status \}\}', + type: 'text', + readonly: true, + control: false + }, + event_data: { + label: 'Event Data', + type: 'textarea', + class: 'span12', + rows: 10 + } + }, + + related: { //related colletions (and maybe items?) + + } + + }); //Form + diff --git a/lib/ui/static/js/forms/Jobs.js b/lib/ui/static/js/forms/Jobs.js index 6fb03ab131..ed05c2b09d 100644 --- a/lib/ui/static/js/forms/Jobs.js +++ b/lib/ui/static/js/forms/Jobs.js @@ -138,11 +138,10 @@ angular.module('JobFormDefinition', []) statusFields: { status: { - label: 'Status', + label: 'Job Status \{\{ status \}\}', type: 'text', readonly: true, - icon: 'icon-circle', - class: 'job-\{\{ job.status \}\}' + control: false }, result_stdout: { label: 'Standard Out', diff --git a/lib/ui/static/js/lists/Credentials.js b/lib/ui/static/js/lists/Credentials.js index 8b2cd981d0..c9df19f878 100644 --- a/lib/ui/static/js/lists/Credentials.js +++ b/lib/ui/static/js/lists/Credentials.js @@ -55,7 +55,7 @@ angular.module('CredentialsListDefinition', []) ngClick: "editCredential(\{\{ credential.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit credential' + awToolTip: 'View/Edit credential' }, delete: { diff --git a/lib/ui/static/js/lists/Groups.js b/lib/ui/static/js/lists/Groups.js index d0d5aba1bd..8cfce4fff3 100644 --- a/lib/ui/static/js/lists/Groups.js +++ b/lib/ui/static/js/lists/Groups.js @@ -42,7 +42,7 @@ angular.module('GroupListDefinition', []) ngClick: "editGroup(\{\{ group.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit group' + awToolTip: 'View/Edit group' }, delete: { diff --git a/lib/ui/static/js/lists/Hosts.js b/lib/ui/static/js/lists/Hosts.js index bff2f3da1d..a3580138b3 100644 --- a/lib/ui/static/js/lists/Hosts.js +++ b/lib/ui/static/js/lists/Hosts.js @@ -42,7 +42,7 @@ angular.module('HostListDefinition', []) ngClick: "editHost(\{\{ host.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit host' + awToolTip: 'View/Edit host' }, delete: { diff --git a/lib/ui/static/js/lists/Inventories.js b/lib/ui/static/js/lists/Inventories.js index 59b8539389..4a0189b415 100644 --- a/lib/ui/static/js/lists/Inventories.js +++ b/lib/ui/static/js/lists/Inventories.js @@ -48,7 +48,7 @@ angular.module('InventoriesListDefinition', []) ngClick: "editInventory(\{\{ inventory.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit' + awToolTip: 'View/Edit inventory' }, delete: { diff --git a/lib/ui/static/js/lists/JobTemplates.js b/lib/ui/static/js/lists/JobTemplates.js index e92c4b40cc..adfc8cf916 100644 --- a/lib/ui/static/js/lists/JobTemplates.js +++ b/lib/ui/static/js/lists/JobTemplates.js @@ -42,13 +42,13 @@ angular.module('JobTemplatesListDefinition', []) edit: { ngClick: "editJobTemplate(\{\{ job_template.id \}\})", icon: 'icon-edit', - awToolTip: 'Edit template', + awToolTip: 'View/Edit template', class: 'btn-mini' }, submit: { icon: 'icon-play', mode: 'all', - class: 'btn-mini', + class: 'btn-mini btn-success', ngClick: 'submitJob(\{\{ job_template.id \}\})', awToolTip: 'Create and run a job using this template' }, diff --git a/lib/ui/static/js/lists/Jobs.js b/lib/ui/static/js/lists/Jobs.js index d5be9f6fd3..87213869e9 100644 --- a/lib/ui/static/js/lists/Jobs.js +++ b/lib/ui/static/js/lists/Jobs.js @@ -46,13 +46,13 @@ angular.module('JobsListDefinition', []) ngClick: "editJob(\{\{ job.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit/View detail', + awToolTip: 'View/Edit detail', }, summary: { title: 'Summary', icon: 'icon-filter', - ngClick: 'viewSummary()', - class: 'btn-info btn-mini', + ngClick: 'viewSummary(\{{ job.id \}\})', + class: 'btn-success btn-mini', awToolTip: 'View host summary', ngDisabled: "job.status == 'new'" }, @@ -60,8 +60,8 @@ angular.module('JobsListDefinition', []) title: 'Detail', icon: 'icon-list-ul', mode: 'all', - ngClick: 'viewEvents()', - class: 'btn-info btn-mini', + ngClick: 'viewEvents(\{{ job.id \}\})', + class: 'btn-success btn-mini', awToolTip: 'View events', ngDisabled: "job.status == 'new'" }, diff --git a/lib/ui/static/js/lists/Organizations.js b/lib/ui/static/js/lists/Organizations.js index 772d426e3e..5b91876bb3 100644 --- a/lib/ui/static/js/lists/Organizations.js +++ b/lib/ui/static/js/lists/Organizations.js @@ -41,14 +41,14 @@ angular.module('OrganizationListDefinition', []) ngClick: "editOrganization(\{\{ organization.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit' + awToolTip: 'View/Edit organization' }, delete: { ngClick: "deleteOrganization(\{\{ organization.id \}\},'\{\{ organization.name \}\}')", icon: 'icon-remove', class: 'btn-mini btn-danger', - awToolTip: 'Delete' + awToolTip: 'Delete organization' } } }); diff --git a/lib/ui/static/js/lists/Projects.js b/lib/ui/static/js/lists/Projects.js index c757c844fb..ac1f5582ea 100644 --- a/lib/ui/static/js/lists/Projects.js +++ b/lib/ui/static/js/lists/Projects.js @@ -42,7 +42,7 @@ angular.module('ProjectsListDefinition', []) ngClick: "editProject(\{\{ project.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit project' + awToolTip: 'View/edit project' }, delete: { diff --git a/lib/ui/static/js/lists/Teams.js b/lib/ui/static/js/lists/Teams.js index 45c2b97e3e..b54feae310 100644 --- a/lib/ui/static/js/lists/Teams.js +++ b/lib/ui/static/js/lists/Teams.js @@ -48,7 +48,7 @@ angular.module('TeamsListDefinition', []) ngClick: "editTeam(\{\{ team.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit team' + awToolTip: 'View/Edit team' }, delete: { diff --git a/lib/ui/static/js/lists/Users.js b/lib/ui/static/js/lists/Users.js index 76850b078e..d4c5dd35ef 100644 --- a/lib/ui/static/js/lists/Users.js +++ b/lib/ui/static/js/lists/Users.js @@ -47,7 +47,7 @@ angular.module('UserListDefinition', []) ngClick: "editUser(\{\{ user.id \}\})", icon: 'icon-edit', class: 'btn-mini', - awToolTip: 'Edit user' + awToolTip: 'View/Edit user' }, delete: { diff --git a/lib/ui/static/lib/ansible/form-generator.js b/lib/ui/static/lib/ansible/form-generator.js index c2e45e4070..c7c88160a9 100644 --- a/lib/ui/static/lib/ansible/form-generator.js +++ b/lib/ui/static/lib/ansible/form-generator.js @@ -154,48 +154,54 @@ angular.module('FormGenerator', ['GeneratorHelpers']) html += "
' + field.label + '' + "\n"; + html += "' + "\n"; html += "
\n"; html += (field.clear) ? "
\n" : ""; - html += "\n"; - html += "
\n"; + if (field.control === null || field.control === undefined || field.control) { + html += "\n"; + html += "
\n"; + } + if (field.ask) { + html += " \n"; + } + html += "
\n"; + // Add error messages + if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) { + html += "A value is required!\n"; + } + if (field.type == "email") { + html += "A valid email address is required!\n"; + } + if (field.awPassMatch) { + html += "Must match Password value\n"; + } + html += "\n"; } - if (field.ask) { - html += " \n"; - } - html += "
\n"; - // Add error messages - if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) { - html += "A value is required!\n"; - } - if (field.type == "email") { - html += "A valid email address is required!\n"; - } - if (field.awPassMatch) { - html += "Must match Password value\n"; - } - html += "\n"; html += "
\n"; html += "\n"; } diff --git a/lib/ui/templates/ui/index.html b/lib/ui/templates/ui/index.html index 4d72f2232e..b9f41a2042 100644 --- a/lib/ui/templates/ui/index.html +++ b/lib/ui/templates/ui/index.html @@ -45,6 +45,7 @@ +