github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/components/freestyle/sg-progress-bar.js (about) 1 import Component from '@ember/component'; 2 import { computed } from '@ember/object'; 3 4 export default Component.extend({ 5 timerTicks: 0, 6 7 startTimer: function() { 8 this.set( 9 'timer', 10 setInterval(() => { 11 this.incrementProperty('timerTicks'); 12 }, 1000) 13 ); 14 }.on('init'), 15 16 willDestroy() { 17 clearInterval(this.get('timer')); 18 }, 19 20 denominator: computed('timerTicks', function() { 21 return Math.round(Math.random() * 1000); 22 }), 23 24 percentage: computed('timerTicks', function() { 25 return Math.round(Math.random() * 100) / 100; 26 }), 27 28 numerator: computed('denominator', 'percentage', function() { 29 return Math.round(this.get('denominator') * this.get('percentage') * 100) / 100; 30 }), 31 32 liveDetails: computed('denominator', 'numerator', 'percentage', function() { 33 return this.getProperties('denominator', 'numerator', 'percentage'); 34 }), 35 });