Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download shared subdirectory #1184

Merged
merged 20 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/api/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function put (url, content = '') {
}

export function download (format, ...files) {
let url = `${baseURL}/api/raw`
let url = store.getters['isSharing'] ? `${baseURL}/api/public/dl/${store.state.hash}` : `${baseURL}/api/raw`

if (files.length === 1) {
url += removePrefix(files[0]) + '?'
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export async function fetchJSON (url, opts) {
export function removePrefix (url) {
if (url.startsWith('/files')) {
url = url.slice(6)
} else if (store.getters['isSharing']) {
url = url.slice(7 + store.state.hash.length)
}

if (url === '') url = '/'
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<search v-if="isLogged"></search>
</div>
<div>
<template v-if="isLogged">
<button @click="openSearch" :aria-label="$t('buttons.search')" :title="$t('buttons.search')" class="search-button action">
<template v-if="isLogged || isSharing">
<button v-show="!isSharing" @click="openSearch" :aria-label="$t('buttons.search')" :title="$t('buttons.search')" class="search-button action">
<i class="material-icons">search</i>
</button>

Expand All @@ -18,7 +18,7 @@
</button>

<!-- Menu that shows on listing AND mobile when there are files selected -->
<div id="file-selection" v-if="isMobile && isListing">
<div id="file-selection" v-if="isMobile && isListing && !isSharing">
<span v-if="selectedCount > 0">{{ selectedCount }} selected</span>
<share-button v-show="showShareButton"></share-button>
<rename-button v-show="showRenameButton"></rename-button>
Expand All @@ -37,13 +37,13 @@
<delete-button v-show="showDeleteButton"></delete-button>
</div>

<shell-button v-if="isExecEnabled && user.perm.execute" />
<shell-button v-if="isExecEnabled && !isSharing && user.perm.execute" />
<switch-button v-show="isListing"></switch-button>
<download-button v-show="showDownloadButton"></download-button>
<upload-button v-show="showUpload"></upload-button>
<info-button v-show="isFiles"></info-button>

<button v-show="isListing" @click="toggleMultipleSelection" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action" >
<button v-show="isListing || (isSharing && req.isDir)" @click="toggleMultipleSelection" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action" >
<i class="material-icons">check_circle</i>
<span>{{ $t('buttons.select') }}</span>
</button>
Expand Down Expand Up @@ -110,7 +110,8 @@ export default {
'isEditor',
'isPreview',
'isListing',
'isLogged'
'isLogged',
'isSharing'
]),
...mapState([
'req',
Expand All @@ -128,7 +129,7 @@ export default {
return this.isListing && this.user.perm.create
},
showDownloadButton () {
return this.isFiles && this.user.perm.download
return (this.isFiles && this.user.perm.download) || (this.isSharing && this.selectedCount > 0)
},
showDeleteButton () {
return this.isFiles && (this.isListing
Expand Down Expand Up @@ -156,7 +157,7 @@ export default {
: this.user.perm.create)
},
showMore () {
return this.isFiles && this.$store.state.show === 'more'
return (this.isFiles || this.isSharing) && this.$store.state.show === 'more'
},
showOverlay () {
return this.showMore
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/buttons/Download.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default {
name: 'download-button',
computed: {
...mapState(['req', 'selected']),
...mapGetters(['isListing', 'selectedCount'])
...mapGetters(['isListing', 'selectedCount', 'isSharing'])
},
methods: {
download: function () {
if (!this.isListing) {
if (!this.isListing && !this.isSharing) {
api.download(null, this.$route.path)
return
}
Expand Down
22 changes: 13 additions & 9 deletions frontend/src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:aria-label="name"
:aria-selected="isSelected">
<div>
<img v-if="type==='image' && isThumbsEnabled" v-lazy="thumbnailUrl">
<img v-if="type==='image' && isThumbsEnabled && !isSharing" v-lazy="thumbnailUrl">
<i v-else class="material-icons">{{ icon }}</i>
</div>

Expand Down Expand Up @@ -47,8 +47,12 @@ export default {
},
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
computed: {
...mapState(['user', 'selected', 'req', 'user', 'jwt']),
...mapGetters(['selectedCount']),
...mapState(['user', 'selected', 'req', 'jwt']),
...mapGetters(['selectedCount', 'isSharing']),
singleClick () {
if (this.isSharing) return false
return this.user.singleClick
},
isSelected () {
return (this.selected.indexOf(this.index) !== -1)
},
Expand All @@ -60,10 +64,10 @@ export default {
return 'insert_drive_file'
},
isDraggable () {
return this.user.perm.rename
return !this.isSharing && this.user.perm.rename
},
canDrop () {
if (!this.isDir) return false
if (!this.isDir || this.isSharing) return false

for (let i of this.selected) {
if (this.req.items[i].url === this.url) {
Expand Down Expand Up @@ -171,11 +175,11 @@ export default {
action(overwrite, rename)
},
itemClick: function(event) {
if (this.user.singleClick && !this.$store.state.multiple) this.open()
if (this.singleClick && !this.$store.state.multiple) this.open()
else this.click(event)
},
click: function (event) {
if (!this.user.singleClick && this.selectedCount !== 0) event.preventDefault()
if (!this.singleClick && this.selectedCount !== 0) event.preventDefault()
if (this.$store.state.selected.indexOf(this.index) !== -1) {
this.removeSelected(this.index)
return
Expand All @@ -202,11 +206,11 @@ export default {
return
}

if (!this.user.singleClick && !event.ctrlKey && !event.metaKey && !this.$store.state.multiple) this.resetSelected()
if (!this.singleClick && !event.ctrlKey && !event.metaKey && !this.$store.state.multiple) this.resetSelected()
this.addSelected(this.index)
},
dblclick: function () {
if (!this.user.singleClick) this.open()
if (!this.singleClick) this.open()
},
touchstart () {
setTimeout(() => {
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/css/_share.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@
}

.share__box__items #listing.list .item {
cursor: auto;
cursor: pointer;
border-left: 0;
border-right: 0;
border-bottom: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.share__box__items #listing.list .item .name {
width: auto;
width: 50%;
}

.share__box__items #listing.list .item .modified {
width: 25%;
}
3 changes: 2 additions & 1 deletion frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
},
"download": {
"downloadFile": "Download File",
"downloadFolder": "Download Folder"
"downloadFolder": "Download Folder",
"downloadSelected": "Download Selected"
}
}
3 changes: 2 additions & 1 deletion frontend/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
},
"download": {
"downloadFile": "下载文件",
"downloadFolder": "下载文件夹"
"downloadFolder": "下载文件夹",
"downloadSelected": "下载已选"
}
}
1 change: 1 addition & 0 deletions frontend/src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const getters = {
isListing: (state, getters) => getters.isFiles && state.req.isDir,
isEditor: (state, getters) => getters.isFiles && (state.req.type === 'text' || state.req.type === 'textImmutable'),
isPreview: state => state.previewMode,
isSharing: state => !state.loading && state.route.name === 'Share',
selectedCount: state => state.selected.length,
progress : state => {
if (state.upload.progress.length == 0) {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const state = {
showShell: false,
showMessage: null,
showConfirm: null,
previewMode: false
previewMode: false,
hash: ''
}

export default new Vuex.Store({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const mutations = {
},
setPreviewMode(state, value) {
state.previewMode = value
}
},
setHash: (state, value) => (state.hash = value),
}

export default mutations