Skip to content

Commit ff2faaa

Browse files
committed
added methods for modpack creation
1 parent 9283eec commit ff2faaa

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

ui/App/components/Mods/ModPacks.jsx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,37 @@ import React from 'react';
33
class ModPacks extends React.Component {
44
constructor(props) {
55
super(props)
6+
this.createModPack = this.createModPack.bind(this);
7+
this.removeModPack = this.removeModPack.bind(this);
8+
}
9+
10+
createModPack(e, modpack) {
11+
e.preventDefault();
12+
self = this;
13+
14+
let modpacks = {};
15+
modpacks["mods"] = [];
16+
modpacks["title"] = this.refs.modpackName.value;
17+
18+
for (var m in this.refs) {
19+
if (this.refs[m].checked) {
20+
modpacks["mods"].push(this.refs[m].id)
21+
}
22+
}
23+
$.ajax({
24+
url: "/api/mods/packs/add",
25+
dataType: "json",
26+
type: "POST",
27+
data: JSON.stringify(modpacks),
28+
success: (resp) => {
29+
if (resp.success === true) {
30+
swal("Added modpack", "Modpack: " + modpacks["title"] + " added successfully", "success")
31+
self.props.loadModPackList();
32+
} else {
33+
swal("Error", "Could not create modpack " + modpacks["title"], "error")
34+
}
35+
}
36+
})
637
}
738

839
removeModPack(modpack, e) {
@@ -39,6 +70,34 @@ class ModPacks extends React.Component {
3970
</div>
4071

4172
<div className="box-body">
73+
<div className="box box-success collapsed-box">
74+
<button type="button" className="btn btn-box-tool" data-widget="collapse">
75+
<div className="box-header with-border">
76+
<i className="fa fa-plus fa-fw"></i><h4 className="box-title">Create Mod Pack</h4>
77+
</div>
78+
</button>
79+
<div className="box-body" style={{display: "none"}}>
80+
<form onSubmit={this.createModPack}>
81+
<label for="modPack">Mod Pack Name</label>
82+
<div id="modpack" className="input-group">
83+
<input ref="modpackName" name="modpack" id="modpack" type="text" className="form-control" placeholder="Enter Mod Pack Name..." />
84+
</div>
85+
{this.props.installedMods.map( (mod, i) => {
86+
return(
87+
<div className="checkbox" key={i}>
88+
<label for={mod}>
89+
<input id={mod} ref={"mod-"+mod} type="checkbox" />
90+
{mod}
91+
</label>
92+
</div>
93+
)
94+
} )}
95+
<div className="col-md-4">
96+
<button className="btn btn-block btn-success" type="submit"><i className="fa fa-save fa-fw"></i>Create Mod Pack</button>
97+
</div>
98+
</form>
99+
</div>
100+
</div>
42101
<table className="table table-striped">
43102
<thead>
44103
<tr>
@@ -49,7 +108,6 @@ class ModPacks extends React.Component {
49108
</thead>
50109
<tbody>
51110
{this.props.modPacks.map( (mod, i) => {
52-
console.log(mod)
53111
let dlURL = "/api/mods/packs/dl/" + mod
54112
return(
55113
<tr key={i}>
@@ -75,6 +133,7 @@ class ModPacks extends React.Component {
75133
}
76134

77135
ModPacks.propTypes = {
136+
installedMods: React.PropTypes.array.isRequired,
78137
modPacks: React.PropTypes.array.isRequired,
79138
loadModPackList: React.PropTypes.func.isRequired,
80139
}

ui/App/components/ServerCtl/ServerCtl.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ class ServerCtl extends React.Component {
5252
dataType: "json",
5353
data: JSON.stringify(serverSettings),
5454
success: (resp) => {
55-
console.log(resp);
5655
this.props.facServStatus();
5756
this.props.getStatus();
58-
alert(resp.data)
57+
if (resp.success === true) {
58+
swal("Factorio Server Started", resp.data)
59+
} else {
60+
swal("Error", "Error starting Factorio Server", "error")
61+
}
5962
}
6063
})
6164
this.setState({
@@ -79,7 +82,7 @@ class ServerCtl extends React.Component {
7982
this.props.facServStatus();
8083
this.props.getStatus();
8184
console.log(resp)
82-
alert(resp.data)
85+
swal(resp.data)
8386
}
8487
});
8588
e.preventDefault();

0 commit comments

Comments
 (0)