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

Fix preview URL #2454

Merged
merged 1 commit into from
Mar 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/Components/File/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<script>
import FileIcon from 'vue-material-design-icons/File.vue'
import { generateOcsUrl } from '@nextcloud/router'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
import { useFilesStore } from '../../store/files.js'

export default {
Expand Down Expand Up @@ -57,23 +57,27 @@ export default {
if (this.backgroundFailed === true) {
return null
}
try {
const previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', {
let previewUrl = ''
if (Object.hasOwn(this.filesStore.getFile(), 'uuid')) {
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', {
nodeId: this.currentNodeId,
})
const url = new URL(previewUrl)
} else {
previewUrl = window.location.origin + generateUrl('/core/preview?fileId={fileid}', {
fileid: this.filesStore.getFile().nodeId,
})
}

// Request tiny previews
url.searchParams.set('x', this.gridMode ? '128' : '32')
url.searchParams.set('y', this.gridMode ? '128' : '32')
url.searchParams.set('mimeFallback', 'true')
const url = new URL(previewUrl)

// Handle cropping
url.searchParams.set('a', this.cropPreviews === true ? '0' : '1')
return url
} catch (e) {
return null
}
// Request tiny previews
url.searchParams.set('x', this.gridMode ? '128' : '32')
url.searchParams.set('y', this.gridMode ? '128' : '32')
url.searchParams.set('mimeFallback', 'true')

// Handle cropping
url.searchParams.set('a', this.cropPreviews === true ? '0' : '1')
return url
},
},
methods: {
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div v-else
id="request-signature-list-signers">
<NcButton v-if="canRequestSign && !filesStore.isFullSigned()"
:type="dataSigners.length === 0 ? 'primary' : 'secondary'"
:type="hasSigners ? 'primary' : 'secondary'"
@click="addSigner">
{{ t('libresign', 'Add signer') }}
</NcButton>
Expand Down Expand Up @@ -123,6 +123,9 @@ export default {
dataSigners() {
return this.filesStore.files[this.filesStore.selectedNodeId].signers
},
hasSigners() {
return this.filesStore.hasSigners()
},
},
watch: {
signers(signers) {
Expand Down
9 changes: 9 additions & 0 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export const useFilesStore = defineStore('files', {
disableIdentifySigner() {
this.identifyingSigner = false
},
hasSigners() {
if (this.selectedNodeId === 0) {
return false
}
if (!Object.hasOwn(this.getFile(), 'signers')) {
return false
}
return this.files[this.selectedNodeId].signers.length > 0
},
isPartialSigned() {
if (this.selectedNodeId === 0) {
return false
Expand Down
Loading