Skip to content

Commit

Permalink
projects everywhere, maybe needs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 9, 2024
1 parent 6e43c09 commit d505236
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/routes/app/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { getPinnedAddons } from "@/lib/api/addons";
import * as projects from "$lib/api/projects.js";

export async function load({ url, fetch }) {
const pinnedAddons = getPinnedAddons(fetch);
const pinnedProjects = projects
.list({ pinned: true }, fetch)
.then((r) => r.results);

return {
pinnedAddons,
pinnedProjects,
};
}
16 changes: 9 additions & 7 deletions src/routes/app/sidebar/Projects.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { page } from "$app/stores";
let pinned: Project[] = [];
let pinned: Project[] | Promise<Project[]> = [];
$: pinned = $page.data.pinnedProjects || [];
</script>
Expand All @@ -18,11 +18,13 @@
<SidebarItem slot="title"><FileDirectory16 /> Projects</SidebarItem>
<Action slot="action" icon={Book16}>Explore</Action>
<Flex direction="column" gap={0}>
{#each pinned as project}
<SidebarItem small>
<Pin active={project.pinned} />
{project.title}
</SidebarItem>
{/each}
{#await pinned then projects}
{#each projects as project}
<SidebarItem small>
<Pin active={project.pinned} />
{project.title}
</SidebarItem>
{/each}
{/await}
</Flex>
</SidebarGroup>
12 changes: 10 additions & 2 deletions src/routes/app/upload/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const actions = {
const ocr_engine: OCREngine = JSON.parse(form.get("ocr_engine") as string);
const force_ocr = Boolean(form.get("force_ocr"));
const revision_control = Boolean(form.get("revision_control"));
const projects = JSON.parse(form.get("projects") as string);
const projects = JSON.parse((form.get("projects") as string) || "[]");

// not yet implemented
// const language = data.get("language");
Expand Down Expand Up @@ -66,6 +66,14 @@ export const actions = {
fetch,
);

console.log(process_response.status);
// todo: i18n
const message = process_response.ok
? `Uploaded ${created.length} documents`
: process_response.statusText;

return {
success: true,
message,
};
},
} satisfies Actions;
15 changes: 14 additions & 1 deletion src/routes/app/upload/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
<script lang="ts">
import Flex from "$lib/components/common/Flex.svelte";
import DocumentUpload from "$lib/components/forms/DocumentUpload.svelte";
export let form;
</script>

<svelte:head>
<title>Upload | DocumentCloud</title>
</svelte:head>

<DocumentUpload />
<Flex direction="column">
<h1>Upload documents</h1>

{#if form?.success}
<p>
{form.message}
</p>
{/if}

<DocumentUpload />
</Flex>

0 comments on commit d505236

Please sign in to comment.