diff --git a/client/coral-admin/src/constants/assets.js b/client/coral-admin/src/constants/assets.js new file mode 100644 index 000000000..59b76390f --- /dev/null +++ b/client/coral-admin/src/constants/assets.js @@ -0,0 +1 @@ +export const ASSETS_FETCH = 'ASSETS_FETCH'; diff --git a/client/coral-admin/src/containers/Streams/Streams.js b/client/coral-admin/src/containers/Streams/Streams.js index bec61e995..ea365d0d1 100644 --- a/client/coral-admin/src/containers/Streams/Streams.js +++ b/client/coral-admin/src/containers/Streams/Streams.js @@ -1,6 +1,8 @@ import React, {Component} from 'react'; import styles from './Streams.css'; +import {connect} from 'react-redux'; import I18n from 'coral-framework/modules/i18n/i18n'; +import {ASSETS_FETCH} from '../../constants/assets'; import translations from '../../translations.json'; import { RadioGroup, @@ -18,6 +20,10 @@ class Streams extends Component { statusFilter: 'all' } + componentDidMount () { + this.props.fetchAssets(0, 25, '', 'desc'); + } + onSettingChange = (setting) => (e) => { this.setState({[setting]: e.target.value}); } @@ -90,6 +96,21 @@ class Streams extends Component { } } -export default Streams; +const mapStateToProps = () => {}; +const mapDispatchToProps = (dispatch) => { + return { + fetchAssets: (skip, limit, search, sort) => { + dispatch({ + type: ASSETS_FETCH, + skip, + limit, + search, + sort + }); + } + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(Streams); const lang = new I18n(translations); diff --git a/client/coral-admin/src/reducers/index.js b/client/coral-admin/src/reducers/index.js index 1f1b444fc..fca4694d8 100644 --- a/client/coral-admin/src/reducers/index.js +++ b/client/coral-admin/src/reducers/index.js @@ -4,6 +4,7 @@ import settings from 'reducers/settings'; import community from 'reducers/community'; import users from 'reducers/users'; import auth from 'reducers/auth'; +import assets from 'reducers/assets'; // Combine all reducers into a main one export default combineReducers({ @@ -11,5 +12,6 @@ export default combineReducers({ comments, community, auth, - users + users, + assets }); diff --git a/routes/api/assets/index.js b/routes/api/assets/index.js index 5aa9b8cc6..a602d7fd0 100644 --- a/routes/api/assets/index.js +++ b/routes/api/assets/index.js @@ -20,8 +20,8 @@ router.get('/', (req, res, next) => { Asset .search(search) .sort({[field]: (sort === 'asc') ? 1 : -1}) - .skip(skip) - .limit(limit), + .skip(parseInt(skip)) + .limit(parseInt(limit)), Asset .search(search) .count()