From 605d7a245f7e7fe11bdd59f90a6721cd10e15b43 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 6 Dec 2018 17:11:01 -0800 Subject: [PATCH] Model isRunning based on the client status of the allocation --- ui/app/models/allocation.js | 3 +++ ui/app/models/task-state.js | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/app/models/allocation.js b/ui/app/models/allocation.js index 1a7e030a5..5e370100b 100644 --- a/ui/app/models/allocation.js +++ b/ui/app/models/allocation.js @@ -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' }), diff --git a/ui/app/models/task-state.js b/ui/app/models/task-state.js index e0c8918c8..c8e25912b 100644 --- a/ui/app/models/task-state.js +++ b/ui/app/models/task-state.js @@ -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'));