-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ff7d7d
commit 87b24d3
Showing
15 changed files
with
317 additions
and
60 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
examples/apps/screenpipe-app-tauri/components/pipe-config-form.tsx
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,74 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Input } from "./ui/input"; | ||
import { Button } from "./ui/button"; | ||
import { Label } from "./ui/label"; | ||
import { Checkbox } from "./ui/checkbox"; | ||
import { Pipe } from "@/lib/hooks/use-pipes"; | ||
import { invoke } from "@tauri-apps/api/core"; | ||
|
||
type PipeConfigFormProps = { | ||
pipe: Pipe; | ||
onConfigSave: (config: Record<string, any>) => void; | ||
}; | ||
|
||
export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({ | ||
pipe, | ||
onConfigSave, | ||
}) => { | ||
const [config, setConfig] = useState<Record<string, any>>(pipe.config || {}); | ||
|
||
useEffect(() => { | ||
const loadConfig = async () => { | ||
try { | ||
const loadedConfig = await invoke("load_pipe_config", { | ||
pipeName: pipe.name, | ||
}); | ||
setConfig(loadedConfig as Record<string, any>); | ||
} catch (error) { | ||
console.error("Error loading pipe config:", error); | ||
} | ||
}; | ||
|
||
loadConfig(); | ||
}, [pipe.name]); | ||
|
||
const handleInputChange = (name: string, value: any) => { | ||
setConfig((prev) => ({ ...prev, [name]: value })); | ||
}; | ||
|
||
const handleSubmit = async (e: React.FormEvent) => { | ||
e.preventDefault(); | ||
try { | ||
await invoke("save_pipe_config", { pipeName: pipe.name, config }); | ||
onConfigSave(config); | ||
} catch (error) { | ||
console.error("Error saving pipe config:", error); | ||
} | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className="space-y-4"> | ||
<h3 className="text-lg font-semibold">Pipe Configuration</h3> | ||
{Object.entries(config).map(([key, value]) => ( | ||
<div key={key} className="space-y-2"> | ||
<Label htmlFor={key}>{key}</Label> | ||
{typeof value === "boolean" ? ( | ||
<Checkbox | ||
id={key} | ||
checked={value} | ||
onCheckedChange={(checked) => handleInputChange(key, checked)} | ||
/> | ||
) : ( | ||
<Input | ||
id={key} | ||
type={typeof value === "number" ? "number" : "text"} | ||
value={value} | ||
onChange={(e) => handleInputChange(key, e.target.value)} | ||
/> | ||
)} | ||
</div> | ||
))} | ||
<Button type="submit">Save Configuration</Button> | ||
</form> | ||
); | ||
}; |
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
30 changes: 30 additions & 0 deletions
30
examples/apps/screenpipe-app-tauri/components/ui/checkbox.tsx
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,30 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox" | ||
import { Check } from "lucide-react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn("flex items-center justify-center text-current")} | ||
> | ||
<Check className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)) | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName | ||
|
||
export { Checkbox } |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/acl-manifests.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.