File tree 7 files changed +64
-12
lines changed
7 files changed +64
-12
lines changed Original file line number Diff line number Diff line change 21
21
"@angular/platform-browser" : " ~8.2.14" ,
22
22
"@angular/platform-browser-dynamic" : " ~8.2.14" ,
23
23
"@angular/router" : " ~8.2.14" ,
24
+ "ansi_up" : " ^4.0.4" ,
24
25
"rxjs" : " ~6.4.0" ,
25
26
"tslib" : " ^1.10.0" ,
26
27
"zone.js" : " ~0.9.1"
Original file line number Diff line number Diff line change 59
59
< mat-card-subtitle >
60
60
logs
61
61
</ mat-card-subtitle >
62
- < mat-card-content >
62
+ < mat-card-content class =" logger-content " >
63
63
< mat-button-toggle-group >
64
64
< mat-button-toggle
65
65
*ngFor ="let type of selectedProject.logType "
70
70
{{ type }}
71
71
</ mat-button-toggle >
72
72
</ mat-button-toggle-group >
73
+ < div class ="dispatcher-logs ">
74
+ < div [innerHTML] ="dispatcherLogs "> </ div >
75
+ </ div >
73
76
</ mat-card-content >
74
77
</ mat-card >
75
78
< mat-card class ="notify-card ">
Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ $full-height: calc(100% - 150px);
62
62
63
63
width : 500px ;
64
64
height : $full-height ;
65
+
66
+ .logger-content {
67
+ height : calc (100% - 80px );
68
+ }
65
69
}
66
70
67
71
.notify-card {
@@ -108,6 +112,10 @@ $full-height: calc(100% - 150px);
108
112
.task-content {
109
113
@include scroll-content ;
110
114
115
+ & ::-webkit-scrollbar {
116
+ width : 0 !important ;
117
+ }
118
+
111
119
.task-item-card {
112
120
@include base-card ;
113
121
@extend .selected ;
@@ -119,3 +127,16 @@ $full-height: calc(100% - 150px);
119
127
* {
120
128
font-weight : 200 ;
121
129
}
130
+
131
+ .dispatcher-logs {
132
+ display : flex ;
133
+ flex-direction : column-reverse ;
134
+ height : calc (100% - 60px );
135
+ overflow-y : scroll ;
136
+ margin-top : 10px ;
137
+ white-space : pre-line ;
138
+
139
+ & ::-webkit-scrollbar {
140
+ width : 0 !important ;
141
+ }
142
+ }
Original file line number Diff line number Diff line change 1
1
import { Component , OnInit } from "@angular/core" ;
2
- import { WebSocketService , HttpInfo } from "src /services" ;
2
+ import { WebSocketService , HttpInfo } from "../.. /services" ;
3
3
import { HttpClient } from "@angular/common/http" ;
4
+ import AnsiUp from "ansi_up" ;
5
+ import { DomSanitizer } from "@angular/platform-browser" ;
4
6
5
7
type LogType = "docker" | "dispatcher" ;
6
8
@@ -38,7 +40,8 @@ export class PanelComponent implements OnInit {
38
40
constructor (
39
41
private websocketService : WebSocketService ,
40
42
private httpClient : HttpClient ,
41
- private httpInfo : HttpInfo
43
+ private httpInfo : HttpInfo ,
44
+ private sanitized : DomSanitizer
42
45
) { }
43
46
44
47
ngOnInit ( ) { }
@@ -66,4 +69,14 @@ export class PanelComponent implements OnInit {
66
69
get tasks ( ) {
67
70
return this . websocketService . tasks ;
68
71
}
72
+
73
+ get dispatcherLogs ( ) {
74
+ console . info (
75
+ new AnsiUp ( ) . ansi_to_html ( this . websocketService . dispatcherLogs . join ( "\n" ) )
76
+ ) ;
77
+
78
+ return this . sanitized . bypassSecurityTrustHtml (
79
+ new AnsiUp ( ) . ansi_to_html ( this . websocketService . dispatcherLogs . join ( "\n" ) )
80
+ ) ;
81
+ }
69
82
}
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ export class AuthInterceptor implements HttpInterceptor {
12
12
req : HttpRequest < any > ,
13
13
next : HttpHandler
14
14
) : Observable < HttpEvent < any > > {
15
- console . info ( "aaaaa" ) ;
15
+ const { token } = this . userService ;
16
16
17
17
return next . handle (
18
18
req . clone ( {
19
- headers : req . headers . set ( "Authentication" , this . userService . token )
19
+ headers : token ? req . headers . set ( "Authentication" , token ) : req . headers
20
20
} )
21
21
) ;
22
22
}
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ export class WebSocketService {
33
33
private conn : WebSocket ;
34
34
35
35
notifications : NotifyPayload [ ] = [ ] ;
36
- loggers : LoggerPayload [ ] = [ ] ;
36
+ dispatcherLogs : LoggerPayload [ ] = [ ] ;
37
+ dockerLogs : LoggerPayload [ ] = [ ] ;
37
38
tasks : TaskPayload [ ] = [ ] ;
38
39
39
40
constructor ( private httpInfo : HttpInfo , private httpClient : HttpClient ) {
@@ -65,17 +66,25 @@ export class WebSocketService {
65
66
return ;
66
67
}
67
68
68
- const CONTAINER_MAP = {
69
- [ EventType . LOGGER ] : this . loggers ,
70
- [ EventType . NOTIFY ] : this . notifications
71
- } ;
72
- const container = CONTAINER_MAP [ type ] ;
73
69
let result = payload ;
70
+ const LOGGER_MAP = {
71
+ [ LoggerType . DOCKER ] : this . dockerLogs ,
72
+ [ LoggerType . DISPATCHER ] : this . dispatcherLogs
73
+ } ;
74
74
75
75
if ( type === EventType . NOTIFY ) {
76
76
result . type = NOTIFY_CLASS_TYPE [ payload . type ] ;
77
+ this . notifications . push ( result ) ;
78
+
79
+ return ;
77
80
}
78
81
79
- container . push ( result ) ;
82
+ if ( type === EventType . LOGGER ) {
83
+ const { logType, content } = payload ;
84
+
85
+ LOGGER_MAP [ logType ] . push ( content ) ;
86
+
87
+ return ;
88
+ }
80
89
}
81
90
}
Original file line number Diff line number Diff line change @@ -1280,6 +1280,11 @@ ansi-styles@^3.2.1:
1280
1280
dependencies :
1281
1281
color-convert "^1.9.0"
1282
1282
1283
+ ansi_up@^4.0.4 :
1284
+ version "4.0.4"
1285
+ resolved "https://registry.npm.taobao.org/ansi_up/download/ansi_up-4.0.4.tgz#5b8c35f0b02e4476f3f18cf89c3bf48d15d054f6"
1286
+ integrity sha1-W4w18LAuRHbz8Yz4nDv0jRXQVPY=
1287
+
1283
1288
anymatch@^2.0.0 :
1284
1289
version "2.0.0"
1285
1290
resolved "https://registry.npm.taobao.org/anymatch/download/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb"
You can’t perform that action at this time.
0 commit comments