@@ -256,6 +256,9 @@ const getComponent = (
256256 } }
257257 value = { value != null ? value : getIn ( directConf , com . field , "" ) }
258258 onChange = { ( e ) => {
259+ updateConfiguration ( forceField || com . field , e . target . value , layer ) ;
260+ } }
261+ onBlur = { ( e ) => {
259262 let v = e . target . value ;
260263 // remove surrounding whitespace, " hi " -> "hi"
261264 if ( typeof v === "string" ) v = v . trim ( ) ;
@@ -280,6 +283,39 @@ const getComponent = (
280283 ) }
281284 </ div >
282285 ) ;
286+ case "textnotrim" :
287+ inner = (
288+ < TextField
289+ className = { c . text }
290+ label = { com . name }
291+ variant = "filled"
292+ size = "small"
293+ inputProps = { {
294+ autoComplete : "off" ,
295+ } }
296+ value = { value != null ? value : getIn ( directConf , com . field , "" ) }
297+ onChange = { ( e ) => {
298+ updateConfiguration ( forceField || com . field , e . target . value , layer ) ;
299+ } }
300+ />
301+ ) ;
302+ return (
303+ < div >
304+ { inlineHelp ? (
305+ < >
306+ { inner }
307+ < div
308+ className = { c . subtitle2 }
309+ dangerouslySetInnerHTML = { { __html : com . description || "" } }
310+ > </ div >
311+ </ >
312+ ) : (
313+ < Tooltip title = { com . description || "" } placement = "top" arrow >
314+ { inner }
315+ </ Tooltip >
316+ ) }
317+ </ div >
318+ ) ;
283319 case "button" :
284320 inner = (
285321 < Button
@@ -685,31 +721,96 @@ const getComponent = (
685721 </ FormControl >
686722 ) ;
687723
724+ let domain =
725+ window . mmgisglobal . NODE_ENV === "development"
726+ ? "http://localhost:8888/"
727+ : window . mmgisglobal . ROOT_PATH || "" ;
728+ if ( domain . length > 0 && ! domain . endsWith ( "/" ) ) domain += "/" ;
729+
730+ let colormap_html
731+ if ( window . mmgisglobal . WITH_TITILER === "true" ) {
732+ // Get colors from TiTiler if it is available
733+ colormap_html = (
734+ < div style = { { width : "100%" } } >
735+ < img id = "titlerCogColormapImage" style = { { height : "20px" , width : "100%" } } src = { `${ domain } titiler/colorMaps/${ dropdown_value . toLowerCase ( ) } ?format=png` } />
736+ </ div >
737+ )
738+ } else {
739+ let colormap = dropdown_value
740+ // js-colormaps data object only contains the non reversed color so we need to track if the color is reversed
741+ let reverse = false
742+
743+ // TiTiler colormap variables are all lower case so we need to format them correctly for js-colormaps
744+ if ( colormap . toLowerCase ( ) . endsWith ( '_r' ) ) {
745+ colormap = colormap . substring ( 0 , colormap . length - 2 )
746+ reverse = true
747+ }
748+
749+ let index = Object . keys ( colormapData ) . findIndex ( v => {
750+ return v . toLowerCase ( ) === colormap . toLowerCase ( ) ;
751+ } ) ;
752+
753+ if ( index > - 1 ) {
754+ colormap = Object . keys ( colormapData ) [ index ]
755+ } else {
756+ console . warn ( `The colormap '${ colormap } ' does not exist` ) ;
757+ }
758+
759+ if ( colormap in colormapData ) {
760+ colormap_html = colormapData [ colormap ] . colors . map (
761+ ( hex ) => {
762+ return (
763+ < div
764+ className = { c . colorDropdownArrayHex }
765+ style = { { background : `rgb(${ hex . map ( v => { return Math . floor ( v * 255 ) } ) . join ( ',' ) } )` } }
766+ > </ div >
767+ ) ;
768+ }
769+ )
770+
771+ if ( reverse === true ) {
772+ colormap_html . reverse ( )
773+ }
774+ } else if ( colormap === 'DEFAULT' ) {
775+ // Default color for velocity layer
776+ const defaultColors = [
777+ 'rgb(36,104, 180)' ,
778+ 'rgb(60,157, 194)' ,
779+ 'rgb(128,205,193 )' ,
780+ 'rgb(151,218,168 )' ,
781+ 'rgb(198,231,181)' ,
782+ 'rgb(238,247,217)' ,
783+ 'rgb(255,238,159)' ,
784+ 'rgb(252,217,125)' ,
785+ 'rgb(255,182,100)' ,
786+ 'rgb(252,150,75)' ,
787+ 'rgb(250,112,52)' ,
788+ 'rgb(245,64,32)' ,
789+ 'rgb(237,45,28)' ,
790+ 'rgb(220,24,32)' ,
791+ 'rgb(180,0,35)' ,
792+ ]
793+
794+ colormap_html = defaultColors . map (
795+ ( hex ) => {
796+ return (
797+ < div
798+ className = { c . colorDropdownArrayHex }
799+ style = { { background : `${ hex } ` } }
800+ > </ div >
801+ ) ;
802+ }
803+ )
804+ }
805+ }
806+
688807 return (
689808 < div >
690809 { inlineHelp ? (
691810 < >
692811 { inner }
693812 < div className = { c . textArrayHexes } >
694- { typeof dropdown_value === "string"
695- ? colormapData [ dropdown_value ] &&
696- colormapData [ dropdown_value ] . colors
697- ? colormapData [ dropdown_value ] . colors . map ( ( hex ) => {
698- return (
699- < div
700- className = { c . colorDropdownArrayHex }
701- style = { {
702- background : `rgb(${ hex
703- . map ( ( v ) => {
704- return Math . floor ( v * 255 ) ;
705- } )
706- . join ( "," ) } )`,
707- } }
708- > </ div >
709- ) ;
710- } )
711- : null
712- : null }
813+ { colormap_html || null }
713814 </ div >
714815 < Typography className = { c . subtitle2 } >
715816 { com . description || "" }
0 commit comments