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) {
{file.Name}
@FileViewDeleteModal(file.ID.String())
@FileViewDownloadModal(file.ID.String())
@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())
}
}
}
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() {
@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
}
}
}
}
@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() {
@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
}
}
}
}
@modal.Script()
}