This commit is contained in:
GMrrc 2024-11-18 14:22:51 +01:00
parent cf5d59dce5
commit 8670be9d4d
4 changed files with 142 additions and 138 deletions

View File

@ -1027,7 +1027,7 @@ var render = function render() {
return _c("div", { return _c("div", {
staticClass: "flex flex-col h-full w-full border" staticClass: "flex flex-col h-full w-full border"
}, [_c("NcBreadcrumbs", { }, [_c("NcBreadcrumbs", {
staticClass: "max-h-8 mr-4" staticClass: "max-h-8 ml-3 mt-1"
}, [_c("NcBreadcrumb", { }, [_c("NcBreadcrumb", {
attrs: { attrs: {
name: "Home", name: "Home",
@ -1053,16 +1053,16 @@ var render = function render() {
})], 2), _vm._v(" "), _vm._m(0), _vm._v(" "), _vm._l(_vm.files, function (file) { })], 2), _vm._v(" "), _vm._m(0), _vm._v(" "), _vm._l(_vm.files, function (file) {
return _c("div", { return _c("div", {
key: file.filename, key: file.filename,
staticClass: "flex h-16 items-center hover:bg-NcGray cursor-pointer rounded-lg border-b last:border-b-0 border-gray-300", staticClass: "flex h-16 items-center hover:bg-NcGray rounded-lg border-b last:border-b-0 border-gray-300",
on: { on: {
click: function ($event) { click: function ($event) {
return _vm.handleClickElem(file); return _vm.handleClickElem(file);
} }
} }
}, [_c("div", { }, [_c("div", {
staticClass: "cursor-pointer w-4/6 flex items-center px-4 py-2 border-r border-gray-300" staticClass: "w-4/6 flex items-center px-4 py-2 border-r border-gray-300 cursor-pointer"
}, [_c("div", { }, [_c("div", {
staticClass: "w-12 h-12 flex items-center justify-center" staticClass: "w-12 h-12 flex items-center justify-center cursor-pointer"
}, [file.type === "directory" ? [_c("svg", { }, [file.type === "directory" ? [_c("svg", {
staticClass: "text-NcBlue w-10 h-10", staticClass: "text-NcBlue w-10 h-10",
attrs: { attrs: {
@ -1074,7 +1074,7 @@ var render = function render() {
d: "M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" d: "M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"
} }
})])] : [_c("div", { })])] : [_c("div", {
staticClass: "flex items-center justify-center" staticClass: "flex items-center justify-center cursor-pointer"
}, [_c("svg", { }, [_c("svg", {
staticClass: "w-10 h-10", staticClass: "w-10 h-10",
staticStyle: { staticStyle: {
@ -1098,12 +1098,12 @@ var render = function render() {
transform: "matrix(.7 0 0 .7 -.43 -.388)" transform: "matrix(.7 0 0 .7 -.43 -.388)"
} }
})])])]], 2), _vm._v(" "), _c("div", { })])])]], 2), _vm._v(" "), _c("div", {
staticClass: "ml-4" staticClass: "ml-4 cursor-pointer"
}, [_vm._v(_vm._s(file.basename))])]), _vm._v(" "), _c("div", { }, [_vm._v(_vm._s(file.basename))])]), _vm._v(" "), _c("div", {
staticClass: "cursor-pointer w-1/6 px-4 py-2 border-r border-gray-300" staticClass: "w-1/6 px-4 py-2 border-r border-gray-300 cursor-pointer"
}, [_vm._v("\r\n " + _vm._s(file.type === "directory" ? "Dossier" : "Fichier") + "\r\n ")]), _vm._v(" "), _c("div", { }, [_vm._v("\n " + _vm._s(file.type === "directory" ? "Dossier" : "Fichier") + "\n ")]), _vm._v(" "), _c("div", {
staticClass: "cursor-pointer w-1/6 px-4 py-2" staticClass: "w-1/6 px-4 py-2 cursor-pointer"
}, [_vm._v("\r\n " + _vm._s(file.type === "directory" ? "-" : _vm.formatFileSize(file.size)) + "\r\n ")])]); }, [_vm._v("\n " + _vm._s(file.type === "directory" ? "-" : _vm.formatFileSize(file.size)) + "\n ")])]);
})], 2); })], 2);
}; };
var staticRenderFns = [function () { var staticRenderFns = [function () {
@ -3044,6 +3044,14 @@ video {
margin-right: 1rem; margin-right: 1rem;
} }
.ml-3 {
margin-left: 0.75rem;
}
.mt-1 {
margin-top: 0.25rem;
}
.flex { .flex {
display: flex; display: flex;
} }

File diff suppressed because one or more lines are too long

View File

@ -1,75 +1,63 @@
<template> <template>
<div class="flex flex-col h-full w-full border"> <div class="flex flex-col h-full w-full border">
<!-- Breadcrumb --> <!-- Breadcrumb -->
<NcBreadcrumbs class="max-h-8 mr-4"> <NcBreadcrumbs class="max-h-8 ml-3 mt-1">
<NcBreadcrumb name="Home" <NcBreadcrumb name="Home" title="Title of the Home folder" @click="handleClickBreadcrumb(-1)">
title="Title of the Home folder" </NcBreadcrumb>
@click="handleClickBreadcrumb(-1)"> <NcBreadcrumb v-if="getBreadcrumbParts().length > 0" v-for="(part, index) in breadcrumbParts" :key="index"
</NcBreadcrumb> :name="part" @click="handleClickBreadcrumb(index)">
<NcBreadcrumb v-if="getBreadcrumbParts().length > 0" </NcBreadcrumb>
v-for="(part, index) in breadcrumbParts" </NcBreadcrumbs>
:key="index"
:name="part"
@click="handleClickBreadcrumb(index)">
</NcBreadcrumb>
</NcBreadcrumbs>
<!-- En-tête --> <!-- En-tête -->
<div class="flex h-12 items-center border-b border-gray-300"> <div class="flex h-12 items-center border-b border-gray-300">
<div class="w-4/6 px-4 py-2 text-gray-500 font-semibold border-r border-gray-300">Nom</div> <div class="w-4/6 px-4 py-2 text-gray-500 font-semibold border-r border-gray-300">Nom</div>
<div class="w-1/6 px-4 py-2 text-gray-500 font-semibold border-r border-gray-300">Type</div> <div class="w-1/6 px-4 py-2 text-gray-500 font-semibold border-r border-gray-300">Type</div>
<div class="w-1/6 px-4 py-2 text-gray-500 font-semibold">Taille</div> <div class="w-1/6 px-4 py-2 text-gray-500 font-semibold">Taille</div>
</div> </div>
<!-- Contenu --> <!-- Contenu -->
<div <div v-for="file in files" :key="file.filename"
v-for="file in files" class="flex h-16 items-center hover:bg-NcGray rounded-lg border-b last:border-b-0 border-gray-300"
:key="file.filename" @click="handleClickElem(file)">
class="flex h-16 items-center hover:bg-NcGray cursor-pointer rounded-lg border-b last:border-b-0 border-gray-300"
@click="handleClickElem(file)" <!-- Nom -->
> <div class="w-4/6 flex items-center px-4 py-2 border-r border-gray-300 cursor-pointer">
<!-- Nom --> <div class="w-12 h-12 flex items-center justify-center cursor-pointer">
<div class="cursor-pointer w-4/6 flex items-center px-4 py-2 border-r border-gray-300"> <template v-if="file.type === 'directory'">
<div class="w-12 h-12 flex items-center justify-center"> <svg fill="currentColor" viewBox="0 0 24 24" class="text-NcBlue w-10 h-10 ">
<template v-if="file.type === 'directory'"> <path
<svg d="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z">
fill="currentColor" </path>
viewBox="0 0 24 24" </svg>
class="text-NcBlue w-10 h-10" </template>
> <template v-else>
<path <div class="flex items-center justify-center cursor-pointer">
d="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" <svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
></path> class="w-10 h-10"
</svg> style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2">
</template> <path
<template v-else> d="M6 22c-.55 0-1.021-.196-1.412-.587A1.927 1.927 0 0 1 4 20V4c0-.55.196-1.021.588-1.413A1.926 1.926 0 0 1 6 2h8l6 6v12a1.93 1.93 0 0 1-.587 1.413A1.93 1.93 0 0 1 18 22H6Z"
<div class="flex items-center justify-center"> style="fill:#969696;fill-rule:nonzero" transform="matrix(.7 0 0 .7 -.43 -.388)" />
<svg </svg>
viewBox="0 0 16 16" </div>
xmlns="http://www.w3.org/2000/svg" </template>
xml:space="preserve" </div>
class="w-10 h-10" <div class="ml-4 cursor-pointer">{{ file.basename }}</div>
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"
>
<path d="M6 22c-.55 0-1.021-.196-1.412-.587A1.927 1.927 0 0 1 4 20V4c0-.55.196-1.021.588-1.413A1.926 1.926 0 0 1 6 2h8l6 6v12a1.93 1.93 0 0 1-.587 1.413A1.93 1.93 0 0 1 18 22H6Z" style="fill:#969696;fill-rule:nonzero" transform="matrix(.7 0 0 .7 -.43 -.388)"/>
</svg>
</div> </div>
</template>
</div>
<div class="ml-4">{{ file.basename }}</div>
</div>
<!-- Type --> <!-- Type -->
<div class="cursor-pointer w-1/6 px-4 py-2 border-r border-gray-300"> <div class="w-1/6 px-4 py-2 border-r border-gray-300 cursor-pointer">
{{ file.type === 'directory' ? 'Dossier' : 'Fichier' }} {{ file.type === 'directory' ? 'Dossier' : 'Fichier' }}
</div> </div>
<!-- Taille -->
<div class="w-1/6 px-4 py-2 cursor-pointer">
{{ file.type === 'directory' ? '-' : formatFileSize(file.size) }}
</div>
</div>
<!-- Taille -->
<div class="cursor-pointer w-1/6 px-4 py-2">
{{ file.type === 'directory' ? '-' : formatFileSize(file.size) }}
</div> </div>
</div>
</div>
</template> </template>
@ -80,72 +68,72 @@ import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js';
import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'; import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js';
export default { export default {
name: 'FileTable', name: 'FileTable',
components: { components: {
NcBreadcrumbs, NcBreadcrumbs,
NcBreadcrumb NcBreadcrumb
},
data() {
return {
files: [], // Liste des fichiers et dossiers récupérés
current_dir: '/',
breadcrumbParts : []
};
},
async mounted() {
await this.fetchFiles();
this.breadcrumbParts = this.getBreadcrumbParts();
},
methods: {
async fetchFiles() {
try {
const client = getClient();
const directoryItems = await client.getDirectoryContents('/files/admin' + this.current_dir); // Remplacez "admin" par le nom de l'utilisateur courant
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);
}
}, },
formatFileSize(size) { data() {
if (size < 1024) return `${size} B`; return {
if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB`; files: [], // Liste des fichiers et dossiers récupérés
if (size < 1024 * 1024 * 1024) return `${(size / 1024 / 1024).toFixed(2)} MB`; current_dir: '/',
return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB`; breadcrumbParts: []
};
}, },
generateCrumbHref(index) { async mounted() {
const parts = this.breadcrumbParts.slice(0, index + 1);
return '/' + parts.join('/');
},
getBreadcrumbParts() {
// Si le current_dir est un simple '/', on le renvoie sous forme de tableau vide.
if (this.current_dir === '/') return [];
return this.current_dir.split('/').filter(part => part);
},
async handleClickElem(file) {
if (file.type === 'directory') {
this.current_dir = this.current_dir === '/' ? '/' + file.basename : this.current_dir + '/' + file.basename;
this.breadcrumbParts = this.getBreadcrumbParts()
await this.fetchFiles();
} else {
window.open(file.href, '_blank');
}
},
async handleClickBreadcrumb(index) {
let dir = '/';
if (index >= -1) {
dir = this.generateCrumbHref(index);
}
this.current_dir = dir;
this.breadcrumbParts = this.getBreadcrumbParts();
await this.fetchFiles(); await this.fetchFiles();
this.breadcrumbParts = this.getBreadcrumbParts();
},
methods: {
async fetchFiles() {
try {
const client = getClient();
const directoryItems = await client.getDirectoryContents('/files/admin' + this.current_dir); // Remplacez "admin" par le nom de l'utilisateur courant
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);
}
},
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`;
},
generateCrumbHref(index) {
const parts = this.breadcrumbParts.slice(0, index + 1);
return '/' + parts.join('/');
},
getBreadcrumbParts() {
// Si le current_dir est un simple '/', on le renvoie sous forme de tableau vide.
if (this.current_dir === '/') return [];
return this.current_dir.split('/').filter(part => part);
},
async handleClickElem(file) {
if (file.type === 'directory') {
this.current_dir = this.current_dir === '/' ? '/' + file.basename : this.current_dir + '/' + file.basename;
this.breadcrumbParts = this.getBreadcrumbParts()
await this.fetchFiles();
} else {
window.open(file.href, '_blank');
}
},
async handleClickBreadcrumb(index) {
let dir = '/';
if (index >= -1) {
dir = this.generateCrumbHref(index);
}
this.current_dir = dir;
this.breadcrumbParts = this.getBreadcrumbParts();
await this.fetchFiles();
}
} }
}
}; };
</script> </script>

View File

@ -565,6 +565,14 @@ video {
margin-right: 1rem; margin-right: 1rem;
} }
.ml-3 {
margin-left: 0.75rem;
}
.mt-1 {
margin-top: 0.25rem;
}
.flex { .flex {
display: flex; display: flex;
} }