8000 Corrections after rebase · corner4world/rclone-webui-react@d1ec2e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1ec2e3

Browse files
committed
Corrections after rebase
1 parent 69cacc9 commit d1ec2e3

File tree

17 files changed

+205
-145
lines changed

17 files changed

+205
-145
lines changed

package-lock.json

Lines changed: 48 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"react-dom": "^16.12.0",
4040
"react-in-viewport": "0.0.38",
4141
"react-iframe": "^1.8.0",
42-
4342
"react-redux": "^7.2.0",
4443
"react-router-config": "^5.1.1",
4544
"react-router-dom": "~5.2.0",

src/actions/pluginActions.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axiosInstance from "../utils/API/API";
22
import urls from "../utils/API/endpoint";
3-
import {ADD_TEST_PLUGIN, GET_TEST_PLUGINS, LOAD_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "./types";
3+
import {ADD_TEST_PLUGIN, LOAD_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "./types";
44
import {toast} from "react-toastify";
55

66
/**
@@ -11,21 +11,27 @@ export const loadTestPlugins = () => {
1111
return (dispatch) => {
1212
axiosInstance.post(urls.listPlugins).then((res) => {
1313
dispatch({
14-
type: GET_TEST_PLUGINS,
14+
type: LOAD_PLUGINS,
1515
status: REQUEST_SUCCESS,
1616
payload: res.data
1717
})
1818
},
1919
(error) => {
2020
dispatch({
21-
type: GET_TEST_PLUGINS,
21+
type: LOAD_PLUGINS,
2222
status: REQUEST_ERROR,
2323
payload: error
2424
})
2525
});
2626
}
2727
};
2828

29+
/**
30+
* Add a test plugin
31+
* @param pluginName {string} Name of the plugin
32+
* @param pluginUrl {string} Github url of the plugin to load from
33+
* @return {function(...[*]=)}
34+
*/
2935
export const addTestPlugin = (pluginName, pluginUrl) => (dispatch) => {
3036
axiosInstance.post(urls.addTestPlugin, {name: pluginName, loadUrl: pluginUrl, test: true}).then(res => {
3137
dispatch(loadTestPlugins());
@@ -38,8 +44,13 @@ export const addTestPlugin = (pluginName, pluginUrl) => (dispatch) => {
3844
})
3945
}
4046

47+
48+
/**
49+
* Load plugins from rclone
50+
* @return {function(...[*]=)}
51+
*/
4152
export const getPlugins = () => (dispatch) => {
42-
axiosInstance.post("pluginsctl/listPlugins").then(res => {
53+
axiosInstance.post(urls.listPlugins).then(res => {
4354
dispatch({
4455
type: LOAD_PLUGINS,
4556
status: REQUEST_SUCCESS,
@@ -57,8 +68,13 @@ export const getPlugins = () => (dispatch) => {
5768

5869
}
5970

71+
/**
72+
* Add a plugin using url of that plugin
73+
* @param pluginURL
74+
* @return {function(...[*]=)}
75+
*/
6076
export const addPlugin = (pluginURL) => dispatch => {
61-
axiosInstance.post("pluginsctl/addPlugin", {url: pluginURL}).then(res => {
77+
axiosInstance.post(urls.addPlugin, {url: pluginURL}).then(res => {
6278
toast.info(`Plugin ${pluginURL} added successfully`);
6379
// reload plugins database
6480
dispatch(getPlugins())

src/actions/types.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ export const CREATE_MOUNT = "CREATE_MOUNT";
4545
export const ADD_TEST_PLUGIN = "ADD_TEST_PLUGIN";
4646
export const LOAD_PLUGINS = "LOAD_PLUGINS";
4747

48-
export const GET_MOUNT_LIST = "GET_MOUNT_LIST";
49-
export const REMOVE_MOUNT = "REMOVE_MOUNT";
50-
export const CREATE_MOUNT = "CREATE_MOUNT";
51-
5248

5349
export const REQUEST_ERROR = 'ERROR';
5450
export const REQUEST_SUCCESS = 'SUCCESS';

src/pluginTypes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const pluginTypes = {
2+
DASHBOARD: "DASHBOARD",
3+
TERMINAL: "TERMINAL",
4+
FILE_HANDLER: "FILE_HANDLER"
5+
}
6+
7+
export default pluginTypes;

src/reducers/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import imagesReducer from "./imagesReducer";
1111
import versionReducer from "./versionReducer";
1212
import pluginsReducer from "./pluginsReducer";
1313
import mountReducer from "./mountReducer";
14-
import pluginsReducer from "./pluginsReducer";
15-
import mountReducer from "./mountReducer";
1614

1715
/**
1816
* Configures the root reducer to be executed before any other reducers configured in the system.

src/reducers/pluginsReducer.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ADD_TEST_PLUGIN, GET_TEST_PLUGINS, LOAD_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "../actions/types";
1+
import {ADD_TEST_PLUGIN, LOAD_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "../actions/types";
22

33
const initialState = {
44
loadedTestPlugins: {},
@@ -14,12 +14,13 @@ const initialState = {
1414
*/
1515
export default function (state = initialState, action) {
1616
switch (action.type) {
17-
case GET_TEST_PLUGINS:
17+
case LOAD_PLUGINS:
1818
if (action.status === REQUEST_SUCCESS) {
1919
return {
2020
...state,
2121
loadedTestPlugins: action.payload.loadedTestPlugins,
22-
loadedPlugins: action.payload.loadedPlugins
22+
loadedPlugins: action.payload.loadedPlugins,
23+
error: ""
2324
}
2425
} else if (action.status === REQUEST_ERROR) {
2526
return {
@@ -32,21 +33,6 @@ export default function (state = initialState, action) {
3233
break;
3334
case ADD_TEST_PLUGIN:
3435
return state;
35-
case LOAD_PLUGINS:
36-
if (action.status === REQUEST_SUCCESS) {
37-
return {
38-
...state,
39-
loadedPlugins: action.payload.loadedPlugins,
40-
error: ""
41-
}
42-
} else if (action.status === REQUEST_ERROR) {
43-
return {
44-
...state,
45-
loadedPlugins: {},
46-
error: action.payload
47-
}
48-
}
49-
return state;
5036
default:
5137
return state;
5238
}

src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const RCloneDashboard = React.lazy(() => import("./views/RCloneDashboard"));
99
const MountDashboard = React.lazy(() => import("./views/MountDashboard"));
1010
const StoreDashboard = React.lazy(() => import("./views/StoreDashboard"));
1111
const TerminalDashboard = React.lazy(() => import("./views/TerminalDashboard"));
12-
12+
const PluginDashboard = React.lazy(() => import("./views/PluginDashboard"))
1313
// https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config
1414
// Define the routes as required
1515
const routes = [

src/utils/API/endpoint.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,11 @@ const urls = {
148148
*/
149149
addTestPlugin: "pluginsctl/addTestPlugin",
150150
151+
/**
152+
* Add a plugin
153+
*/
154+
addPlugin: "pluginsctl/addPlugin",
155+
156+
151157
};
152158
export default urls;

src/utils/PluginTools.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,46 @@ export const getPluginBaseUrl = (ipAddress, pluginName, author) => {
4545
}
4646

4747
return `${ipAddress}/plugins/${author}/${pluginName}/`;
48+
}
49+
50+
/**
51+
* Get plugins from map.
52+
* @param plugins {{}} plugins map
53+
* @returns {[]} array of plugins
54+
*/
55+
export const getPluginsArray = (plugins) => {
56+
const availablePlugins = [];
57+
58+
for (let m in plugins) {
59+
if (plugins.hasOwnProperty(m)) {
60+
let p = plugins[m];
61+
availablePlugins.push(p)
62+
}
63+
}
64+
65+
return availablePlugins;
66+
}
67+
68+
/**
69+
* filter plugins by file handling types
70+
* @param plugins {[]}
71+
* @param MimeType {String}
72+
* @return {[]}
73+
*/
74+
export const filterPluginsByMimeType = (plugins, MimeType) => {
75+
return plugins.filter((p) => p["rclone"] &&
76+
p["rclone"]["handlesType"] &&
77+
p["rclone"]["handlesType"].includes(MimeType));
78+
}
79+
80+
/**
81+
* filter plugins by file handling types
82+
* @param plugins {[]}
83+
* @param type {String}
84+
* @return {[]}
85+
*/
86+
export const filterPluginsByType = (plugins, type) => {
87+
return plugins.filter((p) => p["rclone"] &&
88+
p["rclone"]["pluginType"] &&
89+
p["rclone"]["pluginType"].toUpperCase() === type.toUpperCase());
4890
}

0 commit comments

Comments
 (0)
0