@ -8,7 +8,9 @@ import {
getDebugLog ,
getPeersList ,
addPeerNode ,
getAppConfig
getAppConfig ,
saveAppConfig ,
getAppInfo
} from '../../actions/actionCreators' ;
import Store from '../../store' ;
import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto' ;
@ -30,6 +32,7 @@ class Settings extends React.Component {
debugLinesCount : 10 ,
debugTarget : 'iguana' ,
activeTabHeight : '10px' ,
appSettings : [ ] ,
} ;
this . exportWifKeys = this . exportWifKeys . bind ( this ) ;
this . updateInput = this . updateInput . bind ( this ) ;
@ -44,12 +47,16 @@ class Settings extends React.Component {
componentDidMount ( ) {
Store . dispatch ( iguanaActiveHandle ( ) ) ;
Store . dispatch ( getAppConfig ( ) ) ;
Store . dispatch ( getAppInfo ( ) ) ;
}
_ saveAppConfig ( ) {
Store . dispatch ( saveAppConfig ) ;
}
openTab ( elemId , tab ) {
console . log ( elemId ) ;
const _ height = document . querySelector ( '#' + elemId + ' .panel-collapse .panel-body' ) . clientHeight ;
console . log ( _ height ) ;
const _ height = document . querySelector ( '#' + elemId + ' .panel-collapse .panel-body' ) . offsetHeight ;
this . setState ( Object . assign ( { } , this . state , {
activeTab : tab ,
activeTabHeight : _ height ,
@ -96,6 +103,88 @@ class Settings extends React.Component {
}
}
renderAppInfoTab ( ) {
const releaseInfo = this . props . Settings . appInfo && this . props . Settings . appInfo . releaseInfo ;
if ( releaseInfo ) {
return (
< div className = "panel" id = "AppInfo" >
< div className = "panel-heading" role = "tab" onClick = { ( ) => this . openTab ( 'AppInfo' , 8 ) } >
< a className = { this . state . activeTab === 8 ? 'panel-title' : 'panel-title collapsed' } data - toggle = "collapse" data - parent = "#AppInfoAccordion" >
< i className = "icon md-info" aria - hidden = "true" > < / i > A p p I n f o
< / a >
< / d i v >
< div className = { this . state . activeTab === 8 ? 'panel-collapse collapse in' : 'panel-collapse collapse' } style = { { height : this . state . activeTab === 8 ? this . state . activeTabHeight + 'px' : '10px' } } aria - labelledby = "DebugLog" role = "tabpanel" >
< div className = "panel-body" >
< div className = "col-sm-12" style = { { paddingTop : '15px' } } >
< div className = "row" >
< h5 > App Release < / h 5 >
< div >
Name : { this . props . Settings . appInfo . releaseInfo . name }
< / d i v >
< div >
Version : { this . props . Settings . appInfo . releaseInfo . version }
< / d i v >
< / d i v >
< / d i v >
< div className = "col-sm-12" style = { { paddingTop : '20px' } } >
< div className = "row" >
< h5 > System Info < / h 5 >
< div >
Architecture : { this . props . Settings . appInfo . sysInfo . arch }
< / d i v >
< div >
OS Type : { this . props . Settings . appInfo . sysInfo . os_type }
< / d i v >
< div >
OS Platfrom : { this . props . Settings . appInfo . sysInfo . platform }
< / d i v >
< div >
OS Release : { this . props . Settings . appInfo . sysInfo . os_release }
< / d i v >
< div >
CPU : { this . props . Settings . appInfo . sysInfo . cpu }
< / d i v >
< div >
CPU Cores : { this . props . Settings . appInfo . sysInfo . cpu_cores }
< / d i v >
< div >
Memory : { this . props . Settings . appInfo . sysInfo . totalmem_readable }
< / d i v >
< / d i v >
< / d i v >
< div className = "col-sm-12" style = { { paddingTop : '20px' } } >
< div className = "row" >
< h5 > Locations < / h 5 >
< div >
Cache : { this . props . Settings . appInfo . dirs . cacheLocation }
< / d i v >
< div >
Config : { this . props . Settings . appInfo . dirs . configLocation }
< / d i v >
< div >
Iguana Bin : { this . props . Settings . appInfo . dirs . iguanaBin }
< / d i v >
< div >
Iguana Dir : { this . props . Settings . appInfo . dirs . iguanaDir }
< / d i v >
< div >
Komodo Bin : { this . props . Settings . appInfo . dirs . komododBin }
< / d i v >
< div >
Komodo Dir : { this . props . Settings . appInfo . dirs . komodoDir }
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
) ;
} else {
return null ;
}
}
renderSNPeersList ( ) {
if ( this . state . getPeersCoin ) {
const coin = this . state . getPeersCoin . split ( '|' ) [ 0 ] ;
@ -112,6 +201,51 @@ class Settings extends React.Component {
}
}
renderConfigEditForm ( ) {
console . log ( this . props . Settings . appSettings ) ;
let items = [ ] ;
const _ appConfig = this . props . Settings . appSettings ;
for ( let key in this . props . Settings . appSettings ) {
if ( Object . keys ( this . props . Settings . appSettings [ key ] ) . length && key !== 'host' ) {
items . push (
< tr key = { ` app-settings- ${ key } ` } >
< td style = { { padding : '15px' } } >
{ key }
< / t d >
< td style = { { padding : '15px' } } > < / t d >
< / t r >
) ;
for ( let _ key in this . props . Settings . appSettings [ key ] ) {
items . push (
< tr key = { ` app-settings- ${ key } - ${ _ key } ` } >
< td style = { { padding : '15px' , paddingLeft : '30px' } } >
{ _ key }
< / t d >
< td style = { { padding : '15px' } } >
< input type = "text" name = { ` app-settings- ${ _ key } -edit ` } defaultValue = { _ appConfig [ key ] [ _ key ] } / >
< / t d >
< / t r >
) ;
}
} else {
items . push (
< tr key = { ` app-settings- ${ key } ` } >
< td style = { { padding : '15px' } } >
{ key }
< / t d >
< td style = { { padding : '15px' } } >
< input type = "text" name = { ` app-settings- ${ key } -edit ` } defaultValue = { _ appConfig [ key ] } / >
< / t d >
< / t r >
) ;
}
}
return items ;
}
updateInput ( e ) {
this . setState ( {
[ e . target . name ] : e . target . value ,
@ -393,40 +527,31 @@ class Settings extends React.Component {
< div className = "panel" id = "AppSettings" >
< div className = "panel-heading" role = "tab" onClick = { ( ) => this . openTab ( 'AppSettings' , 7 ) } >
< a className = { this . state . activeTab === 6 ? 'panel-title' : 'panel-title collapsed' } data - toggle = "collapse" data - parent = "#AppSettings" >
< i className = "icon md-info" aria - hidden = "true" > < / i > A p p S e t t i n g s ( c o n f i g . j s o n )
< a className = { this . state . activeTab === 7 ? 'panel-title' : 'panel-title collapsed' } data - toggle = "collapse" data - parent = "#AppSettings" >
< i className = "icon md-info" aria - hidden = "true" > < / i > A p p C o n f i g ( c o n f i g . j s o n )
< / a >
< / d i v >
< div className = { this . state . activeTab === 7 ? 'panel-collapse collapse in' : 'panel-collapse collapse' } style = { { height : this . state . activeTab === 7 ? this . state . activeTabHeight + 'px' : '10px' } } id = "DebugLogTab" aria - labelledby = "DebugLog" role = "tabpanel" >
< div className = "panel-body" >
< p > Manage app settings < / p >
< div className = "col-sm-12" > < / d i v >
< p >
< strong > Most changes to app config require wallet restart ! < / s t r o n g >
< / p >
< form className = "read-debug-log-import-form" method = "post" action = "javascript:" autoComplete = "off" >
< div className = "form-group form-material floating" >
< input type = "text" className = "form-control" name = "debugLinesCount" id = "read_debug_log_lines" value = { this . state . debugLinesCount } onChange = { this . updateInput } / >
< label className = "floating-label" htmlFor = "read_debug_log_lines" > { translate ( 'INDEX.DEBUG_LOG_LINES' ) } < / l a b e l >
< / d i v >
< div className = "form-group form-material floating" >
< select className = "form-control form-material" name = "debugTarget" id = "settings_select_debuglog_options" onChange = { this . updateInput } >
< option value = "iguana" > Iguana < / o p t i o n >
< option value = "komodo" > Komodo < / o p t i o n >
< / s e l e c t >
< label className = "floating-label" htmlFor = "settings_select_debuglog_options" > { translate ( 'INDEX.TARGET' ) } < / l a b e l >
< / d i v >
< div className = "col-sm-12 col-xs-12" style = { { textAlign : 'center' } } >
< button type = "button" className = "btn btn-primary waves-effect waves-light" data - toggle = "modal" data - dismiss = "modal" id = "read_debug_log_btn" onClick = { this . readDebugLog } > { translate ( 'INDEX.LOAD_DEBUG_LOG' ) } < / b u t t o n >
< div className = "col-sm-12" style = { { paddingTop : '15px' } } >
< table >
< tbody >
{ this . renderConfigEditForm ( ) }
< / t b o d y >
< / t a b l e >
< / d i v >
< div className = "col-sm-12 col-xs-12" style = { { textAlign : 'left' } } >
< br / >
< div style = { { padding : '20px 0' } } > { this . props . Settings . debugLog } < / d i v >
< div className = "col-sm-12 col-xs-12" style = { { textAlign : 'center' , paddingTop : '25px' , paddingBottom : '25px' } } >
< button type = "button" className = "btn btn-primary waves-effect waves-light" data - toggle = "modal" data - dismiss = "modal" id = "read_debug_log_btn" onClick = { this . _ saveAppConfig } > Save app config < / b u t t o n >
< / d i v >
< / f o r m >
< div className = "col-sm-12" style = { { paddingTop : '15px' } } >
< div className = "row" data - plugin = "masonry" > < / d i v >
< / d i v >
< / d i v >
< / d i v >
< / d i v >
{ this . renderAppInfoTab ( ) }
< / d i v >
< / d i v >
< / d i v >