mirror of
https://github.com/grocy/grocy.git
synced 2025-09-19 02:57:44 +00:00
Merge used libraries for Barcode/QR-Code generation
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
"jquery-serializejson": "^2.9.0",
|
"jquery-serializejson": "^2.9.0",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.27.0",
|
||||||
"nosleep.js": "^0.11.0",
|
"nosleep.js": "^0.11.0",
|
||||||
"qrcode-generator": "^1.4.4",
|
|
||||||
"sprintf-js": "^1.1.2",
|
"sprintf-js": "^1.1.2",
|
||||||
"startbootstrap-sb-admin": "4.0.0",
|
"startbootstrap-sb-admin": "4.0.0",
|
||||||
"summernote": "^0.8.18",
|
"summernote": "^0.8.18",
|
||||||
|
@@ -185,20 +185,18 @@ function RandomString()
|
|||||||
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQRCodeForContent(url)
|
function QrCodeImgHtml(text)
|
||||||
{
|
{
|
||||||
var qr = qrcode(0, 'L');
|
var dummyCanvas = document.createElement("canvas");
|
||||||
qr.addData(url);
|
var img = document.createElement("img");
|
||||||
qr.make();
|
|
||||||
return qr.createImgTag(10, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
bwipjs.toCanvas(dummyCanvas, {
|
||||||
{
|
bcid: "qrcode",
|
||||||
var content = U('/api') + '|' + apikey_key;
|
text: text,
|
||||||
if (apikey_type === 'special-purpose-calendar-ical')
|
scale: 4,
|
||||||
{
|
includetext: false
|
||||||
content = U('/api/calendar/ical?secret=' + apikey_key);
|
});
|
||||||
}
|
img.src = dummyCanvas.toDataURL("image/png");
|
||||||
return getQRCodeForContent(content);
|
|
||||||
|
return img.outerHTML;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ $("#ical-button").on("click", function(e)
|
|||||||
bootbox.alert({
|
bootbox.alert({
|
||||||
title: __t('Share/Integrate calendar (iCal)'),
|
title: __t('Share/Integrate calendar (iCal)'),
|
||||||
message: __t('Use the following (public) URL to share or integrate the calendar in iCal format') + '<input type="text" class="form-control form-control-sm mt-2 easy-link-copy-textbox" value="' + result.url + '"><p class="text-center mt-4">'
|
message: __t('Use the following (public) URL to share or integrate the calendar in iCal format') + '<input type="text" class="form-control form-control-sm mt-2 easy-link-copy-textbox" value="' + result.url + '"><p class="text-center mt-4">'
|
||||||
+ getQRCodeForContent(result.url) + "</p>",
|
+ QrCodeImgHtml(result.url) + "</p>",
|
||||||
closeButton: false
|
closeButton: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -67,9 +67,21 @@ $(document).on('click', '.apikey-delete-button', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function QrCodeForApiKey(apiKeyType, apiKey)
|
||||||
|
{
|
||||||
|
var content = U('/api') + '|' + apiKey;
|
||||||
|
if (apiKeyType === 'special-purpose-calendar-ical')
|
||||||
|
{
|
||||||
|
content = U('/api/calendar/ical?secret=' + apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QrCodeImgHtml(content);
|
||||||
|
}
|
||||||
|
|
||||||
$('.apikey-show-qr-button').on('click', function()
|
$('.apikey-show-qr-button').on('click', function()
|
||||||
{
|
{
|
||||||
var qrcodeHtml = getQRCodeForAPIKey($(this).data('apikey-type'), $(this).data('apikey-key'));
|
var qrcodeHtml = QrCodeForApiKey($(this).data('apikey-type'), $(this).data('apikey-key'));
|
||||||
bootbox.alert({
|
bootbox.alert({
|
||||||
title: __t('API key'),
|
title: __t('API key'),
|
||||||
message: "<p class='text-center'>" + qrcodeHtml + "</p>",
|
message: "<p class='text-center'>" + qrcodeHtml + "</p>",
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
@push('pageScripts')
|
@push('pageScripts')
|
||||||
<script src="{{ $U('/node_modules/fullcalendar/dist/fullcalendar.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/fullcalendar/dist/fullcalendar.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
@if(!empty($__t('fullcalendar_locale') && $__t('fullcalendar_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/fullcalendar/dist/locale/{{ $__t('fullcalendar_locale') }}.js?v={{ $version }}"></script>@endif
|
@if(!empty($__t('fullcalendar_locale') && $__t('fullcalendar_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/fullcalendar/dist/locale/{{ $__t('fullcalendar_locale') }}.js?v={{ $version }}"></script>@endif
|
||||||
<script src="{{ $U('/node_modules/qrcode-generator/qrcode.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/bwip-js/dist/bwip-js-min.js?v=', true) }}{{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('pageStyles')
|
@push('pageStyles')
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
@section('viewJsName', 'manageapikeys')
|
@section('viewJsName', 'manageapikeys')
|
||||||
|
|
||||||
@push('pageScripts')
|
@push('pageScripts')
|
||||||
<script src="{{ $U('/node_modules/qrcode-generator/qrcode.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/bwip-js/dist/bwip-js-min.js?v=', true) }}{{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('pageStyles')
|
@push('pageStyles')
|
||||||
|
@@ -2362,11 +2362,6 @@ pupa@^2.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
escape-goat "^2.0.0"
|
escape-goat "^2.0.0"
|
||||||
|
|
||||||
qrcode-generator@^1.4.4:
|
|
||||||
version "1.4.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/qrcode-generator/-/qrcode-generator-1.4.4.tgz#63f771224854759329a99048806a53ed278740e7"
|
|
||||||
integrity sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw==
|
|
||||||
|
|
||||||
qs@~6.5.2:
|
qs@~6.5.2:
|
||||||
version "6.5.2"
|
version "6.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||||
|
Reference in New Issue
Block a user