Merge pull request #300 from eReuse/change/2973-sid-in-label

Change/2973 sid in label
This commit is contained in:
cayop 2022-06-08 12:18:42 +02:00 committed by GitHub
commit cfe7639734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -401,6 +401,12 @@ class Device(Thing):
return history
@property
def sid(self):
actions = [x for x in self.actions if x.t == 'Snapshot' and x.sid]
if actions:
return actions[0].sid
@property
def tradings(self):
return {str(x.id): self.trading(x.lot) for x in self.actions if x.t == 'Trade'}

View File

@ -24,6 +24,7 @@ function save_settings() {
var sizePreset = $("#printerType").val();
var data = {"height": height, "width": width, "sizePreset": sizePreset};
data['dhid'] = $("#dhidCheck").prop('checked');
data['sid'] = $("#sidCheck").prop('checked');
data['qr'] = $("#qrCheck").prop('checked');
data['serial_number'] = $("#serialNumberCheck").prop('checked');
data['manufacturer'] = $("#manufacturerCheck").prop('checked');
@ -39,6 +40,7 @@ function load_settings() {
$("#printerType").val(data.sizePreset);
$("#qrCheck").prop('checked', data.qr);
$("#dhidCheck").prop('checked', data.dhid);
$("#sidCheck").prop('checked', data.sid);
$("#serialNumberCheck").prop('checked', data.serial_number);
$("#manufacturerCheck").prop('checked', data.manufacturer);
$("#modelCheck").prop('checked', data.model);
@ -50,6 +52,7 @@ function reset_settings() {
$("#printerType").val('brotherSmall');
$("#qrCheck").prop('checked', true);
$("#dhidCheck").prop('checked', true);
$("#sidCheck").prop('checked', true);
$("#serialNumberCheck").prop('checked', false);
$("#manufacturerCheck").prop('checked', false);
$("#modelCheck").prop('checked', false);
@ -74,6 +77,11 @@ function change_check() {
} else {
$(".dhid").hide();
}
if ($("#sidCheck").prop('checked')) {
$(".sid").show();
} else {
$(".sid").hide();
}
if ($("#serialNumberCheck").prop('checked')) {
$(".serial_number").show();
} else {
@ -109,6 +117,9 @@ function printpdf() {
min_tag_side = (Math.min(height, width)/2) + border;
var last_tag_code = '';
if ($("#sidCheck").prop('checked')) {
height += line;
};
if ($("#serialNumberCheck").prop('checked')) {
height += line;
};
@ -145,6 +156,12 @@ function printpdf() {
space += line;
}
};
if ($("#sidCheck").prop('checked')) {
var sn = $(y).data('sid');
pdf.setFontSize(15);
pdf.text(sn, border, space);
space += line;
};
if ($("#serialNumberCheck").prop('checked')) {
var sn = $(y).data('serial-number');
pdf.setFontSize(12);

View File

@ -35,7 +35,13 @@
<div style="padding-top: 55px">
<b class="tag" data-serial-number="{{ dev.serial_number or '' }}"
data-manufacturer="{{ dev.manufacturer or '' }}"
data-model="{{ dev.model or '' }}">{{ dev.devicehub_id }}</b>
data-model="{{ dev.model or '' }}"
data-sid="{{ dev.sid or '' }}">{{ dev.devicehub_id }}</b>
</div>
</div>
<div class="col sid" style="display: none">
<div>
<b>{{ dev.sid or '' }}</b>
</div>
</div>
</div>
@ -103,6 +109,10 @@
<input class="form-check-input" name="dhid" type="checkbox" id="dhidCheck" checked="">
<label class="form-check-label" for="dhidCheck">Dhid</label>
</div>
<div class="form-switch">
<input class="form-check-input" name="sid" type="checkbox" id="sidCheck">
<label class="form-check-label" for="sidCheck">Sid</label>
</div>
<div class="form-switch">
<input class="form-check-input" name="serial_number" type="checkbox" id="serialNumberCheck">
<label class="form-check-label" for="serialNumberCheck">Serial number</label>