Skip to content

Commit 2b5fa85

Browse files
committed
Improved column width for the logs
1 parent 6bc5ae6 commit 2b5fa85

File tree

3 files changed

+114
-7
lines changed

3 files changed

+114
-7
lines changed

admin/src/app/logs/logs.component.css

+103-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,106 @@
1010

1111
table {
1212
width: 100%;
13-
}
13+
}
14+
15+
16+
.mat-column-date, .mat-column-level, .mat-column-origin, .mat-column-message {
17+
word-wrap: break-word !important;
18+
white-space: unset !important;
19+
flex: 0 0 auto !important;
20+
width: 25% !important;
21+
overflow-wrap: break-word;
22+
word-wrap: break-word;
23+
24+
word-break: break-word;
25+
26+
-ms-hyphens: auto;
27+
-moz-hyphens: auto;
28+
-webkit-hyphens: auto;
29+
hyphens: auto;
30+
}
31+
32+
.mat-column-date {
33+
flex: 0 0 15% !important;
34+
width: 15% !important;
35+
}
36+
37+
.mat-column-level {
38+
flex: 0 0 5% !important;
39+
width: 5% !important;
40+
}
41+
42+
.mat-column-origin {
43+
flex: 0 0 25% !important;
44+
width: 25% !important;
45+
}
46+
47+
.mat-column-message {
48+
flex: 0 0 55% !important;
49+
width: 55% !important;
50+
}
51+
52+
/*
53+
.mat-column-emailid {
54+
word-wrap: break-word !important;
55+
white-space: unset !important;
56+
flex: 0 0 25% !important;
57+
width: 25% !important;
58+
overflow-wrap: break-word;
59+
word-wrap: break-word;
60+
61+
word-break: break-word;
62+
63+
-ms-hyphens: auto;
64+
-moz-hyphens: auto;
65+
-webkit-hyphens: auto;
66+
hyphens: auto;
67+
}
68+
69+
.mat-column-contactno {
70+
word-wrap: break-word !important;
71+
white-space: unset !important;
72+
flex: 0 0 17% !important;
73+
width: 17% !important;
74+
overflow-wrap: break-word;
75+
word-wrap: break-word;
76+
77+
word-break: break-word;
78+
79+
-ms-hyphens: auto;
80+
-moz-hyphens: auto;
81+
-webkit-hyphens: auto;
82+
hyphens: auto;
83+
}
84+
85+
.mat-column-userimage {
86+
word-wrap: break-word !important;
87+
white-space: unset !important;
88+
flex: 0 0 8% !important;
89+
width: 8% !important;
90+
overflow-wrap: break-word;
91+
word-wrap: break-word;
92+
93+
word-break: break-word;
94+
95+
-ms-hyphens: auto;
96+
-moz-hyphens: auto;
97+
-webkit-hyphens: auto;
98+
hyphens: auto;
99+
}
100+
101+
.mat-column-userActivity {
102+
word-wrap: break-word !important;
103+
white-space: unset !important;
104+
flex: 0 0 10% !important;
105+
width: 10% !important;
106+
overflow-wrap: break-word;
107+
word-wrap: break-word;
108+
109+
word-break: break-word;
110+
111+
-ms-hyphens: auto;
112+
-moz-hyphens: auto;
113+
-webkit-hyphens: auto;
114+
hyphens: auto;
115+
} */

admin/src/app/logs/logs.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ng-container matColumnDef="date">
1919
<th mat-header-cell *matHeaderCellDef mat-sort-header="d"> Date </th>
20-
<td mat-cell *matCellDef="let log"> {{log.d.toLocaleString()}} </td>
20+
<td mat-cell *matCellDef="let log"> {{log.d | date: dateFormatStr}} </td>
2121
</ng-container>
2222

2323
<ng-container matColumnDef="level">

admin/src/app/logs/logs.component.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
1+
import { DatePipe, formatDate } from '@angular/common';
2+
import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core';
23
import { MatPaginator } from '@angular/material/paginator';
34
import { MatSort } from '@angular/material/sort';
45
import { MatTableDataSource } from '@angular/material/table';
@@ -12,17 +13,20 @@ import { LogEntry } from '../log-entry';
1213
})
1314
export class LogsComponent implements OnInit, AfterViewInit {
1415

16+
public readonly dateFormatStr = 'dd/MM/yyyy HH:mm:ss.SSS';
17+
pipe: DatePipe;
1518
logs: LogEntry[];
16-
dataSource: MatTableDataSource<LogEntry> = new MatTableDataSource<LogEntry>();
19+
dataSource: MatTableDataSource<LogEntry>;
1720
limit: number = 1000;
1821
@ViewChild(MatPaginator) paginator: MatPaginator;
1922
@ViewChild(MatSort) sort: MatSort;
2023

2124

22-
constructor(private api: BotApi) { }
25+
constructor(private api: BotApi,
26+
@Inject(LOCALE_ID) public locale: string) { }
2327
ngAfterViewInit(): void {
28+
this.pipe = new DatePipe(this.locale);
2429
this.refreshLogs();
25-
console.log(this.paginator);
2630
}
2731

2832
ngOnInit(): void {
@@ -44,9 +48,10 @@ export class LogsComponent implements OnInit, AfterViewInit {
4448
getClipboard(): string {
4549
let cb = ''
4650

51+
4752
if (this.logs){
4853
this.logs.forEach(l=> {
49-
cb += `${l.d.toLocaleString()} [${l.l}] [${l.o}]: ${l.t}\n`
54+
cb += `${this.pipe.transform(l.d, this.dateFormatStr)} [${l.l}] [${l.o}]: ${l.t}\n`
5055
})
5156
}
5257

0 commit comments

Comments
 (0)