2017-07-11 17:37:43 +02:00
|
|
|
import axios from 'axios';
|
|
|
|
import * as ActionTypes from '../../../constants';
|
2019-07-24 18:55:58 +02:00
|
|
|
import { startLoader, stopLoader } from './loader';
|
2017-07-11 17:37:43 +02:00
|
|
|
|
2018-08-24 23:41:23 +02:00
|
|
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
|
|
|
const ROOT_URL = __process.env.API_URL;
|
2017-07-11 17:37:43 +02:00
|
|
|
|
2019-07-24 18:55:58 +02:00
|
|
|
function setAssets(assets, totalSize) {
|
2017-07-11 17:37:43 +02:00
|
|
|
return {
|
|
|
|
type: ActionTypes.SET_ASSETS,
|
2019-07-24 18:55:58 +02:00
|
|
|
assets,
|
|
|
|
totalSize
|
2017-07-11 17:37:43 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-30 06:37:10 +02:00
|
|
|
export function getAssets() {
|
2019-07-24 18:55:58 +02:00
|
|
|
return (dispatch) => {
|
|
|
|
dispatch(startLoader());
|
2018-05-30 06:37:10 +02:00
|
|
|
axios.get(`${ROOT_URL}/S3/objects`, { withCredentials: true })
|
2017-07-11 17:37:43 +02:00
|
|
|
.then((response) => {
|
2019-07-24 18:55:58 +02:00
|
|
|
dispatch(setAssets(response.data.assets, response.data.totalSize));
|
|
|
|
dispatch(stopLoader());
|
2017-07-11 17:37:43 +02:00
|
|
|
})
|
2019-07-24 18:55:58 +02:00
|
|
|
.catch(() => {
|
|
|
|
dispatch({
|
|
|
|
type: ActionTypes.ERROR
|
|
|
|
});
|
|
|
|
dispatch(stopLoader());
|
|
|
|
});
|
2017-07-11 17:37:43 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteAsset(assetKey, userId) {
|
|
|
|
return {
|
|
|
|
type: 'PLACEHOLDER'
|
|
|
|
};
|
|
|
|
}
|