frontend: Highlight files not downloaded
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0f2dafa3b1
commit
4973f7ac4a
2 changed files with 28 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
ListGroupItem,
|
ListGroupItem,
|
||||||
} from '@sveltestrap/sveltestrap';
|
} from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
|
import { hasDownloaded } from '$lib/stores/downloaded.js';
|
||||||
import FileSize from './FileSize.svelte';
|
import FileSize from './FileSize.svelte';
|
||||||
|
|
||||||
export let files = [];
|
export let files = [];
|
||||||
|
@ -27,8 +28,8 @@
|
||||||
</CardBody>
|
</CardBody>
|
||||||
<ListGroup flush class="border-secondary">
|
<ListGroup flush class="border-secondary">
|
||||||
{#each files as file, index}
|
{#each files as file, index}
|
||||||
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex">
|
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex" action on:click={() => hasDownloaded.update((u) => {u[file.path] = true; return u;})}>
|
||||||
<h1 class="me-3">
|
<h1 class="me-3" class:text-info={!$hasDownloaded[file.path]}>
|
||||||
<Icon name="arrow-down-circle" />
|
<Icon name="arrow-down-circle" />
|
||||||
</h1>
|
</h1>
|
||||||
<div style="min-width: 0">
|
<div style="min-width: 0">
|
||||||
|
|
25
frontend/fic/src/lib/stores/downloaded.js
Normal file
25
frontend/fic/src/lib/stores/downloaded.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
function createDownloadedStore() {
|
||||||
|
let init = { };
|
||||||
|
try {
|
||||||
|
if (window.localStorage && window.localStorage.getItem("downloadedStore")) {
|
||||||
|
init = JSON.parse(window.localStorage.getItem("downloadedStore"));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
init = { };
|
||||||
|
}
|
||||||
|
|
||||||
|
const { subscribe, set, update } = writable(init);
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
|
||||||
|
update: (u) => {
|
||||||
|
update(u);
|
||||||
|
if (window.localStorage) localStorage.setItem("downloadedStore", JSON.stringify(init));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const hasDownloaded = createDownloadedStore();
|
Reference in a new issue