Remove Zone.Identifier

This commit is contained in:
GMrrc 2024-11-15 14:17:21 +01:00
parent 50a5750fc8
commit 25ea9a33c3
51 changed files with 350 additions and 22676 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@
/node_modules/
/**/*Zone.Identifier

22882
js/main.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

21
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/files": "^2.1.0",
"@nextcloud/initial-state": "^2.2.0",
"@nextcloud/vue": "^8.11.2",
"vue": "^2.7.16"
@ -1054,6 +1055,26 @@
"node": ">=10"
}
},
"node_modules/@nextcloud/files": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-2.1.0.tgz",
"integrity": "sha512-i5Q8oNPONwBWLnNjQOC3EmnUhExXpwmO45BonzaovzXdhFzFeT/g85kRNR8LWEjiK9vOMOdozz+z6I0adU0JlQ==",
"license": "GPL-3.0-or-later",
"dependencies": {
"@nextcloud/l10n": "^1.3.0",
"core-js": "^3.6.4"
}
},
"node_modules/@nextcloud/files/node_modules/@nextcloud/l10n": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.6.0.tgz",
"integrity": "sha512-aKGlgrwN9OiafN791sYus0shfwNeU3PlrH6Oi9ISma6iJSvN6a8aJM8WGKCJ9pqBaTR5PrDuckuM/WnybBWb6A==",
"license": "GPL-3.0-or-later",
"dependencies": {
"core-js": "^3.6.4",
"node-gettext": "^3.0.0"
}
},
"node_modules/@nextcloud/initial-state": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-2.2.0.tgz",

View File

@ -18,6 +18,7 @@
],
"dependencies": {
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/files": "^2.1.0",
"@nextcloud/initial-state": "^2.2.0",
"@nextcloud/vue": "^8.11.2",
"vue": "^2.7.16"

View File

@ -1,26 +1,21 @@
<template>
<NcAppContent>
<div id="webtransfer">
<h1>Hello world!</h1>
</div>
</NcAppContent>
<div id="app">
<h1>Hello world</h1>
<FileTable />
</div>
</template>
<script>
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
import FileTable from './views/FileTable.vue'
export default {
name: 'App',
components: {
NcAppContent,
FileTable,
},
}
</script>
<style scoped lang="scss">
#webtransfer {
display: flex;
justify-content: center;
margin: 16px;
}
<style>
</style>

View File

@ -1,4 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://apps.nextcloud.com/developer/apps/generate
HostUrl=https://apps.nextcloud.com/developer/apps/generate

94
src/views/FileTable.vue Normal file
View File

@ -0,0 +1,94 @@
<template>
<table>
<thead>
<tr>
<th>Nom</th>
<th>Type</th>
<th>Taille</th>
</tr>
</thead>
<tbody>
<!-- Boucle pour afficher les fichiers et dossiers récupérés -->
<tr v-for="file in files" :key="file.filename">
<td>
<!-- Affiche un lien cliquable vers le fichier ou le dossier -->
<a :href="file.href" target="_blank">{{ file.basename }}</a>
</td>
<td>{{ file.type === 'directory' ? 'Dossier' : 'Fichier' }}</td>
<td>{{ file.type === 'directory' ? '-' : formatFileSize(file.size) }}</td>
</tr>
</tbody>
</table>
</template>
<script>
import { getClient } from '@nextcloud/files/dav'
export default {
name: 'FileTable',
data() {
return {
files: [], // Liste des fichiers et dossiers récupérés
}
},
async mounted() {
await this.fetchFiles()
},
methods: {
async fetchFiles() {
try {
// Création du client WebDAV
const client = getClient()
// Récupération des fichiers et dossiers à la racine
const directoryItems = await client.getDirectoryContents('/files/admin') // changer admin par le nom de l'utilisateur courant
// Mise à jour de la liste des fichiers et dossiers
this.files = directoryItems.map(file => ({
basename: file.basename,
size: file.size,
href: client.getFileDownloadLink(file.filename),
type: file.type,
}))
} catch (error) {
console.error('Erreur lors de la récupération des fichiers et dossiers :', error)
}
},
// Fonction pour formater la taille des fichiers
formatFileSize(size) {
if (size < 1024) return `${size} B`
if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB`
if (size < 1024 * 1024 * 1024) return `${(size / 1024 / 1024).toFixed(2)} MB`
return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB`
},
},
}
</script>
<style scoped>
/* Styles pour le tableau */
table {
border-collapse: collapse;
width: 80%;
margin: 20px auto;
}
table, th, td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #4CAF50;
color: white;
}
tr {
background-color: #f2f2f2;
}
td a {
color: #4CAF50;
text-decoration: none;
}
</style>