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/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/models/job.js b/ui/app/models/job.js index 0ab6345ae..4681b502e 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -84,6 +84,16 @@ 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. + 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); }, 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}}