github.com/manicqin/nomad@v0.9.5/ui/app/components/freestyle/sg-progress-bar.js (about)

     1  import Component from '@ember/component';
     2  import { computed } from '@ember/object';
     3  import { on } from '@ember/object/evented';
     4  
     5  export default Component.extend({
     6    timerTicks: 0,
     7  
     8    startTimer: on('init', function() {
     9      this.set(
    10        'timer',
    11        setInterval(() => {
    12          this.incrementProperty('timerTicks');
    13        }, 1000)
    14      );
    15    }),
    16  
    17    willDestroy() {
    18      clearInterval(this.timer);
    19    },
    20  
    21    denominator: computed('timerTicks', function() {
    22      return Math.round(Math.random() * 1000);
    23    }),
    24  
    25    percentage: computed('timerTicks', function() {
    26      return Math.round(Math.random() * 100) / 100;
    27    }),
    28  
    29    numerator: computed('denominator', 'percentage', function() {
    30      return Math.round(this.denominator * this.percentage * 100) / 100;
    31    }),
    32  
    33    liveDetails: computed('denominator', 'numerator', 'percentage', function() {
    34      return this.getProperties('denominator', 'numerator', 'percentage');
    35    }),
    36  });