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 {
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)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -8,5 +8,6 @@ import (
func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
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>
<html lang="en">
{{define "title"}}Falcon UI{{end}}
<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>Falcon</title>
</head>
{{define "body"}}
<body>
<div class="notification is-link banner">
FALCON
</div>
<div class="container is-fluid">
<div class="columns">
<div class="column is-one-fifth">
<aside class="menu">
<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>Hoja BCP</a></li>
</ul>
<p class="menu-label">Etiquetas</p>
<ul class="menu-list">
<li><a>Ultimas impresiones</a></li>
</ul>
</aside>
</div>
<div class="column">
<nav class="panel is-link">
<p class="panel-heading">Etiquetas leídas</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th>Unidad de almacén</th>
<th>Evacuador de origen</th>
<th>Fecha</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Unidad de almacén</th>
<th>Evacuador de origen</th>
<th>Fecha</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>9401234567</td>
<td>1</td>
<td>05/10/2024 08:19</td>
</tr>
</tbody>
</table>
</div>
</nav>
</div>
<div class="column">
<nav class="panel is-link">
<p class="panel-heading">Paquetes</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</thead>
<tfoot>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>9402555315</td>
<td>131620</td>
<td>40160750</td>
<td>CE253242</td>
<td>S 275 JR +AR</td>
<td>BB01-140X12.1</td>
<td>HEB140</td>
<td>4776</td>
<td>-2.40</td>
<td>No</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
</div>
</nav>
</div>
<div class="column">
<nav class="panel is-link">
<p class="panel-heading">Estadísticas turno</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th>Nro.Etiquetas leídas</th>
<th>Nro.Paquetes confirmados</th>
</tr>
</thead>
</table>
</div>
</nav>
</div>
<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">Etiquetas leídas</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th>Unidad de almacén</th>
<th>Evacuador de origen</th>
<th>Fecha</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Unidad de almacén</th>
<th>Evacuador de origen</th>
<th>Fecha</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>9401234567</td>
<td>1</td>
<td>05/10/2024 08:19</td>
</tr>
</tbody>
</table>
</div>
</nav>
<nav class="panel is-link">
<p class="panel-heading">Estadísticas turno</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th>Nro.Etiquetas leídas</th>
<th>Nro.Paquetes confirmados</th>
</tr>
</thead>
</table>
</div>
</nav>
</div>
<div class="column">
<nav class="panel is-link">
<p class="panel-heading">Paquetes</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</thead>
<tfoot>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>9402555315</td>
<td>131620</td>
<td>40160750</td>
<td>CE253242</td>
<td>S 275 JR +AR</td>
<td>BB01-140X12.1</td>
<td>HEB140</td>
<td>4776</td>
<td>-2.40</td>
<td>No</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
</div>
</nav>
</div>
</div>
</body>
</html>
</div>
{{ end }}