diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js index bf0a2a16d..9dad545b8 100644 --- a/openslides/core/static/js/core/pdf.js +++ b/openslides/core/static/js/core/pdf.js @@ -173,6 +173,11 @@ angular.module('OpenSlidesApp.core.pdf', []) margin: [0,0,0,20], bold: true }, + userDataTitle: { + fontSize: 26, + margin: [0,0,0,0], + bold: true + }, textItem: { fontSize: 11, margin: [0,7] @@ -182,6 +187,19 @@ angular.module('OpenSlidesApp.core.pdf', []) margin: [0,0,0,10], bold: true }, + userDataHeading: { + fontSize: 14, + margin: [0,10], + bold: true + }, + userDataTopic: { + fontSize: 12, + margin: [0,5] + }, + userDataValue: { + fontSize: 12, + margin: [15,5] + }, tableofcontent: { fontSize: 12, margin: [0,3] diff --git a/openslides/users/static/js/users/pdf.js b/openslides/users/static/js/users/pdf.js index a025da4ee..f8805f1c4 100644 --- a/openslides/users/static/js/users/pdf.js +++ b/openslides/users/static/js/users/pdf.js @@ -103,6 +103,151 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf']) createInstance: createInstance }; -}]); +}]) +.factory('UserAccessDataListContentProvider', [ + 'gettextCatalog', + 'PdfPredefinedFunctions', + function(gettextCatalog, PdfPredefinedFunctions) { + + var createInstance = function(userList, groups, Config) { + + var getConfigValue = function(val) { + if (Config.get(val).value) { + return Config.get(val).value; + } else { + return "-"; + } + }; + + var creadeUserHeadLine = function(user) { + var titleLine = []; + titleLine.push({ + text: user.get_short_name(), + style: 'userDataTitle' + }); + if (user.structure_level) { + titleLine.push({ + text: user.structure_level, + style: 'userDataHeading' + }); + } + return titleLine; + }; + + var createAccessDataContent = function(user) { + var accessDataColumns = { + columns: [ + { + stack: [ + { + text: gettextCatalog.getString("WLAN access data"), + style: 'userDataHeading' + }, + { + text: gettextCatalog.getString("WLAN name (SSID)") + ":", + style: 'userDataTopic' + }, + { + text: getConfigValue('users_pdf_wlan_ssid'), + style: 'userDataValue' + }, + { + text: gettextCatalog.getString("WLAN password") + ":", + style: 'userDataTopic' + }, + { + text: getConfigValue('users_pdf_wlan_password'), + style: 'userDataValue' + }, + { + text: gettextCatalog.getString("WLAN encryption") + ":", + style: 'userDataTopic' + }, + { + text: getConfigValue('users_pdf_wlan_encryption'), + style: 'userDataValue' + }, + ] + }, + { + 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: getConfigValue('users_pdf_url'), + link: getConfigValue('users_pdf_url'), + style: 'userDataValue' + }, + ] + } + ], + margin: [0,20] + }; + + return accessDataColumns; + }; + + var createWelcomeText = function() { + return [ + { + text: getConfigValue('users_pdf_welcometitle'), + style: 'userDataHeading' + }, + { + text: getConfigValue('users_pdf_welcometext'), + style: 'userDataTopic' + } + ]; + }; + + var getContent = function() { + var content = []; + angular.forEach(userList, function (user) { + content.push(creadeUserHeadLine(user)); + content.push(createAccessDataContent(user)); + content.push(createWelcomeText()); + content.push({ + text: '', + pageBreak: 'after' + }); + }); + + return [ + content + ]; + }; + + return { + getContent: getContent + }; + }; + + return { + createInstance: createInstance + }; + } +]); }()); diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index df2642289..525d356c1 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -428,10 +428,12 @@ angular.module('OpenSlidesApp.users.site', [ 'Projector', 'ProjectionDefault', 'UserListContentProvider', + 'Config', + 'UserAccessDataListContentProvider', 'PdfMakeDocumentProvider', 'gettextCatalog', function($scope, $state, $http, ngDialog, UserForm, User, Group, PasswordGenerator, Projector, ProjectionDefault, - UserListContentProvider, PdfMakeDocumentProvider, gettextCatalog) { + UserListContentProvider, Config, UserAccessDataListContentProvider, PdfMakeDocumentProvider, gettextCatalog) { User.bindAll({}, $scope, 'users'); Group.bindAll({where: {id: {'>': 1}}}, $scope, 'groups'); $scope.$watch(function () { @@ -563,6 +565,14 @@ angular.module('OpenSlidesApp.users.site', [ var documentProvider = PdfMakeDocumentProvider.createInstance(userListContentProvider); pdfMake.createPdf(documentProvider.getDocument()).download(filename); }; + + $scope.makePDF_userAccessDataList = function () { + var filename = gettextCatalog.getString("List of access data")+".pdf"; + var userAccessDataListContentProvider = UserAccessDataListContentProvider.createInstance( + $scope.users, $scope.groups, Config); + var documentProvider = PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider); + pdfMake.createPdf(documentProvider.getDocument()).download(filename); + }; } ]) diff --git a/openslides/users/static/templates/users/user-list.html b/openslides/users/static/templates/users/user-list.html index 7444431cf..c1dc66670 100644 --- a/openslides/users/static/templates/users/user-list.html +++ b/openslides/users/static/templates/users/user-list.html @@ -13,21 +13,21 @@ Import -
+