@@ -9,6 +9,7 @@ class ConfigContent extends React.Component {
99 this . getServerSettings = this . getServerSettings . bind ( this ) ;
1010 this . updateServerSettings = this . updateServerSettings . bind ( this ) ;
1111 this . handleServerSettingsChange = this . handleServerSettingsChange . bind ( this ) ;
12+ this . formTypeField = this . formTypeField . bind ( this ) ;
1213 this . state = {
1314 config : { } ,
1415 serverSettings : { }
@@ -49,6 +50,7 @@ class ConfigContent extends React.Component {
4950 success : ( resp ) => {
5051 if ( resp . success === true ) {
5152 this . setState ( { serverSettings : resp . data } )
53+ console . log ( this . state )
5254 }
5355 } ,
5456 error : ( xhr , status , err ) => {
@@ -74,6 +76,65 @@ class ConfigContent extends React.Component {
7476 } )
7577 }
7678
79+ formTypeField ( key , setting ) {
80+ if ( typeof setting === "number" ) {
81+ return (
82+ < input
83+ key = { key }
84+ ref = { key }
85+ id = { key }
86+ className = "form-control"
87+ defaultValue = { setting }
88+ type = "number"
89+ onChange = { this . handleServerSettingsChange . bind ( this , key ) }
90+ />
91+ )
92+ } else if ( typeof setting === "string" ) {
93+ return (
94+ < input
95+ key = { key }
96+ ref = { key }
97+ id = { key }
98+ className = "form-control"
99+ defaultValue = { setting }
100+ type = "text"
101+ onChange = { this . handleServerSettingsChange . bind ( this , key ) }
102+ />
103+ )
104+ } else if ( typeof setting === "boolean" ) {
105+ return (
106+ < select key = { key } ref = { key } id = { key } className = "form-control" onChange = { this . handleServerSettingsChange . bind ( this , key ) } >
107+ < option value = { true } > True</ option >
108+ < option value = { false } > False</ option >
109+ </ select >
110+ )
111+ } else if ( Array . isArray ( setting ) ) {
112+ return (
113+ < input
114+ key = { key }
115+ ref = { key }
116+ id = { key }
117+ className = "form-control"
118+ defaultValue = { setting }
119+ type = "password"
120+ onChange = { this . handleServerSettingsChange . bind ( this , key ) }
121+ />
122+ )
123+ } else {
124+ return (
125+ < input
126+ key = { key }
127+ ref = { key }
128+ id = { key }
129+ className = "form-control"
130+ defaultValue = { setting }
131+ type = "text"
132+ onChange = { this . handleServerSettingsChange . bind ( this , key ) }
133+ />
134+ )
135+ }
136+ }
137+
77138
78139 render ( ) {
79140 return (
@@ -108,14 +169,7 @@ class ConfigContent extends React.Component {
108169 < div className = "form-group" >
109170 < label for = { key } className = "control-label col-md-3" > { setting_key } </ label >
110171 < div className = "col-md-6" >
111- < input
112- ref = { key }
113- id = { key }
114- className = "form-control"
115- defaultValue = { setting }
116- type = "text"
117- onChange = { this . handleServerSettingsChange . bind ( this , key ) }
118- />
172+ { this . formTypeField ( key , setting ) }
119173 </ div >
120174 </ div >
121175 )
0 commit comments