2016-11-25 22:21:42 +02:00
|
|
|
{% extends "base.jinja2" %}
|
|
|
|
|
|
|
|
{% block page_title %}{{ title }}{% endblock %}
|
|
|
|
|
2016-12-19 01:15:27 +02:00
|
|
|
{% block jumbotron %}
|
2018-03-05 04:35:31 +02:00
|
|
|
<h1>{{ website['PAGE_TITLE'] }}</h1>
|
|
|
|
<p>{{ website['PAGE_HEADLINE'] }}</p>
|
2016-12-19 01:15:27 +02:00
|
|
|
<!--<p><a class="btn btn-primary btn-lg" href="#" role="button">History of printed labels</a></p>-->
|
|
|
|
{% endblock %}
|
|
|
|
|
2016-11-25 22:21:42 +02:00
|
|
|
{% block content %}
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-4">
|
|
|
|
<fieldset class="form-group">
|
2016-12-19 02:24:26 +02:00
|
|
|
<div class="panel-group" id="accordion">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
|
2017-01-08 11:01:30 +02:00
|
|
|
<span class="glyphicon glyphicon-file" aria-hidden="true"></span> Label Size</a>
|
2016-12-19 02:24:26 +02:00
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse1" class="panel-collapse collapse">
|
2017-01-08 11:01:30 +02:00
|
|
|
<div class="chooser panel-body">
|
2016-12-19 02:24:26 +02:00
|
|
|
<label for="labelSize" style="display: none">Label Size:</label>
|
|
|
|
<select class="form-control" id="labelSize" onChange="preview()">
|
2018-03-05 04:35:31 +02:00
|
|
|
{% for label_size in label_sizes %}<option value="{{label_size[0]}}" {% if label['DEFAULT_SIZE'] == label_size[0] %}selected{% endif %}>{{label_size[1]}}</option>{% endfor %}
|
2016-12-19 02:24:26 +02:00
|
|
|
</select>
|
2017-02-06 14:27:31 +02:00
|
|
|
<label for="orientation" style="margin-top: 10px; margin-bottom: 0">Label Orientation:</label>
|
|
|
|
<div class="radio" style="margin-top: 5px;">
|
2017-02-06 15:10:13 +02:00
|
|
|
<label><input type="radio" onchange="preview()" name="orientation" value="standard" {% if default_orientation == 'standard' %}checked{% endif %}>Standard</label>
|
2017-02-06 14:27:31 +02:00
|
|
|
</div>
|
|
|
|
<div class="radio">
|
2017-02-06 15:10:13 +02:00
|
|
|
<label><input type="radio" onchange="preview()" name="orientation" value="rotated" {% if default_orientation == 'rotated' %}checked{% endif %}>Rotated</label>
|
2017-02-06 14:27:31 +02:00
|
|
|
</div>
|
|
|
|
</div> <!-- class="chooser panel-body" -->
|
2016-12-19 02:24:26 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
|
2017-01-08 11:01:30 +02:00
|
|
|
<span class="glyphicon glyphicon-text-size" aria-hidden="true"></span>
|
|
|
|
Font Settings
|
|
|
|
</a>
|
2016-12-19 02:24:26 +02:00
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse2" class="panel-collapse collapse in">
|
2017-01-08 11:01:30 +02:00
|
|
|
<div class="chooser panel-body">
|
2016-12-19 02:24:26 +02:00
|
|
|
<label for="fontFamily">Font Family:</label>
|
|
|
|
<select class="form-control" id="fontFamily" onChange="preview()">
|
2018-01-03 22:40:22 +02:00
|
|
|
{% for font_family_name in font_family_names %}
|
|
|
|
{% for font_style in fonts[font_family_name].keys() %}
|
2019-08-26 12:29:48 +03:00
|
|
|
<option {% if label['DEFAULT_FONTS']['style'] == font_style and label['DEFAULT_FONTS']['family'] == font_family_name %}selected{% endif %}>{{font_family_name}} ({{ font_style }})</option>
|
2018-01-03 22:40:22 +02:00
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
2016-12-19 02:24:26 +02:00
|
|
|
</select>
|
|
|
|
<label for="fontSize" >Font Size:</label>
|
2018-03-05 04:35:31 +02:00
|
|
|
<input id="fontSize" class="form-control" type="number" min="1" value="{{ label['DEFAULT_FONT_SIZE'] }}" onChange="preview()" required>
|
2017-01-03 21:43:23 +02:00
|
|
|
<label for="fontAlign" class="control-label input-group">Font Alignment:</label>
|
|
|
|
<div class="btn-group" data-toggle="buttons">
|
|
|
|
<label class="btn btn-default">
|
|
|
|
<input type="radio" name="fontAlign" onchange="preview()" value="left" aria-label="Left Align"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
|
|
|
|
</label>
|
|
|
|
<label class="btn btn-default active">
|
|
|
|
<input type="radio" name="fontAlign" onchange="preview()" value="center" aria-label="Center Align" checked=""><span class="glyphicon glyphicon-align-center" aria-hidden="true"></span>
|
|
|
|
</label>
|
|
|
|
<label class="btn btn-default">
|
|
|
|
<input type="radio" name="fontAlign" onchange="preview()" value="right" aria-label="Right Align"><span class="glyphicon glyphicon-align-right" aria-hidden="true"></span>
|
|
|
|
</label>
|
|
|
|
</div>
|
2017-01-08 11:01:30 +02:00
|
|
|
</div> <!-- class="chooser panel-body" -->
|
2017-01-03 21:43:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h4 class="panel-title">
|
|
|
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">
|
2017-02-10 11:49:27 +02:00
|
|
|
<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
|
|
|
|
Detailed Settings
|
|
|
|
</a>
|
2017-01-03 21:43:23 +02:00
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div id="collapse3" class="panel-collapse collapse">
|
2017-01-08 11:01:30 +02:00
|
|
|
<div class="chooser panel-body">
|
2017-02-10 11:07:38 +02:00
|
|
|
<label for="marginTop">Margin Top:</label>
|
2017-02-10 11:34:46 +02:00
|
|
|
<div class="input-group marginsTopBottom">
|
|
|
|
<input id="marginTop" class="form-control" type="number" min="0" max="200" value="24" onChange="preview()" required> <span class="input-group-addon">%</span>
|
|
|
|
</div>
|
2017-02-10 11:07:38 +02:00
|
|
|
<label for="marginBottom">Margin Bottom:</label>
|
2017-02-10 11:34:46 +02:00
|
|
|
<div class="input-group marginsTopBottom">
|
|
|
|
<input id="marginBottom" class="form-control" type="number" min="0" max="200" value="45" onChange="preview()" required> <span class="input-group-addon">%</span>
|
|
|
|
</div>
|
2017-02-10 11:07:38 +02:00
|
|
|
<label for="marginLeft">Margin Left:</label>
|
2017-02-10 11:34:46 +02:00
|
|
|
<div class="input-group marginsLeftRight">
|
|
|
|
<input id="marginLeft" class="form-control" type="number" min="0" max="200" value="35" onChange="preview()" required> <span class="input-group-addon">%</span>
|
|
|
|
</div>
|
2017-02-10 11:07:38 +02:00
|
|
|
<label for="marginRight">Margin Right:</label>
|
2017-02-10 11:34:46 +02:00
|
|
|
<div class="input-group marginsLeftRight">
|
|
|
|
<input id="marginRight" class="form-control" type="number" min="0" max="200" value="35" onChange="preview()" required> <span class="input-group-addon">%</span>
|
|
|
|
</div>
|
2017-01-08 11:01:30 +02:00
|
|
|
</div> <!-- class="chooser panel-body" -->
|
2016-12-19 02:24:26 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-11-25 22:21:42 +02:00
|
|
|
</fieldset>
|
|
|
|
</div>
|
2016-12-19 01:15:27 +02:00
|
|
|
<div class="col-md-4">
|
|
|
|
<fieldset class="form-group">
|
|
|
|
<label for="labelText">Label Text:</label>
|
|
|
|
<textarea rows="7" id="labelText" class="form-control" onChange="preview()" onInput="preview()"></textarea>
|
|
|
|
</fieldset>
|
|
|
|
</div>
|
2016-11-25 22:21:42 +02:00
|
|
|
<div class="col-md-4">
|
|
|
|
<fieldset class="form-group">
|
2017-02-06 14:27:31 +02:00
|
|
|
<label for="previewImg">Label Preview:</label><br />
|
|
|
|
<img id="previewImg" style="border: 1px solid #444; max-height: 350px; width: auto; max-width: 100%; margin-bottom: 10px;"/>
|
2017-02-06 16:11:45 +02:00
|
|
|
<p>Printed size w/o margins: <span id="labelWidth">?</span> cm x <span id="labelHeight">?</span> cm</p>
|
|
|
|
<button id="printButton" type="button" class="btn btn-primary btn-block btn-lg" onClick="print()">
|
|
|
|
<span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print
|
|
|
|
</button>
|
2016-11-25 22:21:42 +02:00
|
|
|
</fieldset>
|
2017-01-04 15:13:17 +02:00
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
2017-02-10 11:49:27 +02:00
|
|
|
<h3 class="panel-title"><span class="glyphicon glyphicon-console" aria-hidden="true" style="margin-right: 0.3em"></span> Status</h3>
|
2017-01-04 15:13:17 +02:00
|
|
|
</div>
|
|
|
|
<div id="statusPanel" class="panel-body">
|
|
|
|
- undefined -
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-11-25 22:21:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block javascript %}
|
|
|
|
var text = $('#labelText');
|
|
|
|
|
2017-01-04 15:13:17 +02:00
|
|
|
function formData() {
|
|
|
|
//var text = $('#labelText').val().replace(/\n/g, "%0A");
|
|
|
|
var text = $('#labelText').val();
|
|
|
|
if (text == '') text = ' ';
|
|
|
|
return {
|
|
|
|
text: text,
|
|
|
|
font_family: $('#fontFamily option:selected').text(),
|
|
|
|
font_size: $('#fontSize').val(),
|
|
|
|
label_size: $('#labelSize option:selected').val(),
|
2017-02-06 14:27:31 +02:00
|
|
|
align: $('input[name=fontAlign]:checked').val(),
|
2017-02-10 11:07:38 +02:00
|
|
|
orientation: $('input[name=orientation]:checked').val(),
|
|
|
|
margin_top: $('#marginTop').val(),
|
|
|
|
margin_bottom: $('#marginBottom').val(),
|
|
|
|
margin_left: $('#marginLeft').val(),
|
|
|
|
margin_right: $('#marginRight').val()
|
2017-01-04 15:13:17 +02:00
|
|
|
}
|
2016-11-25 22:21:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function preview() {
|
2017-02-10 11:07:38 +02:00
|
|
|
if ($('input[name=orientation]:checked').val() == 'standard') {
|
2017-02-10 11:34:46 +02:00
|
|
|
$('.marginsTopBottom').prop('disabled', false).removeAttr('title');
|
|
|
|
$('.marginsLeftRight').prop('disabled', true).prop('title', 'Only relevant if rotated orientation is selected.');
|
2017-02-10 11:07:38 +02:00
|
|
|
} else {
|
2017-02-10 11:34:46 +02:00
|
|
|
$('.marginsTopBottom').prop('disabled', true).prop('title', 'Only relevant if standard orientation is selected.');
|
|
|
|
$('.marginsLeftRight').prop('disabled', false).removeAttr('title');
|
2017-02-10 11:07:38 +02:00
|
|
|
}
|
2016-11-25 22:21:42 +02:00
|
|
|
$.ajax({
|
2017-01-04 15:13:17 +02:00
|
|
|
type: 'POST',
|
|
|
|
url: '/api/preview/text?return_format=base64',
|
|
|
|
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
|
data: formData(),
|
2016-11-25 22:21:42 +02:00
|
|
|
success: function( data ) {
|
2017-01-04 15:13:17 +02:00
|
|
|
$('#previewImg').attr('src', 'data:image/png;base64,' + data);
|
2017-02-06 16:11:45 +02:00
|
|
|
var img = $('#previewImg')[0];
|
|
|
|
img.onload = function() {
|
|
|
|
$('#labelWidth').html( (img.naturalWidth /300*2.54).toFixed(1));
|
|
|
|
$('#labelHeight').html((img.naturalHeight/300*2.54).toFixed(1));
|
|
|
|
};
|
2016-11-25 22:21:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-01-04 15:13:17 +02:00
|
|
|
function setStatus(data) {
|
|
|
|
if (data['success'])
|
2017-01-08 11:01:30 +02:00
|
|
|
$('#statusPanel').html('<div id="statusBox" class="alert alert-success" role="alert"><i class="glyphicon glyphicon-check"></i><span>Printing was successful.</span></div>');
|
2017-01-04 15:13:17 +02:00
|
|
|
else
|
2017-01-08 11:01:30 +02:00
|
|
|
$('#statusPanel').html('<div id="statusBox" class="alert alert-warning" role="alert"><i class="glyphicon glyphicon-alert"></i><span>Printing was unsuccessful:<br />'+data['message']+'</span></div>');
|
|
|
|
$('#printButton').prop('disabled', false);
|
2017-01-04 15:13:17 +02:00
|
|
|
}
|
2016-11-25 22:21:42 +02:00
|
|
|
|
2017-01-04 15:13:17 +02:00
|
|
|
function print() {
|
2017-01-08 11:01:30 +02:00
|
|
|
$('#printButton').prop('disabled', true);
|
2017-02-10 11:49:27 +02:00
|
|
|
$('#statusPanel').html('<div id="statusBox" class="alert alert-info" role="alert"><i class="glyphicon glyphicon-hourglass"></i><span>Processing print request...</span></div>');
|
2017-01-04 15:13:17 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
data: formData(),
|
|
|
|
url: '/api/print/text',
|
|
|
|
success: setStatus,
|
|
|
|
error: setStatus
|
|
|
|
});
|
|
|
|
}
|
2016-11-25 22:21:42 +02:00
|
|
|
|
2017-01-04 15:13:17 +02:00
|
|
|
preview()
|
2016-11-25 22:21:42 +02:00
|
|
|
|
|
|
|
{% endblock %}
|