mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Update LibraryCreationModal
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, {useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {addToast, Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader} from "@heroui/react";
|
import {addToast, Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader} from "@heroui/react";
|
||||||
import {Form, Formik} from "formik";
|
import {Form, Formik} from "formik";
|
||||||
import LibraryDto from "Frontend/generated/de/grimsi/gameyfin/libraries/LibraryDto";
|
import LibraryDto from "Frontend/generated/de/grimsi/gameyfin/libraries/LibraryDto";
|
||||||
@@ -46,50 +46,58 @@ export default function LibraryCreationModal({
|
|||||||
<Modal isOpen={isOpen} onOpenChange={onOpenChange} backdrop="opaque" size="lg">
|
<Modal isOpen={isOpen} onOpenChange={onOpenChange} backdrop="opaque" size="lg">
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
{(onClose) => (
|
{(onClose) => (
|
||||||
<Formik initialValues={{name: "", path: ""}}
|
<Formik initialValues={{name: "", path: selectedPath}}
|
||||||
onSubmit={async (values: any) => {
|
onSubmit={async (values: any) => {
|
||||||
await createLibrary(values);
|
await createLibrary(values);
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(formik) => (
|
{(formik) => {
|
||||||
<Form>
|
useEffect(() => {
|
||||||
<ModalHeader className="flex flex-col gap-1">Add a new library</ModalHeader>
|
formik.setFieldValue("path", selectedPath);
|
||||||
<ModalBody>
|
}, [selectedPath]);
|
||||||
<h4 className="text-l font-bold">Details</h4>
|
|
||||||
<div className="flex flex-col gap-2">
|
return (
|
||||||
<Input
|
<Form>
|
||||||
name="name"
|
<ModalHeader className="flex flex-col gap-1">Add a new library</ModalHeader>
|
||||||
label="Library Name"
|
<ModalBody>
|
||||||
placeholder="Enter library name"
|
<h4 className="text-l font-bold">Details</h4>
|
||||||
value={formik.values.name}
|
<div className="flex flex-col gap-2">
|
||||||
required
|
<Input
|
||||||
/>
|
name="name"
|
||||||
<Input
|
label="Library Name"
|
||||||
name="path"
|
placeholder="Enter library name"
|
||||||
label="path"
|
value={formik.values.name}
|
||||||
placeholder="Enter library path"
|
required
|
||||||
value={formik.values.path}
|
/>
|
||||||
required
|
<Input
|
||||||
/>
|
name="path"
|
||||||
</div>
|
label="Library Path"
|
||||||
<pre>{selectedPath}</pre>
|
placeholder="Select a path"
|
||||||
<FileTreeView onPathChange={setSelectedPath}/>
|
value={formik.values.path}
|
||||||
</ModalBody>
|
isDisabled
|
||||||
<ModalFooter>
|
required
|
||||||
<Button variant="light" onPress={onClose}>
|
/>
|
||||||
Cancel
|
</div>
|
||||||
</Button>
|
<div className="h-64 overflow-auto">
|
||||||
<Button color="primary"
|
<FileTreeView onPathChange={setSelectedPath}/>
|
||||||
isLoading={formik.isSubmitting}
|
</div>
|
||||||
disabled={formik.isSubmitting}
|
</ModalBody>
|
||||||
type="submit"
|
<ModalFooter>
|
||||||
>
|
<Button variant="light" onPress={onClose}>
|
||||||
{formik.isSubmitting ? "" : "Add"}
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</ModalFooter>
|
<Button color="primary"
|
||||||
</Form>
|
isLoading={formik.isSubmitting}
|
||||||
)}
|
disabled={formik.isSubmitting}
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
{formik.isSubmitting ? "" : "Add"}
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}}
|
||||||
</Formik>
|
</Formik>
|
||||||
)}
|
)}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class FilesystemService {
|
|||||||
.filter { !it.isHidden }
|
.filter { !it.isHidden }
|
||||||
.map { FileDto(it.name, if (it.isDirectory) FileType.DIRECTORY else FileType.FILE, it.hashCode()) }
|
.map { FileDto(it.name, if (it.isDirectory) FileType.DIRECTORY else FileType.FILE, it.hashCode()) }
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
log.error { "Error reading directory contents of $path" }
|
log.warn { "Error reading directory contents of $path" }
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user