Compare commits

...

10 commits

22 changed files with 1109 additions and 353 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@ venv/
/storage/ /storage/
scanners/ole/venv/ scanners/ole/venv/
tmp/ tmp/
temp/
**/__pycache__ **/__pycache__
# Created by https://www.toptal.com/developers/gitignore/api/linux,go,vim,visualstudiocode,macos,windows # Created by https://www.toptal.com/developers/gitignore/api/linux,go,vim,visualstudiocode,macos,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,go,vim,visualstudiocode,macos,windows # Edit at https://www.toptal.com/developers/gitignore?templates=linux,go,vim,visualstudiocode,macos,windows

View file

@ -22,15 +22,29 @@ func GetFileByID(fileID string) (sqlc.File, error) {
return file, nil return file, nil
} }
func DeleteFileByID(fileID string) error {
var pgUUID pgtype.UUID
err := pgUUID.Scan(fileID)
if err != nil {
slog.Error("Unable to convert string to UUID", "file-uuid", fileID, "error", err)
}
query := sqlc.New(pool)
err = query.DeleteFile(context.Background(), pgUUID)
if err != nil {
slog.Error("Unable to delete file", "file-uuid", fileID, "error", err)
}
return err
}
func InsertFileProperties(properties sqlc.InsertFilePropertiesParams) error { func InsertFileProperties(properties sqlc.InsertFilePropertiesParams) error {
query := sqlc.New(pool) query := sqlc.New(pool)
slog.Debug("InsertFileProperties", "file-uuid", properties.ID.String(), "file-sha256", slog.Debug("InsertFileProperties", "file-uuid", properties.FileID.String(), "file-sha256",
hex.EncodeToString(properties.Sha256), "file-md5", hex.EncodeToString(properties.Md5), hex.EncodeToString(properties.Sha256), "file-md5", hex.EncodeToString(properties.Md5),
"file-mime", properties.LibmagicMime.String, "file-extension", properties.LibmagicExtension.String, "file-mime", properties.LibmagicMime.String, "file-extension", properties.LibmagicExtension.String,
"file-apple", properties.LibmagicApple.String) "file-apple", properties.LibmagicApple.String)
err := query.InsertFileProperties(context.Background(), properties) err := query.InsertFileProperties(context.Background(), properties)
if err != nil { if err != nil {
slog.Error("Unable to add file properties", "file-uuid", properties.ID.String(), "error", err) slog.Error("Unable to add file properties", "file-uuid", properties.FileID.String(), "error", err)
} }
return err return err
} }

View file

@ -1,11 +1,12 @@
-- name: InsertFileProperties :exec -- name: InsertFileProperties :exec
INSERT INTO file_properties ( INSERT INTO file_properties (
id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
) VALUES ($1, $2, $3, $4, $5, $6); ) VALUES ($1, $2, $3, $4, $5, $6)
;
-- name: GetFileProperties :one -- name: GetFileProperties :one
SELECT * FROM file_properties SELECT * FROM file_properties
WHERE id = $1; WHERE file_id = $1;
-- name: InsertFileDIEC :exec -- name: InsertFileDIEC :exec
INSERT INTO diec ( INSERT INTO diec (

View file

@ -69,7 +69,8 @@ CREATE TABLE IF NOT EXISTS msoffice (
CREATE TABLE IF NOT EXISTS file_properties ( CREATE TABLE IF NOT EXISTS file_properties (
id UUID PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
file_id UUID REFERENCES files (id) ON DELETE CASCADE,
sha256 BYTEA, sha256 BYTEA,
md5 BYTEA, md5 BYTEA,
libmagic_mime TEXT, libmagic_mime TEXT,
@ -91,5 +92,6 @@ CREATE INDEX idx_msoffice_oleid_file_id ON msoffice_oleid (file_id);
CREATE INDEX idx_msoffice_olevba_file_id ON msoffice_olevba (file_id); CREATE INDEX idx_msoffice_olevba_file_id ON msoffice_olevba (file_id);
CREATE INDEX idx_msoffice_mraptor_file_id ON msoffice_mraptor (file_id); CREATE INDEX idx_msoffice_mraptor_file_id ON msoffice_mraptor (file_id);
CREATE INDEX idx_msoffice_results_file_id ON msoffice (file_id); CREATE INDEX idx_msoffice_results_file_id ON msoffice (file_id);
CREATE INDEX idx_file_properties_id ON file_properties (id); CREATE INDEX idx_file_properties_file_id ON file_properties (file_id);
CREATE INDEX idx_file_id ON files (id); CREATE INDEX idx_file_id ON files (id);
CREATE INDEX idx_yara_results_file_id ON yara_results (file_id);

View file

@ -28,7 +28,10 @@ func BasicProcessing(job sqlc.ProcessingJob) error {
} }
fileProperties := sqlc.InsertFilePropertiesParams{} fileProperties := sqlc.InsertFilePropertiesParams{}
fileProperties.ID = job.FileID fileProperties.LibmagicMime.Valid = true
fileProperties.LibmagicApple.Valid = true
fileProperties.LibmagicExtension.Valid = true
fileProperties.FileID = job.FileID
fileProperties.Md5 = md5sum[:] fileProperties.Md5 = md5sum[:]
fileProperties.Sha256 = sha256sum[:] fileProperties.Sha256 = sha256sum[:]
fileProperties.LibmagicMime.String = fileCmdResult.MimeType fileProperties.LibmagicMime.String = fileCmdResult.MimeType

View file

@ -18,7 +18,7 @@ var startup time.Time
func Setup(wg *sync.WaitGroup) { func Setup(wg *sync.WaitGroup) {
startup = time.Now() startup = time.Now()
yara.InitYara() go yara.InitYara()
} }
// Submit() starts the analysis process for a file. // Submit() starts the analysis process for a file.
@ -31,6 +31,14 @@ func Submit(ctx context.Context, file pgtype.UUID) error {
} }
go basic.BasicProcessing(job) go basic.BasicProcessing(job)
yaraJob, err := database.NewProcessingJob(ctx, file, TypeYARA)
if err != nil {
slog.Error("Could not submit processing job", "error", err, "file-uuid", file, "type", TypeBasic)
return err
}
go yara.YaraProcessing(yaraJob)
mimeType, err := database.GetFileMime(file) mimeType, err := database.GetFileMime(file)
if err != nil { if err != nil {
slog.Error("Could not retrieve MimeType", "error", err, "file-uuid", file) slog.Error("Could not retrieve MimeType", "error", err, "file-uuid", file)

View file

@ -25,6 +25,9 @@ const TypeArchive = "Archive"
// Anything not implemented (yet) // Anything not implemented (yet)
const TypeOther = "Other" const TypeOther = "Other"
// Yara Scan (can be done for all filetypes)
const TypeYARA = "Yara"
var MSOfficeMime = []string{ var MSOfficeMime = []string{
"application/msword", "application/msword",
"application/vnd.ms-excel", "application/vnd.ms-excel",

View file

@ -21,7 +21,8 @@ func compileSourcesFromFiles() error {
return err return err
} }
cmd := exec.Command("/usr/local/bin/yr", "compile","-path-as-namespace", "--relaxed-re-syntax", "--output", outputPath, root) cmd := exec.Command("/usr/local/bin/yr", "compile","--path-as-namespace", "--relaxed-re-syntax", "--output", outputPath, root)
slog.Debug("Yara compile command", "cmd", cmd.String())
result, err := cmd.Output() result, err := cmd.Output()
if err != nil { if err != nil {
slog.Error("Error compiling yara rules", "error", err, "result", string(result)) slog.Error("Error compiling yara rules", "error", err, "result", string(result))
@ -46,6 +47,7 @@ func scanFile(fileName string) ([]string, error) {
return matched, err return matched, err
} }
cmd := exec.Command("/usr/local/bin/yr", "scan", "--output-format ndjson", "--print-namespace","--compiled-rules", outputPath, fullPath) cmd := exec.Command("/usr/local/bin/yr", "scan", "--output-format ndjson", "--print-namespace","--compiled-rules", outputPath, fullPath)
slog.Debug("Yara scan command", "cmd", cmd.String())
result, err := cmd.Output() result, err := cmd.Output()
if err != nil { if err != nil {
slog.Error("Error scanning file with yara", "error", err, "file-uuid", fileName,"result", string(result)) slog.Error("Error scanning file with yara", "error", err, "file-uuid", fileName,"result", string(result))

View file

@ -14,6 +14,9 @@ func RegisterRoutes() *http.ServeMux {
mux.HandleFunc("/about", web.AboutWebHandler) mux.HandleFunc("/about", web.AboutWebHandler)
mux.HandleFunc("/admin", web.AdminWebHandler) mux.HandleFunc("/admin", web.AdminWebHandler)
mux.HandleFunc("/files/{uuid}", web.FileViewWebHandler) mux.HandleFunc("/files/{uuid}", web.FileViewWebHandler)
mux.HandleFunc("/files/{uuid}/msoffice", web.FileViewMSOWebHandler)
mux.HandleFunc("/files/{uuid}/download", web.FileViewDownloadWebHandler)
mux.HandleFunc("/files/{uuid}/delete", web.FileViewDeleteWebHandler)
mux.HandleFunc("POST /upload", web.IndexUploadHandler) mux.HandleFunc("POST /upload", web.IndexUploadHandler)
mux.Handle("/assets/", http.FileServer(http.FS(web.Files))) mux.Handle("/assets/", http.FileServer(http.FS(web.Files)))

View file

@ -26,7 +26,8 @@ type File struct {
} }
type FileProperty struct { type FileProperty struct {
ID pgtype.UUID ID int64
FileID pgtype.UUID
Sha256 []byte Sha256 []byte
Md5 []byte Md5 []byte
LibmagicMime pgtype.Text LibmagicMime pgtype.Text

View file

@ -12,15 +12,16 @@ import (
) )
const getFileProperties = `-- name: GetFileProperties :one const getFileProperties = `-- name: GetFileProperties :one
SELECT id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple FROM file_properties SELECT id, file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple FROM file_properties
WHERE id = $1 WHERE file_id = $1
` `
func (q *Queries) GetFileProperties(ctx context.Context, id pgtype.UUID) (FileProperty, error) { func (q *Queries) GetFileProperties(ctx context.Context, fileID pgtype.UUID) (FileProperty, error) {
row := q.db.QueryRow(ctx, getFileProperties, id) row := q.db.QueryRow(ctx, getFileProperties, fileID)
var i FileProperty var i FileProperty
err := row.Scan( err := row.Scan(
&i.ID, &i.ID,
&i.FileID,
&i.Sha256, &i.Sha256,
&i.Md5, &i.Md5,
&i.LibmagicMime, &i.LibmagicMime,
@ -48,12 +49,12 @@ func (q *Queries) InsertFileDIEC(ctx context.Context, arg InsertFileDIECParams)
const insertFileProperties = `-- name: InsertFileProperties :exec const insertFileProperties = `-- name: InsertFileProperties :exec
INSERT INTO file_properties ( INSERT INTO file_properties (
id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple file_id, sha256, md5, libmagic_mime, libmagic_extension, libmagic_apple
) VALUES ($1, $2, $3, $4, $5, $6) ) VALUES ($1, $2, $3, $4, $5, $6)
` `
type InsertFilePropertiesParams struct { type InsertFilePropertiesParams struct {
ID pgtype.UUID FileID pgtype.UUID
Sha256 []byte Sha256 []byte
Md5 []byte Md5 []byte
LibmagicMime pgtype.Text LibmagicMime pgtype.Text
@ -63,7 +64,7 @@ type InsertFilePropertiesParams struct {
func (q *Queries) InsertFileProperties(ctx context.Context, arg InsertFilePropertiesParams) error { func (q *Queries) InsertFileProperties(ctx context.Context, arg InsertFilePropertiesParams) error {
_, err := q.db.Exec(ctx, insertFileProperties, _, err := q.db.Exec(ctx, insertFileProperties,
arg.ID, arg.FileID,
arg.Sha256, arg.Sha256,
arg.Md5, arg.Md5,
arg.LibmagicMime, arg.LibmagicMime,

View file

@ -11,5 +11,6 @@ func AboutWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
slog.Error("Error rendering in AboutWebHandler", "error", err) slog.Error("Error rendering in AboutWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
} }

View file

@ -1,16 +1,25 @@
package web package web
import (
"git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
)
templ About() { templ About() {
@Base("About") { @Base("About") {
<h1>About</h1> <h1>About</h1>
<p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p> <p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p>
<h2>Used tools</h2> <h2>Used tools</h2>
<p>Scanfile uses a variety of open source software:</p> <p>Scanfile uses a variety of open source software:</p>
<ul> <div class="w-full max-w-sm">
<li> @accordion.Accordion(accordion.Props{
<h3><a href="http://www.decalage.info">Oletools</a></h3> Class: "w-full",
<pre> }) {
The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info) @accordion.Item() {
@accordion.Trigger() {
<a href="http://www.decalage.info">Oletools</a>
}
@accordion.Content() {
The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info)
All rights reserved. All rights reserved.
@ -20,9 +29,10 @@ Redistribution and use in source and binary forms, with or without modification,
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</pre> }
</li> }
</ul> }
} </div>
}
} }

View file

@ -8,6 +8,10 @@ package web
import "github.com/a-h/templ" import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime" import templruntime "github.com/a-h/templ/runtime"
import (
"git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
)
func About() templ.Component { func About() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
@ -41,7 +45,97 @@ func About() templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<h1>About</h1><p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p><h2>Used tools</h2><p>Scanfile uses a variety of open source software:</p><ul><li><h3><a href=\"http://www.decalage.info\">Oletools</a></h3><pre>The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</pre></li></ul>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<h1>About</h1><p>Scanfile is a web application that allows you to check a file for various properties to be able to determine whether it is malicious or not</p><h2>Used tools</h2><p>Scanfile uses a variety of open source software:</p><div class=\"w-full max-w-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<a href=\"http://www.decalage.info\">Oletools</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Trigger().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "The python-oletools package is copyright (c) 2012-2024 Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Content().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Item().Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = accordion.Accordion(accordion.Props{
Class: "w-full",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }

View file

@ -1,4 +1,4 @@
/*! tailwindcss v4.1.10 | MIT License | https://tailwindcss.com */ /*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */
@layer properties; @layer properties;
@layer theme, base, components, utilities; @layer theme, base, components, utilities;
@layer theme { @layer theme {
@ -243,6 +243,9 @@
.static { .static {
position: static; position: static;
} }
.sticky {
position: sticky;
}
.inset-0 { .inset-0 {
inset: calc(var(--spacing) * 0); inset: calc(var(--spacing) * 0);
} }
@ -294,6 +297,9 @@
.z-20 { .z-20 {
z-index: 20; z-index: 20;
} }
.z-40 {
z-index: 40;
}
.z-50 { .z-50 {
z-index: 50; z-index: 50;
} }
@ -339,6 +345,9 @@
.mt-4 { .mt-4 {
margin-top: calc(var(--spacing) * 4); margin-top: calc(var(--spacing) * 4);
} }
.mt-24 {
margin-top: calc(var(--spacing) * 24);
}
.mt-auto { .mt-auto {
margin-top: auto; margin-top: auto;
} }
@ -354,6 +363,9 @@
.mb-4 { .mb-4 {
margin-bottom: calc(var(--spacing) * 4); margin-bottom: calc(var(--spacing) * 4);
} }
.mb-12 {
margin-bottom: calc(var(--spacing) * 12);
}
.ml-1 { .ml-1 {
margin-left: calc(var(--spacing) * 1); margin-left: calc(var(--spacing) * 1);
} }
@ -437,6 +449,9 @@
.h-8 { .h-8 {
height: calc(var(--spacing) * 8); height: calc(var(--spacing) * 8);
} }
.h-9 {
height: calc(var(--spacing) * 9);
}
.h-10 { .h-10 {
height: calc(var(--spacing) * 10); height: calc(var(--spacing) * 10);
} }
@ -446,6 +461,18 @@
.h-16 { .h-16 {
height: calc(var(--spacing) * 16); height: calc(var(--spacing) * 16);
} }
.h-48 {
height: calc(var(--spacing) * 48);
}
.h-64 {
height: calc(var(--spacing) * 64);
}
.h-80 {
height: calc(var(--spacing) * 80);
}
.h-96 {
height: calc(var(--spacing) * 96);
}
.h-\[1px\] { .h-\[1px\] {
height: 1px; height: 1px;
} }
@ -476,6 +503,9 @@
.min-h-\[80px\] { .min-h-\[80px\] {
min-height: 80px; min-height: 80px;
} }
.min-h-screen {
min-height: 100vh;
}
.w-0 { .w-0 {
width: calc(var(--spacing) * 0); width: calc(var(--spacing) * 0);
} }
@ -530,6 +560,15 @@
.w-16 { .w-16 {
width: calc(var(--spacing) * 16); width: calc(var(--spacing) * 16);
} }
.w-24 {
width: calc(var(--spacing) * 24);
}
.w-32 {
width: calc(var(--spacing) * 32);
}
.w-80 {
width: calc(var(--spacing) * 80);
}
.w-\[1px\] { .w-\[1px\] {
width: 1px; width: 1px;
} }
@ -692,6 +731,12 @@
.columns-4 { .columns-4 {
columns: 4; columns: 4;
} }
.grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-7 { .grid-cols-7 {
grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-columns: repeat(7, minmax(0, 1fr));
} }
@ -734,6 +779,12 @@
.gap-4 { .gap-4 {
gap: calc(var(--spacing) * 4); gap: calc(var(--spacing) * 4);
} }
.gap-6 {
gap: calc(var(--spacing) * 6);
}
.gap-8 {
gap: calc(var(--spacing) * 8);
}
.space-y-1 { .space-y-1 {
:where(& > :not(:last-child)) { :where(& > :not(:last-child)) {
--tw-space-y-reverse: 0; --tw-space-y-reverse: 0;
@ -755,6 +806,13 @@
margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse))); margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)));
} }
} }
.space-y-3 {
:where(& > :not(:last-child)) {
--tw-space-y-reverse: 0;
margin-block-start: calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));
margin-block-end: calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)));
}
}
.-space-x-1 { .-space-x-1 {
:where(& > :not(:last-child)) { :where(& > :not(:last-child)) {
--tw-space-x-reverse: 0; --tw-space-x-reverse: 0;
@ -948,6 +1006,12 @@
background-color: color-mix(in oklab, var(--background) 80%, transparent); background-color: color-mix(in oklab, var(--background) 80%, transparent);
} }
} }
.bg-background\/95 {
background-color: var(--background);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--background) 95%, transparent);
}
}
.bg-black { .bg-black {
background-color: var(--color-black); background-color: var(--color-black);
} }
@ -987,6 +1051,12 @@
.bg-muted { .bg-muted {
background-color: var(--muted); background-color: var(--muted);
} }
.bg-muted\/30 {
background-color: var(--muted);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--muted) 30%, transparent);
}
}
.bg-muted\/50 { .bg-muted\/50 {
background-color: var(--muted); background-color: var(--muted);
@supports (color: color-mix(in lab, red, red)) { @supports (color: color-mix(in lab, red, red)) {
@ -1002,6 +1072,18 @@
.bg-primary { .bg-primary {
background-color: var(--primary); background-color: var(--primary);
} }
.bg-primary\/10 {
background-color: var(--primary);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--primary) 10%, transparent);
}
}
.bg-primary\/80 {
background-color: var(--primary);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--primary) 80%, transparent);
}
}
.bg-red-500 { .bg-red-500 {
background-color: var(--color-red-500); background-color: var(--color-red-500);
} }
@ -1080,6 +1162,9 @@
.py-8 { .py-8 {
padding-block: calc(var(--spacing) * 8); padding-block: calc(var(--spacing) * 8);
} }
.py-12 {
padding-block: calc(var(--spacing) * 12);
}
.pt-0 { .pt-0 {
padding-top: calc(var(--spacing) * 0); padding-top: calc(var(--spacing) * 0);
} }
@ -1300,6 +1385,11 @@
.filter { .filter {
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,); filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
} }
.backdrop-blur {
--tw-backdrop-blur: blur(8px);
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
}
.backdrop-blur-xs { .backdrop-blur-xs {
--tw-backdrop-blur: blur(var(--blur-xs)); --tw-backdrop-blur: blur(var(--blur-xs));
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,); -webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
@ -1825,6 +1915,14 @@
background-color: var(--muted); background-color: var(--muted);
} }
} }
.supports-\[backdrop-filter\]\:bg-background\/60 {
@supports (backdrop-filter: var(--tw)) {
background-color: var(--background);
@supports (color: color-mix(in lab, red, red)) {
background-color: color-mix(in oklab, var(--background) 60%, transparent);
}
}
}
.sm\:my-8 { .sm\:my-8 {
@media (width >= 40rem) { @media (width >= 40rem) {
margin-block: calc(var(--spacing) * 8); margin-block: calc(var(--spacing) * 8);
@ -1889,11 +1987,41 @@
max-width: 420px; max-width: 420px;
} }
} }
.md\:grid-cols-2 {
@media (width >= 48rem) {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.lg\:flex {
@media (width >= 64rem) {
display: flex;
}
}
.lg\:hidden {
@media (width >= 64rem) {
display: none;
}
}
.lg\:w-1\/3 { .lg\:w-1\/3 {
@media (width >= 64rem) { @media (width >= 64rem) {
width: calc(1/3 * 100%); width: calc(1/3 * 100%);
} }
} }
.lg\:grid-cols-2 {
@media (width >= 64rem) {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
.lg\:grid-cols-3 {
@media (width >= 64rem) {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
.lg\:px-6 {
@media (width >= 64rem) {
padding-inline: calc(var(--spacing) * 6);
}
}
.lg\:px-8 { .lg\:px-8 {
@media (width >= 64rem) { @media (width >= 64rem) {
padding-inline: calc(var(--spacing) * 8); padding-inline: calc(var(--spacing) * 8);

View file

@ -13,17 +13,20 @@ func FileViewWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
slog.Error("Error getting File in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid")) slog.Error("Error getting File in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
fileProperties, err := database.GetFileProperties(file.ID) fileProperties, err := database.GetFileProperties(file.ID)
if err != nil { if err != nil {
slog.Error("Error getting FileProperties in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid")) slog.Error("Error getting FileProperties in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
component := FileView(file, fileProperties) component := FileView(file, fileProperties)
err = component.Render(r.Context(), w) err = component.Render(r.Context(), w)
if err != nil { if err != nil {
slog.Error("Error rendering in FileViewWebHandler", "error", err) slog.Error("Error rendering in FileViewWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
} }
@ -32,20 +35,42 @@ func FileViewMSOWebHandler(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
slog.Error("Error getting Data in FileViewMSOWebHandler", "error", err, "file-uuid", r.PathValue("uuid")) slog.Error("Error getting Data in FileViewMSOWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
component := FileViewMsoffice(data) component := FileViewMsoffice(data)
err = component.Render(r.Context(), w) err = component.Render(r.Context(), w)
if err != nil { if err != nil {
slog.Error("Error rendering in FileViewMSOWebHandler", "error", err) slog.Error("Error rendering in FileViewMSOWebHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return
} }
} }
func FileViewDeleteHandler(w http.ResponseWriter, r *http.Request) { func FileViewDeleteWebHandler(w http.ResponseWriter, r *http.Request) {
fileID := r.PathValue("uuid") fileID := r.PathValue("uuid")
err := store.DeleteFile(fileID) err := store.DeleteFile(fileID)
if err != nil { if err != nil {
slog.Error("Error deleting File in FileViewDeleteHandler", "error", err, "file-uuid", fileID) slog.Error("Error deleting File in FileViewDeleteHandler", "error", err, "file-uuid", fileID)
} }
w.Header().Set("HX-Redirect", "/")
} }
func FileViewDownloadWebHandler(w http.ResponseWriter, r *http.Request) {
file, err := database.GetFileByID(r.PathValue("uuid"))
if err != nil {
slog.Error("Error getting file info in FileViewDownloadWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
filePath, err := store.AbsPath(file.ID.String())
if err != nil {
slog.Error("Error getting absolute path in FileViewDownloadWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
w.Header().Set("Content-Disposition", "attachment; filename="+file.Name)
w.Header().Set("Content-Type", file.Mimetype)
http.ServeFile(w, r, filePath)
}

View file

@ -5,21 +5,29 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "encoding/hex" import "encoding/hex"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button" 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/web/templui/components/modal"
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
import "fmt"
templ FileView(file sqlc.File, fileProperties sqlc.FileProperty) { templ FileView(file sqlc.File, fileProperties sqlc.FileProperty) {
@Base(file.Name) { @Base(file.Name) {
<div class="w-full"> <div class="w-full">
<h1 class="text-4xl">File Name: {file.Name}</h1> <h1 class="text-4xl">File Name: {file.Name}</h1>
@FileViewDeleteModal(file.ID.String()) @FileViewDeleteModal(file.ID.String())
@FileViewDownloadModal(file.ID.String())
<br/> <br/>
</div> </div>
<div class="grid grid-cols-2 gap-4">
@FileViewGenericTable(file, fileProperties) @FileViewGenericTable(file, fileProperties)
if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
@FileViewMsofficeLoader(file.ID.String())
}
</div>
} }
} }
templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) { templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
<div class=" max-w-min w-full"> <div class="w-full">
<h2 class="text-3xl">Generic Information</h2> <h2 class="text-3xl">Generic Information</h2>
@table.Table() { @table.Table() {
@table.Row() { @table.Row() {
@ -103,12 +111,12 @@ templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
} }
} }
</div> </div>
} }
templ FileViewDeleteModal(fileid string) { templ FileViewDeleteModal(fileid string) {
@modal.Trigger(modal.TriggerProps{ @modal.Trigger(modal.TriggerProps{
ModalID: "default-modal", ModalID: "delete-modal",
Class: "p-1",
}) { }) {
@button.Button(button.Props{ @button.Button(button.Props{
Variant: button.VariantDestructive, Variant: button.VariantDestructive,
@ -140,6 +148,7 @@ templ FileViewDeleteModal(fileid string) {
}) { }) {
@button.Button(button.Props{ @button.Button(button.Props{
Variant: button.VariantDestructive, Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/delete", fileid),
}) { }) {
Delete Delete
} }
@ -147,5 +156,52 @@ templ FileViewDeleteModal(fileid string) {
</div> </div>
} }
} }
@modal.Script() @modal.Script()
}
templ FileViewDownloadModal(fileid string) {
@modal.Trigger(modal.TriggerProps{
ModalID: "download-modal",
Class: "p-1",
}) {
@button.Button(button.Props{
Variant: button.VariantDefault,
}) {
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{
ModalID: "download-modal",
}) {
@button.Button() {
Cancel
}
}
@modal.Close(modal.CloseProps{
ModalID: "download-modal",
}) {
@button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/download", fileid),
}) {
Download
}
}
</div>
}
}
@modal.Script()
} }

View file

@ -1,15 +1,26 @@
package web package web
import "git.jmbit.de/jmb/scanfile/server/internal/sqlc" import (
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/badge" "git.jmbit.de/jmb/scanfile/server/internal/sqlc"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon" "git.jmbit.de/jmb/scanfile/server/web/templui/components/badge"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table" "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion" "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/code" "git.jmbit.de/jmb/scanfile/server/web/templui/components/accordion"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/code"
"git.jmbit.de/jmb/scanfile/server/web/templui/components/skeleton"
"fmt"
)
// Loads MSOffice data if required
templ FileViewMsofficeLoader(fileid string) {
<div class="w-full" hx-get={fmt.Sprintf("/files/%s/msoffice", fileid)} hx-trigger="load">
@skeleton.Skeleton(skeleton.Props{Class: "h-12 w-12 rounded-full"})
<p> loading <a href={templ.URL(fmt.Sprintf("/files/%s/msoffice", fileid))}>Microsoft Office Info</a></p>
</div>
}
templ FileViewMsoffice(data sqlc.Msoffice) { templ FileViewMsoffice(data sqlc.Msoffice) {
<div class=" max-w-min w-full"> <div class="w-full">
<h2 class="text-3xl">Microsoft Office</h2> <h2 class="text-3xl">Microsoft Office</h2>
if data.Verdict.String == "suspicious" { if data.Verdict.String == "suspicious" {
@badge.Badge(badge.Props{ @badge.Badge(badge.Props{
@ -34,6 +45,7 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
Encrypted Encrypted
} }
@table.Cell() { @table.Cell() {
{fmt.Sprintf("%v",data.Encrypted.Bool)}
} }
} }
@table.Row() { @table.Row() {
@ -41,6 +53,7 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
File Format File Format
} }
@table.Cell() { @table.Cell() {
{data.FileFormat.String}
} }
} }
@table.Row() { @table.Row() {
@ -48,6 +61,7 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
VBA Macros Result VBA Macros Result
} }
@table.Cell() { @table.Cell() {
{data.VbaMacros.String}
} }
} }
@ -56,6 +70,7 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
XLM Macros Result XLM Macros Result
} }
@table.Cell() { @table.Cell() {
{data.XlmMacros.String}
} }
} }
@table.Row() { @table.Row() {
@ -63,6 +78,7 @@ templ FileViewMsoffice(data sqlc.Msoffice) {
VBA Stomping VBA Stomping
} }
@table.Cell() { @table.Cell() {
{fmt.Sprintf("%v",data.VbaStomping.Bool)}
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,8 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
import "encoding/hex" import "encoding/hex"
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button" 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/web/templui/components/modal"
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
import "fmt"
func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component { func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
@ -54,7 +56,7 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
var templ_7745c5c3_Var3 string var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(file.Name) templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(file.Name)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 12, Col: 48} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 14, Col: 48}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -68,7 +70,11 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<br></div>") templ_7745c5c3_Err = FileViewDownloadModal(file.ID.String()).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<br></div><div class=\"grid grid-cols-2 gap-4\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -76,6 +82,16 @@ func FileView(file sqlc.File, fileProperties sqlc.FileProperty) templ.Component
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
templ_7745c5c3_Err = FileViewMsofficeLoader(file.ID.String()).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil return nil
}) })
templ_7745c5c3_Err = Base(file.Name).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) templ_7745c5c3_Err = Base(file.Name).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
@ -107,7 +123,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
templ_7745c5c3_Var4 = templ.NopComponent templ_7745c5c3_Var4 = templ.NopComponent
} }
ctx = templ.ClearChildren(ctx) ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\" max-w-min w-full\"><h2 class=\"text-3xl\">Generic Information</h2>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<div class=\"w-full\"><h2 class=\"text-3xl\">Generic Information</h2>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -147,7 +163,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "Size") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "Size")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -157,7 +173,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -176,13 +192,13 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var9 string var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(file.Size) templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(file.Size)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 30, Col: 22} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 38, Col: 22}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " Bytes") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " Bytes")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -198,7 +214,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -226,7 +242,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "Filetype") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "Filetype")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -236,7 +252,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -255,7 +271,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var13 string var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(file.Mimetype) templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(file.Mimetype)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 38, Col: 26} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 46, Col: 26}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -273,7 +289,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -301,7 +317,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "Blake2b Hash") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "Blake2b Hash")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -311,7 +327,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -330,7 +346,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var17 string var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(file.Blake2)) templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(file.Blake2))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 47, Col: 44} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 55, Col: 44}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -348,7 +364,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -376,7 +392,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "SHA256 Hash") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "SHA256 Hash")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -386,7 +402,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -405,7 +421,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var21 string var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Sha256)) templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Sha256))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 55, Col: 54} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 63, Col: 54}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -423,7 +439,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -451,7 +467,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "MD5 Hash") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "MD5 Hash")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -461,7 +477,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -480,7 +496,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var25 string var templ_7745c5c3_Var25 string
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Md5)) templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(hex.EncodeToString(fileProperties.Md5))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 63, Col: 51} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 71, Col: 51}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -498,7 +514,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -527,7 +543,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "Mimetype") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "Mimetype")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -537,7 +553,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -556,7 +572,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var29 string var templ_7745c5c3_Var29 string
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicMime.String) templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicMime.String)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 72, Col: 49} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 80, Col: 49}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -575,7 +591,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -604,7 +620,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "File Extensions") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "File Extensions")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -614,7 +630,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -633,7 +649,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var33 string var templ_7745c5c3_Var33 string
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicExtension.String) templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicExtension.String)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 82, Col: 54} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 90, Col: 54}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -652,7 +668,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -681,7 +697,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "Apple Filetype") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "Apple Filetype")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -691,7 +707,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -710,7 +726,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var37 string var templ_7745c5c3_Var37 string
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicApple.String) templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(fileProperties.LibmagicApple.String)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 92, Col: 50} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 100, Col: 50}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -729,7 +745,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -757,7 +773,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "Uploaded") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "Uploaded")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -767,7 +783,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -786,7 +802,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
var templ_7745c5c3_Var41 string var templ_7745c5c3_Var41 string
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(file.Created.Time.String()) templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(file.Created.Time.String())
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 101, Col: 39} return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/fileView.templ`, Line: 109, Col: 39}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -810,7 +826,7 @@ func FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) temp
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -863,7 +879,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "Delete") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "Delete")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -878,7 +894,8 @@ func FileViewDeleteModal(fileid string) templ.Component {
return nil return nil
}) })
templ_7745c5c3_Err = modal.Trigger(modal.TriggerProps{ templ_7745c5c3_Err = modal.Trigger(modal.TriggerProps{
ModalID: "default-modal", ModalID: "delete-modal",
Class: "p-1",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var43), templ_7745c5c3_Buffer) }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var43), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
@ -907,7 +924,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "Are you sure you want to delete this file?") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "Are you sure you want to delete this file?")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -917,7 +934,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -933,7 +950,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "This action cannot be undone. This will permanently delete the file from the server.\t\t\t\t") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "This action cannot be undone. This will permanently delete the file from the server.\t\t\t\t")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -943,7 +960,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -959,7 +976,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<div class=\"flex gap-2\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<div class=\"flex gap-2\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -987,7 +1004,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "Cancel") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "Cancel")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -1029,7 +1046,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "Delete") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "Delete")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -1037,6 +1054,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
}) })
templ_7745c5c3_Err = button.Button(button.Props{ templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDestructive, Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/delete", fileid),
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var52), templ_7745c5c3_Buffer) }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var52), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
@ -1049,7 +1067,7 @@ func FileViewDeleteModal(fileid string) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "</div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -1076,4 +1094,264 @@ func FileViewDeleteModal(fileid string) templ.Component {
}) })
} }
func FileViewDownloadModal(fileid string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var53 := templ.GetChildren(ctx)
if templ_7745c5c3_Var53 == nil {
templ_7745c5c3_Var53 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var54 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var55 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "Download")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDefault,
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var55), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Trigger(modal.TriggerProps{
ModalID: "download-modal",
Class: "p-1",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var54), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var56 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var57 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "Download this file?")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Header().Render(templ.WithChildren(ctx, templ_7745c5c3_Var57), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var58 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "files downloaded from scanfile can be harmful to your system. Are you sure you want to continue?")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Body().Render(templ.WithChildren(ctx, templ_7745c5c3_Var58), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var59 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "<div class=\"flex gap-2\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var60 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var61 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "Cancel")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button().Render(templ.WithChildren(ctx, templ_7745c5c3_Var61), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Close(modal.CloseProps{
ModalID: "download-modal",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var60), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var62 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var63 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "Download")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = button.Button(button.Props{
Variant: button.VariantDestructive,
Href: fmt.Sprintf("/files/%s/download", fileid),
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var63), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Close(modal.CloseProps{
ModalID: "download-modal",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var62), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Footer().Render(templ.WithChildren(ctx, templ_7745c5c3_Var59), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = modal.Modal(modal.Props{
ID: "download-modal",
Class: "max-w-md",
}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var56), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = modal.Script().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate var _ = templruntime.GeneratedTemplate

View file

@ -31,19 +31,19 @@ func IndexUploadHandler(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize) r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize)
defer r.Body.Close() defer r.Body.Close()
fileData, fileHeader, err := r.FormFile("file") fileData, fileHeader, err := r.FormFile("file")
slog.Debug("File form submitted", "file-name", fileHeader.Filename, "file-size", fileHeader.Size)
if err != nil { if err != nil {
slog.Error("Error parsing form in IndexUploadHandler", "error", err) slog.Error("Error parsing form in IndexUploadHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
slog.Debug("File form submitted", "file-name", fileHeader.Filename, "file-size", fileHeader.Size)
fileBytes, err := io.ReadAll(fileData) fileBytes, err := io.ReadAll(fileData)
slog.Debug("File from form read", "file-name", fileHeader.Filename, "file-size", len(fileBytes))
if err != nil { if err != nil {
slog.Error("Error reading file in IndexUploadHandler", "error", err) slog.Error("Error reading file in IndexUploadHandler", "error", err)
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
slog.Debug("File from form read", "file-name", fileHeader.Filename, "file-size", len(fileBytes))
file, err := database.CreateFile(r.Context(), fileHeader.Filename, fileBytes) file, err := database.CreateFile(r.Context(), fileHeader.Filename, fileBytes)
if err != nil { if err != nil {
@ -58,6 +58,7 @@ func IndexUploadHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
//w.Header().Set("HX-Redirect", fmt.Sprintf("/files/%s", file.ID.String()))
component := UploadSuccessCard(file) component := UploadSuccessCard(file)
err = component.Render(r.Context(), w) err = component.Render(r.Context(), w)
if err != nil { if err != nil {

View file

@ -1 +0,0 @@
exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1