Added support for printing
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user