open-nomad/ui/app/components/job-page/parts/job-client-status-summary.js
Phil Renaud 311a6d82c9
Importing string methods directly from @ember/string (#12499)
* Capitalize methods

* Let ESLint yell at us again

* Dasherize
2022-04-07 15:51:41 -04:00

48 lines
1.2 KiB
JavaScript

import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { camelize } from '@ember/string';
import { classNames } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
import jobClientStatus from 'nomad-ui/utils/properties/job-client-status';
@classic
@classNames('boxed-section')
export default class JobClientStatusSummary extends Component {
@service router;
@service store;
@jobClientStatus('nodes', 'job') jobClientStatus;
get nodes() {
return this.store.peekAll('node');
}
job = null;
@action
gotoClients(statusFilter) {
this.router.transitionTo('jobs.job.clients', this.job, {
queryParams: {
status: JSON.stringify(statusFilter),
},
});
}
@computed
get isExpanded() {
const storageValue = window.localStorage.nomadExpandJobClientStatusSummary;
return storageValue != null ? JSON.parse(storageValue) : true;
}
@action
onSliceClick(ev, slice) {
this.gotoClients([camelize(slice.className)]);
}
persist(item, isOpen) {
window.localStorage.nomadExpandJobClientStatusSummary = isOpen;
this.notifyPropertyChange('isExpanded');
}
}