github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/ui/app/components/job-row.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Component from '@ember/component';
     3  import { lazyClick } from '../helpers/lazy-click';
     4  import { watchRelationship } from 'nomad-ui/utils/properties/watch';
     5  import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection';
     6  
     7  export default Component.extend(WithVisibilityDetection, {
     8    store: service(),
     9  
    10    tagName: 'tr',
    11    classNames: ['job-row', 'is-interactive'],
    12  
    13    job: null,
    14  
    15    onClick() {},
    16  
    17    click(event) {
    18      lazyClick([this.get('onClick'), event]);
    19    },
    20  
    21    didReceiveAttrs() {
    22      // Reload the job in order to get detail information
    23      const job = this.get('job');
    24      if (job && !job.get('isLoading')) {
    25        job.reload().then(() => {
    26          this.get('watch').perform(job, 100);
    27        });
    28      }
    29    },
    30  
    31    visibilityHandler() {
    32      if (document.hidden) {
    33        this.get('watch').cancelAll();
    34      } else {
    35        const job = this.get('job');
    36        if (job && !job.get('isLoading')) {
    37          this.get('watch').perform(job, 100);
    38        }
    39      }
    40    },
    41  
    42    willDestroy() {
    43      this.get('watch').cancelAll();
    44      this._super(...arguments);
    45    },
    46  
    47    watch: watchRelationship('summary'),
    48  });