mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
* Add QR-Code for API-Url/Key * Show only API-Keys for current user * Allow only admin users to create custom API-Keys * Use a managed package of qrcode-generator instead of a copy of the JS file * Reuse existing localization string (API key) * Center QR-Code in popups Co-authored-by: Bernd Bestel <bernd@berrnd.de>
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
var firstDay = null;
|
|
if (!Grocy.CalendarFirstDayOfWeek.isEmpty())
|
|
{
|
|
firstDay = parseInt(Grocy.CalendarFirstDayOfWeek);
|
|
}
|
|
|
|
var calendar = $("#calendar").fullCalendar({
|
|
"themeSystem": "bootstrap4",
|
|
"header": {
|
|
"left": "month,agendaWeek,agendaDay,listWeek",
|
|
"center": "title",
|
|
"right": "prev,next"
|
|
},
|
|
"weekNumbers": Grocy.CalendarShowWeekNumbers,
|
|
"defaultView": ($(window).width() < 768) ? "agendaDay" : "month",
|
|
"firstDay": firstDay,
|
|
"eventLimit": false,
|
|
"height": "auto",
|
|
"eventSources": fullcalendarEventSources,
|
|
eventClick: function(info)
|
|
{
|
|
location.href = info.link;
|
|
}
|
|
});
|
|
|
|
$("#ical-button").on("click", function(e)
|
|
{
|
|
e.preventDefault();
|
|
|
|
Grocy.Api.Get('calendar/ical/sharing-link',
|
|
function(result)
|
|
{
|
|
bootbox.alert({
|
|
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">'
|
|
+ getQRCodeForContent(result.url) + "</p>",
|
|
closeButton: false
|
|
});
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
});
|
|
|
|
$(window).on("resize", function()
|
|
{
|
|
// Automatically switch the calendar to "basicDay" view on small screens
|
|
// and to "month" otherwise
|
|
if ($(window).width() < 768)
|
|
{
|
|
calendar.fullCalendar("changeView", "agendaDay");
|
|
}
|
|
else
|
|
{
|
|
calendar.fullCalendar("changeView", "month");
|
|
}
|
|
});
|