2021-04-29 20:00:59 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2017-12-15 21:39:18 +00:00
|
|
|
import Route from '@ember/routing/route';
|
2021-04-29 20:00:59 +00:00
|
|
|
import RSVP from 'rsvp';
|
2018-03-01 00:27:15 +00:00
|
|
|
import { collect } from '@ember/object/computed';
|
2021-04-29 20:00:59 +00:00
|
|
|
import { watchAll, watchQuery } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2021-04-29 20:00:59 +00:00
|
|
|
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
|
|
|
|
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
|
|
|
|
|
2021-12-28 16:08:12 +00:00
|
|
|
export default class IndexRoute extends Route.extend(
|
|
|
|
WithWatchers,
|
|
|
|
WithForbiddenState
|
|
|
|
) {
|
2021-04-29 20:00:59 +00:00
|
|
|
@service store;
|
|
|
|
|
|
|
|
queryParams = {
|
|
|
|
qpNamespace: {
|
|
|
|
refreshModel: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
model(params) {
|
|
|
|
return RSVP.hash({
|
2021-12-28 16:08:12 +00:00
|
|
|
jobs: this.store
|
|
|
|
.query('job', { namespace: params.qpNamespace })
|
|
|
|
.catch(notifyForbidden(this)),
|
2021-04-29 20:00:59 +00:00
|
|
|
namespaces: this.store.findAll('namespace'),
|
|
|
|
});
|
|
|
|
}
|
2017-10-11 20:44:27 +00:00
|
|
|
|
2018-03-06 22:27:01 +00:00
|
|
|
startWatchers(controller) {
|
2021-04-29 20:00:59 +00:00
|
|
|
controller.set('namespacesWatch', this.watchNamespaces.perform());
|
2021-12-28 16:08:12 +00:00
|
|
|
controller.set(
|
|
|
|
'modelWatch',
|
|
|
|
this.watchJobs.perform({ namespace: controller.qpNamesapce })
|
|
|
|
);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-28 03:55:03 +00:00
|
|
|
|
2021-04-29 20:00:59 +00:00
|
|
|
@watchQuery('job') watchJobs;
|
|
|
|
@watchAll('namespace') watchNamespaces;
|
|
|
|
@collect('watchJobs', 'watchNamespaces') watchers;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|