-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: start to implement FileEntry component
Signed-off-by: Vitor Mattos <vitor@php.rio>
- Loading branch information
1 parent
3967ebd
commit b49cd29
Showing
14 changed files
with
790 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { defineStore } from 'pinia' | ||
import Vue from 'vue' | ||
|
||
export const useUserConfigStore = defineStore('userconfig', { | ||
state: () => ({ | ||
grid_view: true, | ||
}), | ||
actions: { | ||
async update(key, value) { | ||
Vue.set(this, key, value) | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<tr /> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'FileEntry', | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<tr> | ||
<td class="files-list__row-name"> | ||
<FileEntryPreview :source="source" /> | ||
</td> | ||
</tr> | ||
</template> | ||
|
||
<script> | ||
import FileEntryPreview from './FileEntryPreview.vue' | ||
export default { | ||
name: 'FileEntryGrid', | ||
components: { | ||
FileEntryPreview, | ||
}, | ||
props: { | ||
source: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<span class="files-list__row-icon"> | ||
<!-- Decorative images, should not be aria documented --> | ||
<span v-if="previewUrl" class="files-list__row-icon-preview-container"> | ||
<img v-if="backgroundFailed !== true" | ||
ref="previewImg" | ||
alt="" | ||
class="files-list__row-icon-preview" | ||
:class="{'files-list__row-icon-preview--loaded': backgroundFailed === false}" | ||
loading="lazy" | ||
:src="previewUrl" | ||
@error="backgroundFailed = true" | ||
@load="backgroundFailed = false"> | ||
</span> | ||
|
||
<FileIcon v-else v-once /> | ||
|
||
<!-- Favorite icon --> | ||
<span v-if="isFavorite" class="files-list__row-icon-favorite"> | ||
<FavoriteIcon v-once /> | ||
</span> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import FileIcon from 'vue-material-design-icons/File.vue' | ||
import { generateUrl, generateOcsUrl } from '@nextcloud/router' | ||
import { useUserConfigStore } from '../../../store/userconfig.js' | ||
export default { | ||
name: 'FileEntryPreview', | ||
components: { | ||
FileIcon, | ||
}, | ||
props: { | ||
source: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
setup() { | ||
const userConfigStore = useUserConfigStore() | ||
return { userConfigStore } | ||
}, | ||
data() { | ||
return { | ||
backgroundFailed: false, | ||
} | ||
}, | ||
computed: { | ||
isFavorite() { | ||
return this.source?.attributes?.favorite === 1 | ||
}, | ||
previewUrl() { | ||
if (this.backgroundFailed === true) { | ||
return null | ||
} | ||
let previewUrl = '' | ||
if (this.source?.uuid?.length > 0) { | ||
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', { | ||
nodeId: this.source.nodeId, | ||
}) | ||
} else { | ||
previewUrl = window.location.origin + generateUrl('/core/preview?fileId={fileid}', { | ||
fileid: this.source.nodeId, | ||
}) | ||
} | ||
const url = new URL(previewUrl) | ||
// Request tiny previews | ||
url.searchParams.set('x', this.userConfigStore.grid_view ? '128' : '32') | ||
url.searchParams.set('y', this.userConfigStore.grid_view ? '128' : '32') | ||
url.searchParams.set('mimeFallback', 'true') | ||
// Handle cropping | ||
url.searchParams.set('a', this.cropPreviews === true ? '0' : '1') | ||
return url | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.