File tree Expand file tree Collapse file tree 7 files changed +170
-7
lines changed
Expand file tree Collapse file tree 7 files changed +170
-7
lines changed Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react' ;
2+ import { createPortal } from 'react-dom' ;
3+
4+ interface LogMessagesProps {
5+ text : string ;
6+ children : JSX . Element | JSX . Element [ ] ;
7+ }
8+
9+ export default function LogMessages ( { text, children } : LogMessagesProps ) {
10+ const [ show , setShow ] = useState < boolean > ( false ) ;
11+
12+ return (
13+ < >
14+ < a href = '#' onClick = { ( ) => setShow ( ! show ) } >
15+ { text }
16+ </ a >
17+ { createPortal (
18+ < div
19+ className = { `log-overlay ${ show ? 'visible' : 'hidden' } ` }
20+ onClick = { ( ) => setShow ( false ) }
21+ >
22+ < div className = "bar" > { show && children } </ div >
23+ </ div > ,
24+ document . body ,
25+ 'help'
26+ ) }
27+ </ >
28+ ) ;
29+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { t, tryFormatNumber } from '../../core/util';
33import { Rrdp } from '../../types' ;
44import Duration from './Duration' ;
55import { StatusContext } from '../../hooks/useStatus' ;
6+ import LogMessages from '../LogMessages' ;
67
78type RrdpKey = keyof Rrdp ;
89
@@ -59,9 +60,18 @@ export default function RrdpTable() {
5960 { values . map ( ( [ key , rrdp ] : [ string , Rrdp ] ) => (
6061 < tr key = { key } >
6162 < th role = "column" title = { key } >
62- < a href = { key } target = "_blank" rel = "noreferrer" >
63- { key }
64- </ a >
63+ { ! rrdp . issues && < span > { key } </ span > }
64+ { rrdp . issues && < LogMessages text = { key } >
65+ < h2 > RRDP log messages</ h2 >
66+ < table className = 'log-messages' >
67+ < tbody >
68+ { rrdp . issues . map ( issue => < tr >
69+ < td > < span className = { `label ${ issue . level } ` } > { issue . level } </ span > </ td >
70+ < td > < span className = 'message' > { issue . messages } </ span > </ td >
71+ </ tr > ) }
72+ </ tbody >
73+ </ table >
74+ </ LogMessages > }
6575 </ th >
6676 < td >
6777 < Duration value = { rrdp . duration } max = { maxDuration } />
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { t, tryFormatNumber } from '../../core/util';
33import { Rsync } from '../../types' ;
44import Duration from './Duration' ;
55import { StatusContext } from '../../hooks/useStatus' ;
6+ import LogMessages from '../LogMessages' ;
67
78type RsyncKey = keyof Rsync ;
89
@@ -52,9 +53,18 @@ export default function RsyncTable() {
5253 ( [ key , rsync ] : [ string , Rsync ] ) => (
5354 < tr key = { key } >
5455 < th role = "column" title = { key } >
55- < a href = { key } target = "_blank" rel = "noreferrer" >
56- { key }
57- </ a >
56+ { ! rsync . issues && < span > { key } </ span > }
57+ { rsync . issues && < LogMessages text = { key } >
58+ < h2 > rsync log messages</ h2 >
59+ < table className = 'log-messages' >
60+ < tbody >
61+ { rsync . issues . map ( issue => < tr >
62+ < td > < span className = { `label ${ issue . level } ` } > { issue . level } </ span > </ td >
63+ < td > < span className = 'message' > { issue . messages } </ span > </ td >
64+ </ tr > ) }
65+ </ tbody >
66+ </ table >
67+ </ LogMessages > }
5868 </ th >
5969 < td >
6070 < Duration value = { rsync . duration } max = { maxDuration } />
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export function arrayToCommaSeperated(arr: string[]): string {
5454}
5555
5656export function tryFormatNumber (
57- v : string | number | boolean | null | undefined
57+ v : string | number | boolean | any | null | undefined
5858) {
5959 return Number . isInteger ( v ) ? ( v || 0 ) . toLocaleString ( 'en' ) : v ;
6060}
Original file line number Diff line number Diff line change 1212@import './prefix-check-sidebar.css' ;
1313@import './prefix-check.css' ;
1414@import './help.css' ;
15+ @import './log-messages.css' ;
Original file line number Diff line number Diff line change 1+ .log-overlay {
2+ visibility : hidden;
3+ position : fixed;
4+ left : 0 ;
5+ top : 0 ;
6+ width : 100% ;
7+ height : 100% ;
8+ background-color : rgba (0 , 0 , 0 , 0.5 );
9+ cursor : pointer;
10+ z-index : 10 ;
11+ transition : all 200ms ease-in-out;
12+ opacity : 0 ;
13+ }
14+
15+ .log-overlay .visible {
16+ visibility : visible;
17+ opacity : 1 ;
18+ }
19+
20+ .log-overlay .bar {
21+ position : absolute;
22+ right : -100% ;
23+ width : 85vw ;
24+ height : 100% ;
25+ max-width : 90% ;
26+ line-height : 1.4 ;
27+ background : var (--white );
28+ padding : 1.5rem ;
29+ color : var (--dark );
30+ overflow-y : auto;
31+ transition : all 200ms ease-in-out;
32+ }
33+
34+ .log-overlay .visible .bar {
35+ right : 0 ;
36+ }
37+
38+ .log-overlay .bar h3 ,
39+ .log-overlay .bar h2 {
40+ font-weight : 500 ;
41+ font-size : 1rem ;
42+ margin-top : 1rem ;
43+ margin-bottom : 0.5rem ;
44+ }
45+
46+ .log-overlay .bar h2 {
47+ font-size : 1.2rem ;
48+ }
49+
50+ .log-overlay .bar p {
51+ margin-bottom : 0.5rem ;
52+ }
53+
54+ .log-overlay .bar ul {
55+ list-style : disc;
56+ padding-left : 1.5rem ;
57+ margin-bottom : 1rem ;
58+ }
59+
60+
61+ .log-messages {
62+ width : 100% ;
63+ }
64+
65+ .log-messages td {
66+ padding : 0.2rem ;
67+ }
68+
69+ .log-messages td : first-child {
70+ text-align : right;
71+ }
72+
73+ .log-messages .label {
74+ border-radius : 0.2rem ;
75+ padding : 0.2rem ;
76+ font-weight : bold;
77+ }
78+
79+ .log-messages .label .TRACE {
80+ background-color : white;
81+ color : black;
82+ }
83+
84+ .log-messages .label .DEBUG {
85+ background-color : white;
86+ color : black;
87+ }
88+
89+ .log-messages .label .INFO {
90+ background-color : # 1976D2 ;
91+ color : white;
92+ }
93+
94+ .log-messages .label .WARN {
95+ background-color : # FFA000 ;
96+ color : white;
97+ }
98+
99+ .log-messages .label .ERROR {
100+ background-color : # E64A19 ;
101+ color : white;
102+ }
103+
104+ .log-messages .message {
105+ font-family : monospace;
106+ }
Original file line number Diff line number Diff line change @@ -90,11 +90,18 @@ export interface Rrdp {
9090 session ?: null | string ;
9191 delta ?: boolean ;
9292 snapshot_reason ?: null ;
93+ issues ?: Issue [ ] ;
9394}
9495
9596export interface Rsync {
9697 status : number ;
9798 duration : number ;
99+ issues : Issue [ ] ;
100+ }
101+
102+ export interface Issue {
103+ level : string ;
104+ messages : string ;
98105}
99106
100107export interface Rtr {
You can’t perform that action at this time.
0 commit comments