Skip to content

Commit 76a4060

Browse files
committed
improving server-settings.json UI
1 parent 54c6396 commit 76a4060

File tree

4 files changed

+102
-9
lines changed

4 files changed

+102
-9
lines changed

ui/App/App.jsx

100644100755
File mode changed.

ui/App/components/ConfigContent.jsx

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
)

ui/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import LoginContent from './App/components/LoginContent.jsx';
1010
import UsersContent from './App/components/UsersContent.jsx';
1111
import Index from './App/components/Index.jsx';
1212

13-
1413
ReactDOM.render((
1514
<Router history={browserHistory}>
1615
<Route path="/login" component={LoginContent}/>

ui/npm-debug.log

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

0 commit comments

Comments
 (0)