diff --git a/client/model/files.js b/client/model/files.js index e76a2a58..42f8cbef 100644 --- a/client/model/files.js +++ b/client/model/files.js @@ -12,7 +12,7 @@ class FileSystem{ this.current_path = null; } - ls(path){ + ls(path, show_hidden = false){ this.current_path = path; this.obs && this.obs.complete(); return Observable.create((obs) => { @@ -20,7 +20,7 @@ class FileSystem{ let keep_pulling_from_http = false; this._ls_from_cache(path, true).then((cache) => { const fetch_from_http = (_path) => { - return this._ls_from_http(_path).then(() => new Promise((done, err) => { + return this._ls_from_http(_path, show_hidden).then(() => new Promise((done, err) => { window.setTimeout(() => done(), 2000); })).then(() => { if(keep_pulling_from_http === false) return Promise.resolve(); @@ -40,14 +40,11 @@ class FileSystem{ }); } - _ls_from_http(path){ + _ls_from_http(path, show_hidden){ const url = appendShareToUrl("/api/files/ls?path="+prepare(path)); return http_get(url).then((response) => { - response.results = (response.results || []).map((f) => { - f.path = pathBuilder(path, f.name, f.type); - return f; - }); + response = fileMiddleware(response, path, show_hidden); return cache.upsert(cache.FILE_PATH, [currentShare(), path], (_files) => { let store = Object.assign({ @@ -72,13 +69,13 @@ class FileSystem{ for(let j=0; j e); store.results = store.results.concat(_files_virtual_to_keep); } store.last_update = new Date(); @@ -361,10 +358,11 @@ class FileSystem{ }); } - search(keyword, path = "/"){ + search(keyword, path = "/", show_hidden){ const url = appendShareToUrl("/api/files/search?path="+prepare(path)+"&q="+encodeURIComponent(keyword)) - return http_get(url).then((res) => { - return res.results + return http_get(url).then((response) => { + response = fileMiddleware(response, path, show_hidden); + return response.results; }); } @@ -441,11 +439,11 @@ class FileSystem{ last_update: new Date() }; } - let file = { + let file = mutateFile({ path: path, name: basename(path), type: /\/$/.test(path) ? 'directory' : 'file' - }; + }, path); if(icon) file.icon = icon; res.results.push(file); return res; @@ -468,4 +466,28 @@ class FileSystem{ } } + +const createLink = (type, path) => { + return type === "file" ? "/view" + path : "/files" + path; +}; + +const fileMiddleware = (response, path, show_hidden) => { + for(let i=0; i { + if(file.path === undefined) { + file.path = pathBuilder(path, file.name, file.type); + } + file.link = createLink(file.type, file.path); + return file; +}; + export const Files = new FileSystem(); diff --git a/client/pages/adminpage/setup.js b/client/pages/adminpage/setup.js index fdb62368..1e455a4f 100644 --- a/client/pages/adminpage/setup.js +++ b/client/pages/adminpage/setup.js @@ -194,7 +194,6 @@ class MultiStepForm extends React.Component { if(value === "tunnel"){ const waitForDomain = (count = 0) => { return this.props.tunnelCall().then((url) => { - console.log("- config tunnel_url: %s - %d", url, count); if(url && /\.filestash\.app$/.test(url) === true){ return Promise.resolve(url); } diff --git a/client/pages/filespage.helper.js b/client/pages/filespage.helper.js index f41cecb2..329cfd81 100644 --- a/client/pages/filespage.helper.js +++ b/client/pages/filespage.helper.js @@ -417,7 +417,3 @@ export const onSearch = (keyword, path = "/") => { .catch((err) => obs.error(err)); }); }; - -export const createLink = (type, path) => { - return type === "file" ? "/view" + path : "/files" + path; -} diff --git a/client/pages/filespage.js b/client/pages/filespage.js index b0a8f989..41abba5c 100644 --- a/client/pages/filespage.js +++ b/client/pages/filespage.js @@ -6,7 +6,7 @@ import { SelectableGroup } from 'react-selectable'; import './filespage.scss'; import './error.scss'; import { Files } from '../model/'; -import { sort, onCreate, onRename, onMultiRename, onDelete, onMultiDelete, onUpload, onSearch, createLink } from './filespage.helper'; +import { sort, onCreate, onRename, onMultiRename, onDelete, onMultiDelete, onUpload, onSearch } from './filespage.helper'; import { NgIf, NgShow, Loader, EventReceiver, LoggedInOnly, ErrorPage } from '../components/'; import { notify, debounce, goToFiles, goToViewer, event, settings_get, settings_put } from '../helpers/'; import { BreadCrumb, FileSystem, FrequentlyAccess, Submenu } from './filespage/'; @@ -120,24 +120,14 @@ export class FilesPage extends React.Component { onRefresh(path = this.state.path){ this._cleanupListeners(); - const observer = Files.ls(path).subscribe((res) => { + const observer = Files.ls(path, this.state.show_hidden).subscribe((res) => { if(res.status !== "ok"){ notify.send(res, "error"); return; } - let files = new Array(res.results.length); - for(let i=0,l=res.results.length; i { - for(let i=0; i { this.setState({ files: sort(f, this.state.sort), loading: false,