mirror of
https://github.com/ae-utbm/sith.git
synced 2025-11-10 05:53:06 +00:00
@@ -5,12 +5,13 @@ import type { PictureSchema } from "#openapi";
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("pictures_download", () => ({
|
||||
isDownloading: false,
|
||||
downloadPictures: [] as PictureSchema[],
|
||||
|
||||
async downloadZip() {
|
||||
this.isDownloading = true;
|
||||
const bar = this.$refs.progress;
|
||||
bar.value = 0;
|
||||
bar.max = this.pictures.length;
|
||||
bar.max = this.downloadPictures.length;
|
||||
|
||||
const incrementProgressBar = (_total: number): undefined => {
|
||||
bar.value++;
|
||||
@@ -29,7 +30,7 @@ document.addEventListener("alpine:init", () => {
|
||||
const zipWriter = new ZipWriter(await fileHandle.createWritable());
|
||||
|
||||
await Promise.all(
|
||||
this.pictures.map((p: PictureSchema) => {
|
||||
this.downloadPictures.map(async (p: PictureSchema) => {
|
||||
const imgName = `${p.album}/IMG_${p.date.replace(/[:\-]/g, "_")}${p.name.slice(p.name.lastIndexOf("."))}`;
|
||||
return zipWriter.add(imgName, new HttpReader(p.full_size_url), {
|
||||
level: 9,
|
||||
|
||||
@@ -57,5 +57,9 @@ document.addEventListener("alpine:init", () => {
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
allPictures(): PictureSchema[] {
|
||||
return this.albums.flatMap((album: Album) => album.pictures);
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user