2017-09-19 14:47:10 +00:00
|
|
|
import Ember from 'ember';
|
2017-09-26 18:57:46 +00:00
|
|
|
import { lazyClick } from '../helpers/lazy-click';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-10-18 00:51:40 +00:00
|
|
|
const { Component, inject, run } = Ember;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
export default Component.extend({
|
2017-10-05 22:21:10 +00:00
|
|
|
store: inject.service(),
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
classNames: ['allocation-row', 'is-interactive'],
|
|
|
|
|
|
|
|
allocation: null,
|
|
|
|
|
|
|
|
// Used to determine whether the row should mention the node or the job
|
|
|
|
context: null,
|
|
|
|
|
|
|
|
onClick() {},
|
|
|
|
|
|
|
|
click(event) {
|
2017-09-26 18:57:46 +00:00
|
|
|
lazyClick([this.get('onClick'), event]);
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
2017-10-04 00:18:33 +00:00
|
|
|
|
|
|
|
didReceiveAttrs() {
|
2017-10-05 22:21:10 +00:00
|
|
|
// TODO: Use this code again once the temporary workaround below
|
|
|
|
// is resolved.
|
|
|
|
|
2017-10-04 00:18:33 +00:00
|
|
|
// If the job for this allocation is incomplete, reload it to get
|
|
|
|
// detailed information.
|
2017-10-05 22:21:10 +00:00
|
|
|
// const allocation = this.get('allocation');
|
|
|
|
// if (
|
|
|
|
// allocation &&
|
|
|
|
// allocation.get('job') &&
|
|
|
|
// !allocation.get('job.isPending') &&
|
|
|
|
// !allocation.get('taskGroup')
|
|
|
|
// ) {
|
|
|
|
// const job = allocation.get('job.content');
|
|
|
|
// job && job.reload();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// TEMPORARY: https://github.com/emberjs/data/issues/5209
|
|
|
|
// Ember Data doesn't like it when relationships aren't reflective,
|
|
|
|
// which means the allocation's job will be null if it hasn't been
|
|
|
|
// resolved through the allocation (allocation.get('job')) before
|
|
|
|
// being resolved through the store (store.findAll('job')). The
|
|
|
|
// workaround is to persist the jobID as a string on the allocation
|
|
|
|
// and manually re-link the two records here.
|
|
|
|
|
2017-10-18 00:51:40 +00:00
|
|
|
run.next(() => {
|
|
|
|
const allocation = this.get('allocation');
|
|
|
|
const job = this.get('store').peekRecord('job', allocation.get('originalJobId'));
|
|
|
|
if (job) {
|
|
|
|
allocation.set('job', job);
|
|
|
|
} else {
|
|
|
|
this.get('store')
|
|
|
|
.findRecord('job', allocation.get('originalJobId'))
|
|
|
|
.then(job => {
|
|
|
|
allocation.set('job', job);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-10-04 00:18:33 +00:00
|
|
|
},
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|