Skip to content

Commit

Permalink
log console
Browse files Browse the repository at this point in the history
  • Loading branch information
garrylachman committed Dec 13, 2020
1 parent 1d61cb8 commit 193b119
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/app/app.component.scss
Expand Up @@ -61,7 +61,6 @@ h5#active-account {


nb-layout-footer {
z-index: 9999999;
position: sticky;
bottom: 0;

Expand Down
12 changes: 7 additions & 5 deletions src/app/components/log-console/log-console.component.html
Expand Up @@ -9,10 +9,10 @@ <h6 class="mt-auto mb-auto">Console Log</h6>
nbInfiniteList
listenWindowScroll
[ngClass]="{'d-none': isMinimized}"
class="mt-3 scrollable"
class="mt-3 scrollable scrollable-container"
>

<nb-list-item *ngFor="let logItem of logItems" class="pl-0 pb-2 pt-2" (click)="toggleClass($event,'format')">
<nb-list-item *ngFor="let logItem of logItems" class="pl-0 pb-2 pt-2 d-flex justify-content-between" (click)="toggleClass($event,'format')" nbTooltip="Click to Pretty Print" nbTooltipIcon="info" nbTooltipAdjustment="horizontal" nbTooltipPlacement="left" nbTooltipStatus="basic" >
<ng-container [ngSwitch]="logItem.type">

<nb-alert *ngSwitchCase="logTypes.error" class="w-100 mb-0" accent="danger">
Expand All @@ -34,9 +34,11 @@ <h6 class="mt-auto mb-auto">Console Log</h6>
</nb-alert>

<ng-container *ngSwitchDefault>
<nb-badge class="mr-2" text="{{logItem.sourceName}}" status="success"></nb-badge>
<nb-badge *ngIf="logItem.method" class="mr-2" position=" end" text="{{logItem.method}}" status="primary"></nb-badge>
{{logItem.message}}
<div>{{logItem.message}}</div>
<div class="mb-auto pl-3">
<nb-badge class="mr-2" text="{{logItem.sourceName}}" status="success"></nb-badge>
<nb-badge *ngIf="logItem.method" position=" end" text="{{logItem.method}}" status="primary"></nb-badge>
</div>
</ng-container>

</ng-container>
Expand Down
6 changes: 5 additions & 1 deletion 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;
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/ipc/accounts.service.ts
Expand Up @@ -24,7 +24,7 @@ export class AccountsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand All @@ -33,7 +33,7 @@ export class AccountsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(rawRes),
rawRes,
getCurrentLine().method
)

Expand All @@ -49,15 +49,15 @@ export class AccountsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

const rawRes:any = await ipcRenderer.invoke(IPCConnect.CHANNEL, req.toJsonValue());

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(rawRes),
rawRes,
getCurrentLine().method
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/services/ipc/queries.ipc.service.ts
Expand Up @@ -22,7 +22,7 @@ export class QueriesIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand Down
17 changes: 8 additions & 9 deletions src/app/services/ipc/views.ipc.service.ts
Expand Up @@ -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({
Expand All @@ -29,7 +28,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(rawRes),
rawRes,
getCurrentLine().method
)

Expand All @@ -44,7 +43,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand All @@ -53,7 +52,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(rawRes),
rawRes,
getCurrentLine().method
)

Expand Down Expand Up @@ -87,7 +86,7 @@ export class ViewsIPCService {
console.log("req", req);
this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand All @@ -110,7 +109,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand All @@ -131,7 +130,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand All @@ -152,7 +151,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand Down Expand Up @@ -184,7 +183,7 @@ export class ViewsIPCService {

this.logConsoleService.addItem(
ConsoleLogItemType.info,
JSON.stringify(req.toJsonValue()),
req.toJsonValue(),
getCurrentLine().method
)

Expand Down
8 changes: 7 additions & 1 deletion src/app/services/log-console.service.ts
Expand Up @@ -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'
Expand All @@ -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}`,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -8,7 +8,8 @@
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"declaration": true,
"allowSyntheticDefaultImports": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand Down

0 comments on commit 193b119

Please sign in to comment.