Files
labelprint/views/upload.erb
T
randy 66e2e7a5c0
deploy / deploy (push) Successful in 10s
Redesign: clear active nav state, Shipping labels + Receipts get free-text/raw print, shared label repository
- Home page is now just the print server overview, no more unrelated
  network links (3D printers, Cockpit) left over from when this was a
  general landing page.
- Navbar shows which section is active; Brother's per-printer buttons
  now live under a dedicated Brother nav item instead of always-visible.
- Shipping labels: paste raw ZPL directly (no need to save to a file
  first), with a Labelary preview link alongside it.
- Receipts: paste already-formatted ESC/POS text directly, printed as-is.
- Both can save what they just printed into a shared label repository
  (lib/label_repository.rb, one JSON file per label under data/labels/)
  for reprinting later -- saving happens independently of whether the
  print itself succeeds, so a failed/offline printer doesn't lose the
  content.
2026-09-13 11:11:12 +02:00

54 lines
2.4 KiB
ERB

<form action="/upload" class="dropzone" id="upload-form" method="POST" enctype="multipart/form-data">
<div class="mb-3">
<label for="formFile" class="form-label">Upload .pdf or .zpl to print label</label>
<input name="file" class="form-control" type="file" id="formFile" accept=".pdf,.zpl" />
</div>
<button class="btn btn-secondary" type="submit">Upload</button>
</form>
<form action="/test-print" method="POST" class="mt-3">
<button class="btn btn-outline-secondary" type="submit">Print test label</button>
</form>
<hr class="mt-4">
<h5>Free text ZPL</h5>
<p>
<a href="https://labelary.com/viewer.html" target="_blank" rel="noopener noreferrer">Labelary ZPL viewer</a>
(preview/build ZPL before pasting it here)
</p>
<form action="/shipping/zpl" method="POST">
<div class="mb-3">
<textarea name="zpl" class="form-control" rows="8" placeholder="^XA...^XZ" style="font-family: monospace;"></textarea>
</div>
<div class="row g-2 align-items-end">
<div class="col-auto">
<label for="save_as_zpl" class="form-label">Save as (optional)</label>
<input name="save_as" class="form-control" type="text" id="save_as_zpl" placeholder="label name" />
</div>
<div class="col-auto">
<button class="btn btn-secondary" type="submit">Print</button>
</div>
</div>
</form>
<% if @labels && !@labels.empty? %>
<hr class="mt-4">
<h5>Saved labels</h5>
<div class="list-group">
<% @labels.each do |label| %>
<div class="list-group-item d-flex justify-content-between align-items-center">
<%= label['name'] %>
<div class="d-flex gap-2">
<form action="/labels/<%= label['id'] %>/print" method="POST">
<button class="btn btn-sm btn-secondary" type="submit">Print</button>
</form>
<form action="/labels/<%= label['id'] %>/delete" method="POST">
<button class="btn btn-sm btn-outline-danger" type="submit">Delete</button>
</form>
</div>
</div>
<% end %>
</div>
<% end %>