wip
This commit is contained in:
parent
88ae0f6c1f
commit
5bb93812ab
34
Makefile
Normal file
34
Makefile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Variables
|
||||||
|
IMAGE_NAME = registry.espin.casa/cml04-falcon-ui
|
||||||
|
CONTAINER_NAME = cml04-falcon-ui
|
||||||
|
|
||||||
|
# Check if Docker or Podman is available
|
||||||
|
DOCKER := $(shell command -v docker 2> /dev/null)
|
||||||
|
PODMAN := $(shell command -v podman 2> /dev/null)
|
||||||
|
|
||||||
|
# Determine which command to use based on availability
|
||||||
|
ifdef DOCKER
|
||||||
|
DOCKER_CMD := docker
|
||||||
|
else ifdef PODMAN
|
||||||
|
DOCKER_CMD := podman
|
||||||
|
else
|
||||||
|
$(error "Neither Docker nor Podman is installed on this system.")
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Build the Docker image
|
||||||
|
build:
|
||||||
|
$(DOCKER_CMD) build -t $(IMAGE_NAME) -f docker/Dockerfile .
|
||||||
|
|
||||||
|
# Run the container
|
||||||
|
run:
|
||||||
|
@templ generate
|
||||||
|
@$(DOCKER_CMD) run $(IMAGE_NAME)
|
||||||
|
|
||||||
|
# Stop and remove the container
|
||||||
|
stop:
|
||||||
|
$(DOCKER_CMD) stop $(CONTAINER_NAME)
|
||||||
|
$(DOCKER_CMD) rm $(CONTAINER_NAME)
|
||||||
|
|
||||||
|
# Remove the Docker image
|
||||||
|
clean:
|
||||||
|
$(DOCKER_CMD) rmi $(IMAGE_NAME)
|
@ -1,9 +1,12 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// Initialize all input of date type.
|
// Initialize all input of date type.
|
||||||
const calendar = bulmaCalendar.attach('[type="date"]',{type:"datetime",isRange:true,color:"link",minuteSteps:1});
|
const calendar = bulmaCalendar.attach('[type="date"]',{
|
||||||
|
weekStart: 1,
|
||||||
|
dateFormat: 'dd/MM/yyyy',
|
||||||
|
type:"datetime",
|
||||||
|
isRange:true,
|
||||||
|
color:"link",
|
||||||
|
minuteSteps:1});
|
||||||
// To access to bulmaCalendar instance of an element
|
// To access to bulmaCalendar instance of an element
|
||||||
$('#submit').click(function() {
|
$('#submit').click(function() {
|
||||||
const dateInput = $('#inicio').val();
|
const dateInput = $('#inicio').val();
|
||||||
|
28
celsa2048.crt
Normal file
28
celsa2048.crt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIE0zCCA7ugAwIBAgIJANu+mC2Jt3uTMA0GCSqGSIb3DQEBCwUAMIGhMQswCQYD
|
||||||
|
VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2Ux
|
||||||
|
FTATBgNVBAoTDFpzY2FsZXIgSW5jLjEVMBMGA1UECxMMWnNjYWxlciBJbmMuMRgw
|
||||||
|
FgYDVQQDEw9ac2NhbGVyIFJvb3QgQ0ExIjAgBgkqhkiG9w0BCQEWE3N1cHBvcnRA
|
||||||
|
enNjYWxlci5jb20wHhcNMTQxMjE5MDAyNzU1WhcNNDIwNTA2MDAyNzU1WjCBoTEL
|
||||||
|
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBK
|
||||||
|
b3NlMRUwEwYDVQQKEwxac2NhbGVyIEluYy4xFTATBgNVBAsTDFpzY2FsZXIgSW5j
|
||||||
|
LjEYMBYGA1UEAxMPWnNjYWxlciBSb290IENBMSIwIAYJKoZIhvcNAQkBFhNzdXBw
|
||||||
|
b3J0QHpzY2FsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
||||||
|
qT7STSxZRTgEFFf6doHajSc1vk5jmzmM6BWuOo044EsaTc9eVEV/HjH/1DWzZtcr
|
||||||
|
fTj+ni205apMTlKBW3UYR+lyLHQ9FoZiDXYXK8poKSV5+Tm0Vls/5Kb8mkhVVqv7
|
||||||
|
LgYEmvEY7HPY+i1nEGZCa46Z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
||||||
|
-----END CERTIFICATE-----
|
38
docker/Dockerfile
Normal file
38
docker/Dockerfile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Etapa de compilación
|
||||||
|
FROM golang:1.23.1-bookworm AS builder
|
||||||
|
|
||||||
|
ENV TZ=Europe/Madrid
|
||||||
|
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
ADD celsa2048.crt /usr/local/share/ca-certificates/celsa2048.crt
|
||||||
|
RUN chmod 644 /usr/local/share/ca-certificates/celsa2048.crt
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates
|
||||||
|
|
||||||
|
RUN update-ca-certificates
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go get -d -v ./...
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=mod -ldflags "-s -w" -o cml04-falcon-system main.go
|
||||||
|
|
||||||
|
# Etapa de producción
|
||||||
|
|
||||||
|
FROM debian:stable
|
||||||
|
ENV TZ=Europe/Madrid
|
||||||
|
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
ADD celsa2048.crt /usr/local/share/ca-certificates/celsa2048.crt
|
||||||
|
RUN chmod 644 /usr/local/share/ca-certificates/celsa2048.crt
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates
|
||||||
|
ADD assets /root/assets
|
||||||
|
ADD templates /root/templates
|
||||||
|
RUN update-ca-certificates
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
COPY --from=builder /app/cml04-falcon-system .
|
||||||
|
|
||||||
|
CMD ["./cml04-falcon-ui"]
|
@ -1,20 +1,82 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"git.espin.casa/albert/cml04-falcon-ui/storage"
|
"git.espin.casa/albert/cml04-falcon-ui/storage"
|
||||||
|
"git.espin.casa/albert/cml04-falcon-ui/types"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BarcodesHandler(storage storage.Storager) httprouter.Handle {
|
func BarcodesHandler(storage storage.Storager) 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/base.html", "templates/barcodes.html")
|
// get method
|
||||||
err := t.Execute(w, nil)
|
if r.Method == http.MethodGet {
|
||||||
if err != nil {
|
// parse template files
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
t, _ := template.ParseFiles("templates/base.html", "templates/barcodes.html")
|
||||||
return
|
// execute templates
|
||||||
|
err := t.Execute(w, nil)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// post method
|
||||||
|
if r.Method == http.MethodPost {
|
||||||
|
// barcodes holder
|
||||||
|
barcodes := []types.Barcode{}
|
||||||
|
// parse form data from formulary
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
// barcode
|
||||||
|
codigo := r.FormValue("codigo")
|
||||||
|
// date range
|
||||||
|
fechas := r.FormValue("fechas")
|
||||||
|
// loading bed
|
||||||
|
evacuadores := r.FormValue("evacuadores")
|
||||||
|
// check form values
|
||||||
|
if codigo != "" {
|
||||||
|
// call storager
|
||||||
|
data, err := storage.Barcode(r.Context(), codigo)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// append barcode to holder
|
||||||
|
barcodes = append(barcodes, *data)
|
||||||
|
} else {
|
||||||
|
inicio := strings.Split(fechas, "-")[0]
|
||||||
|
inicio = strings.TrimSpace(inicio)
|
||||||
|
final := strings.Split(fechas, "-")[1]
|
||||||
|
final = strings.TrimSpace(final)
|
||||||
|
// get loading bed from string
|
||||||
|
lb, ok := types.MapLoadingBed[evacuadores]
|
||||||
|
// if loading bed not found
|
||||||
|
if !ok {
|
||||||
|
http.Error(w, fmt.Errorf("loading bed value not found").Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// call storager
|
||||||
|
data, err := storage.ListBarcode(r.Context(), lb, inicio, final)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//set barcodes
|
||||||
|
barcodes = data
|
||||||
|
}
|
||||||
|
// parse template files
|
||||||
|
t, _ := template.ParseFiles("templates/base.html", "templates/barcodes.html")
|
||||||
|
// execute templates
|
||||||
|
err := t.Execute(w, barcodes)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
|
|||||||
r.GET("/bcp", handlers.BCPHandler(storage))
|
r.GET("/bcp", handlers.BCPHandler(storage))
|
||||||
r.GET("/lcp", handlers.LCPHandler(storage))
|
r.GET("/lcp", handlers.LCPHandler(storage))
|
||||||
r.GET("/barcodes", handlers.BarcodesHandler(storage))
|
r.GET("/barcodes", handlers.BarcodesHandler(storage))
|
||||||
|
r.POST("/barcodes", handlers.BarcodesHandler(storage))
|
||||||
r.GET("/labels", handlers.LabelsHandler())
|
r.GET("/labels", handlers.LabelsHandler())
|
||||||
r.GET("/standards", handlers.StandardsHandler(storage))
|
r.GET("/standards", handlers.StandardsHandler(storage))
|
||||||
r.GET("/bundle", handlers.BundleHandler(storage))
|
r.GET("/bundle", handlers.BundleHandler(storage))
|
||||||
|
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.espin.casa/albert/cml04-falcon-ui/types"
|
"git.espin.casa/albert/cml04-falcon-ui/types"
|
||||||
)
|
)
|
||||||
@ -27,12 +28,14 @@ func (s *storage) Bundle(ctx context.Context, ua string) (bundle *types.BundleDa
|
|||||||
|
|
||||||
// ListBarcode implements Storager.
|
// ListBarcode implements Storager.
|
||||||
func (s *storage) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio string, final string) (barcodes []types.Barcode, err error) {
|
func (s *storage) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio string, final string) (barcodes []types.Barcode, err error) {
|
||||||
panic("unimplemented")
|
fmt.Println(lb, inicio, final)
|
||||||
|
return []types.Barcode{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Barcode implements Storager.
|
// Barcode implements Storager.
|
||||||
func (s *storage) Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) {
|
func (s *storage) Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) {
|
||||||
panic("unimplemented")
|
fmt.Println(reading)
|
||||||
|
return &types.Barcode{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() Storager {
|
func New() Storager {
|
||||||
|
@ -39,14 +39,25 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<nav class="panel is-link">
|
<nav class="panel is-link">
|
||||||
<p class="panel-heading"><i class="far fa-file"></i> Listar códigos leídos</p>
|
<p class="panel-heading"><i class="far fa-file"></i> Listar códigos leídos</p>
|
||||||
<form action="/barcodes">
|
<form action="/barcodes" method="post">
|
||||||
|
<div class="panel-block">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">Código barras</label>
|
||||||
|
<div class="control">
|
||||||
|
<p class="control has-icons-left">
|
||||||
|
<input class="input is-link has-dropdown is-hoverable has-icons-right" type="text"
|
||||||
|
id="codigo" name="codigo" minlength="10" maxlength="10"/>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="panel-block">
|
<div class="panel-block">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Fechas</label>
|
<label class="label">Fechas</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<p class="control has-icons-left">
|
<p class="control has-icons-left">
|
||||||
<input class="input is-link has-dropdown is-hoverable has-icons-right" type="date"
|
<input class="input is-link has-dropdown is-hoverable has-icons-right" type="date"
|
||||||
id="inicio" name="inicio" required/>
|
id="fechas" name="fechas" required/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,7 +68,7 @@
|
|||||||
<div class="control">
|
<div class="control">
|
||||||
<p class="control has-icons-left">
|
<p class="control has-icons-left">
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select name="evacuadores" id="evacuadores" required>
|
<select name="evacuadores" id="evacuadores">
|
||||||
<option value="3">TODOS</option>
|
<option value="3">TODOS</option>
|
||||||
<option value="1">ATA12</option>
|
<option value="1">ATA12</option>
|
||||||
<option value="2">ATA345</option>
|
<option value="2">ATA345</option>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<p class="menu-label">Etiquetas</p>
|
<p class="menu-label">Etiquetas</p>
|
||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><a href="/labels">Ultimas etiquetas</a></li>
|
<li><a href="/labels">Últimas etiquetas</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
@ -43,15 +43,15 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Unidad de almacén</th>
|
<th><abbr title="Unidad de almacén">UA</abbr></th>
|
||||||
<th>Evacuador de origen</th>
|
<th>Origen</th>
|
||||||
<th>Fecha</th>
|
<th>Fecha</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Unidad de almacén</th>
|
<th><abbr title="Unidad de almacén">UA</abbr></th>
|
||||||
<th>Evacuador de origen</th>
|
<th>Origen</th>
|
||||||
<th>Fecha</th>
|
<th>Fecha</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@ -112,9 +112,9 @@
|
|||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>9402555315</td>
|
<td><a href="">9402555315</a></td>
|
||||||
<td>131620</td>
|
<td><a href="">131620</a> </td>
|
||||||
<td>40160750</td>
|
<td><a href="">40160750</a></td>
|
||||||
<td>CE253242</td>
|
<td>CE253242</td>
|
||||||
<td>S 275 JR +AR</td>
|
<td>S 275 JR +AR</td>
|
||||||
<td>BB01-140X12.1</td>
|
<td>BB01-140X12.1</td>
|
||||||
|
@ -16,6 +16,12 @@ const (
|
|||||||
ALL
|
ALL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var MapLoadingBed = map[string]LoadingBed{
|
||||||
|
"1": ATA12,
|
||||||
|
"2": ATA345,
|
||||||
|
"3": ALL,
|
||||||
|
}
|
||||||
|
|
||||||
type Barcode struct {
|
type Barcode struct {
|
||||||
Barcode string `gorm:"primaryKey"`
|
Barcode string `gorm:"primaryKey"`
|
||||||
LoadingBed LoadingBed
|
LoadingBed LoadingBed
|
||||||
|
Loading…
Reference in New Issue
Block a user