added method to download saves, updated readme

This commit is contained in:
majormjr 2016-04-19 22:53:42 -04:00
parent 34bcd07912
commit 81e73a81bb
6 changed files with 103 additions and 17 deletions

View File

@ -1,21 +1,43 @@
#Factorio Server Manager #Factorio Server Manager
A tool for managing both local and remote Factorio servers. ###A tool for managing dedicated Factorio servers.
This tool runs on a Factorio server and allows management of saves, mods and many other features.
![Factorio Server Manager Screenshot](http://i.imgur.com/EbRM03Z.png "Factorio Server Manager") ![Factorio Server Manager Screenshot](http://i.imgur.com/EbRM03Z.png "Factorio Server Manager")
## Installation
1. Clone the repository
2. Build the binary from the repository root (go build)
3. Run the program
Backend is built as a REST api via the Go application. It also acts as the webserver to serve the front end react application ## Usage
Run the server and specify the directory of your Factorio server installation and the interface to run the HTTP server on.
```
Usage of ./factorio-server-manager:
-dir string
Specify location of Factorio config directory. (default "./")
-host string
Specify IP for webserver to listen on. (default "0.0.0.0")
-port string
Specify a port for the server (default "8080")
All api actions are accessible with the /api route. ```
To build
Building Go backend
## Building the server
The backend is built as a REST API via the Go web application.
It also acts as the webserver to serve the front end react application
All api actions are accessible with the /api route. The frontend is accessible with the root url.
###Building Go backend
git clone git clone
cd cd
go build go build
building React frontend ###building React frontend
install nodejs (use )
cd static/js cd static/js
npm install npm install
webpack webpack

View File

@ -25855,15 +25855,15 @@
_react2.default.createElement( _react2.default.createElement(
"strong", "strong",
null, null,
"Copyright © 2015 ", "Copyright © 2016 ",
_react2.default.createElement( _react2.default.createElement(
"a", "a",
{ href: "#" }, { href: "#" },
"Company" "Mitch Roote"
), ),
"." "."
), ),
" All rights reserved." " MIT License."
); );
} }
}]); }]);
@ -26928,6 +26928,11 @@
'th', 'th',
null, null,
'Filesize' 'Filesize'
),
_react2.default.createElement(
'th',
null,
'Download'
) )
) )
), ),
@ -26962,7 +26967,7 @@
/* 238 */ /* 238 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
@ -26992,7 +26997,24 @@
} }
_createClass(Save, [{ _createClass(Save, [{
key: 'render', key: "downloadSave",
value: function downloadSave(e) {
e.preventDefault();
var node = this.refs.saveName;
var saveName = node.name;
$.ajax({
url: "/api/saves/dl/" + saveName,
dataType: "json",
success: function success(data) {
console.log(data);
},
error: function error(xhr, status, err) {
console.log('api/mods/list', status, err.toString());
}
});
}
}, {
key: "render",
value: function render() { value: function render() {
var saveSize = parseFloat(this.props.save.size / 1024 / 1024).toFixed(3); var saveSize = parseFloat(this.props.save.size / 1024 / 1024).toFixed(3);
var saveLastMod = Date.parse(this.props.save.last_mod); var saveLastMod = Date.parse(this.props.save.last_mod);
@ -27000,23 +27022,37 @@
var dateFmt = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDay() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); var dateFmt = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDay() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
return _react2.default.createElement( return _react2.default.createElement(
'tr', "tr",
null, null,
_react2.default.createElement( _react2.default.createElement(
'td', "td",
null, null,
this.props.save.name this.props.save.name
), ),
_react2.default.createElement( _react2.default.createElement(
'td', "td",
null, null,
dateFmt dateFmt
), ),
_react2.default.createElement( _react2.default.createElement(
'td', "td",
null, null,
saveSize, saveSize,
' MB' " MB"
),
_react2.default.createElement(
"td",
null,
_react2.default.createElement(
"form",
{ onSubmit: this.downloadSave.bind(this) },
_react2.default.createElement("input", { className: "btn btn-default btn-sm",
ref: "saveName",
type: "submit",
value: "Download Save",
name: this.props.save.name
})
)
) )
); );
} }

View File

@ -96,3 +96,4 @@ func (m ModList) save() error {
} }
//TODO Add method to allow downloading all installed mods in zip file //TODO Add method to allow downloading all installed mods in zip file
//TODO Add method for uploading new mods

View File

@ -7,7 +7,7 @@ class Footer extends React.Component {
<div className="pull-right hidden-xs"> <div className="pull-right hidden-xs">
Anything you want!!!!!! Anything you want!!!!!!
</div> </div>
<strong>Copyright &copy; 2015 <a href="#">Company</a>.</strong> All rights reserved. <strong>Copyright &copy; 2016 <a href="#">Mitch Roote</a>.</strong> MIT License.
</footer> </footer>
) )
} }

View File

@ -1,6 +1,22 @@
import React from 'react'; import React from 'react';
class Save extends React.Component { class Save extends React.Component {
downloadSave(e) {
e.preventDefault();
const node = this.refs.saveName;
const saveName = node.name;
$.ajax({
url: "/api/saves/dl/" + saveName,
dataType: "json",
success: (data) => {
console.log(data)
},
error: (xhr, status, err) => {
console.log('api/mods/list', status, err.toString());
}
})
}
render() { render() {
let saveSize = parseFloat(this.props.save.size / 1024 / 1024).toFixed(3) let saveSize = parseFloat(this.props.save.size / 1024 / 1024).toFixed(3)
let saveLastMod = Date.parse(this.props.save.last_mod); let saveLastMod = Date.parse(this.props.save.last_mod);
@ -13,6 +29,16 @@ class Save extends React.Component {
<td>{this.props.save.name}</td> <td>{this.props.save.name}</td>
<td>{dateFmt}</td> <td>{dateFmt}</td>
<td>{saveSize} MB</td> <td>{saveSize} MB</td>
<td>
<form onSubmit={this.downloadSave.bind(this)}>
<input className='btn btn-default btn-sm'
ref='saveName'
type='submit'
value='Download Save'
name={this.props.save.name}
/>
</form>
</td>
</tr> </tr>
) )
} }

View File

@ -17,6 +17,7 @@ class SavesList extends React.Component {
<th>Filname</th> <th>Filname</th>
<th>Last Modified Time</th> <th>Last Modified Time</th>
<th>Filesize</th> <th>Filesize</th>
<th>Download</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>