diff --git a/ui/app/adapters/job.js b/ui/app/adapters/job.js index 2999988fa..a8c09ce09 100644 --- a/ui/app/adapters/job.js +++ b/ui/app/adapters/job.js @@ -77,6 +77,9 @@ export default Watchable.extend({ Job: job.get('_newDefinitionJSON'), Diff: true, }, + }).then(json => { + json.ID = job.get('id'); + this.get('store').pushPayload('job-plan', { jobPlans: [json] }); }); }, diff --git a/ui/app/components/placement-failure.js b/ui/app/components/placement-failure.js new file mode 100644 index 000000000..b8052235f --- /dev/null +++ b/ui/app/components/placement-failure.js @@ -0,0 +1,10 @@ +import Component from '@ember/component'; +import { or } from '@ember/object/computed'; + +export default Component.extend({ + // Either provide a taskGroup or a failedTGAlloc + taskGroup: null, + failedTGAlloc: null, + + placementFailures: or('taskGroup.placementFailures', 'failedTGAlloc'), +}); diff --git a/ui/app/controllers/jobs/run.js b/ui/app/controllers/jobs/run.js index 2c1eca1fe..79525e460 100644 --- a/ui/app/controllers/jobs/run.js +++ b/ui/app/controllers/jobs/run.js @@ -1,10 +1,13 @@ import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; import { computed } from '@ember/object'; import { task } from 'ember-concurrency'; import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error'; import localStorageProperty from 'nomad-ui/utils/properties/local-storage'; export default Controller.extend({ + store: service(), + parseError: null, planError: null, runError: null, @@ -30,8 +33,9 @@ export default Controller.extend({ } try { - const planOutput = yield this.get('model').plan(); - this.set('planOutput', planOutput.Diff); + yield this.get('model').plan(); + const plan = this.get('store').peekRecord('job-plan', this.get('model.id')); + this.set('planOutput', plan); } catch (err) { const error = messageFromAdapterError(err) || 'Could not plan job'; this.set('planError', error); diff --git a/ui/app/models/job-plan.js b/ui/app/models/job-plan.js new file mode 100644 index 000000000..8f9c10345 --- /dev/null +++ b/ui/app/models/job-plan.js @@ -0,0 +1,8 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { fragmentArray } from 'ember-data-model-fragments/attributes'; + +export default Model.extend({ + diff: attr(), + failedTGAllocs: fragmentArray('placement-failure', { defaultValue: () => [] }), +}); diff --git a/ui/app/serializers/job-plan.js b/ui/app/serializers/job-plan.js new file mode 100644 index 000000000..028073438 --- /dev/null +++ b/ui/app/serializers/job-plan.js @@ -0,0 +1,12 @@ +import { get } from '@ember/object'; +import { assign } from '@ember/polyfills'; +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + normalize(typeHash, hash) { + hash.FailedTGAllocs = Object.keys(hash.FailedTGAllocs || {}).map(key => { + return assign({ Name: key }, get(hash, `FailedTGAllocs.${key}`) || {}); + }); + return this._super(...arguments); + }, +}); diff --git a/ui/app/templates/components/placement-failure.hbs b/ui/app/templates/components/placement-failure.hbs index 63f49a826..9cf7089ec 100644 --- a/ui/app/templates/components/placement-failure.hbs +++ b/ui/app/templates/components/placement-failure.hbs @@ -1,7 +1,7 @@ -{{#if taskGroup.placementFailures}} - {{#with taskGroup.placementFailures as |failures|}} +{{#if placementFailures}} + {{#with placementFailures as |failures|}}