diff --git a/assets/config.json b/assets/config.json deleted file mode 100644 index e69de29..0000000 diff --git a/config.json b/config.json new file mode 100644 index 0000000..4421082 --- /dev/null +++ b/config.json @@ -0,0 +1,5 @@ +{ + "filePaths": [ + "./assets" + ] +} \ No newline at end of file diff --git a/workspaces/angular-app/src/app/components/multiples/multiples.component.html b/workspaces/angular-app/src/app/components/multiples/multiples.component.html index e465078..74e0d02 100644 --- a/workspaces/angular-app/src/app/components/multiples/multiples.component.html +++ b/workspaces/angular-app/src/app/components/multiples/multiples.component.html @@ -9,7 +9,7 @@ Deuren - + {{ doorOption?.nr }} diff --git a/workspaces/angular-app/src/app/components/multiples/multiples.component.ts b/workspaces/angular-app/src/app/components/multiples/multiples.component.ts index 3d61fc2..4baa43e 100644 --- a/workspaces/angular-app/src/app/components/multiples/multiples.component.ts +++ b/workspaces/angular-app/src/app/components/multiples/multiples.component.ts @@ -35,7 +35,7 @@ export class MultiplesComponent implements OnInit { ); this.electronIpc.receive(WindowApiConst.PRINT_OUTPUT, () => { - console.log('received'); + this.focus(); }); this.refreshProjects(); @@ -45,14 +45,9 @@ export class MultiplesComponent implements OnInit { this.electronIpc.send(WindowApiConst.FILELIST_INPUT, 'refresh'); } - loadProject(project: string): void { - this.electronIpc.send(WindowApiConst.PROJECT_INPUT, project); - } - projectChange(event: any): void { this.door = undefined; - console.log(event); - // this.project = event.value; + this.project = this.projects.find(x => x.name === event.value); this.electronIpc.send(WindowApiConst.PROJECT_INPUT, this.project); } @@ -75,7 +70,10 @@ export class MultiplesComponent implements OnInit { focus(): void { setTimeout(() => { // eslint-disable-next-line unicorn/prefer-query-selector - document.getElementById('textsearch')?.focus(); + const input = document.getElementById('textsearch'); + + (input as any).value = ""; + input?.focus(); }, 0); } } diff --git a/workspaces/electron-app/main/components/window.ts b/workspaces/electron-app/main/components/window.ts index b340909..be6caeb 100644 --- a/workspaces/electron-app/main/components/window.ts +++ b/workspaces/electron-app/main/components/window.ts @@ -7,6 +7,7 @@ import { FileListService } from '../services/file-list-service'; import { PrintService } from './../services/print-service'; import { Logger } from '../utils/logger'; import { DoorService } from '../services/door-service'; +import { readFile } from 'node:fs'; declare const global: Global; declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string; @@ -18,8 +19,20 @@ export class Window { constructor() { this.createWindow(); this.loadRenderer(); - this.registerService(new FileListService()); - this.registerService(new DoorService()); + + const fileListService = new FileListService(); + this.registerService(fileListService); + this.registerService(new DoorService()); + + readFile('./config.json', 'utf8', (error, data) => { + if(error){ + console.log(error); + return; + } + const config = JSON.parse(data); + fileListService.setPaths(config.filePaths); + + }); } private createWindow(): void { diff --git a/workspaces/electron-app/main/services/door-service.ts b/workspaces/electron-app/main/services/door-service.ts index 1e338e1..fd1215a 100644 --- a/workspaces/electron-app/main/services/door-service.ts +++ b/workspaces/electron-app/main/services/door-service.ts @@ -4,7 +4,7 @@ import { readFile, set_fs } from 'xlsx'; import * as fs from 'node:fs'; set_fs(fs); -export class DoorService extends AbstractService { +export class DoorService extends AbstractService { receptionChannel(): string { return WindowApiConst.PROJECT_INPUT; } @@ -13,9 +13,9 @@ export class DoorService extends AbstractService { return WindowApiConst.PROJECT_OUTPUT; } - process(input: string): Promise { + process(input: {name: string, path: string}): Promise { return new Promise((resolve) => { - const workbook = readFile(`./assets/${input}`); + const workbook = readFile(`${input.path}/${input.name}`); const workingSheet = workbook.Sheets['DEURLIJST']; const doorList: Door[] = []; diff --git a/workspaces/electron-app/main/services/file-list-service.ts b/workspaces/electron-app/main/services/file-list-service.ts index 69ed25b..94dcea3 100644 --- a/workspaces/electron-app/main/services/file-list-service.ts +++ b/workspaces/electron-app/main/services/file-list-service.ts @@ -48,4 +48,8 @@ export class FileListService extends AbstractService { }); }); } + + public setPaths(inputPaths: string[]) { + this._paths = inputPaths; + } }