github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/job-page/parts/job-client-status-summary.js (about)

     1  import Component from '@ember/component';
     2  import { action, computed } from '@ember/object';
     3  import { inject as service } from '@ember/service';
     4  import { camelize } from '@ember/string';
     5  import { classNames } from '@ember-decorators/component';
     6  import classic from 'ember-classic-decorator';
     7  import jobClientStatus from 'nomad-ui/utils/properties/job-client-status';
     8  
     9  @classic
    10  @classNames('boxed-section')
    11  export default class JobClientStatusSummary extends Component {
    12    @service router;
    13    @service store;
    14  
    15    @jobClientStatus('nodes', 'job') jobClientStatus;
    16  
    17    get nodes() {
    18      return this.store.peekAll('node');
    19    }
    20  
    21    job = null;
    22  
    23    @action
    24    gotoClients(statusFilter) {
    25      this.router.transitionTo('jobs.job.clients', this.job, {
    26        queryParams: {
    27          status: JSON.stringify(statusFilter),
    28        },
    29      });
    30    }
    31  
    32    @computed
    33    get isExpanded() {
    34      const storageValue = window.localStorage.nomadExpandJobClientStatusSummary;
    35      return storageValue != null ? JSON.parse(storageValue) : true;
    36    }
    37  
    38    @action
    39    onSliceClick(ev, slice) {
    40      this.gotoClients([camelize(slice.className)]);
    41    }
    42  
    43    persist(item, isOpen) {
    44      window.localStorage.nomadExpandJobClientStatusSummary = isOpen;
    45      this.notifyPropertyChange('isExpanded');
    46    }
    47  }