fixed web interface for move to sqlc
This commit is contained in:
		
							parent
							
								
									726bdb0f8f
								
							
						
					
					
						commit
						33a2ddeafa
					
				
					 5 changed files with 14 additions and 14 deletions
				
			
		| 
						 | 
					@ -8,7 +8,7 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func FileViewWebHandler(w http.ResponseWriter, r *http.Request) {
 | 
					func FileViewWebHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
	file, err := database.FileByUUID(r.PathValue("uuid"))
 | 
						file, err := database.GetFileByID(r.PathValue("uuid"))
 | 
				
			||||||
	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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
package web
 | 
					package web
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "git.jmbit.de/jmb/scanfile/server/internal/database"
 | 
					import "git.jmbit.de/jmb/scanfile/server/internal/sqlc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ FileView(file database.File) {
 | 
					templ FileView(file sqlc.File) {
 | 
				
			||||||
  @Base(file.Name) {
 | 
					  @Base(file.Name) {
 | 
				
			||||||
    <h1 class="size-24">{file.Name}</h1>
 | 
					    <h1 class="size-24">{file.Name}</h1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,9 +8,9 @@ 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/internal/database"
 | 
					import "git.jmbit.de/jmb/scanfile/server/internal/sqlc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func FileView(file database.File) templ.Component {
 | 
					func FileView(file sqlc.File) 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
 | 
				
			||||||
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 | 
							if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ import (
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/input"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/input"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/form"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/form"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/internal/database"
 | 
						"git.jmbit.de/jmb/scanfile/server/internal/sqlc"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,7 @@ templ UploadCard() {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ UploadSuccessCard(file database.File) {
 | 
					templ UploadSuccessCard(file sqlc.File) {
 | 
				
			||||||
    @card.Card(card.Props{ID: "upload-card"}) {
 | 
					    @card.Card(card.Props{ID: "upload-card"}) {
 | 
				
			||||||
      @card.Header() {
 | 
					      @card.Header() {
 | 
				
			||||||
        @card.Title() {
 | 
					        @card.Title() {
 | 
				
			||||||
| 
						 | 
					@ -65,10 +65,10 @@ templ UploadSuccessCard(file database.File) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      @card.Content() {
 | 
					      @card.Content() {
 | 
				
			||||||
        <div class="flex flex-col gap-4" hx-encoding='multipart/form-data' hx-post='/upload'>
 | 
					        <div class="flex flex-col gap-4" hx-encoding='multipart/form-data' hx-post='/upload'>
 | 
				
			||||||
        <p>  ID:   { file.Uuid     } </p>
 | 
					        <p>  ID:   { file.ID.String()     } </p>
 | 
				
			||||||
        <p>  Size: { file.Size } Bytes</p>
 | 
					        <p>  Size: { file.Size } Bytes</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          @button.Button(button.Props{Type: button.TypeButton, Href: fmt.Sprintf("/files/%s", file.Uuid)}) {
 | 
					          @button.Button(button.Props{Type: button.TypeButton, Href: fmt.Sprintf("/files/%s", file.ID.String())}) {
 | 
				
			||||||
            Go to file
 | 
					            Go to file
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/internal/database"
 | 
						"git.jmbit.de/jmb/scanfile/server/internal/sqlc"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/card"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/card"
 | 
				
			||||||
	"git.jmbit.de/jmb/scanfile/server/web/templui/components/form"
 | 
						"git.jmbit.de/jmb/scanfile/server/web/templui/components/form"
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,7 @@ func UploadCard() templ.Component {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func UploadSuccessCard(file database.File) templ.Component {
 | 
					func UploadSuccessCard(file sqlc.File) 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
 | 
				
			||||||
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 | 
							if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 | 
				
			||||||
| 
						 | 
					@ -412,9 +412,9 @@ func UploadSuccessCard(file database.File) templ.Component {
 | 
				
			||||||
					return templ_7745c5c3_Err
 | 
										return templ_7745c5c3_Err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				var templ_7745c5c3_Var19 string
 | 
									var templ_7745c5c3_Var19 string
 | 
				
			||||||
				templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(file.Uuid)
 | 
									templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(file.ID.String())
 | 
				
			||||||
				if templ_7745c5c3_Err != nil {
 | 
									if templ_7745c5c3_Err != nil {
 | 
				
			||||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/index.templ`, Line: 68, Col: 30}
 | 
										return templ.Error{Err: templ_7745c5c3_Err, FileName: `server/web/index.templ`, Line: 68, Col: 37}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
 | 
									_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
 | 
				
			||||||
				if templ_7745c5c3_Err != nil {
 | 
									if templ_7745c5c3_Err != nil {
 | 
				
			||||||
| 
						 | 
					@ -455,7 +455,7 @@ func UploadSuccessCard(file database.File) templ.Component {
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					return nil
 | 
										return nil
 | 
				
			||||||
				})
 | 
									})
 | 
				
			||||||
				templ_7745c5c3_Err = button.Button(button.Props{Type: button.TypeButton, Href: fmt.Sprintf("/files/%s", file.Uuid)}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var21), templ_7745c5c3_Buffer)
 | 
									templ_7745c5c3_Err = button.Button(button.Props{Type: button.TypeButton, Href: fmt.Sprintf("/files/%s", file.ID.String())}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var21), templ_7745c5c3_Buffer)
 | 
				
			||||||
				if templ_7745c5c3_Err != nil {
 | 
									if templ_7745c5c3_Err != nil {
 | 
				
			||||||
					return templ_7745c5c3_Err
 | 
										return templ_7745c5c3_Err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue