diff --git a/backend/controllers/personalFile.ts b/backend/controllers/personalFile.ts index 1c5b91f..c0310b0 100644 --- a/backend/controllers/personalFile.ts +++ b/backend/controllers/personalFile.ts @@ -166,6 +166,8 @@ class PersonalFileController { try { + console.log("download personal") + const s3Service = new S3Service(); const user = req.user; diff --git a/backend/db/utils/folderUtils/index.ts b/backend/db/utils/folderUtils/index.ts index ab00c4f..dc62b70 100644 --- a/backend/db/utils/folderUtils/index.ts +++ b/backend/db/utils/folderUtils/index.ts @@ -23,7 +23,7 @@ class DbUtil { return folder; } - getFolderListByParent = async(userID: string, parent: string, sortBy: string, s3Enabled: boolean, type: string, storageType: string) => { + getFolderListByParent = async(userID: string, parent: string, sortBy: string, s3Enabled: boolean, type: string, storageType: string, itemType: string) => { let query: any = {"owner": userID, "parent": parent}; @@ -41,6 +41,11 @@ class DbUtil { } } + if (itemType) { + if (itemType === "personal") query = {...query, "personalFolder": true} + if (itemType === "nonpersonal") query = {...query, "personalFolder": null} + } + // if (storageType === "s3") { // query = {...query, "personalFolder": true} // } @@ -51,7 +56,7 @@ class DbUtil { return folderList; } - getFolderListBySearch = async(userID: string, searchQuery: string, sortBy: string, type: string, parent: string, storageType: string, folderSearch: boolean) => { + getFolderListBySearch = async(userID: string, searchQuery: string, sortBy: string, type: string, parent: string, storageType: string, folderSearch: boolean, itemType: string) => { let query: any = {"name": searchQuery,"owner": userID}; @@ -72,6 +77,12 @@ class DbUtil { query = {...query, parent} } + if (itemType) { + + if (itemType === "personal") query = {...query, "personalFolder": true} + if (itemType === "nonpersonal") query = {...query, "personalFolder": null} + } + const folderList = await Folder.find(query) .sort(sortBy) as FolderInterface[]; diff --git a/backend/express-routers/personalFile.ts b/backend/express-routers/personalFile.ts index 3f9f251..259443e 100644 --- a/backend/express-routers/personalFile.ts +++ b/backend/express-routers/personalFile.ts @@ -10,7 +10,7 @@ const router = Router(); router.post("/file-service-personal/upload", authFullUser, personalFileController.uploadPersonalFile); -router.get("/file-service-personal/download/:id/:tempToken", authFullUser, personalFileController.downloadPersonalFile); +router.get("/file-service-personal/download/:id", authFullUser, personalFileController.downloadPersonalFile); router.get("/file-service-personal/thumbnail/:id", authFullUser, personalFileController.getPersonalThumbnail); diff --git a/backend/services/ChunkService/S3Service.ts b/backend/services/ChunkService/S3Service.ts index ec197ba..3313ddb 100644 --- a/backend/services/ChunkService/S3Service.ts +++ b/backend/services/ChunkService/S3Service.ts @@ -201,6 +201,8 @@ class S3Service implements ChunkInterface { const decipher = crypto.createDecipheriv('aes256', CIPHER_KEY, IV); + console.log("download personal file", currentFile.filename); + res.set('Content-Type', 'binary/octet-stream'); res.set('Content-Disposition', 'attachment; filename="' + currentFile.filename + '"'); res.set('Content-Length', currentFile.metadata.size.toString()); diff --git a/backend/services/FolderService/index.ts b/backend/services/FolderService/index.ts index aa94808..b18feb7 100644 --- a/backend/services/FolderService/index.ts +++ b/backend/services/FolderService/index.ts @@ -115,13 +115,14 @@ class FolderService { const type = query.type; const storageType = query.storageType || undefined; const folderSearch = query.folder_search || undefined; + const itemType = query.itemType || undefined; sortBy = sortBySwitch(sortBy); const s3Enabled = user.s3Enabled ? true : false; if (searchQuery.length === 0) { - const folderList = await utilsFolder.getFolderListByParent(userID, parent, sortBy, s3Enabled, type, storageType); + const folderList = await utilsFolder.getFolderListByParent(userID, parent, sortBy, s3Enabled, type, storageType, itemType); if (!folderList) throw new NotFoundError("Folder List Not Found Error"); @@ -130,7 +131,7 @@ class FolderService { } else { searchQuery = new RegExp(searchQuery, 'i') - const folderList = await utilsFolder.getFolderListBySearch(userID, searchQuery, sortBy, type, parent, storageType, folderSearch); + const folderList = await utilsFolder.getFolderListBySearch(userID, searchQuery, sortBy, type, parent, storageType, folderSearch, itemType); if (!folderList) throw new NotFoundError("Folder List Not Found Error"); diff --git a/src/actions/auth.js b/src/actions/auth.js index 7a6d375..c905b96 100755 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -5,8 +5,6 @@ import axios from "../axiosInterceptor"; import env from "../enviroment/envFrontEnd"; import {setCreateNewAccount} from "./main"; -const currentURL = env.url; - export const login = (id) => ({ type: "LOGIN", id @@ -22,7 +20,7 @@ export const startLogin = (email, password, currentRoute) => { const dt = {email, password}; - axios.post(currentURL+"/user-service/login", dt).then((response) => { + axios.post("/user-service/login", dt).then((response) => { console.log("USER SERVICE LOGIN RESPONSE") @@ -62,7 +60,7 @@ export const startCreateAccount = (email, password) => { return (dispatch) => { const dt = {email, password}; - axios.post(currentURL+"/user-service/create", dt).then((response) => { + axios.post("/user-service/create", dt).then((response) => { const token = response.data.token; const id = response.data.user._id; @@ -154,7 +152,7 @@ export const startLogoutAll = () => { return (dispatch) => { - axios.post(currentURL+"/user-service/logout-all").then(() => { + axios.post("/user-service/logout-all").then(() => { window.localStorage.removeItem("token") @@ -176,7 +174,7 @@ export const startLogout = () => { return (dispatch) => { - axios.post(currentURL+"/user-service/logout").then(() => { + axios.post("/user-service/logout").then(() => { window.localStorage.removeItem("token") diff --git a/src/actions/files.js b/src/actions/files.js index 2097cc7..ecbf144 100644 --- a/src/actions/files.js +++ b/src/actions/files.js @@ -14,8 +14,6 @@ import reduceQuickItemList from "../utils/reduceQuickItemList"; const http = require('http'); const https = require('https'); -const currentURL = env.url; - let cachedResults = {} export const setFiles = (files) => ({ @@ -226,7 +224,7 @@ export const startSetFiles = (parent="/", sortby="DEFAULT", search="", isGoogle= if (isGoogle) { - axios.get(currentURL +`/file-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`).then((results) => { + 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)) @@ -245,7 +243,7 @@ export const startSetFiles = (parent="/", sortby="DEFAULT", search="", isGoogle= } else if (env.googleDriveEnabled && parent === "/") { // Temp Google Drive API - axios.get(currentURL +`/file-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`).then((results) => { + 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); @@ -266,7 +264,7 @@ export const startSetFiles = (parent="/", sortby="DEFAULT", search="", isGoogle= }) } else { - axios.get(currentURL +`/file-service/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`).then((results) => { + axios.get(`/file-service/list?parent=${parent}&sortby=${sortby}&search=${search}&limit=${limit}&storageType=${storageType}`).then((results) => { const mongoData = results.data; //dispatch(setLoading(true)) @@ -304,7 +302,7 @@ export const startLoadMoreFiles = (parent="/", sortby="DEFAULT", search="", star if (isGoogle) { // Temp Google Drive API - axios.get(currentURL +`/file-service-google/list?limit=${limit}&parent=${parent}&sortby=${sortby}&search=${search}&startAt=${true}&startAtDate=${startAtDate}&startAtName=${startAtName}&pageToken=${pageToken}`).then((results) => { + 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)) @@ -324,7 +322,7 @@ export const startLoadMoreFiles = (parent="/", sortby="DEFAULT", search="", star } else { - axios.get(currentURL +`/file-service/list?limit=${limit}&parent=${parent}&sortby=${sortby}&search=${search}&startAt=${true}&startAtDate=${startAtDate}&startAtName=${startAtName}`).then((results) => { + 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) @@ -413,7 +411,7 @@ export const startAddFile = (uploadInput, parent, parentList, storageSwitcherTyp data.append('file', currentFile); - const url = storageType === "drive" ? currentURL +'/file-service-google/upload' : storageType === "s3" ? currentURL +'/file-service-personal/upload' : currentURL +'/file-service/upload'; + 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) { @@ -454,7 +452,7 @@ export const startRemoveFile = (id, isGoogle=false, isPersonal=false) => { if (isGoogle) { - axios.delete(currentURL+"/file-service-google/remove", { + axios.delete("/file-service-google/remove", { data }).then(() => { dispatch(removeFile(id)) @@ -469,7 +467,7 @@ export const startRemoveFile = (id, isGoogle=false, isPersonal=false) => { } else { - const url = !isPersonal ? currentURL+"/file-service/remove" : currentURL+"/file-service-personal/remove"; + const url = !isPersonal ? "/file-service/remove" : "/file-service-personal/remove"; axios.delete(url, { data @@ -496,7 +494,7 @@ export const startRenameFile = (id, title, isGoogle=false) => { if (isGoogle) { - axios.patch(currentURL+"/file-service-google/rename", data).then(() => { + axios.patch("/file-service-google/rename", data).then(() => { dispatch(editFile(id, {filename: title})) @@ -507,7 +505,7 @@ export const startRenameFile = (id, title, isGoogle=false) => { }) } else { - axios.patch(currentURL+"/file-service/rename", data).then(() => { + axios.patch("/file-service/rename", data).then(() => { dispatch(editFile(id, {filename: title})) diff --git a/src/actions/folders.js b/src/actions/folders.js index e14dc21..958f7d0 100644 --- a/src/actions/folders.js +++ b/src/actions/folders.js @@ -6,8 +6,6 @@ import { startResetCache } from "./files"; import uuid from "uuid"; import axios from "../axiosInterceptor"; -const currentURL = env.url; - export const addFolder = (folder) => ({ type: "ADD_FOLDER", folder @@ -39,7 +37,7 @@ export const startAddFolder = (name, owner, parent, parentList, isGoogle=false) if (storageType === "s3") body = {...body, personalFolder: true} // TEMP FIX THIS - const url = storageType === "drive" ? currentURL+"/folder-service-google/upload" : currentURL+"/folder-service/upload"; + const url = storageType === "drive" ? "/folder-service-google/upload" : "/folder-service/upload"; axios.post(url, body).then((response) => { @@ -70,7 +68,7 @@ export const startSetFolders = (parent = "/", sortby="DEFAULT", search="", isGoo if (isGoogle) { - axios.get(currentURL +`/folder-service-google/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`).then((results) => { + 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) => { @@ -79,7 +77,7 @@ export const startSetFolders = (parent = "/", sortby="DEFAULT", search="", isGoo } else if (env.googleDriveEnabled && parent === "/") { // Temp Google Drive API - axios.get(currentURL +`/folder-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`).then((results) => { + axios.get(`/folder-service-google-mongo/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`).then((results) => { const googleMongoList = results.data; dispatch(setFolders(googleMongoList)) @@ -89,7 +87,7 @@ export const startSetFolders = (parent = "/", sortby="DEFAULT", search="", isGoo } else { - axios.get(currentURL+`/folder-service/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`).then((response) => { + axios.get(`/folder-service/list?parent=${parent}&sortby=${sortby}&search=${search}&storageType=${storageType}`).then((response) => { const folders = response.data; dispatch(setFolders(folders)) //DISABLED TEMP @@ -112,7 +110,7 @@ export const startRemoveFolder = (id, parentList, isGoogle=false, parent, person const data = {id, parentList}; - const url = isGoogle ? currentURL+`/folder-service-google/remove` : personalFolder ? `/folder-service-personal/remove` : currentURL+`/folder-service/remove`; + const url = isGoogle ? `/folder-service-google/remove` : personalFolder ? `/folder-service-personal/remove` : `/folder-service/remove`; console.log("personal folder", personalFolder); @@ -145,7 +143,7 @@ export const startRenameFolder = (id, title, isGoogle=false, parent) => { const data = {id, title} - const url = isGoogle ? currentURL+"/folder-service-google/rename" : currentURL+"/folder-service/rename"; + const url = isGoogle ? "/folder-service-google/rename" : "/folder-service/rename"; axios.patch(url, data).then((response) => { diff --git a/src/actions/quickFiles.js b/src/actions/quickFiles.js index d45a938..598eb7f 100644 --- a/src/actions/quickFiles.js +++ b/src/actions/quickFiles.js @@ -2,8 +2,6 @@ import axios from "../axiosInterceptor"; import env from "../enviroment/envFrontEnd"; import mobilecheck from "../utils/mobileCheck"; -const currentURL = env.url; - export const setQuickFiles = (files) => ({ type: "SET_QUICK_FILES", files @@ -15,7 +13,7 @@ export const startSetQuickFiles = () => { if (!env.googleDriveEnabled) { - axios.get(currentURL +`/file-service/quick-list`).then((results) => { + axios.get(`/file-service/quick-list`).then((results) => { //dispatch(setQuickFiles(results.data)) TEMP DISABLED FOR GOOGLE API @@ -37,7 +35,7 @@ export const startSetQuickFiles = () => { } else { // Temp Google Drive API - axios.get(currentURL +`/file-service-google-mongo/quick-list`).then((results) => { + axios.get(`/file-service-google-mongo/quick-list`).then((results) => { let combinedData = results.data; diff --git a/src/actions/selectedItem.js b/src/actions/selectedItem.js index 73d25e6..9bd538a 100644 --- a/src/actions/selectedItem.js +++ b/src/actions/selectedItem.js @@ -1,7 +1,4 @@ import axios from "../axiosInterceptor"; -import env from "../enviroment/envFrontEnd"; - -const currentURL = env.url; export const setSelectedItem = (selectedItem) => ({ type: "SET_SELECTED_ITEM", @@ -26,7 +23,7 @@ export const startSetSelectedItem = (id, file, fromQuickItems, isGoogleDrive) => if (isGoogleDrive) { - axios.get(currentURL +`/file-service-google/info/${id}`).then((results) => { + axios.get(`/file-service-google/info/${id}`).then((results) => { console.log("file info google", results.data, results.data.id); @@ -42,7 +39,7 @@ export const startSetSelectedItem = (id, file, fromQuickItems, isGoogleDrive) => } else { - axios.get(currentURL +`/file-service/info/${id}`).then((results) => { + axios.get(`/file-service/info/${id}`).then((results) => { const {filename: name, length: size, uploadDate: date, parentName: location, metadata, _id: id} = results.data; @@ -57,7 +54,7 @@ export const startSetSelectedItem = (id, file, fromQuickItems, isGoogleDrive) => if (isGoogleDrive) { - axios.get(currentURL +`/folder-service-google/info/${id}`).then((results) => { + axios.get(`/folder-service-google/info/${id}`).then((results) => { const {name, 0: size, createdAt: date, parentName: location, _id: id, drive, personalFolder: personalFile} = results.data; @@ -69,7 +66,7 @@ export const startSetSelectedItem = (id, file, fromQuickItems, isGoogleDrive) => } else { - axios.get(currentURL +`/folder-service/info/${id}`).then((results) => { + axios.get(`/folder-service/info/${id}`).then((results) => { const {name, 0: size, createdAt: date, parentName: location, _id: id, drive, personalFolder: personalFile} = results.data; diff --git a/src/actions/storage.js b/src/actions/storage.js index 5c75f6c..22f6cb8 100644 --- a/src/actions/storage.js +++ b/src/actions/storage.js @@ -1,8 +1,6 @@ import axios from "../axiosInterceptor"; import env from "../enviroment/envFrontEnd"; -const currentURL = env.url; - export const setStorage = (info) => ({ type: "SET_STORAGE", info @@ -16,7 +14,7 @@ export const startSetStorage = () => { return; } - axios.get(currentURL +`/storage-service/info`).then((results) => { + axios.get(`/storage-service/info`).then((results) => { dispatch(setStorage(results.data)) diff --git a/src/components/DownloadPage/index.js b/src/components/DownloadPage/index.js index b4344db..c1b67eb 100644 --- a/src/components/DownloadPage/index.js +++ b/src/components/DownloadPage/index.js @@ -1,12 +1,9 @@ import DownloadPage from "./DownloadPage"; import capitalize from "../../utils/capitalize"; -import env from "../../enviroment/envFrontEnd"; import axios from "../../axiosInterceptor"; import bytes from "bytes"; import React from "react"; -const currentURL = env.url; - class DownloadPageContainer extends React.Component { constructor(props) { @@ -44,7 +41,7 @@ class DownloadPageContainer extends React.Component { const _id = this.props.match.params.id; const tempToken = this.props.match.params.tempToken - axios.get(currentURL +`/file-service/public/info/${_id}/${tempToken}`).then((results) => { + axios.get(`/file-service/public/info/${_id}/${tempToken}`).then((results) => { const data = results.data; @@ -70,7 +67,7 @@ class DownloadPageContainer extends React.Component { const _id = this.props.match.params.id; const tempToken = this.props.match.params.tempToken - const finalUrl = !this.isPersonalFile ? currentURL + `/file-service/public/download/${_id}/${tempToken}` : currentURL + `/file-service-personal/public/download/${_id}/${tempToken}`; + const finalUrl = !this.isPersonalFile ? `/file-service/public/download/${_id}/${tempToken}` : `/file-service-personal/public/download/${_id}/${tempToken}`; const link = document.createElement('a'); document.body.appendChild(link); diff --git a/src/components/FileItem/index.js b/src/components/FileItem/index.js index a6b2c3e..30a96b2 100644 --- a/src/components/FileItem/index.js +++ b/src/components/FileItem/index.js @@ -11,8 +11,6 @@ import Swal from "sweetalert2" import { setMoverID } from "../../actions/mover"; import { setMobileContextMenu } from "../../actions/mobileContextMenu"; -const currentURL = env.url; - class FileItemContainer extends React.Component { constructor(props) { @@ -63,7 +61,7 @@ class FileItemContainer extends React.Component { imageClassname: this.props.listView ? "file__image__listview" : "file__image" })) - const url = !this.props.metadata.personalFile ? currentURL +`/file-service/thumbnail/${thumbnailID}` : currentURL +`/file-service-personal/thumbnail/${thumbnailID}`; + const url = !this.props.metadata.personalFile ? `/file-service/thumbnail/${thumbnailID}` : `/file-service-personal/thumbnail/${thumbnailID}`; axios.get(url, config).then((results) => { diff --git a/src/components/FolderTreeStorage/index.js b/src/components/FolderTreeStorage/index.js index 9ea5672..01c35ee 100644 --- a/src/components/FolderTreeStorage/index.js +++ b/src/components/FolderTreeStorage/index.js @@ -5,8 +5,6 @@ import {connect} from "react-redux"; import {setInsertedFolderTreeID} from "../../actions/folderTree" import FolderTreeStorage from "./FolderTreeStorage"; -const currentURL = env.url; - class FolderTreeStorageContainer extends React.Component { constructor(props) { @@ -25,8 +23,8 @@ class FolderTreeStorageContainer extends React.Component { const parent = this.props.type === "drive" ? "root" : "/"; - const url = this.props.type === "drive" ? currentURL + `/folder-service-google/list?parent=${parent}` - : currentURL + `/folder-service/list?parent=${parent}&type=${this.props.type}`; + const url = this.props.type === "drive" ? `/folder-service-google/list?parent=${parent}` + : `/folder-service/list?parent=${parent}&type=${this.props.type}`; axios.get(url).then((response) => { @@ -99,7 +97,7 @@ class FolderTreeStorageContainer extends React.Component { const id = this.props.firstLoadDetails._id; const url = (this.props.type === "drive") - ? currentURL + `/folder-service-google/subfolder-list-full?id=${id}` : currentURL + `/folder-service/subfolder-list-full?id=${id}` + ? `/folder-service-google/subfolder-list-full?id=${id}` : `/folder-service/subfolder-list-full?id=${id}` axios.get(url).then((response) => { if (response.data.length !== 0) { diff --git a/src/components/FolderTreeStorageSub/index.js b/src/components/FolderTreeStorageSub/index.js index 1c145e8..bcfd94d 100644 --- a/src/components/FolderTreeStorageSub/index.js +++ b/src/components/FolderTreeStorageSub/index.js @@ -7,8 +7,6 @@ import {connect} from "react-redux" import FolderTreeStorageSub2 from ".././FolderTreeStorageSub"; import FolderTreeStorageSub from "./FolderTreeStorageSub"; -const currentURL = env.url; - class FolderTreeStorageSubContainer extends React.Component { constructor(props) { @@ -244,7 +242,7 @@ class FolderTreeStorageSubContainer extends React.Component { const parent = this.props.folder._id; - const url = this.props.type === "drive" ? currentURL + `/folder-service-google/list?parent=${parent}` : currentURL + `/folder-service/list?parent=${parent}`; + const url = this.props.type === "drive" ? `/folder-service-google/list?parent=${parent}` : `/folder-service/list?parent=${parent}`; axios.get(url).then((response) => { this.setState(() => { diff --git a/src/components/Header/index.js b/src/components/Header/index.js index 4e25b25..7ad1ab6 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -97,33 +97,33 @@ class HeaderContainer extends React.Component { return; - if (this.searchValue === "") { + // if (this.searchValue === "") { - return this.setState(() => { - return { - ...this.state, - suggestedList: { - fileList: [], - folderList: [] - } - } - }) - } + // return this.setState(() => { + // return { + // ...this.state, + // suggestedList: { + // fileList: [], + // folderList: [] + // } + // } + // }) + // } - const url = !env.googleDriveEnabled ? currentURL +`/file-service/suggested-list?search=${this.searchValue}` : currentURL +`/file-service-google-mongo/suggested-list?search=${this.searchValue}` + // const url = !env.googleDriveEnabled ? currentURL +`/file-service/suggested-list?search=${this.searchValue}` : currentURL +`/file-service-google-mongo/suggested-list?search=${this.searchValue}` - axios.get(url).then((results) => { + // axios.get(url).then((results) => { - this.setState(() => { - return { - ...this.state, - suggestedList: results.data - } - }) + // this.setState(() => { + // return { + // ...this.state, + // suggestedList: results.data + // } + // }) - }).catch((err) => { - console.log(err) - }) + // }).catch((err) => { + // console.log(err) + // }) } showSettings = () => { diff --git a/src/components/MainSection/index.js b/src/components/MainSection/index.js index 07e8349..f7fe9a0 100644 --- a/src/components/MainSection/index.js +++ b/src/components/MainSection/index.js @@ -12,8 +12,6 @@ import {history} from "../../routers/AppRouter"; import React from "react"; import { getUpdateSettingsID } from "../../utils/updateSettings"; -const currentURL = env.url; - class MainSectionContainer extends React.Component { constructor(props) { @@ -160,9 +158,13 @@ class MainSectionContainer extends React.Component { axios.post("/user-service/get-token").then((response) => { + + const finalUrl = - isGoogle ? !isGoogleDoc ? currentURL + `/file-service-google/download/${fileID}` : currentURL + `/file-service-google-doc/download/${fileID}` - : !isPersonal ? currentURL + `/file-service/download/${fileID}` : currentURL + `/file-service-personal/download/${fileID}` + isGoogle ? !isGoogleDoc ? `/file-service-google/download/${fileID}` : `/file-service-google-doc/download/${fileID}` + : !isPersonal ? `/file-service/download/${fileID}` : `/file-service-personal/download/${fileID}` + + console.log("download file", finalUrl); const link = document.createElement('a'); document.body.appendChild(link); diff --git a/src/components/MobileContextMenu/index.js b/src/components/MobileContextMenu/index.js index 4123aa0..2f00da7 100644 --- a/src/components/MobileContextMenu/index.js +++ b/src/components/MobileContextMenu/index.js @@ -6,11 +6,8 @@ import { startRenameFile, startRemoveFile } from "../../actions/files"; import { setShareSelected, setLastSelected } from "../../actions/selectedItem"; import { resetMobileContextMenu } from "../../actions/mobileContextMenu"; import axios from "../../axiosInterceptor"; -import env from "../../enviroment/envFrontEnd"; import { setMoverID } from "../../actions/mover"; -const currentURL = env.url; - class MobileContextMenuContainer extends React.Component { constructor(props) { @@ -82,8 +79,8 @@ class MobileContextMenuContainer extends React.Component { axios.post("/user-service/get-token").then((response) => { const finalUrl = - isGoogle ? !isGoogleDoc ? currentURL + `/file-service-google/download/${fileID}` : currentURL + `/file-service-google-doc/download/${fileID}` - : !isPersonal ? currentURL + `/file-service/download/${fileID}` : currentURL + `/file-service-personal/download/${fileID}` + isGoogle ? !isGoogleDoc ? `/file-service-google/download/${fileID}` : `/file-service-google-doc/download/${fileID}` + : !isPersonal ? `/file-service/download/${fileID}` : `/file-service-personal/download/${fileID}` const link = document.createElement('a'); document.body.appendChild(link); diff --git a/src/components/MoverMenu/index.js b/src/components/MoverMenu/index.js index 6980521..503875a 100644 --- a/src/components/MoverMenu/index.js +++ b/src/components/MoverMenu/index.js @@ -47,7 +47,7 @@ class MoverMenuContainer extends React.Component { if (this.props.isFile) { - const url = this.props.isGoogle ? currentURL+`/file-service-google/move` : currentURL+`/file-service/move`; + const url = this.props.isGoogle ? `/file-service-google/move` : `/file-service/move`; axios.patch(url, data).then((response) => { @@ -60,7 +60,7 @@ class MoverMenuContainer extends React.Component { } else { - const url = this.props.isGoogle ? currentURL+`/folder-service-google/move` : currentURL+`/folder-service/move`; + const url = this.props.isGoogle ? `/folder-service-google/move` : `/folder-service/move`; axios.patch(url, data).then((response) => { @@ -101,9 +101,9 @@ class MoverMenuContainer extends React.Component { const id = this.props.isGoogle ? "root" : "/" const url = this.props.isGoogle ? - currentURL+`/folder-service-google/list?search=${searchValue}&sortBy=DEFAULT}` - : this.props.isPersonal ? currentURL+`/folder-service/list?parent=${id}&search=${searchValue}&storageType=s3&sortBy=DEFAULT` - : currentURL+`/folder-service/list?parent=${id}&search=${searchValue}&storageType=stripe&sortBy=DEFAULT`; + `/folder-service-google/list?search=${searchValue}&sortBy=DEFAULT}` + : this.props.isPersonal ? `/folder-service/list?parent=${id}&search=${searchValue}&itemType=personal&sortBy=DEFAULT` + : `/folder-service/list?parent=${id}&search=${searchValue}&itemType=nonpersonal&sortBy=DEFAULT`; axios.get(url).then((response) => { @@ -136,7 +136,7 @@ class MoverMenuContainer extends React.Component { const id = this.props.isGoogle ? "root" : "/"; - const url = this.props.isGoogle ? currentURL+`/folder-service-google/list?parent=${id}` : this.props.isPersonal ? currentURL+`/folder-service/list?parent=${id}&storageType=s3` : currentURL+`/folder-service/list?parent=${id}&storageType=stripe`; + const url = this.props.isGoogle ? `/folder-service-google/list?parent=${id}` : this.props.isPersonal ? `/folder-service/list?parent=${id}&itemType=personal` : `/folder-service/list?parent=${id}&itemType=nonpersonal`; axios.get(url).then((response) => { @@ -179,7 +179,7 @@ class MoverMenuContainer extends React.Component { historyList.pop(); } - const url = this.props.isGoogle ? currentURL+`/folder-service-google/list?parent=${currentID}` : this.props.isPersonal ? currentURL+`/folder-service/list?parent=${currentID}&storageType=s3` : currentURL+`/folder-service/list?parent=${currentID}&storageType=stripe`; + const url = this.props.isGoogle ? `/folder-service-google/list?parent=${currentID}` : this.props.isPersonal ? `/folder-service/list?parent=${currentID}&itemType=personal` : `/folder-service/list?parent=${currentID}&itemType=nonpersonal`; axios.get(url).then((response) => { @@ -212,7 +212,7 @@ class MoverMenuContainer extends React.Component { if (lastTimeDifference < 1500 && id === this.state.selected) { - const url = this.props.isGoogle ? currentURL+`/folder-service-google/list?parent=${id}` : this.props.isPersonal ? currentURL+`/folder-service/list?parent=${id}&storageType=s3` : currentURL+`/folder-service/list?parent=${id}&storageType=stripe`; + const url = this.props.isGoogle ? `/folder-service-google/list?parent=${id}` : this.props.isPersonal ? `/folder-service/list?parent=${id}&itemType=personal` : `/folder-service/list?parent=${id}&itemType=nonpersonal`; axios.get(url).then((response) => { @@ -250,7 +250,7 @@ class MoverMenuContainer extends React.Component { const id = this.props.isGoogle ? "root" : "/" - const url = this.props.isGoogle ? currentURL+`/folder-service-google/list?parent=${id}` : this.props.isPersonal ? currentURL+`/folder-service/list?parent=${id}&storageType=s3` : currentURL+`/folder-service/list?parent=${id}&storageType=stripe`; + const url = this.props.isGoogle ? `/folder-service-google/list?parent=${id}` : this.props.isPersonal ? `/folder-service/list?parent=${id}&itemType=personal` : `/folder-service/list?parent=${id}&itemType=nonpersonal`; axios.get(url).then((response) => { diff --git a/src/components/PhotoViewer/index.js b/src/components/PhotoViewer/index.js index 36c012d..c9e9d46 100644 --- a/src/components/PhotoViewer/index.js +++ b/src/components/PhotoViewer/index.js @@ -5,8 +5,6 @@ import React from "react"; import {resetPhotoID} from "../../actions/photoViewer"; import axios from "../../axiosInterceptor"; -const currentURL = env.url; - class PhotoViewerContainer extends React.Component { constructor(props) { @@ -28,8 +26,8 @@ class PhotoViewerContainer extends React.Component { responseType: 'arraybuffer' }; - const url = this.props.isGoogle ? currentURL +`/file-service-google/full-thumbnail/${this.props.photoID}` - : !this.props.isPersonal ? currentURL +`/file-service/full-thumbnail/${this.props.photoID}` : currentURL +`/file-service-personal/full-thumbnail/${this.props.photoID}`; + const url = this.props.isGoogle ? `/file-service-google/full-thumbnail/${this.props.photoID}` + : !this.props.isPersonal ? `/file-service/full-thumbnail/${this.props.photoID}` : `/file-service-personal/full-thumbnail/${this.props.photoID}`; axios.get(url, config).then((response) => { diff --git a/src/components/PopupWindow/index.js b/src/components/PopupWindow/index.js index 690dcba..1946cc1 100644 --- a/src/components/PopupWindow/index.js +++ b/src/components/PopupWindow/index.js @@ -7,8 +7,6 @@ import React from "react"; import { setPhotoID } from "../../actions/photoViewer"; import axiosNonInterceptor from "axios"; -const currentURL = env.url; - class PopupWindowContainer extends React.Component { constructor(props) { @@ -65,8 +63,8 @@ class PopupWindowContainer extends React.Component { const isDrive = this.props.popupFile.metadata.drive; const isPersonal = this.props.popupFile.metadata.personalFile; - const url = isDrive ? currentURL +`/file-service-google/thumbnail/${thumbnailID}` - : !isPersonal ? currentURL +`/file-service/thumbnail/${thumbnailID}` : currentURL +`/file-service-personal/thumbnail/${thumbnailID}`; + const url = isDrive ? `/file-service-google/thumbnail/${thumbnailID}` + : !isPersonal ? `/file-service/thumbnail/${thumbnailID}` : `/file-service-personal/thumbnail/${thumbnailID}`; axios.get(url, config).then((results) => { @@ -110,9 +108,9 @@ class PopupWindowContainer extends React.Component { const isPersonal = this.props.popupFile.metadata.personalFile; const finalUrl = isDrive ? - currentURL + `/file-service-google/stream-video/${this.props.popupFile._id}` - : !isPersonal ? currentURL + `/file-service/stream-video/${this.props.popupFile._id}` - : currentURL + `/file-service-personal/stream-video/${this.props.popupFile._id}` + `/file-service-google/stream-video/${this.props.popupFile._id}` + : !isPersonal ? `/file-service/stream-video/${this.props.popupFile._id}` + : `/file-service-personal/stream-video/${this.props.popupFile._id}` this.setState(() => ({ ...this.state, diff --git a/src/components/QuickAccessItem/index.js b/src/components/QuickAccessItem/index.js index 2305774..4a295a5 100644 --- a/src/components/QuickAccessItem/index.js +++ b/src/components/QuickAccessItem/index.js @@ -93,7 +93,7 @@ class QuickAccessItemContainer extends React.Component { const isPersonal = this.props.metadata.personalFile; - const url = !isPersonal ? currentURL +`/file-service/thumbnail/${thumbnailID}` : currentURL +`/file-service-personal/thumbnail/${thumbnailID}`; + const url = !isPersonal ? `/file-service/thumbnail/${thumbnailID}` : `/file-service-personal/thumbnail/${thumbnailID}`; axios.get(url, config).then((results) => { diff --git a/src/components/RightSection/index.js b/src/components/RightSection/index.js index d88d14d..d61d834 100644 --- a/src/components/RightSection/index.js +++ b/src/components/RightSection/index.js @@ -13,8 +13,6 @@ import { setMoverID } from "../../actions/mover"; import mobilecheck from "../../utils/mobileCheck"; import { setMobileContextMenu } from "../../actions/mobileContextMenu"; -const currentURL = env.url; - class RightSectionContainer extends React.Component { constructor(props) { @@ -65,7 +63,7 @@ class RightSectionContainer extends React.Component { const data = {id: props.selectedItem.id} - axios.delete(currentURL +'/file-service/transcode-video/remove', { + axios.delete('/file-service/transcode-video/remove', { data }).then(() => { @@ -97,7 +95,7 @@ class RightSectionContainer extends React.Component { })) - axios.post(currentURL +'/file-service/transcode-video', data,config) + axios.post('/file-service/transcode-video', data,config) .then((response) => { const data = response.data; diff --git a/src/components/SettingsPage/index.js b/src/components/SettingsPage/index.js index 491e668..a786de0 100644 --- a/src/components/SettingsPage/index.js +++ b/src/components/SettingsPage/index.js @@ -370,7 +370,7 @@ class SettingsPageContainer extends React.Component { const clientID = this.state.googleID; const clientKey = this.state.googleSecret; - const clientRedirect = env.url + "/add-google-account" + const clientRedirect = "/add-google-account" const data = { clientID, @@ -644,7 +644,7 @@ class SettingsPageContainer extends React.Component { const tempToken = response.data.tempToken; - const finalUrl = env.url + `/user-service/download-personal-file-list/${tempToken}`; + const finalUrl = `/user-service/download-personal-file-list/${tempToken}`; const link = document.createElement('a'); document.body.appendChild(link); diff --git a/src/components/ShareMenu/index.js b/src/components/ShareMenu/index.js index 48eb32d..581e040 100644 --- a/src/components/ShareMenu/index.js +++ b/src/components/ShareMenu/index.js @@ -47,7 +47,7 @@ class ShareMenuContainer extends React.Component { componentDidUpdate = () => { if (!this.props.shareSelected.metadata) return; - const shareURL = this.props.shareSelected.metadata.drive ? this.props.shareSelected.metadata.link : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}` + const shareURL = this.props.shareSelected.metadata.drive ? this.props.shareSelected.metadata.link : `/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}` if (this.props.shareSelected.metadata.link && shareURL !== this.state.title) { this.setState(() => { @@ -76,7 +76,7 @@ class ShareMenuContainer extends React.Component { if (result.value) { - const url = this.props.shareSelected.metadata.drive ? currentURL +`/file-service-google/make-public/${this.props.shareSelected._id}` : currentURL +`/file-service/make-public/${this.props.shareSelected._id}`; + const url = this.props.shareSelected.metadata.drive ? `/file-service-google/make-public/${this.props.shareSelected._id}` : `/file-service/make-public/${this.props.shareSelected._id}`; axios.patch(url, undefined).then((results) => { @@ -131,7 +131,7 @@ class ShareMenuContainer extends React.Component { if (result.value) { - axios.patch(currentURL +`/file-service/make-one/${this.props.shareSelected._id}`, undefined).then((results) => { + axios.patch(`/file-service/make-one/${this.props.shareSelected._id}`, undefined).then((results) => { this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": { ...this.props.shareSelected.metadata, @@ -161,7 +161,7 @@ class ShareMenuContainer extends React.Component { removeLink = () => { - const url = this.props.shareSelected.metadata.drive ? currentURL +`/file-service-google/remove-link/${this.props.shareSelected._id}` : currentURL +`/file-service/remove-link/${this.props.shareSelected._id}` + const url = this.props.shareSelected.metadata.drive ? `/file-service-google/remove-link/${this.props.shareSelected._id}` : `/file-service/remove-link/${this.props.shareSelected._id}` axios.delete(url, { }).then(() => { diff --git a/src/components/ShareModel/index.js b/src/components/ShareModel/index.js index c785c57..9cd2979 100644 --- a/src/components/ShareModel/index.js +++ b/src/components/ShareModel/index.js @@ -42,7 +42,7 @@ class ShareModelContainer extends React.Component { const linkType = response.data.metadata.linkType; - const shareURL = this.props.shareSelected.metadata.drive ? results.data : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}` + const shareURL = this.props.shareSelected.metadata.drive ? results.data : `/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}` console.log("share link type", linkType); @@ -262,7 +262,7 @@ class ShareModelContainer extends React.Component { if (result.value) { - const url = this.props.shareSelected.metadata.drive ? currentURL +`/file-service-google/make-public/${this.props.shareSelected._id}` : currentURL +`/file-service/make-public/${this.props.shareSelected._id}`; + const url = this.props.shareSelected.metadata.drive ? `/file-service-google/make-public/${this.props.shareSelected._id}` : `/file-service/make-public/${this.props.shareSelected._id}`; axios.patch(url, undefined).then((results) => { @@ -316,7 +316,7 @@ class ShareModelContainer extends React.Component { if (result.value) { - axios.patch(currentURL +`/file-service/make-one/${this.props.shareSelected._id}`, undefined).then((results) => { + axios.patch(`/file-service/make-one/${this.props.shareSelected._id}`, undefined).then((results) => { this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": { ...this.props.shareSelected.metadata, @@ -358,7 +358,7 @@ class ShareModelContainer extends React.Component { removeLink = () => { - const url = this.props.shareSelected.metadata.drive ? currentURL +`/file-service-google/remove-link/${this.props.shareSelected._id}` : currentURL +`/file-service/remove-link/${this.props.shareSelected._id}` + const url = this.props.shareSelected.metadata.drive ? `/file-service-google/remove-link/${this.props.shareSelected._id}` : `/file-service/remove-link/${this.props.shareSelected._id}` axios.delete(url, { }).then(() => {