Skip to content

Commit

Permalink
Auto refresh in build history page
Browse files Browse the repository at this point in the history
  • Loading branch information
suryagaddipati committed Sep 24, 2015
1 parent 45ff345 commit 7ad1b58
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/jsx/app.jsx
Expand Up @@ -28,10 +28,10 @@ window.onload = function (){
page.base(rootPath);
page('/','/dotCIbuildHistory');
page('/dotCIbuildHistory', function () {
buildHistory.actions.QueryChange({filter: 'All', limit: 50});
buildHistory.actions.QueryChange(buildHistory.query);
});
page('/dotCIbuildMetrics', function () {
buildMetrics.actions.QueryChange({filter: 'All', limit: 50});
buildMetrics.actions.QueryChange(buildMetrics.query);
});
page('/:buildNumber',(ctx)=>{
const {buildNumber} = ctx.params;
Expand Down
5 changes: 4 additions & 1 deletion src/main/jsx/client/BuildHistoryPageActions.js
Expand Up @@ -4,8 +4,11 @@ import BuildHistoryPage from './../pages/BuildHistoryPage.jsx';
import {job} from './../api/Api.jsx';
import {removeFilter,addFilter} from './../api/Api.jsx';
import Drawer from './../Drawer.jsx';
import autoRefreshComponent from './../components/lib/AutoRefreshComponent.js';
function dataChange(buildHistory){
ReactDOM.render(<BuildHistoryPage buildHistory={buildHistory}/>, document.getElementById('content'));
const buildHistoryPage = <BuildHistoryPage buildHistory={buildHistory}/>
const AutoRefreshBuildHistory = autoRefreshComponent(buildHistoryPage, ()=>{buildHistory.actions.QueryChange(buildHistory.query)});
ReactDOM.render(<AutoRefreshBuildHistory/>, document.getElementById('content'));
ReactDOM.render(<Drawer menu="job"/>, document.getElementById('nav'));
}
function queryChange(buildHistory){
Expand Down
14 changes: 14 additions & 0 deletions src/main/jsx/components/lib/AutoRefreshComponent.js
@@ -0,0 +1,14 @@
import React from 'react';
export default function(component,refreshFunction){
return React.createClass({
componentDidMount(){
this.refreshTimer = setInterval(refreshFunction, 5000);
},
componentWillUnmount(){
clearInterval(this.refreshTimer);
},
render(){
return component;
}
});
}
5 changes: 4 additions & 1 deletion src/main/jsx/models/Job.js
@@ -1,7 +1,10 @@
import createAction from './createAction.js';
export default class {
constructor(){
this.query={}
this.query={
filter: 'All',
limit: 50
}
const self = this;
this.actions = {
QueryChange : createAction((data,onAction) =>{
Expand Down

0 comments on commit 7ad1b58

Please sign in to comment.