fix: move node loading to jobs.job route and add auth logic
This commit is contained in:
parent
ee83fb8bb1
commit
c3a305f807
|
@ -67,9 +67,7 @@ export default class ClientsController extends Controller.extend(
|
|||
|
||||
@computed('store')
|
||||
get allNodes() {
|
||||
return this.store.peekAll('node').length
|
||||
? this.store.peekAll('node')
|
||||
: this.store.findAll('node');
|
||||
return this.store.peekAll('node');
|
||||
}
|
||||
|
||||
@computed('allNodes', 'jobClientStatus.byNode')
|
||||
|
|
|
@ -33,6 +33,11 @@ export default class JobRoute extends Route {
|
|||
relatedModelsQueries.push(job.get('recommendationSummaries'));
|
||||
}
|
||||
|
||||
// Optimizing future node look ups by preemptively loading everything
|
||||
if (job.get('hasClientStatus') && this.can.can('read client')) {
|
||||
relatedModelsQueries.push(this.store.findAll('node'));
|
||||
}
|
||||
|
||||
return RSVP.all(relatedModelsQueries).then(() => job);
|
||||
})
|
||||
.catch(notifyError(this));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
import Route from '@ember/routing/route';
|
||||
import { collect } from '@ember/object/computed';
|
||||
import {
|
||||
|
@ -9,9 +10,9 @@ import {
|
|||
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
||||
|
||||
export default class IndexRoute extends Route.extend(WithWatchers) {
|
||||
@service can;
|
||||
|
||||
async model() {
|
||||
// Optimizing future node look ups by preemptively loading everything
|
||||
await this.store.findAll('node');
|
||||
return this.modelFor('jobs.job');
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,8 @@ export default class IndexRoute extends Route.extend(WithWatchers) {
|
|||
list:
|
||||
model.get('hasChildren') &&
|
||||
this.watchAllJobs.perform({ namespace: model.namespace.get('name') }),
|
||||
nodes: model.get('hasClientStatus') && this.watchNodes.perform(),
|
||||
nodes:
|
||||
model.get('hasClientStatus') && this.can.can('read client') && this.watchNodes.perform(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue