@@ -14,6 +14,28 @@ import TablePagination from '@mui/material/TablePagination';
14
14
import { statusToColor , severityToLabel , statusToLabel , severityToColor } from './mappings' ;
15
15
16
16
function unsafe_format ( obj ) {
17
+ // PJS003 -> Invalid characters in GUID
18
+ if ( typeof obj == 'object' && 'invalid_guid_chars' in obj && 'expected_or_observed' in obj ) {
19
+ if ( obj . expected_or_observed === 'expected' ) {
20
+ return < span > { `One of the following characters: ${ obj . invalid_guid_chars } ` } </ span > ;
21
+ } else if ( obj . expected_or_observed === 'observed' && 'inst' in obj ) {
22
+ return (
23
+ < span >
24
+ { `For guid '${ obj . inst } ', the following invalid character(s) is/were found: ${ obj . invalid_guid_chars } ` }
25
+ </ span >
26
+ ) ;
27
+ }
28
+ }
29
+
30
+ // PJS003 -> invalid length
31
+ if ( typeof obj == 'object' && 'length' in obj && 'expected_or_observed' in obj ) {
32
+ if ( obj . expected_or_observed === 'expected' ) {
33
+ return < span > { `A sequence of length ${ obj . length } for the global ID` } </ span > ;
34
+ } else if ( obj . expected_or_observed === 'observed' && 'inst' in obj ) {
35
+ return < span > { `The guid '${ obj . inst } ' is a sequence of length ${ obj . length } ` } </ span > ;
36
+ }
37
+ }
38
+
17
39
if ( typeof obj == 'object' && 'value' in obj ) {
18
40
if ( typeof obj . value === 'string' || obj . value instanceof String || typeof obj . value === 'number' || typeof obj . value === 'boolean' ) {
19
41
return < span style = { { background : '#00000010' , padding : '3px' } } > { obj . value } </ span >
@@ -23,34 +45,34 @@ function unsafe_format(obj) {
23
45
} else if ( typeof obj === 'string' || obj instanceof String ) {
24
46
return < i > { obj } </ i > ;
25
47
} else if ( typeof obj == 'object' && 'instance' in obj ) {
26
- // @todo turn into actual instance in DB
27
48
return < span style = { { padding : '3px' , borderBottom : 'dotted 3px gray' } } > { obj . instance } </ span >
28
49
} else if ( typeof obj == 'object' && 'entity' in obj ) {
29
- // @todo actual URL for schema
30
50
var entity = obj . entity . split ( '(#' ) [ 0 ] ;
31
51
return < a href = { `https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/${ entity } .htm` } > { entity } </ a >
32
52
} else if ( typeof obj == 'object' && 'oneOf' in obj ) {
33
- let ctx = obj . context ? `${ obj . context . charAt ( 0 ) . toUpperCase ( ) } ${ obj . context . slice ( 1 ) } one of:` : `One of:`
34
- return < div > { ctx } < div > </ div > < ul > { obj . oneOf . map ( v => < li > { v } </ li > ) } </ ul > </ div >
35
- } else if ( typeof obj == 'object' && 'num_digits' in obj ) {
36
- // custom formatting for calculated alignment consistency (e.g. ALS016, ALS017, ALS018)
37
- let ctx = obj . context ? `${ obj . context . charAt ( 0 ) . toUpperCase ( ) } ${ obj . context . slice ( 1 ) } :` : `One of:`
53
+ let ctx = obj . context ? `${ obj . context . charAt ( 0 ) . toUpperCase ( ) } ${ obj . context . slice ( 1 ) } one of:` : `One of:` ;
54
+ return < div > { ctx } < div > </ div > < ul > { obj . oneOf . map ( v => < li > { v } </ li > ) } </ ul > </ div > ;
55
+ } else if ( typeof obj == 'object' && 'num_digits' in obj ) {
56
+ // Custom formatting for calculated alignment consistency
57
+ let ctx = obj . context ? `${ obj . context . charAt ( 0 ) . toUpperCase ( ) } ${ obj . context . slice ( 1 ) } :` : `One of:` ;
38
58
let value = obj . expected || obj . observed ;
39
59
let display_value = value . toExponential ( obj . num_digits ) ;
40
60
if ( 'continuity_details' in obj ) {
41
61
let dts = obj . continuity_details ;
42
- return < div >
43
- < div > { ctx } { display_value } </ div >
44
- < div > at end of { dts . previous_segment } </ div >
45
- < ul > Coords: ({ dts . preceding_end_point [ 0 ] } , { dts . preceding_end_point [ 1 ] } )</ ul >
46
- < ul > Tangent Direction: { dts . preceding_end_direction } </ ul >
47
- < br />
48
- < div > and start of { dts . segment_to_analyze } </ div >
49
- < ul > Coords: ({ dts . current_start_point [ 0 ] } , { dts . current_start_point [ 1 ] } )</ ul >
50
- < ul > Tangent Direction: { dts . current_start_direction } </ ul >
51
- </ div >
62
+ return (
63
+ < div >
64
+ < div > { ctx } { display_value } </ div >
65
+ < div > at end of { dts . previous_segment } </ div >
66
+ < ul > Coords: ({ dts . preceding_end_point [ 0 ] } , { dts . preceding_end_point [ 1 ] } )</ ul >
67
+ < ul > Tangent Direction: { dts . preceding_end_direction } </ ul >
68
+ < br />
69
+ < div > and start of { dts . segment_to_analyze } </ div >
70
+ < ul > Coords: ({ dts . current_start_point [ 0 ] } , { dts . current_start_point [ 1 ] } )</ ul >
71
+ < ul > Tangent Direction: { dts . current_start_direction } </ ul >
72
+ </ div >
73
+ ) ;
52
74
} else {
53
- return < div > { ctx } { display_value } </ div >
75
+ return < div > { ctx } { display_value } </ div > ;
54
76
}
55
77
} else {
56
78
return JSON . stringify ( obj ) ;
0 commit comments