Merge pull request #2580 from tsiegleauq/accessDataListPdfMake

Creates the access data list with PdfMake
This commit is contained in:
Emanuel Schütze 2016-11-02 14:53:50 +01:00 committed by GitHub
commit ef36962221
4 changed files with 179 additions and 6 deletions

View File

@ -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]

View File

@ -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
};
}
]);
}());

View File

@ -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);
};
}
])

View File

@ -13,21 +13,21 @@
<i class="fa fa-download fa-lg"></i>
<translate>Import</translate>
</a>
<div class="btn-group" uib-dropdown>
<div class="dropdown pull-right" uib-dropdown>
<button os-perms="users.can_manage" class="btn btn-default btn-sm" uib-dropdown-toggle
id="user-pdf-dropdown">
<i class="fa fa-file-pdf-o fa-lg"></i>
<translate>PDF</translate>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="user-pdf-dropdown">
<ul class="dropdown-menu" dropdown-menu-right aria-labelledby="user-pdf-dropdown">
<li>
<a ng-click="makePDF_userList()" class="btn">
<a href="" ng-click="makePDF_userList()">
<i class="fa fa-list fa-fw"></i>
<translate>List of participants</translate>
</a>
<li os-perms="users.can_manage">
<a ui-sref="user_passwordspdf" target="_blank">
<a href="" ng-click="makePDF_userAccessDataList()">
<i class="fa fa-qrcode fa-fw"></i>
<translate>List of access data</translate>
</a>