Skip to content

Commit c4304e9

Browse files
committed
moved serverSettings to own component, changed settings to format into a table
1 parent e1054bd commit c4304e9

File tree

3 files changed

+72
-24
lines changed

3 files changed

+72
-24
lines changed

src/factorio_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/go-ini/ini"
77
)
88

9+
// Loads config.ini file from the factorio config directory
910
func loadConfig(filename string) (map[string]map[string]string, error) {
1011
log.Printf("Loading config file: %s", filename)
1112
cfg, err := ini.Load(filename)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
3+
class ServerSettings extends React.Component {
4+
constructor(props) {
5+
super(props)
6+
}
7+
8+
render() {
9+
return(
10+
<tr key={this.props.name}>
11+
<td>{this.props.name}</td>
12+
<td>{this.props.setting}</td>
13+
</tr>
14+
)
15+
}
16+
}
17+
18+
ServerSettings.propTypes = {
19+
name: React.PropTypes.string.isRequired,
20+
setting: React.PropTypes.oneOfType([
21+
React.PropTypes.string,
22+
React.PropTypes.number,
23+
React.PropTypes.boolean,
24+
React.PropTypes.array,
25+
]),
26+
}
27+
28+
export default ServerSettings

ui/App/components/ConfigContent.jsx

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {IndexLink} from 'react-router';
33
import Settings from './Config/Settings.jsx';
4+
import ServerSettings from './Config/ServerSettings.jsx';
45

56
class ConfigContent extends React.Component {
67
constructor(props) {
@@ -16,6 +17,7 @@ class ConfigContent extends React.Component {
1617
componentDidMount() {
1718
this.getConfig();
1819
this.getServerSettings();
20+
console.log(this.state.serverSettings);
1921
}
2022

2123
getConfig() {
@@ -41,6 +43,7 @@ class ConfigContent extends React.Component {
4143
if (resp.success === true) {
4244
this.setState({serverSettings: resp.data})
4345
}
46+
console.log(this.state.serverSettings);
4447
},
4548
error: (xhr, status, err) => {
4649
console.log('/api/settings/get', status, err.toString());
@@ -61,6 +64,45 @@ class ConfigContent extends React.Component {
6164
<li className="active">Here</li>
6265
</ol>
6366
</section>
67+
68+
<section className="content">
69+
<div className="box">
70+
<div className="box-header">
71+
<h3 className="box-title">Server Settings</h3>
72+
</div>
73+
74+
<div className="box-body">
75+
<div className="row">
76+
<div className="col-md-6">
77+
<div className="server-settings-section">
78+
<div className="table-responsive">
79+
<table>
80+
<thead>
81+
<tr>
82+
<th>Setting name</th>
83+
<th>Setting value</th>
84+
</tr>
85+
</thead>
86+
<tbody>
87+
{Object.keys(this.state.serverSettings).map(function(key) {
88+
var setting = this.state.serverSettings[key]
89+
console.log(setting)
90+
return(
91+
<ServerSettings
92+
name={key}
93+
setting={setting}
94+
/>
95+
)
96+
}, this)}
97+
</tbody>
98+
</table>
99+
</div>
100+
</div>
101+
</div>
102+
</div>
103+
</div>
104+
</div>
105+
</section>
64106

65107
<section className="content">
66108
<div className="box">
@@ -70,7 +112,7 @@ class ConfigContent extends React.Component {
70112

71113
<div className="box-body">
72114
<div className="row">
73-
<div className="col-md-4">
115+
<div className="col-md-6">
74116
{Object.keys(this.state.config).map(function(key) {
75117
var conf = this.state.config[key]
76118
return(
@@ -99,29 +141,6 @@ class ConfigContent extends React.Component {
99141
</div>
100142
</section>
101143

102-
<section className="content">
103-
<div className="box">
104-
<div className="box-header">
105-
<h3 className="box-title">Server Settings</h3>
106-
</div>
107-
108-
<div className="box-body">
109-
<div className="row">
110-
<div className="col-md-4">
111-
{Object.keys(this.state.serverSettings).map(function(key) {
112-
var value = this.state.serverSettings[key]
113-
return(
114-
<div className="settings-section" key={key}>
115-
<h3>{key}</h3>
116-
<p>{value}</p>
117-
</div>
118-
)
119-
}, this)}
120-
</div>
121-
</div>
122-
</div>
123-
</div>
124-
</section>
125144

126145
</div>
127146
)

0 commit comments

Comments
 (0)