wip
This commit is contained in:
parent
55f9db7b01
commit
5ace78762e
6
assets/js/index.js
Normal file
6
assets/js/index.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
setTimeout(function() {
|
||||||
|
console.log("refresh");
|
||||||
|
location.reload();
|
||||||
|
}, 2000);
|
||||||
|
});
|
@ -16,7 +16,8 @@ func IndexHandler(storage storage.Storager) httprouter.Handle {
|
|||||||
Stats *types.Stats
|
Stats *types.Stats
|
||||||
BundlesATA12 []types.BundleData
|
BundlesATA12 []types.BundleData
|
||||||
BundlesATA345 []types.BundleData
|
BundlesATA345 []types.BundleData
|
||||||
Barcodes []types.Barcode
|
BarcodesATA12 []types.Barcode
|
||||||
|
BarcodesATA345 []types.Barcode
|
||||||
}
|
}
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
// get current shift dates
|
// get current shift dates
|
||||||
@ -25,23 +26,37 @@ func IndexHandler(storage storage.Storager) httprouter.Handle {
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//
|
// get ata12 shift bundles
|
||||||
bundles12, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA12)
|
bundles12, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// get ata345 shift bundles
|
||||||
bundles345, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA345)
|
bundles345, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA345)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// get ata12 shift barcodes
|
||||||
|
barcodesATA12, err := storage.ShiftListBarcode(r.Context(), dates[0], dates[1], types.ATA12)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// get ata345 shift barcodes
|
||||||
|
barcodesATA345, err := storage.ShiftListBarcode(r.Context(), dates[0], dates[1], types.ATA345)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
// create view
|
// create view
|
||||||
view := &PageView{
|
view := &PageView{
|
||||||
Stats: &types.Stats{},
|
Stats: &types.Stats{},
|
||||||
BundlesATA12: bundles12,
|
BundlesATA12: bundles12,
|
||||||
BundlesATA345: bundles345,
|
BundlesATA345: bundles345,
|
||||||
Barcodes: []types.Barcode{},
|
BarcodesATA12: barcodesATA12,
|
||||||
|
BarcodesATA345: barcodesATA345,
|
||||||
}
|
}
|
||||||
|
|
||||||
t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
|
t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
|
||||||
|
File diff suppressed because one or more lines are too long
@ -26,6 +26,7 @@ type DBConfig struct {
|
|||||||
type Storager interface {
|
type Storager interface {
|
||||||
Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error)
|
Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error)
|
||||||
ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (barcodes []types.Barcode, err error)
|
ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (barcodes []types.Barcode, err error)
|
||||||
|
ShiftListBarcode(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.Barcode, err error)
|
||||||
Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error)
|
Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error)
|
||||||
ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time, confirmed bool) (bundles []types.BundleData, err error)
|
ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time, confirmed bool) (bundles []types.BundleData, err error)
|
||||||
ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error)
|
ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error)
|
||||||
@ -36,6 +37,14 @@ type storage struct {
|
|||||||
mux sync.RWMutex
|
mux sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShiftListBarcode implements Storager.
|
||||||
|
func (s *storage) ShiftListBarcode(ctx context.Context, inicio time.Time, final time.Time, lb types.LoadingBed) (barcodes []types.Barcode, err error) {
|
||||||
|
if err := s.db.Where("substr(barcode,1,3)=? and created_at >= ? and created_at < ?", types.MapQueryBed[lb], inicio, final).Order("created_at desc").Limit(limit).Find(&barcodes).WithContext(ctx).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ShiftListBundle implements Storager.
|
// ShiftListBundle implements Storager.
|
||||||
func (s *storage) ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error) {
|
func (s *storage) ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error) {
|
||||||
if err := s.db.Where("substr(nromatricula,1,3)=? and created_at >= ? and created_at < ?", types.MapQueryBed[lb], inicio, final).Order("created_at desc").Limit(limit).Find(&bundles).WithContext(ctx).Error; err != nil {
|
if err := s.db.Where("substr(nromatricula,1,3)=? and created_at >= ? and created_at < ?", types.MapQueryBed[lb], inicio, final).Order("created_at desc").Limit(limit).Find(&bundles).WithContext(ctx).Error; err != nil {
|
||||||
|
@ -49,17 +49,20 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{if .BarcodesATA12}}
|
||||||
|
{{ range .BarcodesATA12}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>9401234567</td>
|
<td>{{ .Barcode}}</td>
|
||||||
<td>1</td>
|
<td>{{ .LoadingBed}}</td>
|
||||||
<td>05/10/2024 08:19</td>
|
<td>{{ .FormatCreatedAt}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
{{ if .BundlesATA12 }}
|
|
||||||
<div class="column is-10">
|
<div class="column is-10">
|
||||||
<nav class="panel is-link">
|
<nav class="panel is-link">
|
||||||
<p class="panel-heading"><i class="fas fa-box"></i> Paquetes ATA12</p>
|
<p class="panel-heading"><i class="fas fa-box"></i> Paquetes ATA12</p>
|
||||||
@ -98,6 +101,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{ if .BundlesATA12 }}
|
||||||
{{ range .BundlesATA12 }}
|
{{ range .BundlesATA12 }}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="">{{ .Nromatricula }}</a></td>
|
<td><a href="">{{ .Nromatricula }}</a></td>
|
||||||
@ -126,6 +130,7 @@
|
|||||||
<td>{{ .FormatCreatedAt }}</td>
|
<td>{{ .FormatCreatedAt }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -151,18 +156,21 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{if .BarcodesATA345}}
|
||||||
|
{{ range .BarcodesATA345}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>9401234567</td>
|
<td>{{ .Barcode}}</td>
|
||||||
<td>1</td>
|
<td>{{ .LoadingBed}}</td>
|
||||||
<td>05/10/2024 08:19</td>
|
<td>{{ .FormatCreatedAt}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
|
||||||
{{ if .BundlesATA345 }}
|
|
||||||
<div class="column is-10">
|
<div class="column is-10">
|
||||||
<nav class="panel is-link">
|
<nav class="panel is-link">
|
||||||
<p class="panel-heading"><i class="fas fa-box"></i> Paquetes ATA345</p>
|
<p class="panel-heading"><i class="fas fa-box"></i> Paquetes ATA345</p>
|
||||||
@ -201,6 +209,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{ if .BundlesATA345 }}
|
||||||
{{ range .BundlesATA345 }}
|
{{ range .BundlesATA345 }}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="">{{ .Nromatricula }}</a></td>
|
<td><a href="">{{ .Nromatricula }}</a></td>
|
||||||
@ -229,12 +238,13 @@
|
|||||||
<td>{{ .FormatCreatedAt }}</td>
|
<td>{{ .FormatCreatedAt }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="/assets/js/index.js"></script>
|
||||||
{{ end }}
|
{{ end }}
|
@ -9,12 +9,16 @@
|
|||||||
<div class="column is-three-fifths">
|
<div class="column is-three-fifths">
|
||||||
<nav class="panel is-link">
|
<nav class="panel is-link">
|
||||||
<p class="panel-heading"><i class="fas fa-barcode" aria-hidden="true"></i> Evacuaciones 12</p>
|
<p class="panel-heading"><i class="fas fa-barcode" aria-hidden="true"></i> Evacuaciones 12</p>
|
||||||
<div class="panel-block">
|
<div class="panel-block image is-3by2">
|
||||||
|
<img src="{{ .Label12 }}" />
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<nav class="panel is-link">
|
<nav class="panel is-link">
|
||||||
<p class="panel-heading"><i class="fas fa-barcode" aria-hidden="true"></i> Evacuaciones 345</p>
|
<p class="panel-heading"><i class="fas fa-barcode" aria-hidden="true"></i> Evacuaciones 345</p>
|
||||||
<div class="panel-block">
|
<div class="panel-block">
|
||||||
|
<figure class="image is-5by4">
|
||||||
|
<!-- <img src="{{ .Label345 }}" /> -->
|
||||||
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,9 +46,9 @@ func (b *Barcode) FormatLoadingBed() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Barcode) FormatCreatedAt() string {
|
func (b *Barcode) FormatCreatedAt() string {
|
||||||
return b.CreatedAt.Format("02/01/2006 15:04:03")
|
return b.CreatedAt.Format("02/01/2006 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Barcode) FormatUpdateAt() string {
|
func (b *Barcode) FormatUpdateAt() string {
|
||||||
return b.UpdatedAt.Format("02/01/2006 15:04:03")
|
return b.UpdatedAt.Format("02/01/2006 15:04:05")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user