mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: file upload status
This commit is contained in:
parent
acda16ad1e
commit
485bd8613d
8 changed files with 98 additions and 12 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||
import { apiUploadCoverLetter } from "../../../@api/candidate";
|
||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
await apiUploadCoverLetter(file, (progressEvent: AxiosProgressEvent) => {
|
||||
console.log(progressEvent.progress)
|
||||
});
|
||||
await fetchSubmProgress();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
@ -16,5 +18,7 @@
|
|||
on:filedrop={e => onFileDrop(e.detail)}
|
||||
title="Motivační dopis"
|
||||
filetype="PDF"
|
||||
filesize="10 MB">
|
||||
filesize="10 MB"
|
||||
fileType={1}
|
||||
>
|
||||
</DashboardUploadCard>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
<script lang="ts">
|
||||
import Circles from "$lib/components/icons/Circles.svelte";
|
||||
import { fetchSubmProgress, submissionProgress } from "../../../stores/portfolio";
|
||||
|
||||
export let title: string;
|
||||
|
||||
fetchSubmProgress();
|
||||
|
||||
$: if ($submissionProgress) {console.log($submissionProgress.status);}
|
||||
</script>
|
||||
|
||||
<div class="card infoCard relative">
|
||||
|
|
|
|||
|
|
@ -1,14 +1,34 @@
|
|||
<script lang="ts">
|
||||
import FileType from './FileType.svelte';
|
||||
import FileDrop from 'filedrop-svelte';
|
||||
import FileMissingNotification from './StatusNotification.svelte';
|
||||
import { submissionProgress, UploadStatus } from '../../../stores/portfolio';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import StatusNotification from './StatusNotification.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let title: string;
|
||||
export let filetype: 'PDF' | 'ZIP';
|
||||
export let filesize: string;
|
||||
export let fileType: number = 0;
|
||||
|
||||
import FileDrop from 'filedrop-svelte';
|
||||
let missing = false;
|
||||
|
||||
$: if ($submissionProgress) {
|
||||
missing = isMissing();
|
||||
}
|
||||
|
||||
const isMissing = (): boolean => {
|
||||
switch ($submissionProgress.status) {
|
||||
case UploadStatus.None:
|
||||
return true;
|
||||
case UploadStatus.Some:
|
||||
return !$submissionProgress.files!.some(code => code === fileType);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let dashAnimationProgress = 0;
|
||||
let dashAnimationInterval: NodeJS.Timer;
|
||||
|
|
@ -41,8 +61,19 @@
|
|||
|
||||
<div class="card uploadCard">
|
||||
<div class="flex flex-col sm:flex-row justify-between sm:items-center">
|
||||
<!-- <div class="grid grid-cols-8">
|
||||
<h3 class="col-start-1 col-end-5">{title}</h3>
|
||||
<div class="mt-1 col-start-5 col-end-8">
|
||||
<FileMissingNotification title="File Missing" />
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="flex flex-col justify-between">
|
||||
</div> -->
|
||||
<h3>{title}</h3>
|
||||
<div class="mt-3 sm:mt-0">
|
||||
{#if missing}
|
||||
<StatusNotification type="missing" />
|
||||
{/if}
|
||||
<div class="mt-1 sm:mt-0">
|
||||
<FileType {filetype} {filesize} />
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -51,6 +82,7 @@
|
|||
multiple={false}
|
||||
maxSize={filetype == 'PDF' ? 100_000_000 : 10_000_000}
|
||||
accept={filetype == 'PDF' ? 'application/pdf' : 'application/zip'}
|
||||
|
||||
on:filedrop={(e) => onFileDrop(e.detail.files)}
|
||||
on:filedragenter={dashAnimationStart}
|
||||
on:filedragleave={dashAnimationStop}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||
import { apiUploadPortfolioLetter } from "../../../@api/candidate";
|
||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
await apiUploadPortfolioLetter(file, (progressEvent: AxiosProgressEvent) => {
|
||||
console.log(progressEvent.loaded)
|
||||
});
|
||||
await fetchSubmProgress();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
@ -16,5 +18,6 @@
|
|||
on:filedrop={e => onFileDrop(e.detail)}
|
||||
title="Portfolio"
|
||||
filetype="PDF"
|
||||
filesize="10 MB">
|
||||
filesize="10 MB"
|
||||
fileType={2}>
|
||||
</DashboardUploadCard>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||
import { apiUploadPortfolioZip } from "../../../@api/candidate";
|
||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
await apiUploadPortfolioZip(file, (progressEvent: AxiosProgressEvent) => {
|
||||
console.log(progressEvent.loaded)
|
||||
});
|
||||
await fetchSubmProgress();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
@ -16,5 +18,6 @@
|
|||
on:filedrop={e => onFileDrop(e.detail)}
|
||||
title="Další data"
|
||||
filetype="ZIP"
|
||||
filesize="100 MB">
|
||||
filesize="100 MB"
|
||||
fileType={3}>
|
||||
</DashboardUploadCard>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
<script lang="ts">
|
||||
export let type: "submitted" | "uploaded" | "missing";
|
||||
let title: string;
|
||||
switch (type) {
|
||||
case "submitted":
|
||||
title = "Odeslané";
|
||||
break;
|
||||
case "uploaded":
|
||||
title = "Nahráno";
|
||||
break;
|
||||
case "missing":
|
||||
title = "Chybí";
|
||||
break;
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- make red dot -->
|
||||
<div class="flex flex-col justify-between">
|
||||
<span class="mt-1 w-5 h-5 rounded-full {type}" />
|
||||
<h3 class="ml-8 font-bold text-xl">{title}</h3>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
span {
|
||||
@apply absolute rounded-full p-1;
|
||||
}
|
||||
|
||||
.submitted {
|
||||
@apply bg-green-700;
|
||||
}
|
||||
|
||||
.uploaded {
|
||||
@apply bg-yellow-700;
|
||||
}
|
||||
|
||||
.missing {
|
||||
@apply bg-red-700;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
import CoverLetterUploadCard from '$lib/components/dashboard/CoverLetterUploadCard.svelte';
|
||||
import PortfolioLetterUploadCard from '$lib/components/dashboard/PortfolioLetterUploadCard.svelte';
|
||||
import PortfolioZipUploadCard from '$lib/components/dashboard/PortfolioZipUploadCard.svelte';
|
||||
import { fetchSubmProgress } from '../../stores/portfolio';
|
||||
|
||||
|
||||
let fullName = "";
|
||||
|
|
@ -20,6 +21,8 @@
|
|||
email = $candidateData.email ?? "";
|
||||
}
|
||||
|
||||
fetchSubmProgress(); // TODO: move to a better place
|
||||
|
||||
$: if ($candidateData.name === undefined) {
|
||||
fetch();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
import { apiFetchSubmissionProgress } from "../@api/candidate";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export enum UploadStatus {
|
||||
None = 1,
|
||||
Some = 2,
|
||||
All = 3,
|
||||
Submitted = 4,
|
||||
}
|
||||
|
||||
export interface SubmissionProgress {
|
||||
status?: number;
|
||||
status?: UploadStatus;
|
||||
files?: [number];
|
||||
}
|
||||
|
||||
export const submissionProgress = writable<SubmissionProgress>();
|
||||
export const submissionProgress = writable<SubmissionProgress>({});
|
||||
|
||||
export async function fetchSubmProgress() {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue