improving server-settings.json UI

This commit is contained in:
majormjr 2016-10-31 18:39:18 -04:00
parent 54c639634b
commit 76a4060341
4 changed files with 102 additions and 9 deletions

0
ui/App/App.jsx Normal file → Executable file
View File

View File

@ -9,6 +9,7 @@ class ConfigContent extends React.Component {
this.getServerSettings = this.getServerSettings.bind(this);
this.updateServerSettings = this.updateServerSettings.bind(this);
this.handleServerSettingsChange = this.handleServerSettingsChange.bind(this);
this.formTypeField = this.formTypeField.bind(this);
this.state = {
config: {},
serverSettings: {}
@ -49,6 +50,7 @@ class ConfigContent extends React.Component {
success: (resp) => {
if (resp.success === true) {
this.setState({serverSettings: resp.data})
console.log(this.state)
}
},
error: (xhr, status, err) => {
@ -74,6 +76,65 @@ class ConfigContent extends React.Component {
})
}
formTypeField(key, setting) {
if (typeof setting === "number") {
return (
<input
key={key}
ref={key}
id={key}
className="form-control"
defaultValue={setting}
type="number"
onChange={this.handleServerSettingsChange.bind(this, key)}
/>
)
} else if (typeof setting === "string") {
return (
<input
key={key}
ref={key}
id={key}
className="form-control"
defaultValue={setting}
type="text"
onChange={this.handleServerSettingsChange.bind(this, key)}
/>
)
} else if (typeof setting === "boolean") {
return (
<select key={key} ref={key} id={key} className="form-control" onChange={this.handleServerSettingsChange.bind(this, key)}>
<option value={true}>True</option>
<option value={false}>False</option>
</select>
)
} else if (Array.isArray(setting)) {
return (
<input
key={key}
ref={key}
id={key}
className="form-control"
defaultValue={setting}
type="password"
onChange={this.handleServerSettingsChange.bind(this, key)}
/>
)
} else {
return (
<input
key={key}
ref={key}
id={key}
className="form-control"
defaultValue={setting}
type="text"
onChange={this.handleServerSettingsChange.bind(this, key)}
/>
)
}
}
render() {
return(
@ -108,14 +169,7 @@ class ConfigContent extends React.Component {
<div className="form-group">
<label for={key} className="control-label col-md-3">{setting_key}</label>
<div className="col-md-6">
<input
ref={key}
id={key}
className="form-control"
defaultValue={setting}
type="text"
onChange={this.handleServerSettingsChange.bind(this, key)}
/>
{this.formTypeField(key, setting)}
</div>
</div>
)

View File

@ -10,7 +10,6 @@ import LoginContent from './App/components/LoginContent.jsx';
import UsersContent from './App/components/UsersContent.jsx';
import Index from './App/components/Index.jsx';
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/login" component={LoginContent}/>

40
ui/npm-debug.log Normal file
View File

@ -0,0 +1,40 @@
0 info it worked if it ends with ok
1 verbose cli [ '/home/mitch/.nvm/versions/node/v4.2.6/bin/node',
1 verbose cli '/home/mitch/.nvm/versions/node/v4.2.6/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@2.14.12
3 info using node@v4.2.6
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info predev factorio-mod-manager@0.1.0
6 info dev factorio-mod-manager@0.1.0
7 verbose unsafe-perm in lifecycle true
8 info factorio-mod-manager@0.1.0 Failed to exec dev script
9 verbose stack Error: factorio-mod-manager@0.1.0 dev: `NODE_ENV=production ./node_modules/webpack/bin/webpack.js -w --progress --profile --colors`
9 verbose stack Exit status 126
9 verbose stack at EventEmitter.<anonymous> (/home/mitch/.nvm/versions/node/v4.2.6/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at EventEmitter.emit (events.js:172:7)
9 verbose stack at ChildProcess.<anonymous> (/home/mitch/.nvm/versions/node/v4.2.6/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at ChildProcess.emit (events.js:172:7)
9 verbose stack at maybeClose (internal/child_process.js:821:16)
9 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid factorio-mod-manager@0.1.0
11 verbose cwd /home/mitch/prog/go/src/github.com/majormjr/factorio-server-manager/ui
12 error Linux 4.4.0-45-generic
13 error argv "/home/mitch/.nvm/versions/node/v4.2.6/bin/node" "/home/mitch/.nvm/versions/node/v4.2.6/bin/npm" "run" "dev"
14 error node v4.2.6
15 error npm v2.14.12
16 error code ELIFECYCLE
17 error factorio-mod-manager@0.1.0 dev: `NODE_ENV=production ./node_modules/webpack/bin/webpack.js -w --progress --profile --colors`
17 error Exit status 126
18 error Failed at the factorio-mod-manager@0.1.0 dev script 'NODE_ENV=production ./node_modules/webpack/bin/webpack.js -w --progress --profile --colors'.
18 error This is most likely a problem with the factorio-mod-manager package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error NODE_ENV=production ./node_modules/webpack/bin/webpack.js -w --progress --profile --colors
18 error You can get their info via:
18 error npm owner ls factorio-mod-manager
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]