Model isRunning based on the client status of the allocation
This commit is contained in:
parent
48adb393d8
commit
076ae5046b
|
@ -1,5 +1,6 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
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';
|
||||
|
@ -38,6 +39,8 @@ export default Model.extend({
|
|||
return STATUS_ORDER[this.get('clientStatus')] || 100;
|
||||
}),
|
||||
|
||||
isRunning: equal('clientStatus', 'running'),
|
||||
|
||||
// When allocations are server-side rescheduled, a paper trail
|
||||
// is left linking all reschedule attempts.
|
||||
previousAllocation: belongsTo('allocation', { inverse: 'nextAllocation' }),
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { none } from '@ember/object/computed';
|
||||
import { computed } from '@ember/object';
|
||||
import { alias } from '@ember/object/computed';
|
||||
import { alias, none } from '@ember/object/computed';
|
||||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import attr from 'ember-data/attr';
|
||||
import { fragment, fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default Fragment.extend({
|
||||
allocation: fragmentOwner(),
|
||||
|
||||
name: attr('string'),
|
||||
state: attr('string'),
|
||||
startedAt: attr('date'),
|
||||
|
@ -13,8 +14,8 @@ export default Fragment.extend({
|
|||
failed: attr('boolean'),
|
||||
|
||||
isActive: none('finishedAt'),
|
||||
isRunning: alias('allocation.isRunning'),
|
||||
|
||||
allocation: fragmentOwner(),
|
||||
task: computed('allocation.taskGroup.tasks.[]', function() {
|
||||
const tasks = this.get('allocation.taskGroup.tasks');
|
||||
return tasks && tasks.findBy('name', this.get('name'));
|
||||
|
|
Loading…
Reference in New Issue