wip
This commit is contained in:
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
"biome.enabled": true,
|
"biome.enabled": true,
|
||||||
"editor.defaultFormatter": "biomejs.biome",
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
"[typescript]": {
|
|
||||||
"editor.defaultFormatter": "biomejs.biome"
|
|
||||||
},
|
|
||||||
"[typescriptreact]": {
|
|
||||||
"editor.defaultFormatter": "biomejs.biome"
|
|
||||||
},
|
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports.biome": "explicit"
|
||||||
|
},
|
||||||
"[rust]": {
|
"[rust]": {
|
||||||
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
||||||
},
|
},
|
||||||
|
@ -21,6 +21,8 @@ services:
|
|||||||
env_file: .env.docker
|
env_file: .env.docker
|
||||||
ports:
|
ports:
|
||||||
- 3040:3040
|
- 3040:3040
|
||||||
|
volumes:
|
||||||
|
- ./.env.docker:/app/.env
|
||||||
depends_on:
|
depends_on:
|
||||||
database:
|
database:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
@ -8,5 +8,10 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"recommended": true
|
"recommended": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "space",
|
||||||
|
"indentWidth": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,50 @@
|
|||||||
import { createEffect, createResource, createSignal, For } from "solid-js";
|
|
||||||
import { Search } from "@kobalte/core/search";
|
import { Search } from "@kobalte/core/search";
|
||||||
import { IconSearch, IconRefresh } from "@tabler/icons-solidjs";
|
import { A, useNavigate } from "@solidjs/router";
|
||||||
|
import { IconRefresh, IconSearch } from "@tabler/icons-solidjs";
|
||||||
|
import { image } from "@tauri-apps/api";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import Fuse from "fuse.js";
|
||||||
|
import { For, createEffect, createResource, createSignal } from "solid-js";
|
||||||
import { ImageViewer } from "./components/ImageViewer";
|
import { ImageViewer } from "./components/ImageViewer";
|
||||||
import { getUserImages } from "./network";
|
import { getUserImages } from "./network";
|
||||||
import { image } from "@tauri-apps/api";
|
|
||||||
import { A, useNavigate } from "@solidjs/router";
|
|
||||||
import Fuse from "fuse.js";
|
|
||||||
|
|
||||||
type UserImages = Awaited<ReturnType<typeof getUserImages>>;
|
type UserImages = Awaited<ReturnType<typeof getUserImages>>;
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [searchResults, setSearchResults] = createSignal<UserImages[number]['Text']>([]);
|
const [searchResults, setSearchResults] = createSignal<
|
||||||
|
UserImages[number]["Text"]
|
||||||
|
>([]);
|
||||||
|
|
||||||
const [images] = createResource(getUserImages);
|
const [images] = createResource(getUserImages);
|
||||||
|
|
||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
|
|
||||||
let fuze = new Fuse<NonNullable<UserImages[number]['Text']>[number]>([], { keys: ["Text.ImageText"] });
|
let fuze = new Fuse<NonNullable<UserImages[number]["Text"]>[number]>([], {
|
||||||
|
keys: ["Text.ImageText"],
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: there's probably a better way?
|
// TODO: there's probably a better way?
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const userImages = images();
|
const userImages = images();
|
||||||
|
|
||||||
|
console.log(userImages);
|
||||||
if (userImages == null) {
|
if (userImages == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageText = userImages.flatMap(i => i.Text ?? []);
|
const imageText = userImages.flatMap((i) => i.Text ?? []);
|
||||||
|
|
||||||
fuze = new Fuse(imageText, { keys: ["ImageText"], threshold: 0.3 });
|
fuze = new Fuse(imageText, {
|
||||||
|
keys: ["ImageText"],
|
||||||
|
threshold: 0.3,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const onInputChange = (query: string) => {
|
const onInputChange = (query: string) => {
|
||||||
// TODO: we can migrate this searching to Rust, so we don't abuse the main thread.
|
// TODO: we can migrate this searching to Rust, so we don't abuse the main thread.
|
||||||
// But, it's not too bad as is.
|
// But, it's not too bad as is.
|
||||||
setSearchResults(fuze.search(query).flatMap(s => s.item));
|
setSearchResults(fuze.search(query).flatMap((s) => s.item));
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main class="container pt-2">
|
<main class="container pt-2">
|
||||||
@ -64,7 +73,7 @@ function App() {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Search.ItemLabel class="mx-[-100px]">
|
<Search.ItemLabel class="mx-[-100px]">
|
||||||
{props.item.rawValue.ImageText ?? ''}
|
{props.item.rawValue.ImageText ?? ""}
|
||||||
</Search.ItemLabel>
|
</Search.ItemLabel>
|
||||||
</Search.Item>
|
</Search.Item>
|
||||||
)}
|
)}
|
||||||
@ -107,16 +116,23 @@ function App() {
|
|||||||
<div class="px-4 mt-4 bg-white rounded-t-2xl">
|
<div class="px-4 mt-4 bg-white rounded-t-2xl">
|
||||||
<div class="h-[254px] overflow-scroll scrollbar-hide">
|
<div class="h-[254px] overflow-scroll scrollbar-hide">
|
||||||
<div class="w-full grid grid-cols-9 grid-rows-9 gap-2 h-[480px] grid-flow-row-dense py-4">
|
<div class="w-full grid grid-cols-9 grid-rows-9 gap-2 h-[480px] grid-flow-row-dense py-4">
|
||||||
<div class="col-span-3 row-span-3 bg-red-200 rounded-xl" />
|
{/* <div class="col-span-3 row-span-3 bg-red-200 rounded-xl" />
|
||||||
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
||||||
<div class="col-span-6 row-span-3 bg-yellow-200 rounded-xl" />
|
<div class="col-span-6 row-span-3 bg-yellow-200 rounded-xl" />
|
||||||
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
||||||
<div class="col-span-3 row-span-3 bg-blue-200 rounded-xl" />
|
<div class="col-span-3 row-span-3 bg-blue-200 rounded-xl" />
|
||||||
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
<div class="col-span-3 row-span-3 bg-green-200 rounded-xl" />
|
||||||
<div class="col-span-6 row-span-3 bg-yellow-200 rounded-xl" />
|
<div class="col-span-6 row-span-3 bg-yellow-200 rounded-xl" /> */}
|
||||||
|
{/* {JSON.stringify(images())} */}
|
||||||
<For each={images()}>
|
<For each={images()}>
|
||||||
{(image) => (
|
{(image) => (
|
||||||
<A href={`/image/${image.ID}`}><img src={`http://localhost:3040/image/${image.ID}`} class="col-span-3 row-span-3 rounded-xl" /></A>
|
<A href={`/image/${image.ID}`}>
|
||||||
|
<img
|
||||||
|
src={`http://localhost:3040/image/${image.ID}`}
|
||||||
|
class="col-span-3 row-span-3 rounded-xl"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</A>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { A, useParams } from "@solidjs/router"
|
import { A, useParams } from "@solidjs/router";
|
||||||
import { createEffect, createResource, For, Suspense } from "solid-js"
|
import { createEffect, createResource, For, Suspense } from "solid-js";
|
||||||
import { getUserImages } from "./network"
|
import { getUserImages } from "./network";
|
||||||
|
|
||||||
export function ImagePage() {
|
export function ImagePage() {
|
||||||
const { imageId } = useParams<{ imageId: string }>()
|
const { imageId } = useParams<{ imageId: string }>();
|
||||||
|
|
||||||
const [image] = createResource(async () => {
|
const [image] = createResource(async () => {
|
||||||
const userImages = await getUserImages();
|
const userImages = await getUserImages();
|
||||||
|
|
||||||
const currentImage = userImages.find(image => image.ID === imageId);
|
const currentImage = userImages.find((image) => image.ID === imageId);
|
||||||
if (currentImage == null) {
|
if (currentImage == null) {
|
||||||
// TODO: this error handling.
|
// TODO: this error handling.
|
||||||
throw new Error("must be valid");
|
throw new Error("must be valid");
|
||||||
@ -19,18 +19,18 @@ export function ImagePage() {
|
|||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log(image());
|
console.log(image());
|
||||||
})
|
});
|
||||||
|
|
||||||
return (<Suspense fallback={<>Loading...</>}>
|
return (
|
||||||
|
<Suspense fallback={<>Loading...</>}>
|
||||||
<A href="/">Back</A>
|
<A href="/">Back</A>
|
||||||
<h1 class="text-2xl font-bold">{image()?.Image.ImageName}</h1>
|
<h1 class="text-2xl font-bold">{image()?.Image.ImageName}</h1>
|
||||||
<img src={`http://localhost:3040/image/${image()?.ID}`} />
|
<img src={`http://localhost:3040/image/${image()?.ID}`} />
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<For each={image()?.Tags ?? []}>
|
<For each={image()?.Tags ?? []}>
|
||||||
{(tag) => (
|
{(tag) => <div>{tag.Tag}</div>}
|
||||||
<div>{tag.Tag}</div>
|
|
||||||
)}
|
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
</Suspense>)
|
</Suspense>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,12 @@ import "./index.css";
|
|||||||
import { Route, Router } from "@solidjs/router";
|
import { Route, Router } from "@solidjs/router";
|
||||||
import { ImagePage } from "./ImagePage";
|
import { ImagePage } from "./ImagePage";
|
||||||
|
|
||||||
render(() => (
|
render(
|
||||||
|
() => (
|
||||||
<Router>
|
<Router>
|
||||||
<Route path="/" component={App} />
|
<Route path="/" component={App} />
|
||||||
<Route path="/image/:imageId" component={ImagePage} />
|
<Route path="/image/:imageId" component={ImagePage} />
|
||||||
</Router>
|
</Router>
|
||||||
), document.getElementById("root") as HTMLElement);
|
),
|
||||||
|
document.getElementById("root") as HTMLElement,
|
||||||
|
);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
array,
|
type InferOutput,
|
||||||
InferOutput,
|
|
||||||
null as Null,
|
null as Null,
|
||||||
|
any,
|
||||||
|
array,
|
||||||
nullable,
|
nullable,
|
||||||
object,
|
object,
|
||||||
parse,
|
parse,
|
||||||
@ -55,24 +56,8 @@ const getUserImagesResponseValidator = array(
|
|||||||
ImageName: string(),
|
ImageName: string(),
|
||||||
Image: Null(),
|
Image: Null(),
|
||||||
}),
|
}),
|
||||||
Tags: nullable(
|
Tags: any(),
|
||||||
array(
|
Links: any(),
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
Tag: string(),
|
|
||||||
ImageID: pipe(string(), uuid()),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Links: nullable(
|
|
||||||
array(
|
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
Links: string(),
|
|
||||||
ImageID: pipe(string(), uuid()),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text: nullable(
|
Text: nullable(
|
||||||
array(
|
array(
|
||||||
object({
|
object({
|
||||||
|
Reference in New Issue
Block a user