diff --git a/frontend/src/api/search.js b/frontend/src/api/search.js
index ec35e6e3..9dfaf8ee 100644
--- a/frontend/src/api/search.js
+++ b/frontend/src/api/search.js
@@ -1,8 +1,26 @@
-import { fetchJSON, removePrefix } from './utils'
+import { fetchURL, removePrefix } from './utils'
+import url from '../utils/url'
-export default async function search (url, query) {
- url = removePrefix(url)
+export default async function search (base, query) {
+ base = removePrefix(base)
query = encodeURIComponent(query)
- return fetchJSON(`/api/search${url}?query=${query}`, {})
-}
+ if (!base.endsWith('/')) {
+ base += '/'
+ }
+
+ let res = await fetchURL(`/api/search${base}?query=${query}`, {})
+
+ if (res.status === 200) {
+ let data = await res.json()
+
+ data = data.map((item) => {
+ item.url = `/files${base}` + url.encodePath(item.path)
+ return item
+ })
+
+ return data
+ } else {
+ throw Error(res.status)
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/components/Search.vue b/frontend/src/components/Search.vue
index 0762f05e..c723d6b1 100644
--- a/frontend/src/components/Search.vue
+++ b/frontend/src/components/Search.vue
@@ -49,7 +49,7 @@
-
-
+
folder
insert_drive_file
./{{ s.path }}
@@ -183,8 +183,12 @@ export default {
this.ongoing = true
+ try {
+ this.results = await search(path, this.value)
+ } catch (error) {
+ this.$showError(error)
+ }
- this.results = await search(path, this.value)
this.ongoing = false
}
}
diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue
index 7a2ded1b..0ae10e32 100644
--- a/frontend/src/components/files/Preview.vue
+++ b/frontend/src/components/files/Preview.vue
@@ -103,7 +103,7 @@ export default {
}
},
computed: {
- ...mapState(['req', 'user', 'oldReq', 'jwt', 'loading']),
+ ...mapState(['req', 'user', 'oldReq', 'jwt', 'loading', 'show']),
hasPrevious () {
return (this.previousLink !== '')
},
@@ -159,6 +159,10 @@ export default {
key (event) {
event.preventDefault()
+ if (this.show !== null) {
+ return
+ }
+
if (event.which === 13 || event.which === 39) { // right arrow
if (this.hasNext) this.next()
} else if (event.which === 37) { // left arrow
diff --git a/frontend/src/components/settings/Commands.vue b/frontend/src/components/settings/Commands.vue
index f09fe53a..62a4ea25 100644
--- a/frontend/src/components/settings/Commands.vue
+++ b/frontend/src/components/settings/Commands.vue
@@ -16,7 +16,11 @@ export default {
return this.commands.join(' ')
},
set (value) {
- this.$emit('update:commands', value.split(' '))
+ if (value !== '') {
+ this.$emit('update:commands', value.split(' '))
+ } else {
+ this.$emit('update:commands', [])
+ }
}
}
}
diff --git a/frontend/src/utils/upload.js b/frontend/src/utils/upload.js
index 54b5669e..a43f5787 100644
--- a/frontend/src/utils/upload.js
+++ b/frontend/src/utils/upload.js
@@ -96,31 +96,25 @@ export function scanFiles(dt) {
})
}
-export function handleFiles(files, path, overwrite = false) {
+export function handleFiles(files, base, overwrite = false) {
for (let i = 0; i < files.length; i++) {
+ let id = store.state.upload.id
+ let path = base
let file = files[i]
- let filename = (file.fullPath !== undefined) ? file.fullPath : file.name
- let filenameEncoded = url.encodeRFC5987ValueChars(filename)
-
- let id = store.state.upload.id
-
- let itemPath = path + filenameEncoded
+ if (file.fullPath !== undefined) {
+ path += url.encodePath(file.fullPath)
+ } else {
+ path += url.encodeRFC5987ValueChars(file.name)
+ }
if (file.isDir) {
- itemPath = path
- let folders = file.fullPath.split("/")
-
- for (let i = 0; i < folders.length; i++) {
- let folder = folders[i]
- let folderEncoded = encodeURIComponent(folder)
- itemPath += folderEncoded + "/"
- }
+ path += '/'
}
const item = {
id,
- path: itemPath,
+ path,
file,
overwrite
}
diff --git a/search/search.go b/search/search.go
index 4d91a00b..e4d3518d 100644
--- a/search/search.go
+++ b/search/search.go
@@ -60,7 +60,9 @@ func Search(fs afero.Fs, scope, query string, checker rules.Checker, found func(
if len(search.Terms) > 0 {
for _, term := range search.Terms {
if strings.Contains(path, term) {
- return found(strings.TrimPrefix(originalPath, scope), f)
+ originalPath = strings.TrimPrefix(originalPath, scope)
+ originalPath = strings.TrimPrefix(originalPath, "/")
+ return found(originalPath, f)
}
}
}