feat(processing-image): displaying initial status from response
This commit is contained in:
@ -43,8 +43,6 @@ func ListenNewImageEvents(db *sql.DB, eventManager *EventManager) {
|
|||||||
|
|
||||||
databaseEventLog.Debug("Starting processing image", "ImageID", imageId)
|
databaseEventLog.Debug("Starting processing image", "ImageID", imageId)
|
||||||
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
import { Route, Router } from "@solidjs/router";
|
import { Route, Router } from "@solidjs/router";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { createEffect, createSignal, For, onCleanup, Show } from "solid-js";
|
import { createEffect, createSignal, onCleanup } from "solid-js";
|
||||||
import { Login } from "./Login";
|
import { Login } from "./Login";
|
||||||
import { ProtectedRoute } from "./ProtectedRoute";
|
import { ProtectedRoute } from "./ProtectedRoute";
|
||||||
import { Search } from "./Search";
|
import { Search } from "./Search";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "./Settings";
|
||||||
import { ImageViewer } from "./components/ImageViewer";
|
import { ImageViewer } from "./components/ImageViewer";
|
||||||
import { ShareTarget } from "./components/share-target/ShareTarget";
|
import { ShareTarget } from "./components/share-target/ShareTarget";
|
||||||
import type { PluginListener } from "@tauri-apps/api/core";
|
import type { sendImage } from "./network";
|
||||||
import {
|
import { ImageStatus } from "./components/image-status/ImageStatus";
|
||||||
listenForShareEvents,
|
|
||||||
type ShareEvent,
|
|
||||||
} from "tauri-plugin-sharetarget-api";
|
|
||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const [logs, setLogs] = createSignal<string[]>([]);
|
const [processingImage, setProcessingImage] =
|
||||||
const [file, setFile] = createSignal<File>();
|
createSignal<Awaited<ReturnType<typeof sendImage>>>();
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
// TODO: Don't use window.location.href
|
// TODO: Don't use window.location.href
|
||||||
@ -57,7 +53,8 @@ export const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ImageViewer />
|
<ImageViewer onSendImage={setProcessingImage} />
|
||||||
|
<ImageStatus processingImage={processingImage} />
|
||||||
<ShareTarget />
|
<ShareTarget />
|
||||||
<Router>
|
<Router>
|
||||||
<Route path="/login" component={Login} />
|
<Route path="/login" component={Login} />
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import { type Component, createEffect } from "solid-js";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
||||||
import { createEffect, createSignal } from "solid-js";
|
|
||||||
import { sendImage } from "../network";
|
import { sendImage } from "../network";
|
||||||
|
|
||||||
// TODO: This component should focus the window and show preview of screenshot,
|
type ImageViewerProps = {
|
||||||
// before we send it to backend, potentially we could draw and annotate
|
onSendImage: (
|
||||||
// OR we kill this and do stuff siltently
|
processingImage: Awaited<ReturnType<typeof sendImage>>,
|
||||||
// anyhow keeping it like this for now
|
) => void;
|
||||||
export function ImageViewer() {
|
};
|
||||||
|
|
||||||
|
export const ImageViewer: Component<ImageViewerProps> = (props) => {
|
||||||
// const [latestImage, setLatestImage] = createSignal<string | null>(null);
|
// const [latestImage, setLatestImage] = createSignal<string | null>(null);
|
||||||
|
|
||||||
createEffect(async () => {
|
createEffect(async () => {
|
||||||
@ -26,6 +26,9 @@ export function ImageViewer() {
|
|||||||
|
|
||||||
const result = await sendImage("test-image.png", base64Data);
|
const result = await sendImage("test-image.png", base64Data);
|
||||||
|
|
||||||
|
props.onSendImage(result);
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
console.log("DBG: ", result);
|
console.log("DBG: ", result);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,4 +53,4 @@ export function ImageViewer() {
|
|||||||
// )}
|
// )}
|
||||||
// </div>
|
// </div>
|
||||||
// );
|
// );
|
||||||
}
|
};
|
||||||
|
22
frontend/src/components/image-status/ImageStatus.tsx
Normal file
22
frontend/src/components/image-status/ImageStatus.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { Show, type Accessor, type Component } from "solid-js";
|
||||||
|
import type { sendImage } from "../../network";
|
||||||
|
|
||||||
|
type ImageStatusProps = {
|
||||||
|
processingImage: Accessor<
|
||||||
|
Awaited<ReturnType<typeof sendImage>> | undefined
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ImageStatus: Component<ImageStatusProps> = (props) => {
|
||||||
|
return (
|
||||||
|
<Show when={props.processingImage()}>
|
||||||
|
{(image) => (
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
{image().ImageID} - {image().Status}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
|
};
|
Reference in New Issue
Block a user