-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed endpoint for search functionality. Created test page at /search…
…test/[query] to test search.
- Loading branch information
1 parent
e873b90
commit 12f6ed6
Showing
9 changed files
with
147 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ export type EditBody = { | |
newName: string; | ||
newContent?: (string | null); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,3 @@ export type ProteinEntry = { | |
mass: number; | ||
content?: (string | null); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ export type UploadBody = { | |
content: string; | ||
pdbFileBase64: string; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ export type ValidationError = { | |
msg: string; | ||
type: string; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<!--THIS IS ONLY A TEST FILE, IT OUGHT TO BE DELETED!!!--> | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import { goto } from "$app/navigation"; | ||
import { Backend } from "$lib/backend"; | ||
import type { ProteinEntry } from "$lib/backend"; | ||
import { humanReadableProteinName, numberWithCommas } from "$lib/format"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableBodyCell, | ||
TableBodyRow, | ||
TableHead, | ||
TableHeadCell, | ||
} from "flowbite-svelte"; | ||
import { Tabs, TabItem } from "flowbite-svelte"; | ||
import { Card, Button, Toggle } from "flowbite-svelte"; | ||
export let data; | ||
// at some point, this should be change to request from the backend | ||
let allEntries: ProteinEntry[] | null = null; | ||
onMount(async () => { | ||
console.log("Requesting", data.query, "info from backend"); | ||
// calls get_all_entries() from backend | ||
// to generate this Backend object run `./run.sh gen_api` for newly created server functions | ||
allEntries = await Backend.searchEntries(data.query); | ||
console.log(allEntries); | ||
}); | ||
</script> | ||
|
||
<!-- akin to <head /> in html --> | ||
<svelte:head> | ||
<title>Home</title> | ||
</svelte:head> | ||
|
||
<section> | ||
<Tabs style="underline" contentClass="bg-none p-5"> | ||
<TabItem open title="Table"> | ||
<Table> | ||
<TableHead> | ||
<TableHeadCell>Protein name</TableHeadCell> | ||
<TableHeadCell>Length</TableHeadCell> | ||
<TableHeadCell>Mass (Da)</TableHeadCell> | ||
</TableHead> | ||
<TableBody tableBodyClass="divide-y"> | ||
{#if allEntries} | ||
{#each allEntries as entry} | ||
<TableBodyRow | ||
class="cursor-pointer hover:bg-gray-100" | ||
on:click={() => { | ||
goto(`/protein/${entry.name}`); | ||
}} | ||
> | ||
<TableBodyCell | ||
><span class="text-primary-700" | ||
>{humanReadableProteinName(entry.name)}</span | ||
></TableBodyCell | ||
> | ||
<TableBodyCell>{entry.length}</TableBodyCell> | ||
<TableBodyCell>{numberWithCommas(entry.mass)}</TableBodyCell> | ||
</TableBodyRow> | ||
{/each} | ||
{/if} | ||
</TableBody> | ||
</Table> | ||
</TabItem> | ||
<TabItem title="Gallery"> | ||
<div class="entries"> | ||
{#if allEntries} | ||
{#each allEntries as entry} | ||
<Card | ||
class="hover:shadow-lg cursor-pointer" | ||
title="Click to see {entry.name}" | ||
on:click={() => goto(`/protein/${entry.name}`)} | ||
> | ||
<div class="name text-primary-700"> | ||
{humanReadableProteinName(entry.name)} | ||
</div> | ||
<div class="description"> | ||
Length: {entry.length}, Mass (Da): {numberWithCommas( | ||
entry.mass | ||
)} | ||
</div> | ||
</Card> | ||
{/each} | ||
{/if} | ||
</div> | ||
</TabItem> | ||
</Tabs> | ||
</section> | ||
|
||
<style> | ||
.entries { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 20px; | ||
} | ||
.name { | ||
font-size: 1.5em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* This scrapes the data from the route | ||
* ie. /protein/your_mom -> { proteinName: "your_mom" } | ||
*/ | ||
export function load({ params }) { | ||
return { query: params.query }; | ||
} |