github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/job-page/parts/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 { classNames } from '@ember-decorators/component';
     5  import classic from 'ember-classic-decorator';
     6  import { camelize } from '@ember/string';
     7  @classic
     8  @classNames('boxed-section')
     9  export default class Summary extends Component {
    10    @service router;
    11  
    12    job = null;
    13    forceCollapsed = false;
    14  
    15    @action
    16    gotoAllocations(status) {
    17      this.router.transitionTo('jobs.job.allocations', this.job, {
    18        queryParams: {
    19          status: JSON.stringify(status),
    20          namespace: this.job.get('namespace.name'),
    21        },
    22      });
    23    }
    24  
    25    @action
    26    onSliceClick(ev, slice) {
    27      this.gotoAllocations([camelize(slice.label)]);
    28    }
    29  
    30    @computed('forceCollapsed')
    31    get isExpanded() {
    32      if (this.forceCollapsed) return false;
    33  
    34      const storageValue = window.localStorage.nomadExpandJobSummary;
    35      return storageValue != null ? JSON.parse(storageValue) : true;
    36    }
    37  
    38    persist(item, isOpen) {
    39      window.localStorage.nomadExpandJobSummary = isOpen;
    40      this.notifyPropertyChange('isExpanded');
    41    }
    42  }