mirror of
https://github.com/fccview/cronmaster.git
synced 2026-01-01 10:29:02 -05:00
Compare commits
1 Commits
bugfix/rep
...
BUG-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b267fb9ce6 |
@@ -39,10 +39,21 @@ export function ScriptModal({
|
|||||||
}: ScriptModalProps) {
|
}: ScriptModalProps) {
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!form.name.trim()) {
|
||||||
|
showToast("error", "Validation Error", "Script name is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!form.content.trim()) {
|
||||||
|
showToast("error", "Validation Error", "Script content is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("name", form.name);
|
formData.append("name", form.name.trim());
|
||||||
formData.append("description", form.description);
|
formData.append("description", form.description.trim());
|
||||||
formData.append("content", form.content);
|
formData.append("content", form.content.trim());
|
||||||
|
|
||||||
Object.entries(additionalFormData).forEach(([key, value]) => {
|
Object.entries(additionalFormData).forEach(([key, value]) => {
|
||||||
formData.append(key, value);
|
formData.append(key, value);
|
||||||
@@ -66,18 +77,24 @@ export function ScriptModal({
|
|||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-foreground mb-2">
|
<label className="block text-sm font-medium text-foreground mb-2">
|
||||||
Script Name
|
Script Name <span className="text-red-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
value={form.name}
|
value={form.name}
|
||||||
onChange={(e) => onFormChange({ name: e.target.value })}
|
onChange={(e) => onFormChange({ name: e.target.value })}
|
||||||
placeholder="My Script"
|
placeholder="My Script"
|
||||||
required
|
required
|
||||||
|
className={
|
||||||
|
!form.name.trim()
|
||||||
|
? "border-red-300 focus:border-red-500 focus:ring-red-500"
|
||||||
|
: ""
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-foreground mb-2">
|
<label className="block text-sm font-medium text-foreground mb-2">
|
||||||
Description
|
Description{" "}
|
||||||
|
<span className="text-muted-foreground text-xs">(optional)</span>
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
value={form.description}
|
value={form.description}
|
||||||
@@ -102,7 +119,7 @@ export function ScriptModal({
|
|||||||
<div className="flex items-center gap-2 mb-4 flex-shrink-0">
|
<div className="flex items-center gap-2 mb-4 flex-shrink-0">
|
||||||
<FileText className="h-4 w-4 text-primary" />
|
<FileText className="h-4 w-4 text-primary" />
|
||||||
<h3 className="text-sm font-medium text-foreground">
|
<h3 className="text-sm font-medium text-foreground">
|
||||||
Script Content
|
Script Content <span className="text-red-500">*</span>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-h-0">
|
<div className="flex-1 min-h-0">
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ async function scanScriptsDirectory(dirPath: string): Promise<Script[]> {
|
|||||||
const content = await fs.readFile(filePath, "utf-8");
|
const content = await fs.readFile(filePath, "utf-8");
|
||||||
const metadata = parseMetadata(content);
|
const metadata = parseMetadata(content);
|
||||||
|
|
||||||
if (metadata.id && metadata.title && metadata.description) {
|
if (metadata.id && metadata.title) {
|
||||||
const stats = await fs.stat(filePath);
|
const stats = await fs.stat(filePath);
|
||||||
|
|
||||||
scripts.push({
|
scripts.push({
|
||||||
id: metadata.id,
|
id: metadata.id,
|
||||||
name: metadata.title,
|
name: metadata.title,
|
||||||
description: metadata.description,
|
description: metadata.description || "",
|
||||||
filename: file,
|
filename: file,
|
||||||
createdAt: stats.birthtime.toISOString(),
|
createdAt: stats.birthtime.toISOString(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user