open-nomad/ui/app/routes/jobs/index.js
Phil Renaud ffb4c63af7
[ui] Adds meta to job list stub and displays a pack logo on the jobs index (#14833)
* Adds meta to job list stub and displays a pack logo on the jobs index

* Changelog

* Modifying struct for optional meta param

* Explicitly ask for meta anytime I look up a job from index or job page

* Test case for the endpoint

* adding meta field to API struct and ommitting from response if empty

* passthru method added to api/jobs.list

* Meta param listed in docs for jobs list

* Update api/jobs.go

Co-authored-by: Tim Gross <tgross@hashicorp.com>

Co-authored-by: Tim Gross <tgross@hashicorp.com>
2022-11-02 16:58:24 -04:00

43 lines
1.2 KiB
JavaScript

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
import { collect } from '@ember/object/computed';
import { watchAll, watchQuery } from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
export default class IndexRoute extends Route.extend(
WithWatchers,
WithForbiddenState
) {
@service store;
queryParams = {
qpNamespace: {
refreshModel: true,
},
};
model(params) {
return RSVP.hash({
jobs: this.store
.query('job', { namespace: params.qpNamespace, meta: true })
.catch(notifyForbidden(this)),
namespaces: this.store.findAll('namespace'),
});
}
startWatchers(controller) {
controller.set('namespacesWatch', this.watchNamespaces.perform());
controller.set(
'modelWatch',
this.watchJobs.perform({ namespace: controller.qpNamespace, meta: true })
);
}
@watchQuery('job') watchJobs;
@watchAll('namespace') watchNamespaces;
@collect('watchJobs', 'watchNamespaces') watchers;
}