@@ -6,19 +6,47 @@ import { Observable as obs } from 'rxjs';
66import rels from 'stream-store/rels' ;
77import store from 'stream-store/store' ;
88import { HalResource } from 'types' ;
9+ import { clientVersion } from 'utils' ;
910import { HalViewerProps } from './types' ;
1011
1112const provider$ = store . hal$ . body$ . map ( ( { provider } ) => provider ) ;
1213
1314const versions$ = store . hal$ . body$ . map ( ( { versions } ) => versions ) ;
1415
16+ const info$ = provider$ . zip ( versions$ ) . map ( ( [ provider , versions ] ) =>
17+ [
18+ {
19+ id : 'Provider' ,
20+ value : inflector . camel2words (
21+ inflector . underscore ( provider ) ,
22+ ) as string ,
23+ } ,
24+ ]
25+ . concat (
26+ Object . keys ( versions ) . map ( key => ( {
27+ id : `${ inflector . camel2words (
28+ inflector . underscore ( key ) ,
29+ ) } Version`,
30+ value : versions [ key ] as string ,
31+ } ) ) ,
32+ )
33+ . concat ( {
34+ id : 'Client Version' ,
35+ value : clientVersion as string ,
36+ } ) ,
37+ ) ;
38+
1539interface RecentState {
1640 recent : HalResource [ ] ;
1741}
1842
43+ interface InfoLineProps {
44+ id : string ;
45+ value : string ;
46+ }
47+
1948interface InfoState {
20- provider : string ;
21- versions : { [ key : string ] : string } ;
49+ info : InfoLineProps [ ] ;
2250}
2351
2452interface IndexState extends RecentState , InfoState { }
@@ -29,50 +57,39 @@ const recent$ = store.hal$.body$.map(
2957
3058const state$ = createState < IndexState > (
3159 obs . merge (
32- provider$ . map ( provider => [ 'provider' , ( ) => provider ] ) ,
33- versions$ . map ( versions => [ 'versions' , ( ) => versions ] ) ,
60+ info$ . map ( info => [ 'info' , ( ) => info ] ) ,
3461 recent$ . map ( recent => [ 'recent' , ( ) => recent ] ) ,
3562 ) ,
36- obs . of < IndexState > ( { recent : [ ] , provider : '' , versions : { } } ) ,
63+ obs . of < IndexState > ( { recent : [ ] , info : [ ] } ) ,
3764) ;
3865
39- const Info : StatelessComponent < InfoState > = ( { provider, versions } ) => (
66+ const InfoLine : StatelessComponent < InfoLineProps > = ( { id, value } ) => (
67+ < Table . Row >
68+ < Table . Cell >
69+ < strong > { id } </ strong >
70+ </ Table . Cell >
71+ < Table . Cell > { value } </ Table . Cell >
72+ </ Table . Row >
73+ ) ;
74+
75+ const Info : StatelessComponent < InfoState > = ( { info } ) => (
4076 < Table >
4177 < Table . Head >
4278 < Table . Row >
4379 < Table . Cell colSpan = { 2 } > { 'Server Information' } </ Table . Cell >
4480 </ Table . Row >
4581 </ Table . Head >
4682 < Table . Body >
47- < Table . Row >
48- < Table . Cell >
49- < strong > { 'Provider' } </ strong >
50- </ Table . Cell >
51- < Table . Cell >
52- { inflector . camel2words ( inflector . underscore ( provider ) ) }
53- </ Table . Cell >
54- </ Table . Row >
55- { Object . keys ( versions ) . map ( key => (
56- < Table . Row key = { key } >
57- < Table . Cell >
58- < strong >
59- { inflector . camel2words ( inflector . underscore ( key ) ) } { ' ' }
60- { 'Version' }
61- </ strong >
62- </ Table . Cell >
63- < Table . Cell > { versions [ key ] } </ Table . Cell >
64- </ Table . Row >
83+ { info . map ( ( { id, value } ) => (
84+ < InfoLine key = { id } id = { id } value = { value } />
6585 ) ) }
6686 </ Table . Body >
6787 </ Table >
6888) ;
6989
70- const Index : ComponentType < IndexState & HalViewerProps > = ( {
71- provider,
72- versions,
73- } ) => (
90+ const Index : ComponentType < IndexState & HalViewerProps > = ( { info } ) => (
7491 < section >
75- < Info provider = { provider } versions = { versions } />
92+ < Info info = { info } />
7693 </ section >
7794) ;
7895
0 commit comments