wip
This commit is contained in:
parent
e7d1cf1a76
commit
f6ae802ff9
49
TODO
Normal file
49
TODO
Normal 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
19
handlers/hbcp.go
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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
19
templates/base.html
Normal 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
49
templates/hbcp.html
Normal 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 }}
|
@ -1,23 +1,16 @@
|
||||
<!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="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>
|
||||
@ -30,11 +23,11 @@
|
||||
<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>
|
||||
<li><a href="/hbcp">Hoja BCP</a></li>
|
||||
</ul>
|
||||
<p class="menu-label">Etiquetas</p>
|
||||
<ul class="menu-list">
|
||||
<li><a>Ultimas impresiones</a></li>
|
||||
<li><a>Ultimas etiquetas</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
@ -67,6 +60,19 @@
|
||||
</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">
|
||||
@ -125,23 +131,6 @@
|
||||
</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>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</div>
|
||||
{{ end }}
|
Loading…
Reference in New Issue
Block a user