Added support for printing
This commit is contained in:
10
config.json
10
config.json
@@ -1,5 +1,13 @@
|
|||||||
{
|
{
|
||||||
"filePaths": [
|
"filePaths": [
|
||||||
"./assets"
|
"./assets"
|
||||||
]
|
],
|
||||||
|
"mapping": {
|
||||||
|
"lr": ["L/R"],
|
||||||
|
"krukSlot": ["Kruk/\r\nSLOT"],
|
||||||
|
"pivot": ["SCHARNIER"],
|
||||||
|
"type": ["SOORT"],
|
||||||
|
"modelKruk": ["MODEL\r\nKRUK"],
|
||||||
|
"remark": ["OPMERKING"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,3 +24,28 @@
|
|||||||
.print-button {
|
.print-button {
|
||||||
margin-left: 2rem;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,2 +1,11 @@
|
|||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
|
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
html {
|
||||||
|
height: 530px;
|
||||||
|
width: 460px;
|
||||||
|
overflow: hidden;
|
||||||
|
zoom: 0.25;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,8 @@ export class Window {
|
|||||||
|
|
||||||
const fileListService = new FileListService();
|
const fileListService = new FileListService();
|
||||||
this.registerService<void, any[]>(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) => {
|
readFile('./config.json', 'utf8', (error, data) => {
|
||||||
if(error){
|
if(error){
|
||||||
@@ -31,7 +32,7 @@ export class Window {
|
|||||||
}
|
}
|
||||||
const config = JSON.parse(data);
|
const config = JSON.parse(data);
|
||||||
fileListService.setPaths(config.filePaths);
|
fileListService.setPaths(config.filePaths);
|
||||||
|
doorService.setMapping(config.mapping);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ export class DoorService extends AbstractService<any, Door[]> {
|
|||||||
sendingChannel(): string {
|
sendingChannel(): string {
|
||||||
return WindowApiConst.PROJECT_OUTPUT;
|
return WindowApiConst.PROJECT_OUTPUT;
|
||||||
}
|
}
|
||||||
|
private _mapping: any = {};
|
||||||
|
|
||||||
|
public setMapping(mapping: any): void {
|
||||||
|
this._mapping = mapping;
|
||||||
|
}
|
||||||
|
|
||||||
process(input: {name: string, path: string}): Promise<Door[]> {
|
process(input: {name: string, path: string}): Promise<Door[]> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@@ -24,14 +29,11 @@ export class DoorService extends AbstractService<any, Door[]> {
|
|||||||
// get header values
|
// get header values
|
||||||
for (let index = 65; index <= 90; index++) {
|
for (let index = 65; index <= 90; index++) {
|
||||||
const currentValue = workingSheet[`${String.fromCodePoint(index)}3`]?.v;
|
const currentValue = workingSheet[`${String.fromCodePoint(index)}3`]?.v;
|
||||||
switch(currentValue) {
|
|
||||||
case 'L/R': this.setObjectWithChar(headers, 'lr', index); break;
|
for (const [key, value] of Object.entries(this._mapping)) {
|
||||||
case 'KRUK/\r\nSLOT': this.setObjectWithChar(headers, 'krukSlot', index); break;
|
if ((value as string[]).find((x: string) => x.includes(currentValue)) != undefined) {
|
||||||
case 'SCHARNIER': this.setObjectWithChar(headers, 'pivot', index); break;
|
this.setObjectWithChar(headers, key, index);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class PrintService extends AbstractService<string, void> {
|
|||||||
process(): Promise<void> {
|
process(): Promise<void> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (this._browserWindow) {
|
if (this._browserWindow) {
|
||||||
this._browserWindow.webContents.print({ silent: true });
|
this._browserWindow.webContents.print({ silent: false });
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user