open-nomad/ui/app/components/freestyle/sg-progress-bar.js
Buck Doyle 9b2fb14e51
UI: Update Ember to 3.12 LTS (#6419)
This is mostly deprecation fixes and blueprint changes. There
are some dependency updates too; the changes to Ember
Basic Dropdown necessitated changing it to angle bracket
component invocation. The conversion of the rest of the
templates will happen separately.
2019-10-15 13:32:58 -05:00

37 lines
918 B
JavaScript

import Component from '@ember/component';
import { computed } from '@ember/object';
import { on } from '@ember/object/evented';
export default Component.extend({
timerTicks: 0,
startTimer: on('init', function() {
this.set(
'timer',
setInterval(() => {
this.incrementProperty('timerTicks');
}, 1000)
);
}),
willDestroy() {
clearInterval(this.timer);
},
denominator: computed('timerTicks', function() {
return Math.round(Math.random() * 1000);
}),
percentage: computed('timerTicks', function() {
return Math.round(Math.random() * 100) / 100;
}),
numerator: computed('denominator', 'percentage', function() {
return Math.round(this.denominator * this.percentage * 100) / 100;
}),
liveDetails: computed('denominator', 'numerator', 'percentage', function() {
return this.getProperties('denominator', 'numerator', 'percentage');
}),
});