-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
3,451 additions
and
4,062 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import axiosInstance from "../utils/API/API"; | ||
import urls from "../utils/API/endpoint"; | ||
import {CREATE_MOUNT, GET_MOUNT_LIST, REMOVE_MOUNT, REQUEST_ERROR, REQUEST_SUCCESS} from "./types"; | ||
|
||
/** | ||
* Get the current mount lists and load into state | ||
* @returns {function(...[*]=)} | ||
*/ | ||
export const getMountList = () => { | ||
return (dispatch) => { | ||
axiosInstance.post(urls.listMounts).then(res => { | ||
console.log(res); | ||
dispatch({ | ||
type: GET_MOUNT_LIST, | ||
status: REQUEST_SUCCESS, | ||
payload: res.data | ||
}) | ||
}, (error) => { | ||
dispatch({ | ||
type: GET_MOUNT_LIST, | ||
status: REQUEST_ERROR, | ||
payload: error | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
/** | ||
* Add a new mount location | ||
* @param fs {string} Name of the remote eg mydrive: | ||
* @param mountPoint {string} Path to mount on the local filesystem where rclone is running | ||
* @param mountType {string} One of "cmount", "mount", "mount2": Specifies what mountType rclone should use | ||
* @returns {function(...[*]=)} | ||
*/ | ||
export const addMount = (fs, mountPoint, mountType) => { | ||
if (!fs.endsWith(":")) fs = fs + ":"; | ||
const type = CREATE_MOUNT | ||
return (dispatch) => { | ||
axiosInstance.post(urls.createMount, {fs, mountPoint, mountType}).then(res => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_SUCCESS, | ||
payload: res.data | ||
}) | ||
}, (error) => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_ERROR, | ||
payload: error | ||
}) | ||
}) | ||
dispatch(getMountList()); | ||
|
||
} | ||
} | ||
|
||
/** | ||
* unmount removes an mounted location "mountPoint" | ||
* @param mountPoint {string} Path to location where the mount was created. | ||
* @returns {function(...[*]=)} | ||
*/ | ||
export const unmount = (mountPoint) => { | ||
const type = REMOVE_MOUNT; | ||
return (dispatch) => { | ||
axiosInstance.post(urls.removeMount, {mountPoint}).then(res => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_SUCCESS, | ||
payload: res.data | ||
}) | ||
|
||
}, (error) => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_ERROR, | ||
payload: error | ||
}) | ||
}) | ||
dispatch(getMountList()); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* unmountAll removes all mounts created by mount/mount | ||
* @returns {function(...[*]=)} | ||
*/ | ||
export const unmountAll = () => { | ||
const type = REMOVE_MOUNT; | ||
return (dispatch) => { | ||
axiosInstance.post(urls.unmountAll).then(res => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_SUCCESS, | ||
payload: res.data | ||
}) | ||
|
||
}, (error) => { | ||
dispatch({ | ||
type, | ||
status: REQUEST_ERROR, | ||
payload: error | ||
}) | ||
}) | ||
dispatch(getMountList()); | ||
} | ||
} |
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
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,43 @@ | ||
import {CREATE_MOUNT, GET_MOUNT_LIST, REMOVE_MOUNT, REQUEST_ERROR, REQUEST_SUCCESS} from "../actions/types"; | ||
import {toast} from "react-toastify"; | ||
|
||
const initialState = { | ||
currentMounts: [], | ||
mountError: null | ||
}; | ||
|
||
export default function (state = initialState, action) { | ||
switch (action.type) { | ||
case CREATE_MOUNT: | ||
if (action.status === REQUEST_SUCCESS) { | ||
toast.info('Mount Success'); | ||
} else if (action.status === REQUEST_ERROR) { | ||
toast.error('Error creating mount ' + action.payload); | ||
} | ||
break; | ||
case GET_MOUNT_LIST: | ||
if (action.status === REQUEST_SUCCESS) { | ||
return { | ||
...state, | ||
currentMounts: action.payload.mountPoints | ||
} | ||
} else if (action.status === REQUEST_ERROR) { | ||
return { | ||
...state, | ||
currentMounts: [], | ||
mountError: action.payload | ||
} | ||
} | ||
break; | ||
case REMOVE_MOUNT: | ||
if (action.status === REQUEST_SUCCESS) { | ||
toast.info('Unmount success'); | ||
} else if (action.status === REQUEST_ERROR) { | ||
toast.error("Couldn't remove mount"); | ||
} | ||
break; | ||
default: | ||
return state; | ||
} | ||
return state | ||
} |
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
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
Oops, something went wrong.