zip transfer

This commit is contained in:
GMrrc 2024-11-26 14:35:33 +01:00
parent 3063b54a69
commit 57f3bf4a05
3 changed files with 91 additions and 73 deletions

View File

@ -30,7 +30,7 @@ export default {
data() { data() {
return { return {
sharedFile: null, sharedFile: null,
zipUrl: null, zip: null,
}; };
}, },
methods: { methods: {

View File

@ -56,7 +56,8 @@
<div :class="[ <div :class="[
'overflow-y-auto h-full rounded-xl', 'overflow-y-auto h-full rounded-xl',
isDragging ? 'border-green-500 border-4 border-dashed transition-all ease-in-out' : '' isDragging ? 'border-green-500 border-4 border-dashed transition-all ease-in-out' : ''
]" @drop.prevent="onDrop" @dragover.prevent="onDragOver" @dragenter.prevent @dragleave.prevent="onDragLeave($event)" > ]" @drop.prevent="onDrop" @dragover.prevent="onDragOver" @dragenter.prevent
@dragleave.prevent="onDragLeave($event)">
<div v-for="file in files" :key="file.filename" <div v-for="file in files" :key="file.filename"
class="flex h-16 items-center hover:bg-NcGray rounded-lg border-b last:border-b-0 border-gray-300" class="flex h-16 items-center hover:bg-NcGray rounded-lg border-b last:border-b-0 border-gray-300"
@ -118,9 +119,11 @@
</div> </div>
</div> </div>
<EditFileName v-if="!editDialogDisabled" :initialFileName="initialFileName" :isDirectory="isDirectory" @update="updateFileName" @close="closeEditDialog"> <EditFileName v-if="!editDialogDisabled" :initialFileName="initialFileName" :isDirectory="isDirectory"
@update="updateFileName" @close="closeEditDialog">
</EditFileName> </EditFileName>
<FileExistsDialog v-if="!fileExistDialogDisabled" :fileName="initialFileName" @overwrite="" @rename="" @cancel="closeFileExistsDialog"> <FileExistsDialog v-if="!fileExistDialogDisabled" :fileName="initialFileName" @overwrite="" @rename=""
@cancel="closeFileExistsDialog">
</FileExistsDialog> </FileExistsDialog>
</div> </div>
</template> </template>
@ -128,9 +131,11 @@
<script> <script>
import { getClient, getRootPath } from '@nextcloud/files/dav'; // Other imports
import JSZip from 'jszip';
// NextCloud Components // NextCloud Components
import { getClient, getRootPath } from '@nextcloud/files/dav';
import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js'; 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';
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'; import NcActions from '@nextcloud/vue/dist/Components/NcActions.js';
@ -165,6 +170,10 @@ export default {
type: Object, type: Object,
default: null, default: null,
}, },
zip: {
type: Object,
default: null,
},
}, },
data() { data() {
return { return {
@ -181,7 +190,7 @@ export default {
initialFileName: '', // Nom originel du fichier/dossier a edite initialFileName: '', // Nom originel du fichier/dossier a edite
isDirectory: false, // Si l'element a edite est un dossier ou non isDirectory: false, // Si l'element a edite est un dossier ou non
transferProgress: 0, transferProgress: 0,
transferStatus: 'bg-blue-500', transferStatus: 'bg-blue-500'
}; };
}, },
async mounted() { async mounted() {
@ -290,9 +299,26 @@ export default {
this.isDragging = false; this.isDragging = false;
this.isTransfering = true; this.isTransfering = true;
const file = this.file; const file = this.file;
const zip = this.zip;
console.log(file); console.log(file);
if (!file) return; console.log(zip);
if (!file && !zip) return;
if (zip) {
const response = await fetch(zip.url);
if (!response.ok) {
throw new Error(`Erreur lors du téléchargement : ${response.statusText}`);
}
const zipFile = await response.arrayBuffer();
await this.moveFileToTarget({
name: zip.name,
content: zipFile
}, '');
this.transferProgress = 100;
} else {
if (file.isDirectory) { if (file.isDirectory) {
await this.moveFilesOfFolder(file, ''); await this.moveFilesOfFolder(file, '');
} else { } else {
@ -304,7 +330,7 @@ export default {
await this.moveFileToTarget(file, ''); await this.moveFileToTarget(file, '');
this.transferProgress = 100; this.transferProgress = 100;
} }
}
this.isTransfering = false; this.isTransfering = false;
this.transferProgress = 0; this.transferProgress = 0;

View File

@ -579,10 +579,6 @@ video {
} }
} }
.visible {
visibility: visible;
}
.fixed { .fixed {
position: fixed; position: fixed;
} }
@ -741,10 +737,6 @@ video {
flex-direction: column; flex-direction: column;
} }
.content-center {
align-content: center;
}
.content-evenly { .content-evenly {
align-content: space-evenly; align-content: space-evenly;
} }