src/module/pdf/subservices/PDFGenerator.credentials.ts
Properties |
|
Methods |
|
constructor(userService: UserService, templateService: TemplateService)
|
|||||||||
Parameters :
|
Public Async generatePDF |
generatePDF()
|
Inherited from
PDFGenerator
|
Defined in
PDFGenerator:21
|
Generates a PDF containing a list with all the given users and their temporary passwords.
Returns :
Promise<Buffer>
Buffer containing the PDF with the temporary passwords of the given users. |
Protected Async generatePDFFromBodyContent | ||||||||
generatePDFFromBodyContent(body: string)
|
||||||||
Inherited from
PDFGenerator
|
||||||||
Defined in
PDFGenerator:31
|
||||||||
Generates a PDF from the given body. The body gets put in an HTML wrapper first.
Parameters :
Returns :
Promise<Buffer>
Buffer containing the generated PDF. |
Private Static getCustomCSS |
getCustomCSS()
|
Inherited from
PDFGenerator
|
Defined in
PDFGenerator:114
|
Returns :
string
Some small customizations to the GitHub markdown CSS. |
Private Async getGithubMarkdownCSS |
getGithubMarkdownCSS()
|
Inherited from
PDFGenerator
|
Defined in
PDFGenerator:88
|
Returns :
Promise<string>
The GitHub markdown CSS. |
Private Async getHighlightCSS |
getHighlightCSS()
|
Inherited from
PDFGenerator
|
Defined in
PDFGenerator:95
|
Returns :
Promise<string>
The HighlightJS CSS. |
Private Async loadCSSFile | ||||||
loadCSSFile(moduleName: string)
|
||||||
Inherited from
PDFGenerator
|
||||||
Defined in
PDFGenerator:99
|
||||||
Parameters :
Returns :
Promise<string>
|
Private Async putBodyInHTML | ||||||||
putBodyInHTML(body: string)
|
||||||||
Inherited from
PDFGenerator
|
||||||||
Defined in
PDFGenerator:69
|
||||||||
Puts the given body in corresponding a
Parameters :
Returns :
Promise<string>
Complete HTML "file" which contains the given |
Private Readonly logger |
Default value : new Logger(PDFGenerator.name)
|
Inherited from
PDFGenerator
|
Defined in
PDFGenerator:13
|
import { Injectable } from '@nestjs/common';
import { getNameOfEntity, sortByName } from '../../../shared/util/helpers';
import { TemplateService } from '../../template/template.service';
import { UserService } from '../../user/user.service';
import { PDFGenerator } from './PDFGenerator.core';
@Injectable()
export class CredentialsPDFGenerator extends PDFGenerator {
constructor(
private readonly userService: UserService,
private readonly templateService: TemplateService
) {
super();
}
/**
* Generates a PDF containing a list with all the given users and their temporary passwords.
*
* @returns Buffer containing the PDF with the temporary passwords of the given users.
*/
public async generatePDF(): Promise<Buffer> {
const users = await this.userService.findAll();
const template = this.templateService.getCredentialsTemplate();
return this.generatePDFFromBodyContent(
template({
users: users.sort(sortByName).map((u) => ({
name: getNameOfEntity(u),
username: u.username,
password: u.temporaryPassword,
})),
})
);
}
}