From ab69c2806caf04550b722d72d706ecbfc56be42d Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 15 Mar 2018 10:27:01 -0700 Subject: [PATCH 1/3] Use the job-summary information available from the jobs list --- ui/app/models/job.js | 5 +++++ ui/app/serializers/job.js | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/ui/app/models/job.js b/ui/app/models/job.js index 0ab6345ae..f9042ec39 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -84,6 +84,11 @@ export default Model.extend({ taskGroups: fragmentArray('task-group', { defaultValue: () => [] }), summary: belongsTo('job-summary'), + // If a job has only been loaded through the list request, the task groups + // are still unknown. However, the count of task groups is available through + // the job-summary model which is embedded in the jobs list response. + taskGroupCount: or('taskGroups.length', 'taskGroupSummaries.length'), + // Alias through to the summary, as if there was no relationship taskGroupSummaries: alias('summary.taskGroupSummaries'), queuedAllocs: alias('summary.queuedAllocs'), diff --git a/ui/app/serializers/job.js b/ui/app/serializers/job.js index 7271f86d8..d4fad4d67 100644 --- a/ui/app/serializers/job.js +++ b/ui/app/serializers/job.js @@ -33,6 +33,14 @@ export default ApplicationSerializer.extend({ hash.ParameterizedJob = true; } + // If the hash contains summary information, push it into the store + // as a job-summary model. + if (hash.JobSummary) { + this.store.pushPayload('job-summary', { + 'job-summary': [hash.JobSummary], + }); + } + return this._super(typeHash, hash); }, From c8b3e91d4a3136af71aa6aad25360a0871a563f4 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 15 Mar 2018 10:27:29 -0700 Subject: [PATCH 2/3] Update job row to no longer watch job-summary or reload the job Now that job summary is pushed into the store from the list request and the task group count is derived from the summary, the detailed job information is no longer needed for a job row. --- ui/app/components/job-row.js | 32 +------------------------ ui/app/templates/components/job-row.hbs | 4 ++-- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/ui/app/components/job-row.js b/ui/app/components/job-row.js index b48913dfc..2b17061eb 100644 --- a/ui/app/components/job-row.js +++ b/ui/app/components/job-row.js @@ -1,10 +1,8 @@ import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { lazyClick } from '../helpers/lazy-click'; -import { watchRelationship } from 'nomad-ui/utils/properties/watch'; -import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection'; -export default Component.extend(WithVisibilityDetection, { +export default Component.extend({ store: service(), tagName: 'tr', @@ -17,32 +15,4 @@ export default Component.extend(WithVisibilityDetection, { click(event) { lazyClick([this.get('onClick'), event]); }, - - didReceiveAttrs() { - // Reload the job in order to get detail information - const job = this.get('job'); - if (job && !job.get('isLoading')) { - job.reload().then(() => { - this.get('watch').perform(job, 100); - }); - } - }, - - visibilityHandler() { - if (document.hidden) { - this.get('watch').cancelAll(); - } else { - const job = this.get('job'); - if (job && !job.get('isLoading')) { - this.get('watch').perform(job, 100); - } - } - }, - - willDestroy() { - this.get('watch').cancelAll(); - this._super(...arguments); - }, - - watch: watchRelationship('summary'), }); diff --git a/ui/app/templates/components/job-row.hbs b/ui/app/templates/components/job-row.hbs index a412279fd..64be67c44 100644 --- a/ui/app/templates/components/job-row.hbs +++ b/ui/app/templates/components/job-row.hbs @@ -5,8 +5,8 @@ {{job.displayType}} {{job.priority}} - {{#if job.taskGroups.length}} - {{job.taskGroups.length}} + {{#if job.taskGroupCount}} + {{job.taskGroupCount}} {{else}} -- {{/if}} From 23cfbb9c277271e2d77ad88f4aa9a24288fc1514 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 15 Mar 2018 14:03:14 -0700 Subject: [PATCH 3/3] Ensure the task group is present whenever an allocation row is rendered --- ui/app/components/allocation-row.js | 3 +++ ui/app/models/job.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/ui/app/components/allocation-row.js b/ui/app/components/allocation-row.js index 5625c092f..088c07a82 100644 --- a/ui/app/components/allocation-row.js +++ b/ui/app/components/allocation-row.js @@ -58,6 +58,9 @@ function qualifyJob() { job, originalJobId: null, }); + if (job.get('isPartial')) { + job.reload(); + } } else { this.get('store') .findRecord('job', allocation.get('originalJobId')) diff --git a/ui/app/models/job.js b/ui/app/models/job.js index f9042ec39..4681b502e 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -84,6 +84,11 @@ export default Model.extend({ taskGroups: fragmentArray('task-group', { defaultValue: () => [] }), summary: belongsTo('job-summary'), + // A job model created from the jobs list response will be lacking + // task groups. This is an indicator that it needs to be reloaded + // if task group information is important. + isPartial: equal('taskGroups.length', 0), + // If a job has only been loaded through the list request, the task groups // are still unknown. However, the count of task groups is available through // the job-summary model which is embedded in the jobs list response.