Show qr codes in access data pdf only if config fields are set.

Disable footer with page numbers.
This commit is contained in:
Emanuel Schütze 2017-01-04 22:43:17 +01:00
parent 9abf9d5d57
commit 388e6353cc
3 changed files with 110 additions and 88 deletions

View File

@ -203,7 +203,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
};
};
// Generates the document(definition) for pdfMake
var getDocument = function() {
var getDocument = function(noFooter) {
var content = contentProvider.getContent();
return {
pageSize: 'A4',
@ -213,7 +213,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
fontSize: 10
},
header: header,
footer: footer,
footer: noFooter ? '' : footer,
content: content,
styles: {
title: {
@ -296,6 +296,9 @@ angular.module('OpenSlidesApp.core.pdf', [])
},
bold: {
bold: true,
},
small: {
fontSize: 8,
}
}
};

View File

@ -128,96 +128,114 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf'])
};
var createAccessDataContent = function(user) {
var wifiQrCode = "WIFI:S:" + Config.get('users_pdf_wlan_ssid').value +
";T:" + Config.get('users_pdf_wlan_encryption').value +
";P:" + Config.get('users_pdf_wlan_password').value + ";;";
var accessDataColumns = {
columns: [
// wlan access data
var columnWifi = [
{
text: gettextCatalog.getString("WLAN access data"),
style: 'userDataHeading'
},
{
text: gettextCatalog.getString("WLAN name (SSID)") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_ssid').value || '-',
style: 'userDataValue'
},
{
text: gettextCatalog.getString("WLAN password") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_password').value || '-',
style: 'userDataValue'
},
{
text: gettextCatalog.getString("WLAN encryption") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_encryption').value || '-',
style: 'userDataValue'
},
{
text: "\n"
}
];
// wifi qr code
if (Config.get('users_pdf_wlan_ssid').value && Config.get('users_pdf_wlan_encryption').value) {
var wifiQrCode = "WIFI:S:" + Config.get('users_pdf_wlan_ssid').value +
";T:" + Config.get('users_pdf_wlan_encryption').value +
";P:" + Config.get('users_pdf_wlan_password').value + ";;";
columnWifi.push(
{
stack: [
{
text: gettextCatalog.getString("WLAN access data"),
style: 'userDataHeading'
},
{
text: gettextCatalog.getString("WLAN name (SSID)") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_ssid').value || '-',
style: 'userDataValue'
},
{
text: gettextCatalog.getString("WLAN password") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_password').value || '-',
style: 'userDataValue'
},
{
text: gettextCatalog.getString("WLAN encryption") + ":",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_wlan_encryption').value || '-',
style: 'userDataValue'
},
{
text: "\n"
},
{
qr: wifiQrCode
},
{
text: gettextCatalog.getString("scan QR code to connect to WLAN")
},
]
qr: wifiQrCode,
fit: 120,
margin: [0, 0, 0, 8]
},
{
stack: [
{
text: gettextCatalog.getString("OpenSlides access data"),
style: 'userDataHeading'
},
{
text: gettextCatalog.getString("Username") + ":",
style: 'userDataTopic'
},
{
text: user.username,
style: 'userDataValue'
},
{
text: gettextCatalog.getString("Initial password") + ":",
style: 'userDataTopic'
},
{
text: user.default_password,
style: 'userDataValue'
},
{
text: "URL:",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_url').value || '-',
link: Config.get('users_pdf_url').value,
style: 'userDataValue'
},
{
text: "\n"
},
{
qr: Config.get('users_pdf_url').value
},
{
text: gettextCatalog.getString("scan QR code to open the URL")
},
]
text: gettextCatalog.getString("Scan this QR code to connect to WLAN."),
style: 'small'
}
);
}
// openslides access data
var columnOpenSlides = [
{
text: gettextCatalog.getString("OpenSlides access data"),
style: 'userDataHeading'
},
{
text: gettextCatalog.getString("Username") + ":",
style: 'userDataTopic'
},
{
text: user.username,
style: 'userDataValue'
},
{
text: gettextCatalog.getString("Initial password") + ":",
style: 'userDataTopic'
},
{
text: user.default_password,
style: 'userDataValue'
},
{
text: "URL:",
style: 'userDataTopic'
},
{
text: Config.get('users_pdf_url').value || '-',
link: Config.get('users_pdf_url').value,
style: 'userDataValue'
},
{
text: "\n"
}
];
// url qr code
if (Config.get('users_pdf_url').value) {
columnOpenSlides.push(
{
qr: Config.get('users_pdf_url').value,
fit: 120,
margin: [0, 0, 0, 8]
},
{
text: gettextCatalog.getString("Scan this QR code to open URL."),
style: 'small'
}
);
}
var accessDataColumns = {
columns: [
columnWifi,
columnOpenSlides,
],
margin: [0,20]
margin: [0, 20]
};
return accessDataColumns;

View File

@ -681,7 +681,8 @@ angular.module('OpenSlidesApp.users.site', [
var userAccessDataListContentProvider = UserAccessDataListContentProvider.createInstance(
$scope.usersFiltered, $scope.groups, Config);
var documentProvider = PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider);
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
var noFooter = true;
pdfMake.createPdf(documentProvider.getDocument(noFooter)).download(filename);
};
// Export as a csv file
$scope.csvExport = function () {