diff --git a/ui/app/models/allocation.js b/ui/app/models/allocation.js index b4563bf39..377904da8 100644 --- a/ui/app/models/allocation.js +++ b/ui/app/models/allocation.js @@ -3,7 +3,7 @@ import { computed } from '@ember/object'; import { equal } from '@ember/object/computed'; import Model from 'ember-data/model'; import attr from 'ember-data/attr'; -import { belongsTo } from 'ember-data/relationships'; +import { belongsTo, hasMany } from 'ember-data/relationships'; import { fragment, fragmentArray } from 'ember-data-model-fragments/attributes'; import intersection from 'lodash.intersection'; import shortUUIDProperty from '../utils/properties/short-uuid'; @@ -46,6 +46,9 @@ export default Model.extend({ previousAllocation: belongsTo('allocation', { inverse: 'nextAllocation' }), nextAllocation: belongsTo('allocation', { inverse: 'previousAllocation' }), + preemptedAllocations: hasMany('allocation', { inverse: 'preemptedByAllocation' }), + preemptedByAllocation: belongsTo('allocation', { inverse: 'preemptedAllocations' }), + followUpEvaluation: belongsTo('evaluation'), statusClass: computed('clientStatus', function() { @@ -88,9 +91,11 @@ export default Model.extend({ 'clientStatus', 'followUpEvaluation.content', function() { - return !this.get('nextAllocation.content') && - !this.get('followUpEvaluation.content') && - this.clientStatus === 'failed'; + return ( + !this.get('nextAllocation.content') && + !this.get('followUpEvaluation.content') && + this.clientStatus === 'failed' + ); } ), }); diff --git a/ui/app/models/job-plan.js b/ui/app/models/job-plan.js index 8f9c10345..1ddc3d4b8 100644 --- a/ui/app/models/job-plan.js +++ b/ui/app/models/job-plan.js @@ -1,8 +1,10 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; import { fragmentArray } from 'ember-data-model-fragments/attributes'; +import { hasMany } from 'ember-data/relationships'; export default Model.extend({ diff: attr(), failedTGAllocs: fragmentArray('placement-failure', { defaultValue: () => [] }), + preemptions: hasMany('allocation'), }); diff --git a/ui/app/serializers/allocation.js b/ui/app/serializers/allocation.js index 08da6e6c4..50f2b004d 100644 --- a/ui/app/serializers/allocation.js +++ b/ui/app/serializers/allocation.js @@ -45,6 +45,9 @@ export default ApplicationSerializer.extend({ hash.NextAllocationID = hash.NextAllocation ? hash.NextAllocation : null; hash.FollowUpEvaluationID = hash.FollowupEvalID ? hash.FollowupEvalID : null; + hash.PreemptedAllocationIDs = hash.PreemptedAllocations || []; + hash.PreemptedByAllocationID = hash.PreemptedByAllocation || null; + return this._super(typeHash, hash); }, }); diff --git a/ui/app/serializers/job-plan.js b/ui/app/serializers/job-plan.js index 19f9556d3..e44e47d6f 100644 --- a/ui/app/serializers/job-plan.js +++ b/ui/app/serializers/job-plan.js @@ -1,5 +1,6 @@ import { assign } from '@ember/polyfills'; import ApplicationSerializer from './application'; +import { get } from '@ember/object'; export default ApplicationSerializer.extend({ normalize(typeHash, hash) { @@ -7,6 +8,7 @@ export default ApplicationSerializer.extend({ hash.FailedTGAllocs = Object.keys(failures).map(key => { return assign({ Name: key }, failures[key] || {}); }); + hash.PreemptionIDs = (get(hash, 'Annotations.PreemptedAllocs') || []).mapBy('ID'); return this._super(...arguments); }, });