-
- column.id === searchColumn
- )[0].header
- }'...`}
- value={
- table
- .getColumn(searchColumn)
- ?.getFilterValue() as string
- }
- onChange={(event) =>
- table
- .getColumn(searchColumn)
- ?.setFilterValue(event.target.value)
- }
- className="max-w-sm"
- />
-
-
-
-
-
-
-
-
- Choose a column to search
-
-
-
-
-
- Search Column
-
-
- {columns
- .filter(
- (column) => column.id && column.header
- )
- .map((column, index) => (
-
- {column.header!.toString()}
-
- ))}
-
-
-
-
-
-
-
-
- Clear table
-
-
-
+ {" "}
+
+
+ table
+ .getColumn("label")
+ ?.setFilterValue(event.target.value)
+ }
+ className="max-w-sm"
+ />
@@ -178,10 +96,7 @@ export function DataTable
({
}
>
{row.getVisibleCells().map((cell: any) => (
-
+
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
diff --git a/src/components/MagikaProcess.tsx b/src/components/MagikaProcess.tsx
index 65cd583..6887b4f 100644
--- a/src/components/MagikaProcess.tsx
+++ b/src/components/MagikaProcess.tsx
@@ -3,10 +3,12 @@
import { Button } from "@/components/ui/button";
import { Loader } from "@/components/ui/loader";
+//@ts-ignore
import { Magika } from "magika";
import { listen } from "@tauri-apps/api/event";
import { useEffect, useState } from "react";
import { readFile } from "@tauri-apps/plugin-fs";
+//@ts-ignore
import { open } from "@tauri-apps/plugin-dialog";
import { columns } from "@/components/DT/columns";
import { DataTable } from "@/components/DT/data-table";
@@ -17,19 +19,22 @@ const MagikaProcess = () => {
useEffect(() => {
if (loading) return;
- listen("tauri://file-drop", async ({ payload }: any) => {
- setLoading(true);
- const filepaths: string[] = payload.paths;
- const filepredictions: any[] = [];
+ const unlisten = listen(
+ "tauri://file-drop",
+ async ({ payload }: any) => {
+ setLoading(true);
+ const filepaths: string[] = payload.paths;
+ const filepredictions: any[] = [];
- for await (const filepath of filepaths) {
- const prediction = await getPrediction(filepath);
- filepredictions.push(prediction);
+ for await (const filepath of filepaths) {
+ const prediction = await getPrediction(filepath);
+ filepredictions.push(prediction);
+ }
+
+ setPredictions(filepredictions);
+ setLoading(false);
}
-
- setPredictions(filepredictions);
- setLoading(false);
- });
+ );
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -38,13 +43,9 @@ const MagikaProcess = () => {
const fileBytes = await readFile(filepath);
const magika = new Magika();
await magika.load({});
- const result = await magika.identifyBytes(
- new Uint16Array(fileBytes.buffer)
- );
- return {
- path: filepath,
- result: result,
- };
+ const prediction = await magika.identifyBytes(fileBytes);
+ prediction.path = filepath;
+ return prediction;
} catch (e) {
console.error(
`Error while getting prediction for ${filepath}: ${e}`
@@ -67,6 +68,7 @@ const MagikaProcess = () => {
}
setPredictions(filePredictions);
} else if (selected === null) {
+ // user cancelled the selection
console.log("User cancelled selection");
} else {
// user selected a single file
@@ -88,7 +90,7 @@ const MagikaProcess = () => {
fformat
- Identify potential file content types
+ Examine file formats
@@ -108,11 +110,7 @@ const MagikaProcess = () => {
{predictions.length > 0 && (
-
+
)}