mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-12 23:25:10 +00:00
32 lines
721 B
JavaScript
32 lines
721 B
JavaScript
|
'use strict';
|
||
|
|
||
|
define([
|
||
|
'underscore',
|
||
|
'react',
|
||
|
'templates/app/components/common/progress/index'
|
||
|
], function(_, React, template) {
|
||
|
return React.createClass({
|
||
|
render: template,
|
||
|
_computePercent: function() {
|
||
|
var build = this.props.build;
|
||
|
return Math.round((Date.now() - build.startDate) /
|
||
|
build.project.avgBuildDuration * 100);
|
||
|
},
|
||
|
componentDidMount: function() {
|
||
|
var self = this,
|
||
|
updateCallback = function() {
|
||
|
if (self.props.build.status === 'in-progress') {
|
||
|
self.setState({percent: self._computePercent()});
|
||
|
_.delay(updateCallback, 100);
|
||
|
}
|
||
|
}
|
||
|
updateCallback();
|
||
|
},
|
||
|
getInitialState: function() {
|
||
|
return {
|
||
|
percent: this._computePercent()
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
});
|