From 193b11986a13f4a5ec97e4ce34855315364e7031 Mon Sep 17 00:00:00 2001 From: Garry Lachman Date: Sun, 13 Dec 2020 08:22:32 +0200 Subject: [PATCH] log console --- package.json | 1 + src/app/app.component.scss | 1 - .../log-console/log-console.component.html | 12 +++++++----- .../log-console/log-console.component.scss | 6 +++++- src/app/services/ipc/accounts.service.ts | 8 ++++---- src/app/services/ipc/queries.ipc.service.ts | 2 +- src/app/services/ipc/views.ipc.service.ts | 17 ++++++++--------- src/app/services/log-console.service.ts | 8 +++++++- tsconfig.json | 3 ++- 9 files changed, 35 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 2cffb609..c32ffd59 100644 --- a/package.json +++ b/package.json @@ -146,6 +146,7 @@ "popper.js": "^1.16.1", "reflect-metadata": "^0.1.13", "sqlite3": "^4.2.0", + "stringify-object": "^3.3.0", "tunnel-ssh": "^4.1.4", "type-fest": "^0.8.1", "uuid": "^3.4.0" diff --git a/src/app/app.component.scss b/src/app/app.component.scss index 269842e3..16020358 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -61,7 +61,6 @@ h5#active-account { nb-layout-footer { - z-index: 9999999; position: sticky; bottom: 0; diff --git a/src/app/components/log-console/log-console.component.html b/src/app/components/log-console/log-console.component.html index 03f1641c..ddbce7ec 100644 --- a/src/app/components/log-console/log-console.component.html +++ b/src/app/components/log-console/log-console.component.html @@ -9,10 +9,10 @@
Console Log
nbInfiniteList listenWindowScroll [ngClass]="{'d-none': isMinimized}" - class="mt-3 scrollable" + class="mt-3 scrollable scrollable-container" > - + @@ -34,9 +34,11 @@
Console Log
- - - {{logItem.message}} +
{{logItem.message}}
+
+ + +
diff --git a/src/app/components/log-console/log-console.component.scss b/src/app/components/log-console/log-console.component.scss index 32fde1e8..a7734725 100644 --- a/src/app/components/log-console/log-console.component.scss +++ b/src/app/components/log-console/log-console.component.scss @@ -1,8 +1,12 @@ nb-list { - height: 10em; + height: 10em !important; overflow-y: scroll !important; } +.scrollable-container { + height: 10em !important; +} + nb-list nb-list-item { border-bottom: 0px !important; line-height: 1.2rem !important; diff --git a/src/app/services/ipc/accounts.service.ts b/src/app/services/ipc/accounts.service.ts index ea6bf7a9..6e81d959 100644 --- a/src/app/services/ipc/accounts.service.ts +++ b/src/app/services/ipc/accounts.service.ts @@ -24,7 +24,7 @@ export class AccountsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -33,7 +33,7 @@ export class AccountsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(rawRes), + rawRes, getCurrentLine().method ) @@ -49,7 +49,7 @@ export class AccountsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -57,7 +57,7 @@ export class AccountsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(rawRes), + rawRes, getCurrentLine().method ) diff --git a/src/app/services/ipc/queries.ipc.service.ts b/src/app/services/ipc/queries.ipc.service.ts index ace85a6d..1fbac3b5 100644 --- a/src/app/services/ipc/queries.ipc.service.ts +++ b/src/app/services/ipc/queries.ipc.service.ts @@ -22,7 +22,7 @@ export class QueriesIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) diff --git a/src/app/services/ipc/views.ipc.service.ts b/src/app/services/ipc/views.ipc.service.ts index eca3ef88..794afddd 100644 --- a/src/app/services/ipc/views.ipc.service.ts +++ b/src/app/services/ipc/views.ipc.service.ts @@ -11,7 +11,6 @@ import { import { ipcRenderer } from 'electron-better-ipc'; import { LogConsoleService } from '../log-console.service'; import { ConsoleLogItemType } from '../../../shared/interfaces/log-console.interface'; -//import * as ParentModule from 'parent-module'; import getCurrentLine from 'get-current-line' @Injectable({ @@ -29,7 +28,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(rawRes), + rawRes, getCurrentLine().method ) @@ -44,7 +43,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -53,7 +52,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(rawRes), + rawRes, getCurrentLine().method ) @@ -87,7 +86,7 @@ export class ViewsIPCService { console.log("req", req); this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -110,7 +109,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -131,7 +130,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -152,7 +151,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) @@ -184,7 +183,7 @@ export class ViewsIPCService { this.logConsoleService.addItem( ConsoleLogItemType.info, - JSON.stringify(req.toJsonValue()), + req.toJsonValue(), getCurrentLine().method ) diff --git a/src/app/services/log-console.service.ts b/src/app/services/log-console.service.ts index e1ccc768..5901e234 100644 --- a/src/app/services/log-console.service.ts +++ b/src/app/services/log-console.service.ts @@ -4,6 +4,8 @@ import { ConsoleLogItem, ConsoleLogItemType, ConsoleLogItemSource } from '../../ import { ipcRenderer } from 'electron-better-ipc'; import { IPCConsoleLog } from '../../shared/ipc/console-log.ipc'; +import { JsonValue } from 'type-fest'; +import * as stringifyObject from 'stringify-object' @Injectable({ providedIn: 'root' @@ -17,9 +19,13 @@ export class LogConsoleService { ipcRenderer.on(IPCConsoleLog.CHANNEL, (event: any, data: any) => this.addItem(data.message.type, data.message.message, data.message.method, ConsoleLogItemSource.Backend)) } - addItem(type: ConsoleLogItemType, message: string, method?: string, source: ConsoleLogItemSource = ConsoleLogItemSource.UI): void { + addItem(type: ConsoleLogItemType, message: string | JsonValue, method?: string, source: ConsoleLogItemSource = ConsoleLogItemSource.UI): void { console.log("addItem", type, message, source) + if (typeof message == "object") { + message = stringifyObject(message) + } + this.logItems$.next({ type: type, message: `${message}`, diff --git a/tsconfig.json b/tsconfig.json index 595d69fb..977c2956 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "compilerOptions": { "outDir": "./dist/out-tsc", "sourceMap": true, - "declaration": false, + "declaration": true, + "allowSyntheticDefaultImports": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true,