| | |
| | | import createBrowserHistory from 'history/createBrowserHistory'; |
| | | import {Route, Router, Switch} from 'react-router'; |
| | | import {connect} from 'react-redux'; |
| | | import {Badge} from 'reactstrap'; |
| | | |
| | | import Menu from '../components/general/Menu'; |
| | | import Start from '../components/views/Start'; |
| | |
| | | import ConfigurationPage from '../components/views/config/ConfigurationPage'; |
| | | import RestServices from '../components/views/develop/RestServices'; |
| | | import JobMonitorView from '../components/views/jobs/JobMonitorView'; |
| | | import {isDevelopmentMode} from '../utilities/global'; |
| | | import {getRestServiceUrl, isDevelopmentMode} from '../utilities/global'; |
| | | import LogPage from '../components/views/logging/LogPage'; |
| | | import Footer from '../components/views/footer/Footer'; |
| | | import {loadVersion} from '../actions'; |
| | |
| | | |
| | | componentDidMount = () => { |
| | | this.props.loadVersion(); |
| | | this.interval = setInterval(() => this.fetchJobStatistics(), 5000); |
| | | }; |
| | | |
| | | fetchJobStatistics = () => { |
| | | fetch(getRestServiceUrl('jobs/statistics'), { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Accept': 'application/json' |
| | | } |
| | | }) |
| | | .then(response => response.json()) |
| | | .then(json => { |
| | | this.setState({ |
| | | statistics: json |
| | | }); |
| | | }) |
| | | .catch(); |
| | | }; |
| | | |
| | | render() { |
| | | let jobsBadge = ''; |
| | | if (this.state && this.state.statistics && this.state.statistics.numberOfRunningAndQueuedJobs > 0) { |
| | | jobsBadge = <Badge color="danger" pill>{this.state.statistics.numberOfRunningAndQueuedJobs}</Badge>; |
| | | } |
| | | let routes = [ |
| | | ['Start', '/', Start], |
| | | ['Repositories', '/repos', RepoListView], |
| | | ['Job monitor', '/jobmonitor', JobMonitorView], |
| | | ['Job monitor', '/jobmonitor', JobMonitorView, {badge: jobsBadge}], |
| | | [getTranslation('logviewer'), '/logging', LogPage], |
| | | [getTranslation('configuration'), '/config', ConfigurationPage] |
| | | ]; |