From 7e5beeff464e75ab185c430cd96e7cc67209ccc1 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Mon, 13 Jul 2020 14:20:56 +0000 Subject: [PATCH 01/10] fix: directory conflict checking --- frontend/src/utils/upload.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/utils/upload.js b/frontend/src/utils/upload.js index 61e6a8e7..54b5669e 100644 --- a/frontend/src/utils/upload.js +++ b/frontend/src/utils/upload.js @@ -6,10 +6,7 @@ export function checkConflict(files, items) { items = [] } - let folder_upload = false - if (files[0].fullPath !== undefined) { - folder_upload = true - } + let folder_upload = files[0].fullPath !== undefined let conflict = false for (let i = 0; i < files.length; i++) { @@ -69,7 +66,7 @@ export function scanFiles(dt) { const dir = { isDir: true, size: 0, - path: `${directory}${entry.name}` + fullPath: `${directory}${entry.name}` } contents.push(dir) @@ -112,7 +109,7 @@ export function handleFiles(files, path, overwrite = false) { if (file.isDir) { itemPath = path - let folders = file.path.split("/") + let folders = file.fullPath.split("/") for (let i = 0; i < folders.length; i++) { let folder = folders[i] From b3b644527d5673e16e61d404ff58a3c7bd6b6637 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Mon, 13 Jul 2020 17:37:43 +0000 Subject: [PATCH 02/10] fix: dark theme colors --- frontend/public/themes/dark.css | 66 +++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/frontend/public/themes/dark.css b/frontend/public/themes/dark.css index 978b4f0f..e916457a 100644 --- a/frontend/public/themes/dark.css +++ b/frontend/public/themes/dark.css @@ -1,7 +1,7 @@ :root { - --background: #121212; - --surfacePrimary: #171819; - --surfaceSecondary: #212528; + --background: #141D24; + --surfacePrimary: #20292F; + --surfaceSecondary: #3A4147; --divider: rgba(255, 255, 255, 0.12); --icon: #ffffff; --textPrimary: rgba(255, 255, 255, 0.87); @@ -30,25 +30,34 @@ header { #search #input { background: var(--surfaceSecondary); + border-color: var(--surfacePrimary); } -#search.active #input, -#search.active .boxes { +#search #input input::placeholder { + color: var(--textSecondary); +} +#search.active #input { background: var(--surfacePrimary); } #search.active input { color: var(--textPrimary); } -#search.active #result { +#search #result { background: var(--background); color: var(--textPrimary); } -#search.active .boxes h3 { +#search .boxes { + background: var(--surfaceSecondary); +} +#search .boxes h3 { color: var(--textPrimary); } .action { color: var(--textPrimary) !important; } +.action:hover { + background-color: rgba(255, 255, 255, .1); +} .action i { color: var(--icon) !important; } @@ -93,6 +102,10 @@ nav > div { background: var(--background); } +.message { + color: var(--textPrimary); +} + .card { background: var(--surfacePrimary); color: var(--textPrimary); @@ -106,9 +119,23 @@ nav > div { .dashboard p label { color: var(--textPrimary); } +.card#share ul li input, +.card#share ul li select, .input { background: var(--surfaceSecondary); color: var(--textPrimary); + border: 1px solid rgba(255, 255, 255, 0.05); +} +.input:hover, +.input:focus { + border-color: rgba(255, 255, 255, 0.15); +} +.input--red { + background: #73302D; +} + +.input--green { + background: #147A41; } .dashboard #nav li, @@ -119,10 +146,27 @@ nav > div { color: var(--textPrimary); } +table th { + color: var(--textSecondary); +} + +.file-list li:hover { + background: var(--surfaceSecondary); +} +.file-list li:before { + color: var(--textSecondary); +} +.file-list li[aria-selected=true]:before { + color: var(--icon); +} + .shell { background: var(--surfacePrimary); color: var(--textPrimary); } +.shell__result { + border-top: 1px solid var(--divider); +} #editor-container { background: var(--background); @@ -146,3 +190,11 @@ nav > div { background: var(--surfaceSecondary) !important; } } + +.share__box, .share__box__download { + background: var(--surfaceSecondary) !important; + color: var(--textPrimary); +} +.share__box__download { + border-bottom-color: var(--divider); +} \ No newline at end of file From 194030fcfcf54a2cf5e2f8ececcbb4754474d8f8 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Mon, 13 Jul 2020 18:09:01 +0000 Subject: [PATCH 03/10] fix: prompt before closing window --- frontend/src/api/files.js | 6 +----- frontend/src/store/modules/upload.js | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 602090c1..135e9799 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -94,9 +94,6 @@ export async function post (url, content = '', overwrite = false, onupload) { request.upload.onprogress = onupload } - // Send a message to user before closing the tab during file upload - window.onbeforeunload = () => "Files are being uploaded." - request.onload = () => { if (request.status === 200) { resolve(request.responseText) @@ -112,8 +109,7 @@ export async function post (url, content = '', overwrite = false, onupload) { } request.send(content) - // Upload is done no more message before closing the tab - }).finally(() => { window.onbeforeunload = null }) + }) } function moveCopy (items, copy = false) { diff --git a/frontend/src/store/modules/upload.js b/frontend/src/store/modules/upload.js index 738edaf9..6552dd01 100644 --- a/frontend/src/store/modules/upload.js +++ b/frontend/src/store/modules/upload.js @@ -37,6 +37,11 @@ const mutations = { } } +const beforeUnload = (event) => { + event.preventDefault() + event.returnValue = '' +} + const actions = { upload: (context, item) => { let uploadsCount = Object.keys(context.state.uploads).length; @@ -45,6 +50,7 @@ const actions = { let isUploadsEmpty = uploadsCount == 0 if (isQueueEmpty && isUploadsEmpty) { + window.addEventListener('beforeunload', beforeUnload) buttons.loading('upload') } @@ -67,6 +73,7 @@ const actions = { let canProcess = isBellowLimit && !isQueueEmpty if (isFinished) { + window.removeEventListener('beforeunload', beforeUnload) buttons.success('upload') context.commit('reset') context.commit('setReload', true, { root: true }) From 0727496601a9918c8131c56f62419bfac7ac589a Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Mon, 13 Jul 2020 18:59:48 +0000 Subject: [PATCH 04/10] fix: remove incomplete uploaded files --- http/resource.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http/resource.go b/http/resource.go index 95224083..2fd6cf04 100644 --- a/http/resource.go +++ b/http/resource.go @@ -127,6 +127,10 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques return nil }, action, r.URL.Path, "", d.user) + if err != nil { + _ = d.user.Fs.RemoveAll(r.URL.Path) + } + return errToStatus(err), err }) From 716396a726329f0ba42fc34167dd07497c5bf47c Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:19:48 +0000 Subject: [PATCH 05/10] feat: add previewer title and loading indicator --- frontend/public/themes/dark.css | 2 +- frontend/src/components/files/Preview.vue | 37 ++++++++++++++++------- frontend/src/css/styles.css | 12 +++++++- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/frontend/public/themes/dark.css b/frontend/public/themes/dark.css index e916457a..1ee5f1ac 100644 --- a/frontend/public/themes/dark.css +++ b/frontend/public/themes/dark.css @@ -16,7 +16,7 @@ body { #loading { background: var(--background); } -#loading .spinner div { +#loading .spinner div, #previewer .loading .spinner div { background: var(--icon); } diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue index 1294fa5f..f0a7ef02 100644 --- a/frontend/src/components/files/Preview.vue +++ b/frontend/src/components/files/Preview.vue @@ -5,18 +5,33 @@ close - - - - + - - +
+
+
+
+
+
+
+ + diff --git a/frontend/src/css/_buttons.css b/frontend/src/css/_buttons.css index 79dab790..087c6286 100644 --- a/frontend/src/css/_buttons.css +++ b/frontend/src/css/_buttons.css @@ -25,8 +25,8 @@ background: var(--red); } -.button--red:hover { - background: var(--dark-red); +.button--blue { + background: var(--blue); } .button--flat { diff --git a/http/resource.go b/http/resource.go index e3859549..20376968 100644 --- a/http/resource.go +++ b/http/resource.go @@ -148,12 +148,31 @@ var resourcePatchHandler = withUser(func(w http.ResponseWriter, r *http.Request, return http.StatusForbidden, nil } - if r.URL.Query().Get("override") != "true" { - if _, err := d.user.Fs.Stat(dst); err == nil { + override := r.URL.Query().Get("override") == "true" + rename := r.URL.Query().Get("rename") == "true" + + if !override && !rename { + if _, err = d.user.Fs.Stat(dst); err == nil { return http.StatusConflict, nil } } + if rename { + counter := 1 + dir, name := filepath.Split(dst) + ext := filepath.Ext(name) + base := strings.TrimSuffix(name, ext) + + for { + if _, err = d.user.Fs.Stat(dst); err != nil { + break + } + new := fmt.Sprintf("%s(%d)%s", base, counter, ext) + dst = filepath.Join(dir, new) + counter++ + } + } + err = d.RunHook(func() error { switch action { // TODO: use enum From 43526d9d1a8c837245e3f5059e0b4737583eeaeb Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Thu, 16 Jul 2020 19:50:00 +0000 Subject: [PATCH 09/10] feat: duplicate files in the same directory --- frontend/src/components/files/Listing.vue | 9 ++++++++- frontend/src/components/prompts/Copy.vue | 15 ++++++++++++++- frontend/src/store/mutations.js | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/files/Listing.vue b/frontend/src/components/files/Listing.vue index 0ebc2a9c..6f811efb 100644 --- a/frontend/src/components/files/Listing.vue +++ b/frontend/src/components/files/Listing.vue @@ -248,7 +248,8 @@ export default { this.$store.commit('updateClipboard', { key: key, - items: items + items: items, + path: this.$route.path }) }, paste (event) { @@ -282,6 +283,12 @@ export default { } } + if (this.$store.state.clipboard.path == this.$route.path) { + action(false, true) + + return + } + let conflict = upload.checkConflict(items, this.req.items) let overwrite = false diff --git a/frontend/src/components/prompts/Copy.vue b/frontend/src/components/prompts/Copy.vue index d31b05df..c8618b4f 100644 --- a/frontend/src/components/prompts/Copy.vue +++ b/frontend/src/components/prompts/Copy.vue @@ -16,7 +16,6 @@ :title="$t('buttons.cancel')">{{ $t('buttons.cancel') }} @@ -59,6 +58,13 @@ export default { await api.copy(items, overwrite, rename).then(() => { buttons.success('copy') + + if (this.$route.path === this.dest) { + this.$store.commit('setReload', true) + + return + } + this.$router.push({ path: this.dest }) }).catch((e) => { buttons.done('copy') @@ -66,6 +72,13 @@ export default { }) } + if (this.$route.path === this.dest) { + this.$store.commit('closeHovers') + action(false, true) + + return + } + let dstItems = (await api.fetch(this.dest)).items let conflict = upload.checkConflict(items, dstItems) diff --git a/frontend/src/store/mutations.js b/frontend/src/store/mutations.js index caefcf53..46aad6e6 100644 --- a/frontend/src/store/mutations.js +++ b/frontend/src/store/mutations.js @@ -78,6 +78,7 @@ const mutations = { updateClipboard: (state, value) => { state.clipboard.key = value.key state.clipboard.items = value.items + state.clipboard.path = value.path }, resetClipboard: (state) => { state.clipboard.key = '' From 10570ade442b573ebe00af08369e28b1b0688df6 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Fri, 17 Jul 2020 01:01:27 +0000 Subject: [PATCH 10/10] fix: reset clipboard after pasting cutted files --- frontend/src/components/files/Listing.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/files/Listing.vue b/frontend/src/components/files/Listing.vue index 6f811efb..6a4eefdb 100644 --- a/frontend/src/components/files/Listing.vue +++ b/frontend/src/components/files/Listing.vue @@ -278,6 +278,7 @@ export default { if (this.$store.state.clipboard.key === 'x') { action = (overwrite, rename) => { api.move(items, overwrite, rename).then(() => { + this.$store.commit('resetClipboard') this.$store.commit('setReload', true) }).catch(this.$showError) }