summaryrefslogtreecommitdiff
path: root/app/client/dataset/dataset.reducer.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-31 22:59:56 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-31 22:59:56 +0200
commitfe399143527972050534b3262c94dfbf291ddb41 (patch)
treea5a51eacca14c96919d9ca996bdef6f5eb2a272d /app/client/dataset/dataset.reducer.js
parentb8885039a6ba87cf329be1daf96c80914ecfef0b (diff)
split out datasets folder
Diffstat (limited to 'app/client/dataset/dataset.reducer.js')
-rw-r--r--app/client/dataset/dataset.reducer.js136
1 files changed, 136 insertions, 0 deletions
diff --git a/app/client/dataset/dataset.reducer.js b/app/client/dataset/dataset.reducer.js
new file mode 100644
index 0000000..c7a2e26
--- /dev/null
+++ b/app/client/dataset/dataset.reducer.js
@@ -0,0 +1,136 @@
+import types from '../types'
+
+const datasetInitialState = {
+ loading: false,
+ error: null,
+ status: '',
+}
+
+const datasetReducer = (state = datasetInitialState, action) => {
+ console.log(action)
+ switch(action.type) {
+ case types.socket.connect:
+ return {
+ ...state,
+ }
+ case types.task.task_begin:
+ return {
+ ...state,
+ }
+ case types.task.task_finish:
+ return {
+ ...state,
+ }
+
+ case types.folder.index:
+ return {
+ ...state,
+ folders: action.data,
+ folder: action.data[0],
+ }
+ case types.folder.update:
+ return state
+ case types.file.index:
+ return {
+ ...state,
+ files: action.data
+ }
+
+ case types.folder.upload_loading:
+ return {
+ ...state,
+ upload: {
+ loading: true,
+ status: 'Loading...',
+ },
+ }
+ case types.folder.upload_error:
+ return {
+ ...state,
+ upload: {
+ loading: false,
+ status: 'Error uploading :(',
+ },
+ }
+ case types.folder.upload_progress:
+ console.log(action)
+ return {
+ ...state,
+ upload: {
+ loading: true,
+ status: 'Upload progress ' + action.percent + '%',
+ },
+ }
+ case types.folder.upload_waiting:
+ console.log(action)
+ return {
+ ...state,
+ upload: {
+ loading: true,
+ status: 'Waiting for server to finish processing...',
+ },
+ }
+ case types.file.create_loading:
+ return {
+ ...state,
+ upload: {
+ loading: true,
+ status: 'Creating file...'
+ }
+ }
+ case types.file.create:
+ console.log('booo')
+ if (state.folder.id === action.data.folder_id) {
+ return {
+ ...state,
+ files: [action.data].concat(state.files),
+ upload: {
+ loading: false,
+ status: 'File created',
+ },
+ }
+ } else {
+ return {
+ ...state,
+ upload: {
+ loading: false,
+ status: 'created',
+ },
+ }
+ }
+ case types.folder.upload_complete:
+ console.log(action)
+ if (state.folder.id === action.folder) {
+ return {
+ ...state,
+ files: [action.files].concat(state.files),
+ upload: {
+ loading: false,
+ status: 'Upload complete',
+ },
+ }
+ } else {
+ return {
+ ...state,
+ upload: {
+ loading: false,
+ status: 'Upload complete',
+ },
+ }
+ }
+ case types.socket.status:
+ return datasetSocket(state, action.data)
+ default:
+ return state
+ }
+}
+
+const datasetSocket = (state, action) => {
+ console.log(action)
+ switch (action.key) {
+ default:
+ return state
+ }
+}
+
+export default datasetReducer