removed actions
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
export const showAddOptions = (show) => ({
|
||||
type: "SHOW_ADD_OPTIONS",
|
||||
show
|
||||
})
|
||||
|
||||
export const showAddOptions2 = (show) => ({
|
||||
type: "SHOW_ADD_OPTIONS2",
|
||||
show
|
||||
})
|
||||
@@ -1,179 +0,0 @@
|
||||
import { setLoginFailed } from "./main";
|
||||
// import { // history } from "../routers/AppRouter";
|
||||
import { resetUpload } from "./uploads";
|
||||
import axios from "../axiosInterceptor";
|
||||
import env from "../enviroment/envFrontEnd";
|
||||
import { setCreateNewAccount } from "./main";
|
||||
|
||||
export const login = (id) => ({
|
||||
type: "LOGIN",
|
||||
id,
|
||||
});
|
||||
|
||||
export const logout = () => ({
|
||||
type: "LOGOUT",
|
||||
});
|
||||
|
||||
export const startLogin = (email, password, currentRoute) => {
|
||||
return async (dispatch) => {
|
||||
const dt = { email, password };
|
||||
|
||||
try {
|
||||
const response = await axios.post("/user-service/login", dt);
|
||||
// console.log("USER SERVICE LOGIN RESPONSE")
|
||||
|
||||
const id = response.data.user._id;
|
||||
const emailVerified = response.data.user.emailVerified;
|
||||
|
||||
env.googleDriveEnabled = response.data.user.googleDriveEnabled;
|
||||
env.s3Enabled = response.data.user.s3Enabled;
|
||||
env.activeSubscription = response.data.user.activeSubscription;
|
||||
env.emailAddress = response.data.user.email;
|
||||
env.name = response.data.user.name || "";
|
||||
|
||||
//window.localStorage.setItem("token", token);
|
||||
|
||||
if (emailVerified) {
|
||||
dispatch(setLoginFailed(false));
|
||||
dispatch(login(id));
|
||||
// history.push(currentRoute);
|
||||
return true;
|
||||
} else {
|
||||
console.log("Email Not Verified");
|
||||
dispatch(setLoginFailed("Unverified Email", 404));
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("USER SERVICE LOGIN ERROR", err);
|
||||
const code = err.response?.status;
|
||||
dispatch(setLoginFailed("Incorrect Email or Password", code));
|
||||
console.log(err);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const startCreateAccount = (email, password) => {
|
||||
return (dispatch) => {
|
||||
const dt = { email, password };
|
||||
axios
|
||||
.post("/user-service/create", dt)
|
||||
.then((response) => {
|
||||
const token = response.data.token;
|
||||
const id = response.data.user._id;
|
||||
const emailVerified = response.data.user.emailVerified;
|
||||
|
||||
// window.localStorage.setItem("token", token);
|
||||
|
||||
if (emailVerified) {
|
||||
dispatch(setLoginFailed(false));
|
||||
dispatch(login(id));
|
||||
// history.push("/home");
|
||||
} else {
|
||||
console.log("Email Not Verified");
|
||||
dispatch(setLoginFailed("Unverified Email", 404));
|
||||
dispatch(setCreateNewAccount(true));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
if (err.response) {
|
||||
const errStatus = err.response.status;
|
||||
|
||||
if (errStatus === 401) {
|
||||
dispatch(setLoginFailed("Create Blocked By Admin"));
|
||||
} else {
|
||||
dispatch(setLoginFailed("Duplicate Email, or Invalid Password"));
|
||||
}
|
||||
} else {
|
||||
dispatch(setLoginFailed("Duplicate Email, or Invalid Password"));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
setTimeout(() => {
|
||||
window.location.reload(true);
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
export const startLoginCheck = (currentRoute) => {
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.get("/user-service/user");
|
||||
|
||||
const emailVerified = response.data.emailVerified;
|
||||
|
||||
const id = response.data._id;
|
||||
|
||||
env.googleDriveEnabled = response.data.googleDriveEnabled;
|
||||
env.s3Enabled = response.data.s3Enabled;
|
||||
env.activeSubscription = response.data.activeSubscription;
|
||||
env.emailAddress = response.data.email;
|
||||
env.name = response.data.name || "";
|
||||
|
||||
if (emailVerified) {
|
||||
dispatch(setLoginFailed(false));
|
||||
dispatch(login(id));
|
||||
// history.push(currentRoute);
|
||||
return true;
|
||||
} else {
|
||||
console.log("Email Not Verified");
|
||||
dispatch(setLoginFailed("Unverified Email", 404));
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(
|
||||
"login check error",
|
||||
err,
|
||||
err.response?.data,
|
||||
err.data,
|
||||
err.response
|
||||
);
|
||||
// window.localStorage.removeItem("token")
|
||||
dispatch(setLoginFailed("Login Expired"));
|
||||
return false;
|
||||
// // history.push("/login")
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const startLogoutAll = () => {
|
||||
return (dispatch) => {
|
||||
axios
|
||||
.post("/user-service/logout-all")
|
||||
.then(() => {
|
||||
window.localStorage.removeItem("token");
|
||||
|
||||
dispatch(resetUpload());
|
||||
dispatch(setLoginFailed(false));
|
||||
dispatch(logout());
|
||||
|
||||
// history.push("/");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const startLogout = () => {
|
||||
return (dispatch) => {
|
||||
axios
|
||||
.post("/user-service/logout")
|
||||
.then(() => {
|
||||
window.localStorage.removeItem("token");
|
||||
|
||||
dispatch(resetUpload());
|
||||
dispatch(setLoginFailed(false));
|
||||
dispatch(logout());
|
||||
|
||||
// history.push("/");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,524 +0,0 @@
|
||||
import { addUpload, editUpload, cancelUpload } from "./uploads";
|
||||
import { loadMoreItems, setLoading, setLoadingMoreItems } from "./main";
|
||||
import { resetSelected } from "./selectedItem";
|
||||
import { addQuickFile, startSetQuickFiles, setQuickFiles } from "./quickFiles";
|
||||
import { startSetStorage } from "./storage";
|
||||
import uuid from "uuid";
|
||||
import axios from "../axiosInterceptor";
|
||||
import axiosNonInterceptor from "axios";
|
||||
import env from "../enviroment/envFrontEnd";
|
||||
import Swal from "sweetalert2";
|
||||
import { setFolders } from "./folders";
|
||||
import reduceQuickItemList from "../utils/reduceQuickItemList";
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
import { addFileUploadCancelToken } from "../utils/cancelTokenManager";
|
||||
|
||||
let cachedResults = {};
|
||||
|
||||
export const setFiles = (files) => ({
|
||||
type: "SET_FILES",
|
||||
files,
|
||||
});
|
||||
|
||||
export const editFile = (id, file) => ({
|
||||
type: "EDIT_FILE",
|
||||
id,
|
||||
file,
|
||||
});
|
||||
|
||||
export const editFileMetadata = (id, metadata) => ({
|
||||
type: "EDIT_FILE_METADATA",
|
||||
id,
|
||||
metadata,
|
||||
});
|
||||
|
||||
export const startSetFileAndFolderItems = (
|
||||
historyKey,
|
||||
parent = "/",
|
||||
sortby = "DEFAULT",
|
||||
search = "",
|
||||
isGoogle = false,
|
||||
storageType = "DEFAULT",
|
||||
folderSearch = false
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
if (cachedResults[historyKey]) {
|
||||
const { fileList, folderList } = cachedResults[historyKey];
|
||||
|
||||
dispatch(setFiles(fileList));
|
||||
dispatch(setFolders(folderList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (fileList.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
|
||||
delete cachedResults[historyKey];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//isGoogle = env.googleDriveEnabled;
|
||||
|
||||
let limit = window.localStorage.getItem("list-size") || 50;
|
||||
limit = parseInt(limit);
|
||||
|
||||
let fileURL = "";
|
||||
let folderURL = "";
|
||||
|
||||
if (search && search !== "") {
|
||||
if (env.googleDriveEnabled) {
|
||||
fileURL = `/file-service-google-mongo/list?search=${search}`;
|
||||
folderURL = `/folder-service-google-mongo/list?search=${search}`;
|
||||
} else {
|
||||
fileURL = `/file-service/list?search=${search}`;
|
||||
folderURL = `/folder-service/list?search=${search}`;
|
||||
}
|
||||
} else {
|
||||
fileURL = isGoogle
|
||||
? `/file-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
: env.googleDriveEnabled && parent === "/"
|
||||
? `/file-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
: `/file-service/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`;
|
||||
|
||||
folderURL = isGoogle
|
||||
? `/folder-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
: env.googleDriveEnabled && parent === "/"
|
||||
? `/folder-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
: `/folder-service/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`;
|
||||
}
|
||||
|
||||
dispatch(setFiles([]));
|
||||
dispatch(setFolders([]));
|
||||
dispatch(setLoading(true));
|
||||
|
||||
const itemList = [axios.get(fileURL), axios.get(folderURL)];
|
||||
|
||||
Promise.all(itemList)
|
||||
.then((values) => {
|
||||
const fileList = values[0].data;
|
||||
const folderList = values[1].data;
|
||||
|
||||
dispatch(setFiles(fileList));
|
||||
dispatch(setFolders(folderList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (fileList.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
|
||||
cachedResults[historyKey] = { fileList, folderList };
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("Get All Items Error", e);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const startSetAllItems = (
|
||||
clearCache,
|
||||
parent = "/",
|
||||
sortby = "DEFAULT",
|
||||
search = "",
|
||||
isGoogle = false,
|
||||
storageType = "DEFAULT"
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
if (clearCache) cachedResults = {};
|
||||
|
||||
//isGoogle = env.googleDriveEnabled;
|
||||
let limit = window.localStorage.getItem("list-size") || 50;
|
||||
limit = parseInt(limit);
|
||||
|
||||
if (cachedResults[parent]) {
|
||||
const { fileList, folderList, quickItemList } = cachedResults[parent];
|
||||
|
||||
dispatch(setFiles(fileList));
|
||||
dispatch(setFolders(folderList));
|
||||
dispatch(setQuickFiles(quickItemList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (fileList.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
|
||||
cachedResults = {};
|
||||
cachedResults[parent] = { fileList, folderList, quickItemList };
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const fileURL = isGoogle
|
||||
? `/file-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
: env.googleDriveEnabled && parent === "/"
|
||||
? `/file-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
: `/file-service/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`;
|
||||
|
||||
const folderURL = isGoogle
|
||||
? `/folder-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
: env.googleDriveEnabled && parent === "/"
|
||||
? `/folder-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
: `/folder-service/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`;
|
||||
|
||||
const quickItemsURL = !env.googleDriveEnabled
|
||||
? `/file-service/quick-list`
|
||||
: `/file-service-google-mongo/quick-list`;
|
||||
|
||||
dispatch(setFiles([]));
|
||||
dispatch(setFolders([]));
|
||||
dispatch(setQuickFiles([]));
|
||||
dispatch(setLoading(true));
|
||||
|
||||
const itemList = [
|
||||
axios.get(fileURL),
|
||||
axios.get(folderURL),
|
||||
axios.get(quickItemsURL),
|
||||
];
|
||||
|
||||
Promise.all(itemList)
|
||||
.then((values) => {
|
||||
const fileList = values[0].data;
|
||||
const folderList = values[1].data;
|
||||
const quickItemList = reduceQuickItemList(values[2].data);
|
||||
|
||||
dispatch(setFiles(fileList));
|
||||
dispatch(setFolders(folderList));
|
||||
dispatch(setQuickFiles(quickItemList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (fileList.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
|
||||
cachedResults = {};
|
||||
cachedResults[parent] = { fileList, folderList, quickItemList };
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("Get All Items Error", e);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const startSetFiles = (
|
||||
parent = "/",
|
||||
sortby = "DEFAULT",
|
||||
search = "",
|
||||
isGoogle = false,
|
||||
storageType = "DEFAULT"
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
let limit = window.localStorage.getItem("list-size") || 50;
|
||||
limit = parseInt(limit);
|
||||
|
||||
dispatch(setFiles([]));
|
||||
dispatch(setLoading(true));
|
||||
|
||||
if (env.googleDriveEnabled) {
|
||||
axios
|
||||
.get(
|
||||
`/file-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
)
|
||||
.then((results) => {
|
||||
const googleList = results.data;
|
||||
//dispatch(loadMoreFiles(googleList))
|
||||
dispatch(setFiles(googleList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (googleList.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else if (env.googleDriveEnabled && parent === "/") {
|
||||
// Temp Google Drive API
|
||||
axios
|
||||
.get(
|
||||
`/file-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
)
|
||||
.then((results) => {
|
||||
// console.log("Google Data", results.data.data.files);
|
||||
// const convertedList = convertDriveListToMongoList(results.data.data.files);
|
||||
// console.log("Converted List", convertedList);
|
||||
const googleMongoList = results.data;
|
||||
//dispatch(loadMoreFiles(googleList))
|
||||
//dispatch(setLoading(true))
|
||||
dispatch(setFiles(googleMongoList));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (results.data.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.get(
|
||||
`/file-service/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`
|
||||
)
|
||||
.then((results) => {
|
||||
const mongoData = results.data;
|
||||
//dispatch(setLoading(true))
|
||||
dispatch(setFiles(mongoData));
|
||||
dispatch(setLoading(false));
|
||||
|
||||
if (results.data.length === limit) {
|
||||
dispatch(loadMoreItems(true));
|
||||
} else {
|
||||
dispatch(loadMoreItems(false));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const loadMoreFiles = (files) => ({
|
||||
type: "LOAD_MORE_FILES",
|
||||
files,
|
||||
});
|
||||
|
||||
export const startLoadMoreFiles = (
|
||||
parent = "/",
|
||||
sortby = "DEFAULT",
|
||||
search = "",
|
||||
startAtDate,
|
||||
startAtName,
|
||||
pageToken,
|
||||
isGoogle = false
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
dispatch(setLoadingMoreItems(true));
|
||||
|
||||
let limit = window.localStorage.getItem("list-size") || 50;
|
||||
limit = parseInt(limit);
|
||||
|
||||
if (isGoogle) {
|
||||
// Temp Google Drive API
|
||||
axios
|
||||
.get(
|
||||
`/file-service-google/list?limit=${limit}&parent=${parent}&sortby=${sortby}&search=${search}&startAt=${true}&startAtDate=${startAtDate}&startAtName=${startAtName}&pageToken=${pageToken}`
|
||||
)
|
||||
.then((results) => {
|
||||
dispatch(loadMoreFiles(results.data));
|
||||
|
||||
if (results.data.length !== limit) {
|
||||
dispatch(loadMoreItems(false));
|
||||
} else {
|
||||
dispatch(loadMoreItems(true));
|
||||
}
|
||||
|
||||
dispatch(setLoadingMoreItems(false));
|
||||
//dispatch(setLoading(false))
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.get(
|
||||
`/file-service/list?limit=${limit}&parent=${parent}&sortby=${sortby}&search=${search}&startAt=${true}&startAtDate=${startAtDate}&startAtName=${startAtName}`
|
||||
)
|
||||
.then((results) => {
|
||||
//console.log("load more files result", results.data.length)
|
||||
|
||||
dispatch(loadMoreFiles(results.data));
|
||||
|
||||
if (results.data.length !== limit) {
|
||||
dispatch(loadMoreItems(false));
|
||||
} else {
|
||||
dispatch(loadMoreItems(true));
|
||||
}
|
||||
|
||||
// dispatch(setLoading(false))
|
||||
dispatch(setLoadingMoreItems(false));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const addFile = (file) => ({
|
||||
type: "ADD_FILE",
|
||||
file,
|
||||
});
|
||||
|
||||
export const startAddFile = (uploadInput, parent) => {
|
||||
return (dispatch, getState) => {
|
||||
for (let i = 0; i < uploadInput.files.length; i++) {
|
||||
const currentFile = uploadInput.files[i];
|
||||
const currentID = uuid();
|
||||
|
||||
const CancelToken = axiosNonInterceptor.CancelToken;
|
||||
const source = CancelToken.source();
|
||||
|
||||
const config = {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Transfere-Encoding": "chunked",
|
||||
},
|
||||
onUploadProgress: (progressEvent) => {
|
||||
const currentProgress = Math.round(
|
||||
(progressEvent.loaded / progressEvent.total) * 100
|
||||
);
|
||||
|
||||
if (currentProgress !== 100) {
|
||||
dispatch(editUpload(currentID, currentProgress));
|
||||
}
|
||||
},
|
||||
cancelToken: source.token,
|
||||
};
|
||||
|
||||
addFileUploadCancelToken(currentID, source);
|
||||
|
||||
dispatch(
|
||||
addUpload({
|
||||
id: currentID,
|
||||
progress: 0,
|
||||
name: currentFile.name,
|
||||
completed: false,
|
||||
// source, // TODO: Fix canceling uploads
|
||||
canceled: false,
|
||||
size: currentFile.size,
|
||||
})
|
||||
);
|
||||
|
||||
const storageType = env.uploadMode;
|
||||
|
||||
const data = new FormData();
|
||||
|
||||
data.append("filename", currentFile.name);
|
||||
data.append("parent", parent);
|
||||
data.append("currentID", currentID);
|
||||
data.append("size", currentFile.size);
|
||||
if (storageType === "s3") data.append("personal-file", true);
|
||||
data.append("file", currentFile);
|
||||
|
||||
const url =
|
||||
storageType === "drive"
|
||||
? "/file-service-google/upload"
|
||||
: storageType === "s3"
|
||||
? "/file-service-personal/upload"
|
||||
: "/file-service/upload";
|
||||
|
||||
axios
|
||||
.post(url, data, config)
|
||||
.then(function (response) {
|
||||
console.log("uploaded");
|
||||
// dispatch(addQuickFile(response.data));
|
||||
dispatch(editUpload(currentID, 100, true));
|
||||
// dispatch(resetSelected());
|
||||
// dispatch(startSetStorage());
|
||||
|
||||
// cachedResults = {};
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("uploadError", error);
|
||||
dispatch(cancelUpload(currentID));
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const removeFile = (id) => ({
|
||||
type: "REMOVE_FILE",
|
||||
id,
|
||||
});
|
||||
|
||||
export const startRemoveFile = (id, isGoogle = false, isPersonal = false) => {
|
||||
return (dispatch) => {
|
||||
const data = { id };
|
||||
|
||||
if (isGoogle) {
|
||||
axios
|
||||
.delete("/file-service-google/remove", {
|
||||
data,
|
||||
})
|
||||
.then(() => {
|
||||
dispatch(removeFile(id));
|
||||
dispatch(startSetStorage());
|
||||
dispatch(startSetQuickFiles());
|
||||
|
||||
cachedResults = {};
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
const url = !isPersonal
|
||||
? "/file-service/remove"
|
||||
: "/file-service-personal/remove";
|
||||
|
||||
axios
|
||||
.delete(url, {
|
||||
data,
|
||||
})
|
||||
.then(() => {
|
||||
dispatch(removeFile(id));
|
||||
dispatch(startSetStorage());
|
||||
dispatch(startSetQuickFiles());
|
||||
|
||||
cachedResults = {};
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const startRenameFile = (id, title, isGoogle = false) => {
|
||||
return (dispatch) => {
|
||||
const data = { id, title };
|
||||
|
||||
if (isGoogle) {
|
||||
axios
|
||||
.patch("/file-service-google/rename", data)
|
||||
.then(() => {
|
||||
dispatch(editFile(id, { filename: title }));
|
||||
|
||||
cachedResults = {};
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.patch("/file-service/rename", data)
|
||||
.then(() => {
|
||||
dispatch(editFile(id, { filename: title }));
|
||||
|
||||
cachedResults = {};
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const startResetCache = () => {
|
||||
return (dispatch) => {
|
||||
cachedResults = {};
|
||||
};
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
export const setSortBy = (sortBy) => ({
|
||||
type: "SET_SORT_BY",
|
||||
sortBy
|
||||
})
|
||||
|
||||
export const setSearch = (search) => ({
|
||||
type: "SET_SEARCH",
|
||||
search
|
||||
})
|
||||
|
||||
export const resetSearch = () => ({
|
||||
type: "RESET_SEARCH"
|
||||
})
|
||||
|
||||
export const enableListView = () => ({
|
||||
type: "ENABLE_LIST_VIEW"
|
||||
})
|
||||
|
||||
export const disableListView = () => ({
|
||||
type: "DISABLE_LIST_VIEW"
|
||||
})
|
||||
|
||||
export const setCurrentlySearching = () => ({
|
||||
type: "SET_CURRENTLY_SEARCHING"
|
||||
})
|
||||
|
||||
export const resetCurrentlySearching = () => ({
|
||||
type: "RESET_CURRENTLY_SEARCHING"
|
||||
})
|
||||
|
||||
export const setNotGoogle = () => ({
|
||||
type: "SET_NOT_GOOGLE"
|
||||
})
|
||||
|
||||
export const setIsGoogle = () => ({
|
||||
type: "SET_IS_GOOGLE"
|
||||
})
|
||||
@@ -1,68 +0,0 @@
|
||||
export const setFolderTreeID = (id) => ({
|
||||
type:"SET_ID",
|
||||
id
|
||||
})
|
||||
|
||||
export const resetFolderTreeID = () => ({
|
||||
type:"RESET_ID"
|
||||
})
|
||||
|
||||
export const removeFolderTreeID = (id) => ({
|
||||
type: "REMOVE_ID",
|
||||
id
|
||||
})
|
||||
|
||||
export const addNewFolderTreeID = (id, addData) => ({
|
||||
type: "ADD_NEW_IDS",
|
||||
id,
|
||||
addData
|
||||
})
|
||||
|
||||
export const removeNewFolderTreeID = (id) => ({
|
||||
type: "REMOVE_NEW_IDS",
|
||||
id
|
||||
})
|
||||
|
||||
export const addDeleteFolderTreeID = (id, deleteData) => ({
|
||||
type: "ADD_DELETE_IDS",
|
||||
id,
|
||||
deleteData
|
||||
})
|
||||
|
||||
export const removeDeleteFolderTreeID = (id) => ({
|
||||
type: "REMOVE_DELETE_IDS",
|
||||
id
|
||||
})
|
||||
|
||||
export const addMoveFolderTreeID = (id, moveData) => ({
|
||||
type: "ADD_MOVE_IDS",
|
||||
id,
|
||||
moveData
|
||||
})
|
||||
|
||||
export const removeMoveFolderTreeID = (id) => ({
|
||||
type: "REMOVE_MOVE_IDS",
|
||||
id
|
||||
})
|
||||
|
||||
export const addRenameFolderTreeID = (id, renameData) => ({
|
||||
type: "ADD_RENAME_IDS",
|
||||
id,
|
||||
renameData
|
||||
})
|
||||
|
||||
export const removeRenameFolderTreeID = (id) => ({
|
||||
type: "REMOVE_RENAME_IDS",
|
||||
id
|
||||
})
|
||||
|
||||
export const setFirstLoadDetailsFolderTree = (firstLoadDetails) => ({
|
||||
type: "SET_FIRST_LOAD_DETAILS",
|
||||
firstLoadDetails
|
||||
})
|
||||
|
||||
export const setInsertedFolderTreeID = (id, insertedList) => ({
|
||||
type: "SET_INSERT_IDS",
|
||||
id,
|
||||
insertedList
|
||||
})
|
||||
@@ -1,209 +0,0 @@
|
||||
import { startSetQuickFiles } from "./quickFiles";
|
||||
import env from "../enviroment/envFrontEnd";
|
||||
import Swal from "sweetalert2";
|
||||
import {
|
||||
addNewFolderTreeID,
|
||||
addDeleteFolderTreeID,
|
||||
removeDeleteFolderTreeID,
|
||||
addRenameFolderTreeID,
|
||||
setFirstLoadDetailsFolderTree,
|
||||
} from "./folderTree";
|
||||
import { startResetCache } from "./files";
|
||||
import uuid from "uuid";
|
||||
import axios from "../axiosInterceptor";
|
||||
|
||||
export const addFolder = (folder) => ({
|
||||
type: "ADD_FOLDER",
|
||||
folder,
|
||||
});
|
||||
|
||||
export const startAddFolder = (
|
||||
name,
|
||||
owner,
|
||||
parent,
|
||||
parentList,
|
||||
isGoogle = false
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
if (env.uploadMode === "") {
|
||||
console.log("No Storage Accounts!");
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "No Storage Accounts Active",
|
||||
text: "Go to settings to add a storage account",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const storageType = env.uploadMode;
|
||||
|
||||
let body = { name, parent, owner, parentList };
|
||||
|
||||
if (storageType === "s3") body = { ...body, personalFolder: true };
|
||||
|
||||
// TEMP FIX THIS
|
||||
const url =
|
||||
storageType === "drive"
|
||||
? "/folder-service-google/upload"
|
||||
: "/folder-service/upload";
|
||||
|
||||
axios
|
||||
.post(url, body)
|
||||
.then((response) => {
|
||||
const folder = response.data;
|
||||
|
||||
dispatch(addFolder(folder));
|
||||
dispatch(addNewFolderTreeID(folder._id, folder));
|
||||
dispatch(startResetCache());
|
||||
|
||||
if (parent === "/")
|
||||
dispatch(
|
||||
setFirstLoadDetailsFolderTree({
|
||||
status: "RESET",
|
||||
resetToken: uuid.v4(),
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const setFolders = (folders) => ({
|
||||
type: "SET_FOLDERS",
|
||||
folders,
|
||||
});
|
||||
|
||||
export const startSetFolders = (
|
||||
parent = "/",
|
||||
sortby = "DEFAULT",
|
||||
search = "",
|
||||
isGoogle = false,
|
||||
storageType = "DEFAULT"
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
dispatch(setFolders([]));
|
||||
|
||||
if (isGoogle) {
|
||||
axios
|
||||
.get(
|
||||
`/folder-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
)
|
||||
.then((results) => {
|
||||
const googleList = results.data;
|
||||
dispatch(setFolders(googleList));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else if (env.googleDriveEnabled && parent === "/") {
|
||||
// Temp Google Drive API
|
||||
axios
|
||||
.get(
|
||||
`/folder-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
)
|
||||
.then((results) => {
|
||||
const googleMongoList = results.data;
|
||||
dispatch(setFolders(googleMongoList));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.get(
|
||||
`/folder-service/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`
|
||||
)
|
||||
.then((response) => {
|
||||
const folders = response.data;
|
||||
dispatch(setFolders(folders)); //DISABLED TEMP
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const removeFolder = (id) => ({
|
||||
type: "REMOVE_FOLDER",
|
||||
id,
|
||||
});
|
||||
|
||||
export const startRemoveFolder = (
|
||||
id,
|
||||
parentList,
|
||||
isGoogle = false,
|
||||
parent,
|
||||
personalFolder = false
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
const data = { id, parentList };
|
||||
|
||||
const url = isGoogle
|
||||
? `/folder-service-google/remove`
|
||||
: personalFolder
|
||||
? `/folder-service-personal/remove`
|
||||
: `/folder-service/remove`;
|
||||
|
||||
axios
|
||||
.delete(url, {
|
||||
data,
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch(removeFolder(id));
|
||||
dispatch(startSetQuickFiles());
|
||||
dispatch(addDeleteFolderTreeID(id, { _id: id }));
|
||||
dispatch(startResetCache());
|
||||
|
||||
if (parent === "/")
|
||||
dispatch(
|
||||
setFirstLoadDetailsFolderTree({
|
||||
status: "RESET",
|
||||
resetToken: uuid.v4(),
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const editFolder = (id, folder) => ({
|
||||
type: "EDIT_FOLDER",
|
||||
id,
|
||||
folder,
|
||||
});
|
||||
|
||||
export const startRenameFolder = (id, title, parent) => {
|
||||
return (dispatch) => {
|
||||
const data = { id, title };
|
||||
|
||||
const url = "/folder-service/rename";
|
||||
|
||||
axios
|
||||
.patch(url, data)
|
||||
.then((response) => {
|
||||
dispatch(editFolder(id, { name: title }));
|
||||
dispatch(addRenameFolderTreeID(id, { _id: id, name: title }));
|
||||
dispatch(startResetCache());
|
||||
|
||||
if (parent === "/")
|
||||
dispatch(
|
||||
setFirstLoadDetailsFolderTree({
|
||||
status: "RESET",
|
||||
resetToken: uuid.v4(),
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,82 +0,0 @@
|
||||
export const showSideBar = () => ({
|
||||
type: "SHOW_SIDEBAR"
|
||||
})
|
||||
|
||||
export const hideSideBar = () => ({
|
||||
type: "HIDE_SIDEBAR"
|
||||
})
|
||||
|
||||
export const goneSideBar = () => ({
|
||||
type: "GONE_SIDEBAR"
|
||||
})
|
||||
|
||||
export const resetItems = () => ({
|
||||
type: "RESET_ITEMS"
|
||||
})
|
||||
|
||||
export const showUploader = () => ({
|
||||
type: "SHOW_UPLOADER"
|
||||
})
|
||||
|
||||
export const hideUploader = () => ({
|
||||
type: "HIDE_UPLOADER"
|
||||
})
|
||||
|
||||
export const loadMoreItems = (load) => ({
|
||||
type: "LOAD_MORE_ITEMS",
|
||||
load
|
||||
})
|
||||
|
||||
export const setLoading = (load) => ({
|
||||
type: "SET_LOADING",
|
||||
load
|
||||
})
|
||||
|
||||
export const setLoginFailed = (message, code=401) => ({
|
||||
type: "SET_LOGIN_FAILED",
|
||||
message,
|
||||
code
|
||||
})
|
||||
|
||||
export const setCreateNewAccount = (value) => ({
|
||||
type: "SET_CREATE_NEW_ACCOUNT",
|
||||
value
|
||||
})
|
||||
|
||||
export const setCurrentRouteType = (route) => ({
|
||||
type:"SET_CURRENT_ROUTE_TYPE",
|
||||
route
|
||||
})
|
||||
|
||||
export const setCachedSearch = (search) => ({
|
||||
type: "SET_CACHED_SEARCH",
|
||||
search
|
||||
})
|
||||
|
||||
export const openUploadOverlay = () => ({
|
||||
type: "OPEN_UPLOAD_OVERLAY"
|
||||
})
|
||||
|
||||
export const closeUploadOverlay = () => ({
|
||||
type: "CLOSE_UPLOAD_OVERLAY"
|
||||
})
|
||||
|
||||
export const setLeftSectionMode = (mode) => ({
|
||||
type: "SET_LEFT_SECTION_MODE",
|
||||
mode
|
||||
})
|
||||
|
||||
export const setRightSectionMode = (mode) => ({
|
||||
type: "SET_RIGHT_SECTION_MODE",
|
||||
mode
|
||||
})
|
||||
|
||||
export const setLoadingMoreItems = (loading) => ({
|
||||
type: "LOADING_MORE_ITEMS",
|
||||
loading
|
||||
})
|
||||
|
||||
// export const resetSettingsMain = (id) => ({
|
||||
// type: "RESET_SETTINGS_MAIN",
|
||||
// id
|
||||
// })
|
||||
@@ -1,9 +0,0 @@
|
||||
export const setMobileContextMenu = (isFile, data) => ({
|
||||
type: "SET_MOBILE_CONTEXT",
|
||||
isFile,
|
||||
data
|
||||
})
|
||||
|
||||
export const resetMobileContextMenu = () => ({
|
||||
type: "RESET_MOBILE_CONTEXT"
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
export const setMoverID = (id, parent, isFile) => ({
|
||||
type: "SET_MOVER_ID",
|
||||
id,
|
||||
parent,
|
||||
isFile,
|
||||
});
|
||||
|
||||
export const resetMoverID = () => ({
|
||||
type: "RESET_MOVER_ID",
|
||||
});
|
||||
@@ -1,106 +0,0 @@
|
||||
import axios from "../axiosInterceptor";
|
||||
|
||||
let cachedResults = {};
|
||||
|
||||
export const setParent = (parent="/") => ({
|
||||
type: "SET_PARENT",
|
||||
parent
|
||||
})
|
||||
|
||||
export const addParentList = (parent, name) => ({
|
||||
type: "ADD_PARENT_LIST",
|
||||
parent,
|
||||
name
|
||||
})
|
||||
|
||||
export const setParentList = (parentList, parentNameList) => ({
|
||||
type: "SET_PARENT_LIST",
|
||||
parentList,
|
||||
parentNameList
|
||||
})
|
||||
|
||||
export const startSetParentList = (id, isGoogle=false) => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
if (cachedResults[id]) {
|
||||
|
||||
const {_id, name} = cachedResults[id];
|
||||
|
||||
const parentList = ["/", _id];
|
||||
const parentNameList = ["Home", name];
|
||||
|
||||
dispatch(setParentList(parentList, parentNameList));
|
||||
|
||||
delete cachedResults[id];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const URL = isGoogle ? `/folder-service-google/info/${id}` : `/folder-service/info/${id}`;
|
||||
|
||||
dispatch(setParentList(["/", ""], ["Home", ""]))
|
||||
|
||||
axios.get(URL).then((response) => {
|
||||
|
||||
const parentList = ["/", response.data._id];
|
||||
const parentNameList = ["Home", response.data.name];
|
||||
|
||||
dispatch(setParentList(parentList, parentNameList));
|
||||
|
||||
cachedResults[id] = {_id: response.data._id, name: response.data.name};
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("Error getting folder info for parent list", err);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const adjustParentList = (parentList, parentNameList) => ({
|
||||
type: "ADJUST_PARENT_LIST",
|
||||
parentList,
|
||||
parentNameList
|
||||
})
|
||||
|
||||
export const startAdjustParentList = (id, parentList, parentNameList) => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
const adjustedParentList = [];
|
||||
const adjustedParentNameList = [];
|
||||
|
||||
for (let i = 0; i < parentList.length; i++) {
|
||||
|
||||
const currentID = parentList[i];
|
||||
const currentName = parentNameList[i];
|
||||
|
||||
adjustedParentList.push(currentID)
|
||||
adjustedParentNameList.push(currentName)
|
||||
|
||||
if (currentID === id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(adjustParentList(adjustedParentList, adjustedParentNameList));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const addParentNameList = (name) => ({
|
||||
type: "ADD_PARENT_NAME_LIST",
|
||||
name
|
||||
})
|
||||
|
||||
export const startResetParentList = () => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
cachedResults = {};
|
||||
dispatch(resetParentList());
|
||||
}
|
||||
}
|
||||
|
||||
export const resetParentList = () => ({
|
||||
type: "RESET_PARENT_LIST"
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
export const setPhotoID = (id, isGoogle=false, isPersonal=false) => ({
|
||||
type: "SET_PHOTO_ID",
|
||||
id,
|
||||
isGoogle,
|
||||
isPersonal
|
||||
})
|
||||
|
||||
export const resetPhotoID = () => ({
|
||||
type: "RESET_PHOTO_ID"
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
export const setPopupFile = (file) => ({
|
||||
type: "SET_POPUP_FILE",
|
||||
file
|
||||
})
|
||||
|
||||
export const hidePopup = () => ({
|
||||
type: "HIDE_POPUP"
|
||||
})
|
||||
@@ -1,63 +0,0 @@
|
||||
import axios from "../axiosInterceptor";
|
||||
import env from "../enviroment/envFrontEnd";
|
||||
import mobilecheck from "../utils/mobileCheck";
|
||||
|
||||
export const setQuickFiles = (files) => ({
|
||||
type: "SET_QUICK_FILES",
|
||||
files
|
||||
})
|
||||
|
||||
export const startSetQuickFiles = () => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
if (!env.googleDriveEnabled) {
|
||||
|
||||
axios.get(`/file-service/quick-list`).then((results) => {
|
||||
|
||||
//dispatch(setQuickFiles(results.data)) TEMP DISABLED FOR GOOGLE API
|
||||
|
||||
let mongoData = results.data;
|
||||
|
||||
const isMobile = mobilecheck();
|
||||
|
||||
if (mongoData.length > 10 && !isMobile) {
|
||||
mongoData = mongoData.slice(0, 10);
|
||||
} else if (mongoData.length > 2 && isMobile) {
|
||||
mongoData = mongoData.slice(0, 2);
|
||||
}
|
||||
|
||||
dispatch(setQuickFiles(mongoData))
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
} else {
|
||||
|
||||
// Temp Google Drive API
|
||||
axios.get(`/file-service-google-mongo/quick-list`).then((results) => {
|
||||
|
||||
let combinedData = results.data;
|
||||
|
||||
const isMobile = mobilecheck();
|
||||
|
||||
if (combinedData.length > 10 && !isMobile) {
|
||||
combinedData = combinedData.slice(0, 10);
|
||||
} else if (combinedData.length > 2 && isMobile) {
|
||||
combinedData = combinedData.slice(0, 2);
|
||||
}
|
||||
|
||||
dispatch(setQuickFiles(combinedData))
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const addQuickFile = (file) => ({
|
||||
type: "ADD_QUICK_FILE",
|
||||
file
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
export const setCurrentRoute = (route) => ({
|
||||
type: "SET_CURRENT_ROUTE",
|
||||
route
|
||||
})
|
||||
|
||||
export const resetCurrentRoute = () => ({
|
||||
type: "RESET_CURRENT_ROUTE"
|
||||
})
|
||||
@@ -1,200 +0,0 @@
|
||||
import axios from "../axiosInterceptor";
|
||||
|
||||
export const setSelectedItem = (selectedItem) => ({
|
||||
type: "SET_SELECTED_ITEM",
|
||||
selectedItem,
|
||||
});
|
||||
|
||||
export const startSetSelectedItem = (
|
||||
id,
|
||||
file,
|
||||
fromQuickItems,
|
||||
isGoogleDrive
|
||||
) => {
|
||||
return (dispatch) => {
|
||||
const currentDate = Date.now();
|
||||
|
||||
dispatch(setLastSelected(currentDate));
|
||||
|
||||
if (!fromQuickItems) {
|
||||
dispatch(setSelected(id));
|
||||
} else {
|
||||
dispatch(setSelected("quick-" + id));
|
||||
}
|
||||
|
||||
if (file) {
|
||||
if (isGoogleDrive) {
|
||||
axios
|
||||
.get(`/file-service-google/info/${id}`)
|
||||
.then((results) => {
|
||||
const data = results.data;
|
||||
|
||||
const {
|
||||
filename: name,
|
||||
length: size,
|
||||
uploadDate: date,
|
||||
parentName: location,
|
||||
metadata,
|
||||
_id: id,
|
||||
} = results.data;
|
||||
|
||||
dispatch(
|
||||
setSelectedItem({
|
||||
name,
|
||||
size,
|
||||
date,
|
||||
file,
|
||||
location,
|
||||
transcoded: metadata.transcoded,
|
||||
isVideo: metadata.isVideo,
|
||||
id,
|
||||
linkType: metadata.linkType,
|
||||
link: metadata.link,
|
||||
drive: metadata.drive,
|
||||
personalFile: metadata.personalFile,
|
||||
data: results.data,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.get(`/file-service/info/${id}`)
|
||||
.then((results) => {
|
||||
const {
|
||||
filename: name,
|
||||
length: size,
|
||||
uploadDate: date,
|
||||
parentName: location,
|
||||
metadata,
|
||||
_id: id,
|
||||
} = results.data;
|
||||
|
||||
dispatch(
|
||||
setSelectedItem({
|
||||
name,
|
||||
size,
|
||||
date,
|
||||
file,
|
||||
location,
|
||||
transcoded: metadata.transcoded,
|
||||
isVideo: metadata.isVideo,
|
||||
id,
|
||||
linkType: metadata.linkType,
|
||||
link: metadata.link,
|
||||
drive: metadata.drive,
|
||||
personalFile: metadata.personalFile,
|
||||
data: results.data,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (isGoogleDrive) {
|
||||
axios
|
||||
.get(`/folder-service-google/info/${id}`)
|
||||
.then((results) => {
|
||||
const {
|
||||
name,
|
||||
0: size,
|
||||
createdAt: date,
|
||||
parentName: location,
|
||||
_id: id,
|
||||
drive,
|
||||
personalFolder: personalFile,
|
||||
} = results.data;
|
||||
|
||||
dispatch(
|
||||
setSelectedItem({
|
||||
name,
|
||||
size,
|
||||
date,
|
||||
file,
|
||||
location,
|
||||
id,
|
||||
drive,
|
||||
personalFile,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.get(`/folder-service/info/${id}`)
|
||||
.then((results) => {
|
||||
const {
|
||||
name,
|
||||
0: size,
|
||||
createdAt: date,
|
||||
parentName: location,
|
||||
_id: id,
|
||||
drive,
|
||||
personalFolder: personalFile,
|
||||
} = results.data;
|
||||
|
||||
dispatch(
|
||||
setSelectedItem({
|
||||
name,
|
||||
size,
|
||||
date,
|
||||
file,
|
||||
location,
|
||||
id,
|
||||
drive,
|
||||
personalFile,
|
||||
data: results.data,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const editSelectedItem = (item) => ({
|
||||
type: "EDIT_SELECTED_ITEM",
|
||||
item,
|
||||
});
|
||||
|
||||
export const resetSelectedItem = () => ({
|
||||
type: "RESET_SELECTED_ITEM",
|
||||
});
|
||||
|
||||
export const resetSelected = () => ({
|
||||
type: "RESET_SELECTED",
|
||||
});
|
||||
|
||||
export const setLastSelected = (lastSelected) => ({
|
||||
type: "SET_LAST_SELECTED",
|
||||
lastSelected,
|
||||
});
|
||||
|
||||
export const setRightSelected = (selected) => ({
|
||||
type: "SET_RIGHT_SELECTED",
|
||||
selected,
|
||||
});
|
||||
|
||||
export const setShareSelected = (selected) => ({
|
||||
type: "SET_SHARE_SELECTED",
|
||||
selected,
|
||||
});
|
||||
|
||||
export const editShareSelected = (selected) => ({
|
||||
type: "EDIT_SHARE_SELECTED",
|
||||
selected,
|
||||
});
|
||||
|
||||
export const setSelected = (selected) => ({
|
||||
type: "SET_SELECTED",
|
||||
selected,
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
export const showSettings = () => ({
|
||||
type: "SHOW_SETTINGS"
|
||||
})
|
||||
|
||||
export const hideSettings = () => ({
|
||||
type: "HIDE_SETTINGS"
|
||||
})
|
||||
@@ -1,29 +0,0 @@
|
||||
import axios from "../axiosInterceptor";
|
||||
import env from "../enviroment/envFrontEnd";
|
||||
|
||||
export const setStorage = (info) => ({
|
||||
type: "SET_STORAGE",
|
||||
info
|
||||
})
|
||||
|
||||
export const startSetStorage = () => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
return;
|
||||
|
||||
if (env.disableStorage === "true") {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.get(`/storage-service/info`).then((results) => {
|
||||
|
||||
dispatch(setStorage(results.data))
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
export const setStorageSwitcherStorage = (storage) => ({
|
||||
type: "SET_UPLOAD_SWITCHER_ID",
|
||||
storage
|
||||
})
|
||||
|
||||
export const resetStorageSwitcherStorage = () => ({
|
||||
type: "RESET_UPLOAD_SWITCHER_ID"
|
||||
})
|
||||
@@ -1,40 +0,0 @@
|
||||
export const addUpload = (upload) => ({
|
||||
type: "ADD_UPLOAD",
|
||||
upload
|
||||
})
|
||||
|
||||
export const resetUpload = () => ({
|
||||
type: "RESET_UPLOADS"
|
||||
})
|
||||
|
||||
export const editUpload = (id, progress, completed = false) => ({
|
||||
type: "EDIT_UPLOAD",
|
||||
id,
|
||||
progress,
|
||||
completed
|
||||
})
|
||||
|
||||
export const cancelUpload = (id) => ({
|
||||
type: "CANCEL_UPLOAD",
|
||||
id
|
||||
})
|
||||
|
||||
export const startCancelAllUploads = (uploads) => {
|
||||
|
||||
return (dispatch) => {
|
||||
|
||||
for (let i = 0; i < uploads.length; i++) {
|
||||
|
||||
const upload = uploads[i];
|
||||
|
||||
if (!upload.completed) {
|
||||
|
||||
upload.source.cancel("All uploads cancelling")
|
||||
|
||||
dispatch(cancelUpload(upload.id))
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(resetUpload());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user