Added support for printing

This commit is contained in:
2023-11-21 11:51:37 +01:00
parent c891fdad45
commit f34d8e836a
6 changed files with 57 additions and 12 deletions

View File

@@ -1,5 +1,13 @@
{
"filePaths": [
"./assets"
]
],
"mapping": {
"lr": ["L/R"],
"krukSlot": ["Kruk/\r\nSLOT"],
"pivot": ["SCHARNIER"],
"type": ["SOORT"],
"modelKruk": ["MODEL\r\nKRUK"],
"remark": ["OPMERKING"]
}
}

View File

@@ -24,3 +24,28 @@
.print-button {
margin-left: 2rem;
}
@media print {
mat-form-field {
display: none;
}
button {
display: none;
}
.door {
flex-direction: column;
}
.specs {
flex-direction: row;
p {
display: inline-block;
width: 220px;
}
}
}

View File

@@ -1,2 +1,11 @@
/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
@media print {
html {
height: 530px;
width: 460px;
overflow: hidden;
zoom: 0.25;
}
}

View File

@@ -22,7 +22,8 @@ export class Window {
const fileListService = new FileListService();
this.registerService<void, any[]>(fileListService);
this.registerService<any, Door[]>(new DoorService());
const doorService = new DoorService();
this.registerService<any, Door[]>(doorService);
readFile('./config.json', 'utf8', (error, data) => {
if(error){
@@ -31,7 +32,7 @@ export class Window {
}
const config = JSON.parse(data);
fileListService.setPaths(config.filePaths);
doorService.setMapping(config.mapping);
});
}

View File

@@ -12,6 +12,11 @@ export class DoorService extends AbstractService<any, Door[]> {
sendingChannel(): string {
return WindowApiConst.PROJECT_OUTPUT;
}
private _mapping: any = {};
public setMapping(mapping: any): void {
this._mapping = mapping;
}
process(input: {name: string, path: string}): Promise<Door[]> {
return new Promise((resolve) => {
@@ -24,14 +29,11 @@ export class DoorService extends AbstractService<any, Door[]> {
// get header values
for (let index = 65; index <= 90; index++) {
const currentValue = workingSheet[`${String.fromCodePoint(index)}3`]?.v;
switch(currentValue) {
case 'L/R': this.setObjectWithChar(headers, 'lr', index); break;
case 'KRUK/\r\nSLOT': this.setObjectWithChar(headers, 'krukSlot', index); break;
case 'SCHARNIER': this.setObjectWithChar(headers, 'pivot', index); break;
case 'SOORT DEUR': this.setObjectWithChar(headers, 'type', index); break;
case 'MODEL\r\nKRUK': this.setObjectWithChar(headers, 'modelKruk', index); break;
case 'OPMERKING': this.setObjectWithChar(headers, 'remark', index); break;
default: break;
for (const [key, value] of Object.entries(this._mapping)) {
if ((value as string[]).find((x: string) => x.includes(currentValue)) != undefined) {
this.setObjectWithChar(headers, key, index);
}
}
}

View File

@@ -15,7 +15,7 @@ export class PrintService extends AbstractService<string, void> {
process(): Promise<void> {
return new Promise((resolve) => {
if (this._browserWindow) {
this._browserWindow.webContents.print({ silent: true });
this._browserWindow.webContents.print({ silent: false });
}
resolve();
});