forked from Netsyms/PackageHelper
Add list sharing feature (no sync, simply transfer+merge).
parent
c4900d2505
commit
9f5caa2593
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
function uploadList() {
|
||||
if (packages.length == 0) {
|
||||
app.dialog.alert("Your list doesn't have anything to send.", "Empty List");
|
||||
return;
|
||||
}
|
||||
app.dialog.preloader("Uploading...");
|
||||
var uploadlistdialogopen = true;
|
||||
$.ajax({
|
||||
url: SETTINGS.sharelistapi,
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
data: {
|
||||
packages: JSON.stringify(packages)
|
||||
},
|
||||
timeout: 15 * 1000,
|
||||
success: function (resp) {
|
||||
if (uploadlistdialogopen) {
|
||||
app.dialog.close();
|
||||
uploadlistdialogopen = false;
|
||||
}
|
||||
if (resp.status == "OK") {
|
||||
JsBarcode("#listidbarcode", resp.uuid, {
|
||||
format: "code128",
|
||||
ean128: false,
|
||||
width: 2,
|
||||
height: 40
|
||||
});
|
||||
$("#listidbarcodeli").css("display", "");
|
||||
} else {
|
||||
app.dialog.alert(resp.message, "Error");
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, status, errorThrown) {
|
||||
if (uploadlistdialogopen) {
|
||||
app.dialog.close();
|
||||
uploadlistdialogopen = false;
|
||||
}
|
||||
app.dialog.alert("There was a network or server issue while uploading the list. Please try again.", "Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function downloadItemList(code) {
|
||||
if (typeof code == "undefined") {
|
||||
code = $("#getlistidbox").val();
|
||||
}
|
||||
if (code.match(/^[a-f0-9]{10}$/i)) {
|
||||
app.dialog.preloader("Downloading...");
|
||||
var downloadlistdialogopen = true;
|
||||
$.ajax({
|
||||
url: SETTINGS.sharelistapi,
|
||||
dataType: 'json',
|
||||
method: 'get',
|
||||
data: {
|
||||
uuid: code
|
||||
},
|
||||
timeout: 15 * 1000,
|
||||
success: function (resp) {
|
||||
if (downloadlistdialogopen) {
|
||||
app.dialog.close();
|
||||
downloadlistdialogopen = false;
|
||||
}
|
||||
if (resp.status == "OK") {
|
||||
var skipped = importPackageList(resp.packages);
|
||||
if (skipped > 0) {
|
||||
app.dialog.alert("List imported and merged with the existing one. " + skipped + " items already existed locally and were skipped. Verify their delivery status manually.", "Import Complete");
|
||||
} else {
|
||||
app.dialog.alert("List imported and merged with the existing one.", "Import Complete");
|
||||
}
|
||||
} else {
|
||||
app.dialog.alert(resp.message, "Error");
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, status, errorThrown) {
|
||||
if (downloadlistdialogopen) {
|
||||
app.dialog.close();
|
||||
downloadlistdialogopen = false;
|
||||
}
|
||||
app.dialog.alert("There was a network or server issue while downloading the list. Please try again.", "Error");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
app.dialog.alert("That's not a valid list ID.", "Error");
|
||||
}
|
||||
}
|
||||
|
||||
function scanListIDBarcode() {
|
||||
scanBarcode(function (code) {
|
||||
playSound("scan");
|
||||
downloadItemList(code);
|
||||
}, function (error) {
|
||||
app.dialog.alert(error, "Error");
|
||||
});
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<div class="page" data-name="sharelist">
|
||||
|
||||
<div class="navbar">
|
||||
<div class="navbar-bg"></div>
|
||||
<div class="navbar-inner">
|
||||
<div class="left">
|
||||
<a href="#" class="link icon-only back">
|
||||
<i class="icon icon-back"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">Share Item List</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="list media-list no-hairlines tablet-inset no-margin-top">
|
||||
<ul>
|
||||
<li class="item-divider">Send List</li>
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<a class="button button-fill" id="sendlistbtn" onclick="uploadList();"><i class="fas fa-upload"></i> Upload List</a>
|
||||
</div>
|
||||
</li>
|
||||
<li style="display: none;" id="listidbarcodeli">
|
||||
<div class="item-content" style="background-color: white; display: flex; justify-content: center; padding-left: 1rem; padding-right: 1rem;">
|
||||
<svg class="barcode" id="listidbarcode"></svg>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="item-divider">Receive List</li>
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title item-label">List ID</div>
|
||||
<div class="item-input-wrap">
|
||||
<input type="text" id="getlistidbox" placeholder="" autocomplete="off" autocorrect="off" autocapitalize="off" />
|
||||
<span class="input-clear-button"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item-content">
|
||||
<a class="button button-fill" onclick="downloadItemList();"><i class="fas fa-download"></i> Download List</a>
|
||||
</li>
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<a class="button button-fill" id="scanlistbarcodebtn" onclick="scanListIDBarcode();"><i class="fas fa-barcode"></i> Scan List Barcode</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="block text-align-center">
|
||||
<i class="material-icons">info</i>
|
||||
<br />
|
||||
Share your delivery list to another device. The sender uploads the list,
|
||||
and the receiver(s) either scan the barcode on the sender's device, or
|
||||
type in the code beneath the barcode.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/toolbox_sharelist.js"></script>
|
||||
</div>
|
Loading…
Reference in New Issue