mirror of
https://github.com/grocy/grocy.git
synced 2026-04-08 21:46:16 +02:00
Add QR-Code for API-Url/Key
This commit is contained in:
parent
32a4f81f62
commit
308f10f738
|
|
@ -175,3 +175,19 @@ function animateCSS(selector, animationName, callback, speed = "faster")
|
||||||
function RandomString() {
|
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)
|
||||||
|
{
|
||||||
|
var qr = qrcode(0, 'L');
|
||||||
|
qr.addData(url);
|
||||||
|
qr.make();
|
||||||
|
return qr.createImgTag(10, 5);
|
||||||
|
}
|
||||||
|
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
||||||
|
{
|
||||||
|
var content = U('/api') + '|' + apikey_key;
|
||||||
|
if(apikey_type === 'special-purpose-calendar-ical')
|
||||||
|
{
|
||||||
|
content = U('/api/calendar/ical?secret=' + apikey_key);
|
||||||
|
}
|
||||||
|
return getQRCodeForContent(content);
|
||||||
|
}
|
||||||
|
|
|
||||||
2297
public/js/qrcode.js
Normal file
2297
public/js/qrcode.js
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -32,7 +32,8 @@ $("#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 + '">',
|
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 + '">'
|
||||||
|
+ getQRCodeForContent(result.url),
|
||||||
closeButton: false
|
closeButton: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -61,3 +61,11 @@ $(document).on('click', '.apikey-delete-button', function(e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$('.apikey-show-qr-button').on('click', function () {
|
||||||
|
var QRhtml = getQRCodeForAPIKey( $(this).data('apikey-key'), $(this).data('apikey-type'));
|
||||||
|
bootbox.alert({
|
||||||
|
title: __t('API-Key'),
|
||||||
|
message: QRhtml,
|
||||||
|
closeButton: false
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -701,6 +701,7 @@
|
||||||
<script src="{{ $U('/js/grocy_wakelockhandling.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy_wakelockhandling.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/js/grocy_nightmode.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy_nightmode.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/js/grocy_clock.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy_clock.js?v=', true) }}{{ $version }}"></script>
|
||||||
|
<script src="{{ $U('/js/qrcode.js?v=', true) }}{{ $version }}"></script>
|
||||||
@stack('pageScripts')
|
@stack('pageScripts')
|
||||||
|
|
||||||
@php
|
@php
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,13 @@
|
||||||
data-apikey-apikey="{{ $apiKey->api_key }}">
|
data-apikey-apikey="{{ $apiKey->api_key }}">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-info btn-sm apikey-show-qr-button"
|
||||||
|
href="#"
|
||||||
|
data-apikey-key="{{ $apiKey->api_key }}"
|
||||||
|
data-apikey-type="{{ $apiKey->key_type }}"
|
||||||
|
>
|
||||||
|
<i class="fas fa-qrcode"></i>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ $apiKey->api_key }}
|
{{ $apiKey->api_key }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user