This commit is contained in:
1 parent
61d190ed91
commit
7ea03e5bc5
6 files changed
+19
-19
No files matched your search
@@ -424,27 +424,27 @@ post '/epson/raw' do
|
|||||||
redirect '/epson'
|
redirect '/epson'
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/labels' do
|
get '/repository' do
|
||||||
@labels = LABEL_REPO.all
|
@labels = LABEL_REPO.all
|
||||||
erb :labels
|
erb :repository
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/labels/:id/edit' do
|
get '/repository/:id/edit' do
|
||||||
@label = LABEL_REPO.find(params[:id])
|
@label = LABEL_REPO.find(params[:id])
|
||||||
halt 404, 'unknown label' unless @label
|
halt 404, 'unknown label' unless @label
|
||||||
|
|
||||||
erb :label_edit
|
erb :label_edit
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/labels/:id' do
|
post '/repository/:id' do
|
||||||
label = LABEL_REPO.update(params[:id], name: params[:name].to_s, content: params[:content].to_s)
|
label = LABEL_REPO.update(params[:id], name: params[:name].to_s, content: params[:content].to_s)
|
||||||
halt 404, 'unknown label' unless label
|
halt 404, 'unknown label' unless label
|
||||||
|
|
||||||
flash "Saved '#{label['name']}'", 'success'
|
flash "Saved '#{label['name']}'", 'success'
|
||||||
redirect '/labels'
|
redirect '/repository'
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/labels/:id/preview.png' do
|
get '/repository/:id/preview.png' do
|
||||||
label = LABEL_REPO.find(params[:id])
|
label = LABEL_REPO.find(params[:id])
|
||||||
halt 404 unless label && label['type'] == 'zpl'
|
halt 404 unless label && label['type'] == 'zpl'
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ get '/labels/:id/preview.png' do
|
|||||||
png
|
png
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/labels/:id/print' do
|
post '/repository/:id/print' do
|
||||||
label = LABEL_REPO.find(params[:id])
|
label = LABEL_REPO.find(params[:id])
|
||||||
halt 404, 'unknown label' unless label
|
halt 404, 'unknown label' unless label
|
||||||
|
|
||||||
@@ -470,13 +470,13 @@ post '/labels/:id/print' do
|
|||||||
rescue => e
|
rescue => e
|
||||||
flash "Print failed (#{e.message})", 'danger'
|
flash "Print failed (#{e.message})", 'danger'
|
||||||
end
|
end
|
||||||
redirect '/labels'
|
redirect '/repository'
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/labels/:id/delete' do
|
post '/repository/:id/delete' do
|
||||||
LABEL_REPO.delete(params[:id])
|
LABEL_REPO.delete(params[:id])
|
||||||
flash 'Label deleted', 'success'
|
flash 'Label deleted', 'success'
|
||||||
redirect '/labels'
|
redirect '/repository'
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/brother' do
|
get '/brother' do
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
<a class="nav-link <%= 'active' if request.path == '/epson' %>" href="/epson">Receipts</a>
|
<a class="nav-link <%= 'active' if request.path == '/epson' %>" href="/epson">Receipts</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link border-start <%= 'active' if request.path.start_with?('/labels') %>" href="/labels">Labels</a>
|
<a class="nav-link border-start <%= 'active' if request.path.start_with?('/repository') %>" href="/repository">Labels</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<% if request.path.start_with?('/brother') %>
|
<% if request.path.start_with?('/brother') %>
|
||||||
|
|||||||
+1
-1
@@ -51,4 +51,4 @@ GS V 0x00 # Full cut</code></pre>
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="mt-4"><a href="/labels">See saved receipts →</a></p>
|
<p class="mt-4"><a href="/repository">See saved receipts →</a></p>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<span class="badge bg-info text-dark">ESC/POS · Epson</span>
|
<span class="badge bg-info text-dark">ESC/POS · Epson</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<form action="/labels/<%= @label['id'] %>" method="POST" class="mt-3">
|
<form action="/repository/<%= @label['id'] %>" method="POST" class="mt-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="name" class="form-label">Name</label>
|
<label for="name" class="form-label">Name</label>
|
||||||
<input name="name" class="form-control" type="text" id="name" value="<%= @label['name'] %>" />
|
<input name="name" class="form-control" type="text" id="name" value="<%= @label['name'] %>" />
|
||||||
@@ -16,5 +16,5 @@
|
|||||||
<textarea name="content" class="form-control" id="content" rows="12" style="font-family: monospace;"><%= @label['content'] %></textarea>
|
<textarea name="content" class="form-control" id="content" rows="12" style="font-family: monospace;"><%= @label['content'] %></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-secondary" type="submit">Save</button>
|
<button class="btn btn-secondary" type="submit">Save</button>
|
||||||
<a href="/labels" class="btn btn-outline-secondary">Cancel</a>
|
<a href="/repository" class="btn btn-outline-secondary">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
<strong class="ms-2"><%= label['name'] %></strong>
|
<strong class="ms-2"><%= label['name'] %></strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex gap-2">
|
<div class="d-flex gap-2">
|
||||||
<form action="/labels/<%= label['id'] %>/print" method="POST">
|
<form action="/repository/<%= label['id'] %>/print" method="POST">
|
||||||
<button class="btn btn-sm btn-secondary" type="submit">Print</button>
|
<button class="btn btn-sm btn-secondary" type="submit">Print</button>
|
||||||
</form>
|
</form>
|
||||||
<a href="/labels/<%= label['id'] %>/edit" class="btn btn-sm btn-outline-secondary">Edit</a>
|
<a href="/repository/<%= label['id'] %>/edit" class="btn btn-sm btn-outline-secondary">Edit</a>
|
||||||
<form action="/labels/<%= label['id'] %>/delete" method="POST">
|
<form action="/repository/<%= label['id'] %>/delete" method="POST">
|
||||||
<button class="btn btn-sm btn-outline-danger" type="submit">Delete</button>
|
<button class="btn btn-sm btn-outline-danger" type="submit">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<% if label['type'] == 'zpl' %>
|
<% if label['type'] == 'zpl' %>
|
||||||
<img src="/labels/<%= label['id'] %>/preview.png" alt="preview" style="max-height: 150px;" onerror="this.remove()" />
|
<img src="/repository/<%= label['id'] %>/preview.png" alt="preview" style="max-height: 150px;" onerror="this.remove()" />
|
||||||
<% else %>
|
<% else %>
|
||||||
<pre class="bg-light p-2 mb-0" style="max-height: 150px; overflow: auto;"><%= label['content'] %></pre>
|
<pre class="bg-light p-2 mb-0" style="max-height: 150px; overflow: auto;"><%= label['content'] %></pre>
|
||||||
<% end %>
|
<% end %>
|
||||||
+1
-1
@@ -33,4 +33,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="mt-4"><a href="/labels">See saved labels →</a></p>
|
<p class="mt-4"><a href="/repository">See saved labels →</a></p>
|
||||||
Reference in new issue
Block a user