mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-08 12:30:56 +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">
|
<script lang="ts">
|
||||||
import type { AxiosProgressEvent } from "axios";
|
import type { AxiosProgressEvent } from "axios";
|
||||||
|
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||||
import { apiUploadCoverLetter } from "../../../@api/candidate";
|
import { apiUploadCoverLetter } from "../../../@api/candidate";
|
||||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||||
|
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
await apiUploadCoverLetter(file, (progressEvent: AxiosProgressEvent) => {
|
await apiUploadCoverLetter(file, (progressEvent: AxiosProgressEvent) => {
|
||||||
console.log(progressEvent.progress)
|
console.log(progressEvent.progress)
|
||||||
});
|
});
|
||||||
|
await fetchSubmProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -16,5 +18,7 @@
|
||||||
on:filedrop={e => onFileDrop(e.detail)}
|
on:filedrop={e => onFileDrop(e.detail)}
|
||||||
title="Motivační dopis"
|
title="Motivační dopis"
|
||||||
filetype="PDF"
|
filetype="PDF"
|
||||||
filesize="10 MB">
|
filesize="10 MB"
|
||||||
|
fileType={1}
|
||||||
|
>
|
||||||
</DashboardUploadCard>
|
</DashboardUploadCard>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Circles from "$lib/components/icons/Circles.svelte";
|
import Circles from "$lib/components/icons/Circles.svelte";
|
||||||
import { fetchSubmProgress, submissionProgress } from "../../../stores/portfolio";
|
|
||||||
|
|
||||||
export let title: string;
|
export let title: string;
|
||||||
|
|
||||||
fetchSubmProgress();
|
|
||||||
|
|
||||||
$: if ($submissionProgress) {console.log($submissionProgress.status);}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="card infoCard relative">
|
<div class="card infoCard relative">
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,34 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FileType from './FileType.svelte';
|
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 { createEventDispatcher } from 'svelte';
|
||||||
|
import StatusNotification from './StatusNotification.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
export let title: string;
|
export let title: string;
|
||||||
export let filetype: 'PDF' | 'ZIP';
|
export let filetype: 'PDF' | 'ZIP';
|
||||||
export let filesize: string;
|
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 dashAnimationProgress = 0;
|
||||||
let dashAnimationInterval: NodeJS.Timer;
|
let dashAnimationInterval: NodeJS.Timer;
|
||||||
|
|
@ -41,8 +61,19 @@
|
||||||
|
|
||||||
<div class="card uploadCard">
|
<div class="card uploadCard">
|
||||||
<div class="flex flex-col sm:flex-row justify-between sm:items-center">
|
<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>
|
<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} />
|
<FileType {filetype} {filesize} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -51,6 +82,7 @@
|
||||||
multiple={false}
|
multiple={false}
|
||||||
maxSize={filetype == 'PDF' ? 100_000_000 : 10_000_000}
|
maxSize={filetype == 'PDF' ? 100_000_000 : 10_000_000}
|
||||||
accept={filetype == 'PDF' ? 'application/pdf' : 'application/zip'}
|
accept={filetype == 'PDF' ? 'application/pdf' : 'application/zip'}
|
||||||
|
|
||||||
on:filedrop={(e) => onFileDrop(e.detail.files)}
|
on:filedrop={(e) => onFileDrop(e.detail.files)}
|
||||||
on:filedragenter={dashAnimationStart}
|
on:filedragenter={dashAnimationStart}
|
||||||
on:filedragleave={dashAnimationStop}
|
on:filedragleave={dashAnimationStop}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { AxiosProgressEvent } from "axios";
|
import type { AxiosProgressEvent } from "axios";
|
||||||
|
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||||
import { apiUploadPortfolioLetter } from "../../../@api/candidate";
|
import { apiUploadPortfolioLetter } from "../../../@api/candidate";
|
||||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||||
|
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
await apiUploadPortfolioLetter(file, (progressEvent: AxiosProgressEvent) => {
|
await apiUploadPortfolioLetter(file, (progressEvent: AxiosProgressEvent) => {
|
||||||
console.log(progressEvent.loaded)
|
console.log(progressEvent.loaded)
|
||||||
});
|
});
|
||||||
|
await fetchSubmProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -16,5 +18,6 @@
|
||||||
on:filedrop={e => onFileDrop(e.detail)}
|
on:filedrop={e => onFileDrop(e.detail)}
|
||||||
title="Portfolio"
|
title="Portfolio"
|
||||||
filetype="PDF"
|
filetype="PDF"
|
||||||
filesize="10 MB">
|
filesize="10 MB"
|
||||||
|
fileType={2}>
|
||||||
</DashboardUploadCard>
|
</DashboardUploadCard>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { AxiosProgressEvent } from "axios";
|
import type { AxiosProgressEvent } from "axios";
|
||||||
|
import { fetchSubmProgress } from "../../../stores/portfolio";
|
||||||
import { apiUploadPortfolioZip } from "../../../@api/candidate";
|
import { apiUploadPortfolioZip } from "../../../@api/candidate";
|
||||||
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
import DashboardUploadCard from "./DashboardUploadCard.svelte";
|
||||||
|
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
await apiUploadPortfolioZip(file, (progressEvent: AxiosProgressEvent) => {
|
await apiUploadPortfolioZip(file, (progressEvent: AxiosProgressEvent) => {
|
||||||
console.log(progressEvent.loaded)
|
console.log(progressEvent.loaded)
|
||||||
});
|
});
|
||||||
|
await fetchSubmProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -16,5 +18,6 @@
|
||||||
on:filedrop={e => onFileDrop(e.detail)}
|
on:filedrop={e => onFileDrop(e.detail)}
|
||||||
title="Další data"
|
title="Další data"
|
||||||
filetype="ZIP"
|
filetype="ZIP"
|
||||||
filesize="100 MB">
|
filesize="100 MB"
|
||||||
|
fileType={3}>
|
||||||
</DashboardUploadCard>
|
</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 CoverLetterUploadCard from '$lib/components/dashboard/CoverLetterUploadCard.svelte';
|
||||||
import PortfolioLetterUploadCard from '$lib/components/dashboard/PortfolioLetterUploadCard.svelte';
|
import PortfolioLetterUploadCard from '$lib/components/dashboard/PortfolioLetterUploadCard.svelte';
|
||||||
import PortfolioZipUploadCard from '$lib/components/dashboard/PortfolioZipUploadCard.svelte';
|
import PortfolioZipUploadCard from '$lib/components/dashboard/PortfolioZipUploadCard.svelte';
|
||||||
|
import { fetchSubmProgress } from '../../stores/portfolio';
|
||||||
|
|
||||||
|
|
||||||
let fullName = "";
|
let fullName = "";
|
||||||
|
|
@ -20,6 +21,8 @@
|
||||||
email = $candidateData.email ?? "";
|
email = $candidateData.email ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchSubmProgress(); // TODO: move to a better place
|
||||||
|
|
||||||
$: if ($candidateData.name === undefined) {
|
$: if ($candidateData.name === undefined) {
|
||||||
fetch();
|
fetch();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
import { apiFetchSubmissionProgress } from "../@api/candidate";
|
import { apiFetchSubmissionProgress } from "../@api/candidate";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
|
export enum UploadStatus {
|
||||||
|
None = 1,
|
||||||
|
Some = 2,
|
||||||
|
All = 3,
|
||||||
|
Submitted = 4,
|
||||||
|
}
|
||||||
|
|
||||||
export interface SubmissionProgress {
|
export interface SubmissionProgress {
|
||||||
status?: number;
|
status?: UploadStatus;
|
||||||
files?: [number];
|
files?: [number];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const submissionProgress = writable<SubmissionProgress>();
|
export const submissionProgress = writable<SubmissionProgress>({});
|
||||||
|
|
||||||
export async function fetchSubmProgress() {
|
export async function fetchSubmProgress() {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue