This commit is contained in:
Albert Espín 2024-10-05 18:43:25 +02:00
parent e7d1cf1a76
commit f6ae802ff9
8 changed files with 270 additions and 143 deletions

1
.ignore Normal file
View File

@ -0,0 +1 @@
TODO

49
TODO Normal file
View File

@ -0,0 +1,49 @@
Defining template:
{{ define “template_name” }} {{ end }}
Using template:
{{ template “template_name” . }}
Block:
{{ block “content” . }} {{ end }}
Is equivalent to => {{ template “content” . }} {{ define “content” }} {{ end }}
If:
{{ if var }} //… {{ else if var }} //… {{ else }} //… {{ end }}
Assignment:
{{ $first_name := “arash” }} {{ $first_name = .Name }}
With:
{{ with . Firstname }} // . refers to Firstname {{ end }}
{{ with $ firstname := .Firstname }} // . and $firstname both refer to Firstname {{ end }}
Range:
{{ range .Users }} {{ .Firstname }} {{ end }}
{{ range $user := .Users }} {{ .Firstname }} {{ $user.Firstname }} {{ else }} No users found {{ end }}
{{ range $index, $user := .Users }} {{ end }}
Functions:
{{ if and cond1 cond2 … }}
{{ if or cond1 cond2 … }}
{{ if not cond }}
{{ len var }}
tmpl, _ := template.New(“template_name”).Parse(“...”)
tmpl.Name() => name of current template
tmpl.Execute(...) => execute current template
tmpl.ExecuteTemplate(...) => execute template by name
tmpl = tmpl.Lookup(“template_name”) => change current template
tmpl.Templates() => Get defined templates

19
handlers/hbcp.go Normal file
View File

@ -0,0 +1,19 @@
package handlers
import (
"net/http"
"text/template"
"github.com/julienschmidt/httprouter"
)
func HBCPHandler() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
t, _ := template.ParseFiles("templates/base.html", "templates/hbcp.html")
err := t.Execute(w, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
}

View File

@ -9,7 +9,7 @@ import (
func IndexHandler() httprouter.Handle { func IndexHandler() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
t, _ := template.ParseFiles("templates/index.html") t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
err := t.Execute(w, nil) err := t.Execute(w, nil)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -8,5 +8,6 @@ import (
func CreateRoutes(r *httprouter.Router, storage storage.Storager) { func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
r.GET("/", handlers.IndexHandler()) r.GET("/", handlers.IndexHandler())
r.GET("/hbcp", handlers.HBCPHandler())
} }

19
templates/base.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/css/bulma.min.css">
<link rel="stylesheet" href="/assets/css/app.css">
<title>{{ template "title" . }}</title>
</head>
<body>
<div class="notification is-link banner">
FALCON
</div>
{{ template "body" . }}
</body>
</html>

49
templates/hbcp.html Normal file
View File

@ -0,0 +1,49 @@
{{define "title"}}Falcon UI{{end}}
{{define "body"}}
<div class="container is-fluid">
<div class="columns">
<div class="column is-one-fifth">
<aside class="menu">
<p class="menu-label">Panel</p>
<ul class="menu-list">
<li><a href="/">Inicio</a></li>
</ul>
<p class="menu-label">Etiquetas leídas</p>
<ul class="menu-list">
<li><a>Consultar</a></li>
</ul>
<p class="menu-label">Paquetes</p>
<ul class="menu-list">
<li><a>Consultar</a></li>
</ul>
<p class="menu-label">Datos de fabricación</p>
<ul class="menu-list">
<li><a>Orden de producción</a></li>
<li><a>Orden de cliente</a></li>
<li><a href="/hbcp">Hoja BCP</a></li>
</ul>
<p class="menu-label">Etiquetas</p>
<ul class="menu-list">
<li><a>Ultimas etiquetas</a></li>
</ul>
</aside>
</div>
<div class="column">
<nav class="panel is-link">
<p class="panel-heading">Hoja patrón corte</p>
<div class="panel-block">
</div>
</nav>
</div>
</div>
</div>
{{ end }}

View File

@ -1,147 +1,136 @@
<!DOCTYPE html> {{define "title"}}Falcon UI{{end}}
<html lang="en">
<head> {{define "body"}}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/css/bulma.min.css">
<link rel="stylesheet" href="/assets/css/app.css">
<title>Falcon</title>
</head>
<body>
<div class="notification is-link banner">
FALCON
</div>
<div class="container is-fluid"> <div class="container is-fluid">
<div class="columns"> <div class="columns">
<div class="column is-one-fifth"> <div class="column is-one-fifth">
<aside class="menu"> <aside class="menu">
<p class="menu-label">Etiquetas leídas</p> <p class="menu-label">Panel</p>
<ul class="menu-list"> <ul class="menu-list">
<li><a>Consultar</a></li> <li><a href="/">Inicio</a></li>
</ul> </ul>
<p class="menu-label">Paquetes</p> <p class="menu-label">Etiquetas leídas</p>
<ul class="menu-list"> <ul class="menu-list">
<li><a>Consultar</a></li> <li><a>Consultar</a></li>
</ul> </ul>
<p class="menu-label">Datos de fabricación</p> <p class="menu-label">Paquetes</p>
<ul class="menu-list"> <ul class="menu-list">
<li><a>Orden de producción</a></li> <li><a>Consultar</a></li>
<li><a>Orden de cliente</a></li> </ul>
<li><a>Hoja BCP</a></li> <p class="menu-label">Datos de fabricación</p>
</ul> <ul class="menu-list">
<p class="menu-label">Etiquetas</p> <li><a>Orden de producción</a></li>
<ul class="menu-list"> <li><a>Orden de cliente</a></li>
<li><a>Ultimas impresiones</a></li> <li><a href="/hbcp">Hoja BCP</a></li>
</ul> </ul>
</aside> <p class="menu-label">Etiquetas</p>
</div> <ul class="menu-list">
<div class="column"> <li><a>Ultimas etiquetas</a></li>
<nav class="panel is-link"> </ul>
<p class="panel-heading">Etiquetas leídas</p> </aside>
<div class="panel-block"> </div>
<table class="table"> <div class="column">
<thead> <nav class="panel is-link">
<tr> <p class="panel-heading">Etiquetas leídas</p>
<th>Unidad de almacén</th> <div class="panel-block">
<th>Evacuador de origen</th> <table class="table">
<th>Fecha</th> <thead>
</tr> <tr>
</thead> <th>Unidad de almacén</th>
<tfoot> <th>Evacuador de origen</th>
<tr> <th>Fecha</th>
<th>Unidad de almacén</th> </tr>
<th>Evacuador de origen</th> </thead>
<th>Fecha</th> <tfoot>
</tr> <tr>
</tfoot> <th>Unidad de almacén</th>
<tbody> <th>Evacuador de origen</th>
<tr> <th>Fecha</th>
<td>9401234567</td> </tr>
<td>1</td> </tfoot>
<td>05/10/2024 08:19</td> <tbody>
</tr> <tr>
</tbody> <td>9401234567</td>
</table> <td>1</td>
</div> <td>05/10/2024 08:19</td>
</nav> </tr>
</div> </tbody>
<div class="column"> </table>
<nav class="panel is-link"> </div>
<p class="panel-heading">Paquetes</p> </nav>
<div class="panel-block"> <nav class="panel is-link">
<table class="table"> <p class="panel-heading">Estadísticas turno</p>
<thead> <div class="panel-block">
<tr> <table class="table">
<th><abbr title="Unidad de almacén">UA</abbr></th> <thead>
<th>PO</th> <tr>
<th>CO</th> <th>Nro.Etiquetas leídas</th>
<th>Colada</th> <th>Nro.Paquetes confirmados</th>
<th>Calidad</th> </tr>
<th>Código SAP</th> </thead>
<th>Producto</th> </table>
<th>Peso</th> </div>
<th>Desvío</th> </nav>
<th>Confirmado</th> </div>
<th>Nivel 3</th> <div class="column">
<th>SAP</th> <nav class="panel is-link">
</tr> <p class="panel-heading">Paquetes</p>
</thead> <div class="panel-block">
<tfoot> <table class="table">
<tr> <thead>
<th><abbr title="Unidad de almacén">UA</abbr></th> <tr>
<th>PO</th> <th><abbr title="Unidad de almacén">UA</abbr></th>
<th>CO</th> <th>PO</th>
<th>Colada</th> <th>CO</th>
<th>Calidad</th> <th>Colada</th>
<th>Código SAP</th> <th>Calidad</th>
<th>Producto</th> <th>Código SAP</th>
<th>Peso</th> <th>Producto</th>
<th>Desvío</th> <th>Peso</th>
<th>Confirmado</th> <th>Desvío</th>
<th>Nivel 3</th> <th>Confirmado</th>
<th>SAP</th> <th>Nivel 3</th>
</tr> <th>SAP</th>
</tfoot> </tr>
<tbody> </thead>
<tr> <tfoot>
<td>9402555315</td> <tr>
<td>131620</td> <th><abbr title="Unidad de almacén">UA</abbr></th>
<td>40160750</td> <th>PO</th>
<td>CE253242</td> <th>CO</th>
<td>S 275 JR +AR</td> <th>Colada</th>
<td>BB01-140X12.1</td> <th>Calidad</th>
<td>HEB140</td> <th>Código SAP</th>
<td>4776</td> <th>Producto</th>
<td>-2.40</td> <th>Peso</th>
<td>No</td> <th>Desvío</th>
<td>No</td> <th>Confirmado</th>
<td>No</td> <th>Nivel 3</th>
</tr> <th>SAP</th>
</tbody> </tr>
</table> </tfoot>
</div> <tbody>
</nav> <tr>
</div> <td>9402555315</td>
<div class="column"> <td>131620</td>
<nav class="panel is-link"> <td>40160750</td>
<p class="panel-heading">Estadísticas turno</p> <td>CE253242</td>
<div class="panel-block"> <td>S 275 JR +AR</td>
<table class="table"> <td>BB01-140X12.1</td>
<thead> <td>HEB140</td>
<tr> <td>4776</td>
<th>Nro.Etiquetas leídas</th> <td>-2.40</td>
<th>Nro.Paquetes confirmados</th> <td>No</td>
</tr> <td>No</td>
</thead> <td>No</td>
</table> </tr>
</div> </tbody>
</nav> </table>
</div> </div>
</nav>
</div> </div>
</div> </div>
</body> </div>
{{ end }}
</html>