UI updates & browser window handling.
This commit is contained in:
@@ -35,6 +35,7 @@ export type ScrubHistoryItem = {
|
||||
claimNumber: string;
|
||||
pdfUrl: string | null;
|
||||
results: Array<{
|
||||
id: number;
|
||||
createdAt: number;
|
||||
anchor: string | null;
|
||||
category: string | null;
|
||||
@@ -239,6 +240,7 @@ export function getScrubHistory(): ScrubHistoryItem[] {
|
||||
for (const r of results) {
|
||||
const bucket = resultsByJobId.get(r.job_id) ?? [];
|
||||
bucket.push({
|
||||
id: r.id,
|
||||
createdAt: r.created_at,
|
||||
anchor: r.anchor,
|
||||
category: r.category,
|
||||
@@ -341,6 +343,7 @@ export function getScrubHistoryPage(params: {
|
||||
for (const r of results) {
|
||||
const bucket = resultsByJobId.get(r.job_id) ?? [];
|
||||
bucket.push({
|
||||
id: r.id,
|
||||
createdAt: r.created_at,
|
||||
anchor: r.anchor,
|
||||
category: r.category,
|
||||
|
||||
@@ -181,11 +181,6 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
});
|
||||
// uploadNotification.on("click", () => {
|
||||
// if (scrubPdfURL) {
|
||||
// shell.openExternal(scrubPdfURL);
|
||||
// }
|
||||
// });
|
||||
|
||||
uploadNotification.show();
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { app, ipcMain } from "electron";
|
||||
import { ipcMain } from "electron";
|
||||
import log from "electron-log/main";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import path from "path";
|
||||
import ipcTypes from "../../util/ipcTypes.json";
|
||||
import ImportJob from "../decoder/decoder";
|
||||
import store from "../store/store";
|
||||
import { StartWatcher, StopWatcher } from "../watcher/watcher";
|
||||
import {
|
||||
ScrubHistoryClearAll,
|
||||
@@ -14,16 +11,13 @@ import {
|
||||
import {
|
||||
getSetting,
|
||||
setSetting,
|
||||
SettingEmsOutFilePathGet,
|
||||
SettingEmsOutFilePathSet,
|
||||
SettingsPpcFilePathGet,
|
||||
SettingsPpcFilePathSet,
|
||||
SettingsWatchedFilePathsAdd,
|
||||
SettingsWatchedFilePathsGet,
|
||||
SettingsWatchedFilePathsRemove,
|
||||
SettingsWatcherPollingGet,
|
||||
SettingsWatcherPollingSet,
|
||||
} from "./ipcMainHandler.settings";
|
||||
import newWindow from "../../util/newWindow";
|
||||
|
||||
// Log all IPC messages and their payloads
|
||||
const logIpcMessages = (): void => {
|
||||
@@ -102,4 +96,8 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => {
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(ipcTypes.toMain.openExternal, async (event, url: string) => {
|
||||
newWindow(url);
|
||||
});
|
||||
|
||||
logIpcMessages();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { electronAPI } from "@electron-toolkit/preload";
|
||||
import { contextBridge } from "electron";
|
||||
import { contextBridge, shell } from "electron";
|
||||
import "electron-log/preload";
|
||||
import store from "../main/store/store";
|
||||
import newWindow from "../util/newWindow";
|
||||
|
||||
// Custom APIs for renderer
|
||||
interface Api {
|
||||
@@ -13,7 +12,7 @@ interface Api {
|
||||
const api: Api = {
|
||||
isTest: (): boolean => store.get("app.isTest") || false,
|
||||
openExternal: async (url: string): Promise<void> => {
|
||||
newWindow(url);
|
||||
await shell.openExternal(url);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
// renderer/Home.tsx
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
DatabaseOutlined,
|
||||
DeleteOutlined,
|
||||
DeleteRowOutlined,
|
||||
FileTextOutlined,
|
||||
SettingOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -14,16 +23,9 @@ import {
|
||||
theme,
|
||||
} from "antd";
|
||||
import { FC, useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router";
|
||||
import {
|
||||
FileTextOutlined,
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
SettingOutlined,
|
||||
DatabaseOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import ipcTypes from "../../../../util/ipcTypes.json";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate } from "react-router";
|
||||
import ipcTypes from "../../../../util/ipcTypes.json";
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
@@ -47,6 +49,7 @@ type ScrubHistoryItem = {
|
||||
};
|
||||
|
||||
type ScrubHistoryResultItem = {
|
||||
id: number;
|
||||
createdAt: number;
|
||||
anchor: string | null;
|
||||
category: string | null;
|
||||
@@ -212,7 +215,7 @@ const Home: FC = () => {
|
||||
disabled={!record.pdfUrl}
|
||||
onClick={() => {
|
||||
if (!record.pdfUrl) return;
|
||||
window.api.openExternal(record.pdfUrl);
|
||||
ipcRenderer.send(ipcTypes.toMain.openExternal, record.pdfUrl);
|
||||
}}
|
||||
>
|
||||
Open
|
||||
@@ -243,7 +246,7 @@ const Home: FC = () => {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "",
|
||||
title: "Actions",
|
||||
key: "actions",
|
||||
width: 110,
|
||||
render: (_: unknown, record: ScrubHistoryItem) => (
|
||||
@@ -254,9 +257,7 @@ const Home: FC = () => {
|
||||
cancelText="Cancel"
|
||||
onConfirm={() => deleteJob(record.id)}
|
||||
>
|
||||
<Button type="link" danger>
|
||||
Delete
|
||||
</Button>
|
||||
<Button icon={<DeleteRowOutlined />} danger></Button>
|
||||
</Popconfirm>
|
||||
),
|
||||
},
|
||||
@@ -401,7 +402,11 @@ const Home: FC = () => {
|
||||
onConfirm={clearAll}
|
||||
disabled={history.length === 0}
|
||||
>
|
||||
<Button danger disabled={history.length === 0}>
|
||||
<Button
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
disabled={history.length === 0}
|
||||
>
|
||||
{t("dashboard.actions.clear_all")}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
@@ -497,8 +502,8 @@ const Home: FC = () => {
|
||||
<Table
|
||||
columns={resultColumns}
|
||||
dataSource={items}
|
||||
rowKey={(row, idx) =>
|
||||
`${category}-${row.createdAt}-${idx}`
|
||||
rowKey={(row) =>
|
||||
`${category}-${row.createdAt}-${row.id}`
|
||||
}
|
||||
pagination={false}
|
||||
size="small"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"toMain": {
|
||||
"test": "toMain_test",
|
||||
"authStateChanged": "toMain_authStateChanged",
|
||||
"openExternal": "toMain_openExternal",
|
||||
"scrubHistory": {
|
||||
"getAll": "toMain_scrubHistory_getAll",
|
||||
"deleteJob": "toMain_scrubHistory_deleteJob",
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { app, BrowserWindow } from "electron";
|
||||
import { BrowserWindow, shell } from "electron";
|
||||
|
||||
async function newWindow(url: string): Promise<void> {
|
||||
// BrowserWindow is a main-process API. If this gets called from preload/renderer
|
||||
// (or a non-Electron context), fall back to the OS default handler.
|
||||
if (typeof process === "undefined" || process.type !== "browser") {
|
||||
await shell.openExternal(url);
|
||||
return;
|
||||
}
|
||||
|
||||
const pdfWindow = new BrowserWindow({
|
||||
title: app.name,
|
||||
webPreferences: {
|
||||
plugins: true, // Enable PDF viewing
|
||||
},
|
||||
});
|
||||
|
||||
pdfWindow.loadURL(url);
|
||||
await pdfWindow.loadURL(url);
|
||||
pdfWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user