added editing Name & Comment on File View Page
parent
01acbf6940
commit
03ce9ab90c
10
README.md
10
README.md
|
@ -8,15 +8,13 @@ manual analysis
|
|||
# Icon
|
||||
Based on https://pictogrammers.com/library/mdi/icon/gate/ and https://pictogrammers.com/library/mdi/icon/floppy/
|
||||
|
||||
# AccessLevel
|
||||
0 = User // can add files, view status of files created by them, edit comments, download cleared files
|
||||
3 = Helpdesk // can see all files, full analysis of all files, can manually trigger steps
|
||||
5 = Analyst // can do everything with files, but not change the software settings
|
||||
10 = Admin // Can do literally anything
|
||||
# Podman
|
||||
To have full access to Podman (especially to manage networks), root access is required on startup. However, these
|
||||
privileges should be dropped as soon as the Application has started
|
||||
|
||||
## Useful Links for Development
|
||||
https://chenyitian.gitbooks.io/gin-tutorials/content/gin/8.html // Go Templates
|
||||
https://min.io/docs/minio/linux/developers/go/API.html // MINIO Docs
|
||||
https://gorm.io/docs/index.html // ORM Mapper Docs
|
||||
https://blog.logrocket.com/rest-api-golang-gin-gorm/ // Introduction to the GO tech stack used
|
||||
https://github.com/zalando/gin-oauth2 // OAUTH2 Library for Gin
|
||||
https://github.com/zalando/gin-oauth2 // OAUTH2 Library for Gin
|
||||
|
|
19
cmd/root.go
19
cmd/root.go
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
"git.jmbit.de/filegate/filegate/db"
|
||||
"git.jmbit.de/filegate/filegate/files"
|
||||
"git.jmbit.de/filegate/filegate/pods"
|
||||
"git.jmbit.de/filegate/filegate/utils"
|
||||
"git.jmbit.de/filegate/filegate/web"
|
||||
)
|
||||
|
@ -37,26 +38,23 @@ var production bool
|
|||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "filegate",
|
||||
Short: "Basic scaffhold for GO web applications",
|
||||
Long: `A longer description that spans multiple lines and likely contains
|
||||
examples and usage of using your application. For example:
|
||||
Short: "Manage the Download and analsyis of suspicious files",
|
||||
Long: `A Web application that allows you to safely work with suspicious files and make their handling and processing
|
||||
easier for the IT team and all other staff`,
|
||||
|
||||
This filegate enables quick development of small and big Web applications
|
||||
based on Golang with Server side Rendering based on HTML templates, HTMX
|
||||
Frontend tooling and Bulma CSS`,
|
||||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
db.ConnectDB()
|
||||
// Check if local Filesystem should be used
|
||||
log.Print(localfs, viper.GetString("localfs"))
|
||||
// override any Filesystem declared via config file with the cli arg
|
||||
viper.Set("localfs", localfs)
|
||||
if localfs == "" || viper.GetString("localfs") == "" {
|
||||
if viper.GetString("localfs") == "" {
|
||||
files.MinioConnect()
|
||||
files.MinioSetup()
|
||||
}
|
||||
pods.ConnectSocket()
|
||||
web.Router(production)
|
||||
utils.DropPrivileges()
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -129,7 +127,10 @@ func initConfig() {
|
|||
viper.SetDefault("minio.sslmode", "true")
|
||||
viper.SetDefault("minio.bucket", "MINIO_BUCKET")
|
||||
viper.SetDefault("minio.location", "MINIO_LOCATION")
|
||||
// General Runtime configs
|
||||
viper.SetDefault("tempfiles", "/var/tmp/filegate/")
|
||||
viper.SetDefault("user", "filegate")
|
||||
viper.SetDefault("group", "filegate")
|
||||
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
|
||||
|
|
14
db/files.go
14
db/files.go
|
@ -33,7 +33,7 @@ func (file *File) new() (*File,error) {
|
|||
}
|
||||
|
||||
// save writes the given file to the Database
|
||||
func (file *File) save() error {
|
||||
func (file *File) Save() error {
|
||||
if err := conn.Save(file).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ func CountFilesEntries() int64 {
|
|||
return count
|
||||
}
|
||||
|
||||
func GetFileByID(id uint) File {
|
||||
func GetFileByID(id uint) *File {
|
||||
var file File
|
||||
conn.First(&file, id)
|
||||
return file
|
||||
return &file
|
||||
}
|
||||
|
||||
func GetFileByBlob(blob string) File {
|
||||
func GetFileByBlob(blob string) *File {
|
||||
var file File
|
||||
conn.Where("blob = ?", blob).First(&file)
|
||||
return file
|
||||
return &file
|
||||
}
|
||||
|
||||
func GetFileBlob(id uint) string {
|
||||
|
@ -140,12 +140,12 @@ func GetFileBlob(id uint) string {
|
|||
return file.Blob
|
||||
}
|
||||
|
||||
func GetFileList(page int, count int, c *gin.Context) ([]File, error) {
|
||||
func GetFileList(page int, count int, c *gin.Context) ([]*File, error) {
|
||||
query, err := searchQueryBuilder(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var list []File
|
||||
var list []*File
|
||||
conn.Limit(page * count).Where(query).Find(&list)
|
||||
|
||||
return list, nil
|
||||
|
|
|
@ -6,11 +6,15 @@ After=minio.service
|
|||
|
||||
[Service]
|
||||
WorkingDirectory=/var/lib/filegate
|
||||
User=filegate
|
||||
Group=filegate
|
||||
ProtectProc=true
|
||||
ExecStart=/usr/local/bin/filegate --config /etc/filegate/config.yaml
|
||||
Restart=always
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/var/lib/filegate /var/run/podman/podman.sock
|
||||
ConfigurationDirectory=/etc/filegate/
|
||||
StateDirectory=/var/lib/filegate
|
||||
PrivateTmp=true
|
||||
|
||||
|
||||
[Install]
|
||||
|
|
2
go.mod
2
go.mod
|
@ -8,6 +8,7 @@ require (
|
|||
github.com/gin-contrib/multitemplate v0.0.0-20231211133547-5f8f48f9d29f
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/google/uuid v1.5.0
|
||||
github.com/minio/minio-go/v7 v7.0.66
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/viper v1.18.2
|
||||
|
@ -78,7 +79,6 @@ require (
|
|||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-containerregistry v0.16.1 // indirect
|
||||
github.com/google/go-intervals v0.0.2 // indirect
|
||||
github.com/google/uuid v1.5.0 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/gorilla/schema v1.2.0 // indirect
|
||||
|
|
|
@ -76,7 +76,7 @@ func initializeDownloadContainer(
|
|||
// startDownloadContainer() takes a Container struct and creates the DownloadContainer for it
|
||||
func startDownloadContainer(container *db.Container) (*db.Container, error) {
|
||||
image := "docker.io/linuxserver/firefox:latest"
|
||||
conn := socketConnection()
|
||||
conn := Socket
|
||||
_, err := images.Pull(conn, image, nil)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
@ -113,7 +113,7 @@ func registerDownloadContainer(container *db.Container) error {
|
|||
|
||||
// removeDownloadContainer() removes the Container from Podman and the Database
|
||||
func removeDownloadContainer(container *db.Container) error {
|
||||
conn := socketConnection()
|
||||
conn := Socket
|
||||
if err := containers.Kill(conn, container.ContainerID, nil); err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
|
|
|
@ -3,15 +3,21 @@ package pods
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
)
|
||||
|
||||
var Socket = socketConnection()
|
||||
|
||||
func socketConnection() context.Context {
|
||||
uri := fmt.Sprintf("unix:///run/user/%d/podman/podman.sock", os.Getuid())
|
||||
var uri string
|
||||
if os.Getuid() != 0 {
|
||||
uri = fmt.Sprintf("unix:///run/user/%d/podman/podman.sock", os.Getuid())
|
||||
} else {
|
||||
uri = "unix:///run/podman/podman.sock"
|
||||
}
|
||||
conn, err := bindings.NewConnection(context.Background(), uri)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -22,3 +28,8 @@ func socketConnection() context.Context {
|
|||
func TestPodman() {
|
||||
_ = socketConnection()
|
||||
}
|
||||
|
||||
// ConnectSocket()
|
||||
func ConnectSocket() {
|
||||
Socket = socketConnection()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/user"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func DropPrivileges() {
|
||||
currentUser, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if currentUser.Uid == "0" {
|
||||
return
|
||||
}
|
||||
|
||||
targetUser, err := user.Lookup(viper.GetString("user"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
uid, err := strconv.Atoi(targetUser.Uid)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gid, err := strconv.Atoi(targetUser.Gid)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = syscall.Setuid(uid)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = syscall.Setgid(gid)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package templates
|
|||
import "git.jmbit.de/filegate/filegate/db"
|
||||
import "fmt"
|
||||
|
||||
templ FileListTable(files []db.File) {
|
||||
templ FileListTable(files []*db.File) {
|
||||
<div class="table-container" id="filesTable">
|
||||
<table class="table is-bordered is-striped is-hoverable">
|
||||
<thead>
|
||||
|
@ -32,7 +32,7 @@ templ FileListTable(files []db.File) {
|
|||
</div>
|
||||
}
|
||||
|
||||
templ FileListWrapper(files []db.File) {
|
||||
templ FileListWrapper(files []*db.File) {
|
||||
<div class="container">
|
||||
<form id="filesForm" name="search" action="/file/" method="POST" hx-post="/file/" hx-target="filesTable">
|
||||
<div class="field is-horizontal">
|
||||
|
|
|
@ -13,7 +13,7 @@ import "bytes"
|
|||
import "git.jmbit.de/filegate/filegate/db"
|
||||
import "fmt"
|
||||
|
||||
func FileListTable(files []db.File) templ.Component {
|
||||
func FileListTable(files []*db.File) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
@ -155,7 +155,7 @@ func FileListTable(files []db.File) templ.Component {
|
|||
})
|
||||
}
|
||||
|
||||
func FileListWrapper(files []db.File) templ.Component {
|
||||
func FileListWrapper(files []*db.File) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
|
|
@ -5,11 +5,11 @@ import "fmt"
|
|||
|
||||
// FileView constructs the overall view of the File Information
|
||||
|
||||
templ FileView(file db.File) {
|
||||
templ FileView(file *db.File) {
|
||||
<div class="section is-medium">
|
||||
<div class="container">
|
||||
<div class="level">
|
||||
<h2 class="title level-left">{ file.Name }</h2>
|
||||
@FileViewTitle(file.Name, file.ID)
|
||||
<a
|
||||
class="level-right"
|
||||
href={ templ.URL(fmt.Sprintf("/user/%d", file.Assignee().ID)) }
|
||||
|
@ -17,7 +17,7 @@ templ FileView(file db.File) {
|
|||
Assignee: { file.Assignee().Name }
|
||||
</a>
|
||||
</div>
|
||||
<div class="block">
|
||||
<div id="fileComment" class="block">
|
||||
{ fmt.Sprint(file.Comment) }
|
||||
</div>
|
||||
</div>
|
||||
|
@ -29,7 +29,7 @@ templ FileView(file db.File) {
|
|||
|
||||
// FileProperties builds a table of File Properties
|
||||
|
||||
templ FileProperties(file db.File) {
|
||||
templ FileProperties(file *db.File) {
|
||||
<div class="table-container" id="filesTable">
|
||||
<h3 class="subtitle">Main properties</h3>
|
||||
<table class="table is-bordered is-striped is-hoverable">
|
||||
|
@ -98,28 +98,28 @@ templ FileAttachments(attachments []db.Attachment, fileID uint) {
|
|||
{ attachment.Name }
|
||||
</a>
|
||||
}
|
||||
<form id='attachmentUpload' hx-encoding='multipart/form-data' hx-post="/attachment/new">
|
||||
<div class="file">
|
||||
<label class="file-label">
|
||||
<input class="file-input" type="file" name="attachment"></input>
|
||||
<span class="file-cta">
|
||||
<span class="file-icon material-icons">
|
||||
upload_file
|
||||
</span>
|
||||
<span class="file-label">
|
||||
Choose a file...
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<progress id='attachmentUploadProgress' value='0' max='100'></progress>
|
||||
<button>
|
||||
Upload
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" id="fileID" name="fileID" value={ fmt.Sprintf("\"%d\"", fileID) }></input>
|
||||
</form>
|
||||
<form id="attachmentUpload" hx-encoding="multipart/form-data" hx-post="/attachment/new">
|
||||
<div class="file">
|
||||
<label class="file-label">
|
||||
<input class="file-input" type="file" name="attachment"/>
|
||||
<span class="file-cta">
|
||||
<span class="file-icon material-icons">
|
||||
upload_file
|
||||
</span>
|
||||
<span class="file-label">
|
||||
Choose a file...
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<progress id="attachmentUploadProgress" value="0" max="100"></progress>
|
||||
<button>
|
||||
Upload
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" id="fileID" name="fileID" value={ fmt.Sprintf("\"%d\"", fileID) }/>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
htmx.on('#attachmentUpload', 'htmx:xhr:progress', function(evt) {
|
||||
htmx.find('#attachmentUploadProgress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100)
|
||||
})
|
||||
|
@ -128,13 +128,64 @@ templ FileAttachments(attachments []db.Attachment, fileID uint) {
|
|||
|
||||
// FileActions
|
||||
|
||||
templ FileActions() {
|
||||
<div class="container">
|
||||
<div class="level">
|
||||
<div class="level-left">
|
||||
<button class="button is-green">Approve</button>
|
||||
<button class="button is-danger">Deny</button>
|
||||
</div>
|
||||
templ FileActionsAgent() {
|
||||
<div class="container">
|
||||
<div class="level">
|
||||
<div class="level-left">
|
||||
<button class="button is-green">Approve</button>
|
||||
<button class="button is-danger">Deny</button>
|
||||
<div class="select">
|
||||
<select></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FileViewEditComment(comment *string, fileID uint) {
|
||||
<div id="fileComment" class="level-left">
|
||||
<form id="editCommentForm" hx-post={ fmt.Sprintf("\"/file/%d/comment\"", fileID) }>
|
||||
<input
|
||||
id="fileComment"
|
||||
name="fileComment"
|
||||
class="box block level-left"
|
||||
required
|
||||
placeholder={ fmt.Sprintf("\"%s\"", *comment) }
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FileViewComment(comment *string, fileID uint) {
|
||||
<div id="fileComment" class="level-left">
|
||||
<p
|
||||
id="fileComment"
|
||||
class="level-left box block"
|
||||
hx-get={ fmt.Sprintf("\"/file/%d/comment\"", fileID) }
|
||||
hx-trigger="click"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#fileTitle"
|
||||
>{ *comment }</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FileViewEditTitle(title string, fileID uint) {
|
||||
<div id="fileTitle" class="level-left">
|
||||
<form id="editTitleForm" hx-post={ fmt.Sprintf("\"/file/%d/title\"", fileID) }>
|
||||
<input id="fileName" name="fileName" class="title" required placeholder={ fmt.Sprintf("\"%s\"", title) }/>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ FileViewTitle(title string, fileID uint) {
|
||||
<div id="fileTitle" class="level-left">
|
||||
<h2
|
||||
id="fileName"
|
||||
class="title level-left"
|
||||
hx-get={ fmt.Sprintf("\"/file/%d/title\"", fileID) }
|
||||
hx-trigger="click"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#fileTitle"
|
||||
>{ title }</h2>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import "fmt"
|
|||
|
||||
// FileView constructs the overall view of the File Information
|
||||
|
||||
func FileView(file db.File) templ.Component {
|
||||
func FileView(file *db.File) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
@ -28,21 +28,20 @@ func FileView(file db.File) templ.Component {
|
|||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"section is-medium\"><div class=\"container\"><div class=\"level\"><h2 class=\"title level-left\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"section is-medium\"><div class=\"container\"><div class=\"level\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string = file.Name
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
templ_7745c5c3_Err = FileViewTitle(file.Name, file.ID).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2><a class=\"level-right\" href=\"")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a class=\"level-right\" href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 templ.SafeURL = templ.URL(fmt.Sprintf("/user/%d", file.Assignee().ID))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var3)))
|
||||
var templ_7745c5c3_Var2 templ.SafeURL = templ.URL(fmt.Sprintf("/user/%d", file.Assignee().ID))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var2)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -50,30 +49,30 @@ func FileView(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var4 := `Assignee: `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
|
||||
templ_7745c5c3_Var3 := `Assignee: `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string = file.Assignee().Name
|
||||
var templ_7745c5c3_Var4 string = file.Assignee().Name
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></div><div id=\"fileComment\" class=\"block\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string = fmt.Sprint(file.Comment)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></div><div class=\"block\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string = fmt.Sprint(file.Comment)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div><div class=\"section is-medium\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = columns(FileProperties(file), FileAttachments(file.Attachments)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = columns(FileProperties(file), FileAttachments(file.Attachments, file.ID)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ func FileView(file db.File) templ.Component {
|
|||
|
||||
// FileProperties builds a table of File Properties
|
||||
|
||||
func FileProperties(file db.File) templ.Component {
|
||||
func FileProperties(file *db.File) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
@ -98,17 +97,17 @@ func FileProperties(file db.File) templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var7 == nil {
|
||||
templ_7745c5c3_Var7 = templ.NopComponent
|
||||
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var6 == nil {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"table-container\" id=\"filesTable\"><h3 class=\"subtitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var8 := `Main properties`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
||||
templ_7745c5c3_Var7 := `Main properties`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -116,8 +115,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var9 := `File ID`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
|
||||
templ_7745c5c3_Var8 := `File ID`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -125,8 +124,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string = fmt.Sprint(file.ID)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
var templ_7745c5c3_Var9 string = fmt.Sprint(file.ID)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -134,8 +133,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var11 := `Original Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
|
||||
templ_7745c5c3_Var10 := `Original Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -143,8 +142,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string = file.Properties.OriginalName
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
var templ_7745c5c3_Var11 string = file.Properties.OriginalName
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -152,8 +151,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var13 := `MIME Type`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
|
||||
templ_7745c5c3_Var12 := `MIME Type`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -161,8 +160,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string = file.Properties.Mime
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
var templ_7745c5c3_Var13 string = file.Properties.Mime
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -170,8 +169,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var15 := `Size`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||
templ_7745c5c3_Var14 := `Size`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -179,8 +178,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var16 string = fmt.Sprint(file.Properties.Size)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
var templ_7745c5c3_Var15 string = fmt.Sprint(file.Properties.Size)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -188,8 +187,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var17 := `Extension`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
||||
templ_7745c5c3_Var16 := `Extension`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -197,8 +196,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var18 string = file.Properties.Extension
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
var templ_7745c5c3_Var17 string = file.Properties.Extension
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -206,8 +205,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var19 := `Source URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||
templ_7745c5c3_Var18 := `Source URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -215,8 +214,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var20 string = file.Properties.Url
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
var templ_7745c5c3_Var19 string = file.Properties.Url
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -224,8 +223,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var21 := `File Command`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21)
|
||||
templ_7745c5c3_Var20 := `File Command`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -233,8 +232,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var22 string = file.Properties.FileCmd
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||
var templ_7745c5c3_Var21 string = file.Properties.FileCmd
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -242,8 +241,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var23 := `Checksums`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
templ_7745c5c3_Var22 := `Checksums`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -251,8 +250,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var24 := `Sha256`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24)
|
||||
templ_7745c5c3_Var23 := `Sha256`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -260,8 +259,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var25 string = file.Properties.Sha256
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||
var templ_7745c5c3_Var24 string = file.Properties.Sha256
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -269,8 +268,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var26 := `Sha1`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var26)
|
||||
templ_7745c5c3_Var25 := `Sha1`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var25)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -278,8 +277,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var27 string = file.Properties.Sha1
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
||||
var templ_7745c5c3_Var26 string = file.Properties.Sha1
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -287,8 +286,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var28 := `Md5`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var28)
|
||||
templ_7745c5c3_Var27 := `Md5`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var27)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -296,8 +295,8 @@ func FileProperties(file db.File) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var29 string = file.Properties.Md5
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
|
||||
var templ_7745c5c3_Var28 string = file.Properties.Md5
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -314,7 +313,7 @@ func FileProperties(file db.File) templ.Component {
|
|||
|
||||
// FileAttachments
|
||||
|
||||
func FileAttachments(attachments []db.Attachment) templ.Component {
|
||||
func FileAttachments(attachments []db.Attachment, fileID uint) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
@ -322,17 +321,17 @@ func FileAttachments(attachments []db.Attachment) templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var30 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var30 == nil {
|
||||
templ_7745c5c3_Var30 = templ.NopComponent
|
||||
templ_7745c5c3_Var29 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var29 == nil {
|
||||
templ_7745c5c3_Var29 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"panel\"><p class=\"panel-heading\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var31 := `Attachments`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var31)
|
||||
templ_7745c5c3_Var30 := `Attachments`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var30)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -345,8 +344,8 @@ func FileAttachments(attachments []db.Attachment) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var32 templ.SafeURL = templ.URL(fmt.Sprintf("/attachment/%d", attachment.ID))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var32)))
|
||||
var templ_7745c5c3_Var31 templ.SafeURL = templ.URL(fmt.Sprintf("/attachment/%d", attachment.ID))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var31)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -362,8 +361,8 @@ func FileAttachments(attachments []db.Attachment) templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var33 string = attachment.Name
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
|
||||
var templ_7745c5c3_Var32 string = attachment.Name
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -372,7 +371,261 @@ func FileAttachments(attachments []db.Attachment) templ.Component {
|
|||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"attachmentUpload\" hx-encoding=\"multipart/form-data\" hx-post=\"/attachment/new\"><div class=\"file\"><label class=\"file-label\"><input class=\"file-input\" type=\"file\" name=\"attachment\"> <span class=\"file-cta\"><span class=\"file-icon material-icons\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var33 := `upload_file`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var33)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span> <span class=\"file-label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var34 := `Choose a file...`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var34)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></span></label> <progress id=\"attachmentUploadProgress\" value=\"0\" max=\"100\"></progress> <button>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var35 := `Upload`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var35)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div><input type=\"hidden\" id=\"fileID\" name=\"fileID\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"%d\"", fileID)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></form></div><script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var36 := `
|
||||
htmx.on('#attachmentUpload', 'htmx:xhr:progress', function(evt) {
|
||||
htmx.find('#attachmentUploadProgress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100)
|
||||
})
|
||||
`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var36)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
// FileActions
|
||||
|
||||
func FileActionsAgent() templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var37 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var37 == nil {
|
||||
templ_7745c5c3_Var37 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"container\"><div class=\"level\"><div class=\"level-left\"><button class=\"button is-green\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var38 := `Approve`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var38)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button> <button class=\"button is-danger\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var39 := `Deny`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var39)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button><div class=\"select\"><select></select></div></div></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FileViewEditComment(comment *string, fileID uint) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var40 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var40 == nil {
|
||||
templ_7745c5c3_Var40 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"fileComment\" class=\"level-left\"><form id=\"editCommentForm\" hx-post=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"/file/%d/comment\"", fileID)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><input id=\"fileComment\" name=\"fileComment\" class=\"box block level-left\" required placeholder=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"%s\"", *comment)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></form></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FileViewComment(comment *string, fileID uint) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var41 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var41 == nil {
|
||||
templ_7745c5c3_Var41 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"fileComment\" class=\"level-left\"><p id=\"fileComment\" class=\"level-left box block\" hx-get=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"/file/%d/comment\"", fileID)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"click\" hx-swap=\"outerHTML\" hx-target=\"#fileTitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var42 string = *comment
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FileViewEditTitle(title string, fileID uint) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var43 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var43 == nil {
|
||||
templ_7745c5c3_Var43 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"fileTitle\" class=\"level-left\"><form id=\"editTitleForm\" hx-post=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"/file/%d/title\"", fileID)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><input id=\"fileName\" name=\"fileName\" class=\"title\" required placeholder=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"%s\"", title)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></form></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func FileViewTitle(title string, fileID uint) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var44 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var44 == nil {
|
||||
templ_7745c5c3_Var44 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"fileTitle\" class=\"level-left\"><h2 id=\"fileName\" class=\"title level-left\" hx-get=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(fmt.Sprintf("\"/file/%d/title\"", fileID)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"click\" hx-swap=\"outerHTML\" hx-target=\"#fileTitle\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var45 string = title
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ templ uploadForm() {
|
|||
<input name="file" class="file-input" type="file" name="resume"/>
|
||||
<span class="file-cta">
|
||||
<span class="file-icon material-icons">
|
||||
upload_file
|
||||
upload_file
|
||||
</span>
|
||||
<span class="file-label">
|
||||
Choose a file…
|
||||
|
|
|
@ -110,25 +110,25 @@ func uploadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <textarea class=\"textarea\" name=\"comment\" placeholder=\"e.g. This is an old Microsoft Office Format\"></textarea></div><div class=\"file has-name is-boxed\"><label class=\"file-label\"><input name=\"file\" class=\"file-input\" type=\"file\" name=\"resume\"> <span class=\"file-cta\"><span class=\"file-icon\"><i class=\"fas fa-upload\"></i></span> <span class=\"file-label\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</label> <textarea class=\"textarea\" name=\"comment\" placeholder=\"e.g. This is an old Microsoft Office Format\"></textarea></div><div class=\"file has-name is-boxed\"><label class=\"file-label\"><input name=\"file\" class=\"file-input\" type=\"file\" name=\"resume\"> <span class=\"file-cta\"><span class=\"file-icon material-icons\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var10 := `Choose a file…`
|
||||
templ_7745c5c3_Var10 := `upload_file`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></span> <span class=\"file-name\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span> <span class=\"file-label\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var11 := `Invoice.docm`
|
||||
templ_7745c5c3_Var11 := `Choose a file…`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></label></div><div class=\"field\"><div class=\"control\"><button class=\"button is-primary\" type=\"submit\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></span></label></div><div class=\"field\"><div class=\"control\"><button class=\"button is-primary\" type=\"submit\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -137,20 +137,7 @@ func uploadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div></div><progress id=\"progress\" value=\"0\" max=\"100\"></progress></form><script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var13 := `
|
||||
htmx.on('#uploadForm', 'htmx:xhr:progress', function(evt) {
|
||||
htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100)
|
||||
});
|
||||
`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</script>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button></div></div></form>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -169,17 +156,17 @@ func urlDownloadForm() templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var14 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var14 == nil {
|
||||
templ_7745c5c3_Var14 = templ.NopComponent
|
||||
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var13 == nil {
|
||||
templ_7745c5c3_Var13 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"urldownload\" name=\"urldownload\" action=\"/file/new/download\" method=\"POST\" enctype=\"multipart/form-data\" hx-post=\"/file/new/download\" hx-target=\"#upload-options\" hx-swap=\"outerHTML\"><h2 class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var15 := `Download `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||
templ_7745c5c3_Var14 := `Download `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -187,8 +174,8 @@ func urlDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var16 := `tries to directly download a file. Might or might not work, depending on how the Website is made`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||
templ_7745c5c3_Var15 := `tries to directly download a file. Might or might not work, depending on how the Website is made`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -196,8 +183,8 @@ func urlDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var17 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
||||
templ_7745c5c3_Var16 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -205,8 +192,8 @@ func urlDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var18 := `URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
||||
templ_7745c5c3_Var17 := `URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -214,8 +201,8 @@ func urlDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var19 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||
templ_7745c5c3_Var18 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -223,8 +210,8 @@ func urlDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var20 := `Submit`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||
templ_7745c5c3_Var19 := `Submit`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -247,17 +234,17 @@ func browserDownloadForm() templ.Component {
|
|||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var21 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var21 == nil {
|
||||
templ_7745c5c3_Var21 = templ.NopComponent
|
||||
templ_7745c5c3_Var20 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var20 == nil {
|
||||
templ_7745c5c3_Var20 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<form id=\"urldownload\" name=\"urldownload\" action=\"/file/new/browser\" enctype=\"multipart/form-data\" method=\"POST\" hx-post=\"/file/new/browser\" hx-target=\"#upload-options\" hx-swap=\"outerHTML\"><h2 class=\"title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var22 := `Download-Browser `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
templ_7745c5c3_Var21 := `Download-Browser `
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -265,8 +252,8 @@ func browserDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var23 := `Opens a Browser inside a container to download a suspicious file.`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
templ_7745c5c3_Var22 := `Opens a Browser inside a container to download a suspicious file.`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -274,8 +261,8 @@ func browserDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var24 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24)
|
||||
templ_7745c5c3_Var23 := `File Name`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var23)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -283,8 +270,8 @@ func browserDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var25 := `Start-URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var25)
|
||||
templ_7745c5c3_Var24 := `Start-URL`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -292,8 +279,8 @@ func browserDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var26 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var26)
|
||||
templ_7745c5c3_Var25 := `Comment/Description`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var25)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
@ -301,8 +288,8 @@ func browserDownloadForm() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var27 := `Open`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var27)
|
||||
templ_7745c5c3_Var26 := `Open`
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var26)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ templ Index(metaContent utils.MetaContent, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
templ FileListPage(metaContent utils.MetaContent, title string, files []db.File, err error) {
|
||||
templ FileListPage(metaContent utils.MetaContent, title string, files []*db.File, err error) {
|
||||
@wrapBase(metaContent, title, err) {
|
||||
<div class="section is-medium">
|
||||
<div class="container">
|
||||
|
@ -64,7 +64,7 @@ templ FileListPage(metaContent utils.MetaContent, title string, files []db.File,
|
|||
}
|
||||
}
|
||||
|
||||
templ FileViewPage(metaContent utils.MetaContent, title string, file db.File, err error) {
|
||||
templ FileViewPage(metaContent utils.MetaContent, title string, file *db.File, err error) {
|
||||
@wrapBase(metaContent, title, err) {
|
||||
@FileView(file)
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ func Index(metaContent utils.MetaContent, err error) templ.Component {
|
|||
})
|
||||
}
|
||||
|
||||
func FileListPage(metaContent utils.MetaContent, title string, files []db.File, err error) templ.Component {
|
||||
func FileListPage(metaContent utils.MetaContent, title string, files []*db.File, err error) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
@ -247,7 +247,7 @@ func FileListPage(metaContent utils.MetaContent, title string, files []db.File,
|
|||
})
|
||||
}
|
||||
|
||||
func FileViewPage(metaContent utils.MetaContent, title string, file db.File, err error) templ.Component {
|
||||
func FileViewPage(metaContent utils.MetaContent, title string, file *db.File, err error) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.jmbit.de/filegate/filegate/db"
|
||||
"git.jmbit.de/filegate/filegate/utils"
|
||||
"git.jmbit.de/filegate/filegate/web/templates"
|
||||
)
|
||||
|
||||
func getFileView(c *gin.Context) {
|
||||
metaContent := utils.GenMetaContent(c)
|
||||
id64, err := strconv.ParseUint(c.Param("id"), 10, 0)
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
id := uint(id64)
|
||||
file := db.GetFileByID(id)
|
||||
log.Println(err)
|
||||
c.HTML(http.StatusOK, "", templates.FileViewPage(metaContent, file.Name, file, err))
|
||||
}
|
||||
|
||||
func getFileViewEditName(c *gin.Context) {
|
||||
id64, err := strconv.ParseUint(c.Param("id"), 10, 0)
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
id := uint(id64)
|
||||
name := db.GetFileByID(id).Name
|
||||
|
||||
c.HTML(http.StatusOK, "", templates.FileViewEditTitle(name, id))
|
||||
}
|
||||
|
||||
func putFileViewName(c *gin.Context) {
|
||||
id64, err := strconv.ParseUint(c.Param("id"), 10, 0)
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
id := uint(id64)
|
||||
file := db.GetFileByID(id)
|
||||
name := templ.EscapeString(c.PostForm("fileName"))
|
||||
if len(name) < 128 {
|
||||
name = name[:128]
|
||||
}
|
||||
file.Name = name
|
||||
err = file.Save()
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "", templates.FileViewTitle(file.Name, id))
|
||||
}
|
||||
|
||||
func getFileViewEditComment(c *gin.Context) {
|
||||
id64, err := strconv.ParseUint(c.Param("id"), 10, 0)
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
id := uint(id64)
|
||||
comment := db.GetFileByID(id).Comment
|
||||
|
||||
c.HTML(http.StatusOK, "", templates.FileViewEditComment(comment, id))
|
||||
}
|
||||
|
||||
func putFileViewComment(c *gin.Context) {
|
||||
id64, err := strconv.ParseUint(c.Param("id"), 10, 0)
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
id := uint(id64)
|
||||
file := db.GetFileByID(id)
|
||||
comment := templ.EscapeString(c.PostForm("fileComment"))
|
||||
if len(comment) < 1024 {
|
||||
comment = comment[:128]
|
||||
}
|
||||
file.Comment = &comment
|
||||
err = file.Save()
|
||||
if err != nil {
|
||||
fileViewError(c, err)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "", templates.FileViewComment(&comment, id))
|
||||
}
|
||||
|
||||
func fileViewError(c *gin.Context, err error) {
|
||||
metaContent := utils.GenMetaContent(c)
|
||||
metaContent.ErrorTitle = "Error"
|
||||
metaContent.ErrorText = err.Error()
|
||||
c.HTML(http.StatusOK, "", templates.ErrorMessage("Could not create File", err.Error()))
|
||||
log.Println(err)
|
||||
c.Abort()
|
||||
}
|
|
@ -19,6 +19,11 @@ func GroupWeb(router *gin.Engine) *gin.Engine {
|
|||
file.POST("/new/upload", postNewFileUpload)
|
||||
file.POST("/new/download", postNewFileDownload)
|
||||
file.POST("/new/browser", postNewFileBrowser)
|
||||
file.GET("/:id/", getFileView)
|
||||
file.GET("/:id/title", getFileViewEditName)
|
||||
file.GET("/:id/comment", getFileViewEditComment)
|
||||
file.POST("/:id/title", putFileViewName)
|
||||
file.POST("/:id/comment", putFileViewComment)
|
||||
browser := router.Group("/browser")
|
||||
browser.GET("/:id", getBrowser)
|
||||
router.Any("/ct/:id/*any", getContainer)
|
||||
|
|
Loading…
Reference in New Issue