1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-10-04 12:14:19 +02:00
foris-js/src/common/WiFiSettings/qrCodeHelpers.js
2020-03-25 21:17:12 +01:00

43 lines
1.2 KiB
JavaScript

/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
export function createAndDownloadPdf(SSID, password) {
const docDefinition = {
content: [
{
text: "Wi-Fi",
style: "header",
fontSize: 55,
alignment: "center",
},
{
qr: toQRCodeContent(SSID, password),
fit: "350",
margin: [0, 80],
alignment: "center",
},
{
text: `SSID: ${SSID}`,
fontSize: 25,
alignment: "center",
},
{
text: `Password: ${password}`,
fontSize: 25,
alignment: "center",
},
],
};
// pdfmake is exposed by reForis main application. Thus we can use it from globals.
window.pdfMake.createPdf(docDefinition).download("wifi.pdf");
}
export function toQRCodeContent(SSID, password) {
return `WIFI:S:${SSID};T:WPA2;P:${password};;`;
}