diff --git a/frontend/public/themes/dark.css b/frontend/public/themes/dark.css index 9a5be1f7..4e3c6f5f 100644 --- a/frontend/public/themes/dark.css +++ b/frontend/public/themes/dark.css @@ -69,13 +69,16 @@ nav > div { border-color: var(--divider); } -#breadcrumbs { +.breadcrumbs { border-color: var(--divider); color: var(--textPrimary) !important; } -#breadcrumbs span { +.breadcrumbs span { color: var(--textPrimary) !important; } +.breadcrumbs a:hover { + background-color: rgba(255, 255, 255, .1); +} #listing .item { background: var(--surfacePrimary); @@ -114,13 +117,20 @@ nav > div { background: var(--surfaceSecondary); } +.dashboard #nav ul li { + color: var(--textSecondary); +} +.dashboard #nav ul li:hover { + background: var(--surfaceSecondary); +} + .card h3, .dashboard #nav, .dashboard p label { color: var(--textPrimary); } -.card#share ul li input, -.card#share ul li select, +.card#share input, +.card#share select, .input { background: var(--surfaceSecondary); color: var(--textPrimary); @@ -138,7 +148,7 @@ nav > div { background: #147A41; } -.dashboard #nav li, +.dashboard #nav .wrapper, .collapsible { border-color: var(--divider); } diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index bada7c7c..89d21a54 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -58,7 +58,7 @@ export async function put (url, content = '') { } export function download (format, ...files) { - let url = store.getters['isSharing'] ? `${baseURL}/api/public/dl/${store.state.hash}` : `${baseURL}/api/raw` + let url = `${baseURL}/api/raw` if (files.length === 1) { url += removePrefix(files[0]) + '?' @@ -74,15 +74,13 @@ export function download (format, ...files) { url += `/?files=${arg}&` } - if (format !== null) { + if (format) { url += `algo=${format}&` } - if (store.state.jwt !== ''){ + + if (store.state.jwt){ url += `auth=${store.state.jwt}&` } - if (store.state.token !== ''){ - url += `token=${store.state.token}` - } window.open(url) } diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js index 11bb49d9..5dd59ae7 100644 --- a/frontend/src/api/index.js +++ b/frontend/src/api/index.js @@ -2,6 +2,7 @@ import * as files from './files' import * as share from './share' import * as users from './users' import * as settings from './settings' +import * as pub from './pub' import search from './search' import commands from './commands' @@ -10,6 +11,7 @@ export { share, users, settings, + pub, commands, search } diff --git a/frontend/src/api/pub.js b/frontend/src/api/pub.js new file mode 100644 index 00000000..5afd0913 --- /dev/null +++ b/frontend/src/api/pub.js @@ -0,0 +1,37 @@ +import { fetchJSON, removePrefix } from './utils' +import { baseURL } from '@/utils/constants' + +export async function fetch(hash, password = "") { + return fetchJSON(`/api/public/share/${hash}`, { + headers: {'X-SHARE-PASSWORD': password}, + }) +} + +export function download(format, hash, token, ...files) { + let url = `${baseURL}/api/public/dl/${hash}` + + const prefix = `/share/${hash}` + if (files.length === 1) { + url += removePrefix(files[0], prefix) + '?' + } else { + let arg = '' + + for (let file of files) { + arg += removePrefix(file, prefix) + ',' + } + + arg = arg.substring(0, arg.length - 1) + arg = encodeURIComponent(arg) + url += `/?files=${arg}&` + } + + if (format) { + url += `algo=${format}&` + } + + if (token) { + url += `token=${token}&` + } + + window.open(url) +} \ No newline at end of file diff --git a/frontend/src/api/share.js b/frontend/src/api/share.js index 4e6c40db..fbeecd70 100644 --- a/frontend/src/api/share.js +++ b/frontend/src/api/share.js @@ -4,12 +4,6 @@ export async function list() { return fetchJSON('/api/shares') } -export async function getHash(hash, password = "") { - return fetchJSON(`/api/public/share/${hash}`, { - headers: {'X-SHARE-PASSWORD': password}, - }) -} - export async function get(url) { url = removePrefix(url) return fetchJSON(`/api/share${url}`) diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index 68337d10..ffe7844c 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -33,11 +33,11 @@ export async function fetchJSON (url, opts) { } } -export function removePrefix (url) { +export function removePrefix (url, prefix) { if (url.startsWith('/files')) { url = url.slice(6) - } else if (store.getters['isSharing']) { - url = url.slice(7 + store.state.hash.length) + } else if (prefix) { + url = url.replace(prefix, '') } if (url === '') url = '/' diff --git a/frontend/src/components/Breadcrumbs.vue b/frontend/src/components/Breadcrumbs.vue new file mode 100644 index 00000000..43ade6a3 --- /dev/null +++ b/frontend/src/components/Breadcrumbs.vue @@ -0,0 +1,67 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue deleted file mode 100644 index 6d9a1270..00000000 --- a/frontend/src/components/Header.vue +++ /dev/null @@ -1,185 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Copy.vue b/frontend/src/components/buttons/Copy.vue deleted file mode 100644 index 84f4ce70..00000000 --- a/frontend/src/components/buttons/Copy.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Delete.vue b/frontend/src/components/buttons/Delete.vue deleted file mode 100644 index 5901ba78..00000000 --- a/frontend/src/components/buttons/Delete.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Download.vue b/frontend/src/components/buttons/Download.vue deleted file mode 100644 index 3798771f..00000000 --- a/frontend/src/components/buttons/Download.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Info.vue b/frontend/src/components/buttons/Info.vue deleted file mode 100644 index 4b20e798..00000000 --- a/frontend/src/components/buttons/Info.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Move.vue b/frontend/src/components/buttons/Move.vue deleted file mode 100644 index 3c1985fc..00000000 --- a/frontend/src/components/buttons/Move.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/PreviewSize.vue b/frontend/src/components/buttons/PreviewSize.vue deleted file mode 100644 index 3183b56f..00000000 --- a/frontend/src/components/buttons/PreviewSize.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Rename.vue b/frontend/src/components/buttons/Rename.vue deleted file mode 100644 index 6eb61e39..00000000 --- a/frontend/src/components/buttons/Rename.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Share.vue b/frontend/src/components/buttons/Share.vue deleted file mode 100644 index d9a2ec6a..00000000 --- a/frontend/src/components/buttons/Share.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Shell.vue b/frontend/src/components/buttons/Shell.vue deleted file mode 100644 index a60e5602..00000000 --- a/frontend/src/components/buttons/Shell.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/SwitchView.vue b/frontend/src/components/buttons/SwitchView.vue deleted file mode 100644 index eea4bba5..00000000 --- a/frontend/src/components/buttons/SwitchView.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/frontend/src/components/buttons/Upload.vue b/frontend/src/components/buttons/Upload.vue deleted file mode 100644 index 9e7f07bd..00000000 --- a/frontend/src/components/buttons/Upload.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/frontend/src/components/files/ListingItem.vue b/frontend/src/components/files/ListingItem.vue index 596ce736..8f4bb8ba 100644 --- a/frontend/src/components/files/ListingItem.vue +++ b/frontend/src/components/files/ListingItem.vue @@ -13,7 +13,7 @@ :aria-label="name" :aria-selected="isSelected">
- + {{ icon }}
@@ -45,13 +45,12 @@ export default { touches: 0 } }, - props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'], + props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index', 'readOnly'], computed: { ...mapState(['user', 'selected', 'req', 'jwt']), - ...mapGetters(['selectedCount', 'isSharing']), + ...mapGetters(['selectedCount']), singleClick () { - if (this.isSharing) return false - return this.user.singleClick + return this.readOnly == undefined && this.user.singleClick }, isSelected () { return (this.selected.indexOf(this.index) !== -1) @@ -64,10 +63,10 @@ export default { return 'insert_drive_file' }, isDraggable () { - return !this.isSharing && this.user.perm.rename + return this.readOnly == undefined && this.user.perm.rename }, canDrop () { - if (!this.isDir || this.isSharing) return false + if (!this.isDir || this.readOnly == undefined) return false for (let i of this.selected) { if (this.req.items[i].url === this.url) { @@ -139,7 +138,7 @@ export default { to: this.url + this.req.items[i].name, name: this.req.items[i].name }) - } + } let base = el.querySelector('.name').innerHTML + '/' let path = this.$route.path + base diff --git a/frontend/src/components/header/Action.vue b/frontend/src/components/header/Action.vue new file mode 100644 index 00000000..7279f9ce --- /dev/null +++ b/frontend/src/components/header/Action.vue @@ -0,0 +1,32 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/header/HeaderBar.vue b/frontend/src/components/header/HeaderBar.vue new file mode 100644 index 00000000..ef4edc4c --- /dev/null +++ b/frontend/src/components/header/HeaderBar.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/prompts/Delete.vue b/frontend/src/components/prompts/Delete.vue index 67cbb33e..89d5fe3a 100644 --- a/frontend/src/components/prompts/Delete.vue +++ b/frontend/src/components/prompts/Delete.vue @@ -26,7 +26,7 @@ export default { name: 'delete', computed: { ...mapGetters(['isListing', 'selectedCount']), - ...mapState(['req', 'selected']) + ...mapState(['req', 'selected', 'showConfirm']) }, methods: { ...mapMutations(['closeHovers']), @@ -38,7 +38,7 @@ export default { await api.remove(this.$route.path) buttons.success('delete') - this.$root.$emit('preview-deleted') + this.showConfirm() this.closeHovers() return } diff --git a/frontend/src/components/prompts/Download.vue b/frontend/src/components/prompts/Download.vue index fa129590..743bfd41 100644 --- a/frontend/src/components/prompts/Download.vue +++ b/frontend/src/components/prompts/Download.vue @@ -7,43 +7,29 @@

{{ $t('prompts.downloadMessage') }}

- - - - - - - +
diff --git a/frontend/src/components/prompts/Share.vue b/frontend/src/components/prompts/Share.vue index 043847d8..f4163975 100644 --- a/frontend/src/components/prompts/Share.vue +++ b/frontend/src/components/prompts/Share.vue @@ -4,61 +4,82 @@

{{ $t('buttons.share') }}

-
-
@@ -75,11 +96,10 @@ export default { return { time: '', unit: 'hours', - hasPermanent: false, links: [], clip: null, password: '', - passwordPermalink: '' + listing: true } }, computed: { @@ -104,11 +124,8 @@ export default { this.links = links this.sort() - for (let link of this.links) { - if (link.expire === 0) { - this.hasPermanent = true - break - } + if (this.links.length == 0) { + this.listing = false } } catch (e) { this.$showError(e) @@ -125,22 +142,25 @@ export default { }, methods: { submit: async function () { - if (!this.time) return + let isPermanent = !this.time || this.time == 0 try { - const res = await api.create(this.url, this.password, this.time, this.unit) + let res = null + + if (isPermanent) { + res = await api.create(this.url, this.password) + } else { + res = await api.create(this.url, this.password, this.time, this.unit) + } + this.links.push(res) this.sort() - } catch (e) { - this.$showError(e) - } - }, - getPermalink: async function () { - try { - const res = await api.create(this.url, this.passwordPermalink) - this.links.push(res) - this.sort() - this.hasPermanent = true + + this.time = '' + this.unit = 'hours' + this.password = '' + + this.listing = true } catch (e) { this.$showError(e) } @@ -149,8 +169,11 @@ export default { event.preventDefault() try { await api.remove(link.hash) - if (link.expire === 0) this.hasPermanent = false this.links = this.links.filter(item => item.hash !== link.hash) + + if (this.links.length == 0) { + this.listing = false + } } catch (e) { this.$showError(e) } @@ -167,6 +190,13 @@ export default { if (b.expire === 0) return 1 return new Date(a.expire) - new Date(b.expire) }) + }, + switchListing () { + if (this.links.length == 0 && !this.listing) { + this.$store.commit('closeHovers') + } + + this.listing = !this.listing } } } diff --git a/frontend/src/components/prompts/ShareDelete.vue b/frontend/src/components/prompts/ShareDelete.vue index c927f104..3e195225 100644 --- a/frontend/src/components/prompts/ShareDelete.vue +++ b/frontend/src/components/prompts/ShareDelete.vue @@ -1,7 +1,7 @@