-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from plouc/feat-redux-migration
Migrate to redux
- Loading branch information
Showing
102 changed files
with
2,363 additions
and
2,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
.travis.yml | ||
CHANGELOG.md | ||
CHANGELOG.md | ||
.nyc_output | ||
coverage | ||
.DS_Store | ||
test | ||
npm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
language: node_js | ||
node_js: | ||
- '0.12' | ||
- '4' | ||
- '5' | ||
before_install: | ||
- npm install -g npm | ||
- '6' | ||
script: | ||
- npm run eslint | ||
- npm test | ||
- npm run test-cover | ||
after_success: | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const API_SUBSCRIPTION = 'API_SUBSCRIPTION' | ||
export const BUFFER_API_SUBSCRIPTION = 'BUFFER_API_SUBSCRIPTION' | ||
export const API_DATA = 'API_DATA' | ||
|
||
export const subscribeToApi = subscription => { | ||
return (dispatch, getState) => { | ||
const { ws } = getState() | ||
const type = ws.connected ? API_SUBSCRIPTION : BUFFER_API_SUBSCRIPTION | ||
|
||
dispatch({ type, subscription }) | ||
} | ||
} | ||
|
||
export const receiveApiData = ({ id, body }) => ({ | ||
type: API_DATA, | ||
id, | ||
data: body, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import request from 'superagent' | ||
import { connect } from './wsActions' | ||
import { | ||
setDashboards, | ||
startDashboardRotation, | ||
} from './dashboardsActions' | ||
import { | ||
notifySuccess, | ||
} from './notificationsActions' | ||
|
||
export const FETCH_CONFIGURATION = 'FETCH_CONFIGURATION' | ||
export const FETCH_CONFIGURATION_SUCCESS = 'FETCH_CONFIGURATION_SUCCESS' | ||
export const FETCH_CONFIGURATION_FAILURE = 'FETCH_CONFIGURATION_FAILURE' | ||
|
||
const fetchConfigurationSuccess = configuration => ({ | ||
type: FETCH_CONFIGURATION_SUCCESS, | ||
configuration, | ||
}) | ||
|
||
const fetchConfigurationFailure = error => ({ | ||
type: FETCH_CONFIGURATION_FAILURE, | ||
error, | ||
}) | ||
|
||
export const fetchConfiguration = () => dispatch => { | ||
dispatch({ | ||
type: FETCH_CONFIGURATION, | ||
}) | ||
|
||
request.get('http://localhost:5000/config') | ||
.end((error, res) => { | ||
if (error) { | ||
dispatch(fetchConfigurationFailure(error)) | ||
} else { | ||
const configuration = res.body | ||
|
||
dispatch(fetchConfigurationSuccess(res.body)) | ||
dispatch(connect(configuration)) | ||
//dispatch(notifySuccess({ | ||
// message: 'configuration loaded', | ||
// ttl: 2000, | ||
//})) | ||
dispatch(setDashboards(configuration.dashboards)) | ||
dispatch(startDashboardRotation(configuration.rotationDuration)) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export const SET_DASHBOARDS = 'SET_DASHBOARDS' | ||
export const SET_CURRENT_DASHBOARD = 'SET_CURRENT_DASHBOARD' | ||
|
||
|
||
export const setDashboards = dashboards => ({ | ||
type: SET_DASHBOARDS, | ||
dashboards, | ||
}) | ||
|
||
const setCurrentDashboard = index => { | ||
return { | ||
type: SET_CURRENT_DASHBOARD, | ||
index, | ||
} | ||
} | ||
|
||
const nextDashboard = (interval, dispatch, getState) => { | ||
setTimeout(() => { | ||
const { dashboards: { dashboards, current } } = getState() | ||
|
||
let next | ||
if (current < dashboards.length - 1) { | ||
next = current + 1 | ||
} else { | ||
next = 0 | ||
} | ||
|
||
dispatch(setCurrentDashboard(next)) | ||
nextDashboard(interval, dispatch, getState) | ||
}, interval) | ||
} | ||
|
||
export const startDashboardRotation = interval => { | ||
return (dispatch, getState) => { | ||
nextDashboard(interval, dispatch, getState) | ||
} | ||
} | ||
|
Oops, something went wrong.