127 lines
3.1 KiB
Text
127 lines
3.1 KiB
Text
package web
|
|
|
|
import "git.jmbit.de/jmb/scanfile/server/internal/sqlc"
|
|
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
|
|
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/modal"
|
|
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
|
|
import "fmt"
|
|
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
|
|
import "git.jmbit.de/jmb/scanfile/server/internal/database"
|
|
|
|
templ FileView(file sqlc.File, fileProperties sqlc.FileProperty, diec database.Diec) {
|
|
@Base(file.Name) {
|
|
<div class="flex space-x-4 pb-4">
|
|
<h1 class="text-4xl">{file.Name}</h1>
|
|
@FileViewDeleteModal(file.ID.String())
|
|
@FileViewDownloadModal(file.ID.String())
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-4">
|
|
@FileViewGenericTable(file, fileProperties, diec)
|
|
if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
|
|
@FileViewMsofficeLoader(file.ID.String())
|
|
}
|
|
if processing.TypeFromMime(file.Mimetype) == processing.TypeELF || processing.TypeFromMime(file.Mimetype) == processing.TypePE {
|
|
@FileViewCapaLoader(file.ID.String())
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
templ FileViewDeleteModal(fileid string) {
|
|
@modal.Trigger(modal.TriggerProps{
|
|
For: "delete-modal",
|
|
Class: "p-1",
|
|
}) {
|
|
@button.Button(button.Props{
|
|
Class: "flex gap-2 items-center",
|
|
Variant: button.VariantDestructive,
|
|
}) {
|
|
@icon.Trash()
|
|
Delete
|
|
}
|
|
}
|
|
@modal.Modal(modal.Props{
|
|
ID: "delete-modal",
|
|
Class: "max-w-md",
|
|
}) {
|
|
@modal.Header() {
|
|
Are you sure you want to delete this file?
|
|
}
|
|
@modal.Body() {
|
|
This action cannot be undone. This will permanently delete the file from the server.
|
|
}
|
|
@modal.Footer() {
|
|
<div class="flex gap-2">
|
|
@modal.Close(modal.CloseProps{
|
|
For: "delete-modal",
|
|
}) {
|
|
@button.Button() {
|
|
Cancel
|
|
}
|
|
}
|
|
@modal.Close(modal.CloseProps{
|
|
For: "delete-modal",
|
|
}) {
|
|
@button.Button(button.Props{
|
|
Variant: button.VariantDestructive,
|
|
Href: fmt.Sprintf("/files/%s/delete", fileid),
|
|
}) {
|
|
Delete
|
|
}
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
@modal.Script()
|
|
}
|
|
|
|
templ FileViewDownloadModal(fileid string) {
|
|
@modal.Trigger(modal.TriggerProps{
|
|
For: "download-modal",
|
|
Class: "p-1",
|
|
}) {
|
|
@button.Button(button.Props{
|
|
Class: "flex gap-2 items-center",
|
|
Variant: button.VariantDefault,
|
|
}) {
|
|
@icon.ArrowBigDown()
|
|
Download
|
|
}
|
|
}
|
|
@modal.Modal(modal.Props{
|
|
ID: "download-modal",
|
|
Class: "max-w-md",
|
|
}) {
|
|
@modal.Header() {
|
|
Download this file?
|
|
}
|
|
@modal.Body() {
|
|
Files downloaded from scanfile can be harmful to your system. Are you sure you want to continue?
|
|
}
|
|
@modal.Footer() {
|
|
<div class="flex gap-2">
|
|
@modal.Close(modal.CloseProps{
|
|
For: "download-modal",
|
|
}) {
|
|
@button.Button() {
|
|
Cancel
|
|
}
|
|
}
|
|
@modal.Close(modal.CloseProps{
|
|
For: "download-modal",
|
|
}) {
|
|
@button.Button(button.Props{
|
|
Variant: button.VariantDestructive,
|
|
Href: fmt.Sprintf("/files/%s/download", fileid),
|
|
}) {
|
|
Download
|
|
}
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
@modal.Script()
|
|
}
|