LocationBasedServices/mowesta/pipeline/head This commit looks good
Code base cleanup in styles.scss cityview icon display order map & log encapsulation
125 lines
4.2 KiB
TypeScript
125 lines
4.2 KiB
TypeScript
import { Component, OnInit, OnDestroy, ViewChild, DoCheck, ElementRef, ViewEncapsulation } from '@angular/core';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import { DataSource } from '@angular/cdk/table';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { LogMessage } from '../api';
|
|
import { LogDialogComponent } from '../dialogs/log-dialog.component';
|
|
import { TableColumn, TableHandler } from '../utils/tables';
|
|
import { ManageLogService } from '../services/manage-log.service';
|
|
import { ResourceService } from '../services/resource.service';
|
|
import { NgStyle, AsyncPipe, DatePipe } from '@angular/common';
|
|
import { MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow } from '@angular/material/table';
|
|
import { MatProgressBar } from '@angular/material/progress-bar';
|
|
import { MatTooltip } from '@angular/material/tooltip';
|
|
import { MatIconButton } from '@angular/material/button';
|
|
import { MatIcon } from '@angular/material/icon';
|
|
import { MatToolbar } from '@angular/material/toolbar';
|
|
|
|
@Component({
|
|
selector: 'app-manage-log',
|
|
templateUrl: './manage-log.component.html',
|
|
standalone: true,
|
|
encapsulation: ViewEncapsulation.None,
|
|
styleUrl: 'manage-log.component.scss',
|
|
imports: [MatToolbar, MatIcon, MatIconButton, MatTooltip, MatProgressBar, MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, NgStyle, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow, AsyncPipe, DatePipe]
|
|
})
|
|
export class ManageLogComponent implements OnInit, OnDestroy, DoCheck {
|
|
|
|
private static COLUMNS: TableColumn[] = [
|
|
{ name: 'id', dropPriority: 1, width: 80, fixedWidth: true },
|
|
{ name: 'time', dropPriority: 3, width: 170, fixedWidth: true },
|
|
{ name: 'level', dropPriority: 0, width: 70, fixedWidth: true },
|
|
{ name: 'thread', dropPriority: 4, width: 50, fixedWidth: true },
|
|
{ name: 'className', dropPriority: 5, width: 220, fixedWidth: true },
|
|
{ name: 'message', dropPriority: 0, width: 200 },
|
|
{ name: 'trace', dropPriority: 2, width: 60, fixedWidth: true },
|
|
{ name: 'actions', dropPriority: 0, width: 80, fixedWidth: true }
|
|
];
|
|
|
|
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
|
|
|
readonly connecting: BehaviorSubject<boolean>;
|
|
readonly dataSource: DataSource<LogMessage>;
|
|
connected: boolean;
|
|
|
|
private tableHandler: TableHandler;
|
|
|
|
constructor(public res: ResourceService, private logService: ManageLogService, private dialog: MatDialog) {
|
|
this.connecting = logService.connecting;
|
|
this.dataSource = logService;
|
|
}
|
|
|
|
ngDoCheck(): void {
|
|
this.tableHandler.onCheck();
|
|
}
|
|
|
|
getStyle(column: string): any {
|
|
return this.tableHandler.getColumnStyle(column);
|
|
}
|
|
|
|
getColumns(): string[] {
|
|
return this.tableHandler.getDisplayColumns();
|
|
}
|
|
|
|
|
|
ngOnInit() {
|
|
this.tableHandler = new TableHandler(this.table, ManageLogComponent.COLUMNS);
|
|
this.logService.open();
|
|
this.connected = true;
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
this.connected = false;
|
|
this.logService.close();
|
|
}
|
|
|
|
onConnect(): void {
|
|
this.connected = true;
|
|
this.logService.close();
|
|
this.logService.open();
|
|
}
|
|
|
|
onDisconnect(): void {
|
|
this.connected = false;
|
|
this.logService.close();
|
|
}
|
|
|
|
onClear(): void {
|
|
this.logService.clear();
|
|
}
|
|
|
|
getClassName(name: string) {
|
|
const idx = name.lastIndexOf('.');
|
|
if (idx === -1) {
|
|
return name;
|
|
} else {
|
|
return name.substring(idx + 1);
|
|
}
|
|
}
|
|
|
|
getLevel(level: string) {
|
|
if (level === 'ERROR') {
|
|
return 'error';
|
|
} else if (level === 'SEVERE') {
|
|
return 'error_outline';
|
|
} else if (level === 'INFO') {
|
|
return 'info_outline';
|
|
} else {
|
|
return 'panorama_fish_eye';
|
|
}
|
|
}
|
|
|
|
getColor(level: string): boolean {
|
|
if (level === 'ERROR' || level === 'SEVERE') {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
onShow(message: LogMessage): void {
|
|
LogDialogComponent.open(this.dialog, message);
|
|
}
|
|
|
|
}
|