feat: add avatar to uploaded files

This commit is contained in:
Arman committed 2022-07-12 17:12:03 +02:00
1 parent 6f8e7a6ea0
commit bc47475e77
1 file changed
+11 -12
+11 -12
View File
@@ -2,12 +2,15 @@
import { uploader } from '$lib/stores/uploader';
import { Pill } from '$lib/elements';
import { sdkForProject } from '$lib/stores/sdk';
import { Avatar } from '$lib/components';
async function removeFile($id: string, bucketId: string) {
const file = await sdkForProject.storage.getFile(bucketId, $id);
console.log(file);
uploader.removeFile(file);
}
const getPreview = (fileId: string, bucketId: string) =>
sdkForProject.storage.getFilePreview(bucketId, fileId, 32, 32).toString() + '&mode=admin';
</script>
{#if $uploader?.isOpen}
@@ -34,21 +37,17 @@
<div class="upload-box-content" class:is-open={!$uploader.isCollapsed}>
<ul class="upload-box-list">
{#each $uploader.files as file}
{#if file.completed}
{#if file.completed || file.progress === 100}
<li class="upload-box-item">
<div class="upload-image u-margin-inline-end-16">
<div
class="progress"
role="progressbar"
aria-valuenow={file.progress}
aria-valuemin={0}
aria-valuemax={100} />
<span class="icon">{file.progress}%</span>
<div class="u-margin-inline-end-16">
<Avatar
size={32}
src={getPreview(file.$id, file.bucketId)}
name={file.name} />
</div>
<label for={file.name} class="file-name">{file.name}</label>
<button class="icon-button" aria-label="Completed"
><span class="icon-check" /></button>
<span class="icon-check" />
</li>
{:else if file.failed}
<li class="upload-box-item">