1
- import React , { useEffect , useState } from " react" ;
2
- import { useDispatch } from " react-redux" ;
3
- import { buildOptionsObj } from " ../helper/processLogHelper" ;
4
- import { getLogs } from " ../helper/commands" ;
5
- import * as actions from " ../../redux/actions/actions" ;
6
- import " ./ProcessLogsCard" ;
1
+ import React , { useEffect , useState } from ' react' ;
2
+ import { useDispatch } from ' react-redux' ;
3
+ import { buildOptionsObj } from ' ../helper/processLogHelper' ;
4
+ import { getLogs } from ' ../helper/commands' ;
5
+ import * as actions from ' ../../redux/actions/actions' ;
6
+ import ' ./ProcessLogsCard' ;
7
7
8
- import store from " ../../renderer/store" ;
9
- import { DataGrid } from " @mui/x-data-grid" ;
10
- import { Checkbox , FormControlLabel , FormGroup , Button } from " @mui/material" ; // use for container selection
11
- import { CSVLink } from " react-csv" ;
8
+ import store from ' ../../renderer/store' ;
9
+ import { DataGrid } from ' @mui/x-data-grid' ;
10
+ import { Checkbox , FormControlLabel , FormGroup , Button } from ' @mui/material' ; // use for container selection
11
+ import { CSVLink } from ' react-csv' ;
12
12
13
13
/**
14
14
* Displays process logs as table
@@ -24,7 +24,7 @@ const ProcessLogsTable = () => {
24
24
25
25
// grab clicked container
26
26
const urlString = window . location . href ;
27
- const containerID = urlString . split ( "/" ) ;
27
+ const containerID = urlString . split ( '/' ) ;
28
28
const id = containerID [ containerID . length - 1 ] ;
29
29
30
30
// access runningList from state
@@ -34,7 +34,7 @@ const ProcessLogsTable = () => {
34
34
const [ rows , setRows ] = useState ( [ ] ) ;
35
35
36
36
const [ csvData , setCsvData ] = useState ( [
37
- [ " container" , " type" , " time" , " message" ] ,
37
+ [ ' container' , ' type' , ' time' , ' message' ] ,
38
38
] ) ;
39
39
40
40
const [ logs , setLogs ] = useState ( { stdout : [ ] , stderr : [ ] } ) ;
@@ -61,10 +61,10 @@ const ProcessLogsTable = () => {
61
61
} ;
62
62
63
63
const columns = [
64
- { field : " container" , headerName : " Container" , width : 150 } ,
65
- { field : " type" , headerName : " Log Type" , width : 120 } ,
66
- { field : " time" , headerName : " Timestamp" , width : 200 } ,
67
- { field : " message" , headerName : " Message" , width : 550 } ,
64
+ { field : ' container' , headerName : ' Container' , width : 150 } ,
65
+ { field : ' type' , headerName : ' Log Type' , width : 120 } ,
66
+ { field : ' time' , headerName : ' Timestamp' , width : 200 } ,
67
+ { field : ' message' , headerName : ' Message' , width : 550 } ,
68
68
] ;
69
69
70
70
const createContainerCheckboxes = ( currId : string ) => {
@@ -142,34 +142,34 @@ const ProcessLogsTable = () => {
142
142
if ( stdout ) {
143
143
stdout . forEach ( ( log , index ) => {
144
144
const currCont = runningList . find (
145
- ( el ) => el . ID === log [ " containerName" ]
145
+ ( el ) => el . ID === log [ ' containerName' ]
146
146
) ;
147
147
newRows . push ( {
148
148
container : currCont . Name ,
149
- type : " stdout" ,
150
- time : log [ " timeStamp" ] ,
151
- message : log [ " logMsg" ] ,
149
+ type : ' stdout' ,
150
+ time : log [ ' timeStamp' ] ,
151
+ message : log [ ' logMsg' ] ,
152
152
id : Math . random ( ) * 100 ,
153
153
} ) ;
154
- newCSV . push ( [ currCont . Name , " stdout" , log [ " timeStamp" ] , log [ " logMsg" ] ] ) ;
154
+ newCSV . push ( [ currCont . Name , ' stdout' , log [ ' timeStamp' ] , log [ ' logMsg' ] ] ) ;
155
155
} ) ;
156
156
157
157
stderr . forEach ( ( log , index ) => {
158
158
const currCont = runningList . find (
159
- ( el ) => el . ID === log [ " containerName" ]
159
+ ( el ) => el . ID === log [ ' containerName' ]
160
160
) ;
161
161
newRows . push ( {
162
162
container : currCont . Name ,
163
- type : " stderr" ,
164
- time : log [ " timeStamp" ] ,
165
- message : log [ " logMsg" ] ,
163
+ type : ' stderr' ,
164
+ time : log [ ' timeStamp' ] ,
165
+ message : log [ ' logMsg' ] ,
166
166
id : parseInt ( `stderr ${ index } ` ) ,
167
167
} ) ;
168
- newCSV . push ( [ currCont . Name , " stderr" , log [ " timeStamp" ] , log [ " logMsg" ] ] ) ;
168
+ newCSV . push ( [ currCont . Name , ' stderr' , log [ ' timeStamp' ] , log [ ' logMsg' ] ] ) ;
169
169
} ) ;
170
170
171
171
setRows ( newRows as keyof typeof setRows ) ;
172
- setCsvData ( [ [ " container" , " type" , " time" , " message" ] , ...newCSV ] ) ;
172
+ setCsvData ( [ [ ' container' , ' type' , ' time' , ' message' ] , ...newCSV ] ) ;
173
173
}
174
174
} ;
175
175
@@ -178,30 +178,54 @@ const ProcessLogsTable = () => {
178
178
< div className = "settings-container" >
179
179
< form >
180
180
< h1 style = { { margin : 10 } } > Container Process Logs</ h1 >
181
-
181
+ < h3 >
182
+ < a
183
+ style = { { margin : 5 } }
184
+ target = "_blank"
185
+ rel = "noreferrer"
186
+ href = "https://docs.docker.com/engine/reference/commandline/logs/"
187
+ >
188
+ Click here
189
+ </ a > { '' }
190
+ for more information on logs
191
+ </ h3 >
192
+ < br > </ br >
182
193
< input
183
194
style = { { margin : 5 } }
184
195
type = "radio"
185
196
id = "sinceInput"
186
197
name = "logOption"
187
198
/>
188
- < label style = { { margin : 5 } } htmlFor = "sinceInput" >
199
+ < label
200
+ style = { { margin : 5 } }
201
+ htmlFor = "sinceInput"
202
+ >
189
203
Since
190
204
</ label >
191
- < input type = "text" id = "sinceText" />
205
+ < input
206
+ type = "text"
207
+ id = "sinceText"
208
+ />
192
209
< br > </ br >
193
210
< input
194
211
style = { { margin : 5 } }
195
212
type = "radio"
196
213
id = "tailInput"
197
214
name = "logOption"
198
215
/>
199
- < label style = { { margin : 5 } } htmlFor = "tailInput" >
216
+ < label
217
+ style = { { margin : 5 } }
218
+ htmlFor = "tailInput"
219
+ >
200
220
Tail
201
221
</ label >
202
- < input style = { { marginLeft : 14 } } type = "text" id = "tailText" />
222
+ < input
223
+ style = { { marginLeft : 14 } }
224
+ type = "text"
225
+ id = "tailText"
226
+ />
203
227
204
- < FormGroup style = { { display : " flex" , flexDirection : " row" } } >
228
+ < FormGroup style = { { display : ' flex' , flexDirection : ' row' } } >
205
229
{ containerSelectors } { /** Checkboxes for running containers */ }
206
230
</ FormGroup >
207
231
< Button
@@ -230,9 +254,9 @@ const ProcessLogsTable = () => {
230
254
>
231
255
< CSVLink
232
256
style = { {
233
- textDecoration : " none" ,
234
- color : " white" ,
235
- fontFamily : " Roboto, Helvetica, Arial, sans-serif" ,
257
+ textDecoration : ' none' ,
258
+ color : ' white' ,
259
+ fontFamily : ' Roboto, Helvetica, Arial, sans-serif' ,
236
260
} }
237
261
data = { csvData }
238
262
>
@@ -243,16 +267,16 @@ const ProcessLogsTable = () => {
243
267
244
268
< div
245
269
className = "process-logs-container"
246
- style = { { height : 660 , width : " 100%" } }
270
+ style = { { height : 660 , width : ' 100%' } }
247
271
>
248
272
< DataGrid
249
273
key = "DataGrid"
250
274
rows = { rows }
251
275
columns = { columns }
252
- getRowHeight = { ( ) => " auto" }
276
+ getRowHeight = { ( ) => ' auto' }
253
277
initialState = { {
254
278
sorting : {
255
- sortModel : [ { field : " time" , sort : " desc" } ] , // default sorts table by time
279
+ sortModel : [ { field : ' time' , sort : ' desc' } ] , // default sorts table by time
256
280
} ,
257
281
} }
258
282
/>
0 commit comments