mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-06 03:54:06 +02:00
added update all buttons (currently bugged)
This commit is contained in:
parent
5d9900d34a
commit
cbed7ae23b
@ -8,7 +8,8 @@ This tool runs on a Factorio server and allows management of the Factorio server
|
||||
## Features
|
||||
* Allows control of the Factorio Server, starting and stopping the Factorio binary.
|
||||
* Allows the management of save files, upload, download and delete saves.
|
||||
* Manage installed mods, upload new ones, delete uneeded mods. Enable or disable individual mods.
|
||||
* Manage installed mods, upload new ones and more
|
||||
* Manage modpacks, so it is easier to play with different configurations
|
||||
* Allow viewing of the server logs and current configuration.
|
||||
* Authentication for protecting against unauthorized users
|
||||
* Available as a Docker container
|
||||
|
@ -104,7 +104,6 @@ func (mods *Mods) createMod(mod_name string, file_name string, file_rc io.Reader
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//create new mod
|
||||
err = mods.ModInfoList.createMod(mod_name, file_name, file_rc)
|
||||
if err != nil {
|
||||
@ -143,6 +142,8 @@ func (mods *Mods) downloadMod(url string, filename string, mod_id string) (error
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("download complete\n StatusCode: %d\n Status: %s", response.StatusCode, response.Status)
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode != 200 {
|
||||
@ -157,6 +158,8 @@ func (mods *Mods) downloadMod(url string, filename string, mod_id string) (error
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("completed copying the response.Body")
|
||||
|
||||
//done everything is made inside the createMod
|
||||
|
||||
return nil
|
||||
|
@ -141,12 +141,6 @@ func (mod_info_list *ModInfoList) createMod(mod_name string, file_name string, m
|
||||
}
|
||||
defer new_file.Close()
|
||||
|
||||
_, err = io.Copy(new_file, mod_file)
|
||||
if err != nil {
|
||||
log.Printf("error on copying file to disk: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
//reload the list
|
||||
err = new_file.Close()
|
||||
if err != nil {
|
||||
|
@ -333,6 +333,8 @@ func UpdateModHandler(w http.ResponseWriter, r *http.Request) {
|
||||
download_url := r.FormValue("downloadUrl")
|
||||
file_name := r.FormValue("filename")
|
||||
|
||||
log.Println("--------------------------------------------------------------")
|
||||
|
||||
mods, err := newMods(config.FactorioModsDir)
|
||||
if err == nil {
|
||||
err = mods.updateMod(mod_name, download_url, file_name)
|
||||
|
@ -36,6 +36,9 @@ class Mod extends React.Component {
|
||||
success: (data) => {
|
||||
let newest_release = JSON.parse(data.data).releases[0];
|
||||
if(newest_release.version != this.props.mod.version) {
|
||||
if(this_class.props.updateCountAdd)
|
||||
this_class.props.updateCountAdd();
|
||||
|
||||
this_class.setState({
|
||||
newVersionAvailable: true,
|
||||
newVersion: {
|
||||
@ -47,7 +50,7 @@ class Mod extends React.Component {
|
||||
this_class.setState({
|
||||
newVersionAvailable: false,
|
||||
newVersion: null
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
error: (jqXHR, status, err) => {
|
||||
@ -81,7 +84,7 @@ class Mod extends React.Component {
|
||||
let version;
|
||||
if(this.state.newVersionAvailable) {
|
||||
version = <span>{this.props.mod.version}
|
||||
<a className="btn btn-xs btn-default"
|
||||
<a className="btn btn-xs btn-default update-button"
|
||||
style={{
|
||||
marginLeft: 10,
|
||||
display: "inline-flex",
|
||||
@ -143,6 +146,7 @@ Mod.propTypes = {
|
||||
toggleMod: React.PropTypes.func.isRequired,
|
||||
deleteMod: React.PropTypes.func.isRequired,
|
||||
updateMod: React.PropTypes.func.isRequired,
|
||||
updateCountAdd: React.PropTypes.func,
|
||||
};
|
||||
|
||||
export default Mod
|
||||
|
@ -2,6 +2,12 @@ import React from "react";
|
||||
import Mod from "./Mod.jsx";
|
||||
|
||||
class ModManager extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="box-body">
|
||||
@ -40,6 +46,7 @@ ModManager.propTypes = {
|
||||
toggleMod: React.PropTypes.func.isRequired,
|
||||
deleteMod: React.PropTypes.func.isRequired,
|
||||
updateMod: React.PropTypes.func.isRequired,
|
||||
updateCountAdd: React.PropTypes.func,
|
||||
}
|
||||
|
||||
export default ModManager;
|
@ -79,18 +79,28 @@ class ModOverview extends React.Component {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="box">
|
||||
<div className="box" id="manage-mods">
|
||||
<div className="box-header" data-widget="collapse" style={{cursor: "pointer"}}>
|
||||
<i className="fa fa-minus"></i>
|
||||
<h3 className="box-title">Manage Mods</h3>
|
||||
<div className="box-tools pull-right">
|
||||
{
|
||||
this.props.installedMods != null ?
|
||||
<NativeListener onClick={this.props.deleteAll}>
|
||||
<button className="btn btn-box-tool btn-danger" style={{color: "#fff"}}>Delete ALL
|
||||
this.props.updates_available > 0 ?
|
||||
<NativeListener onClick={this.props.updateAllMods}>
|
||||
<button className="btn btn-box-tool btn-default" style={{marginRight: 20}}>
|
||||
Update all Mods
|
||||
</button>
|
||||
</NativeListener>
|
||||
: null
|
||||
: null
|
||||
}
|
||||
{
|
||||
this.props.installedMods != null ?
|
||||
<NativeListener onClick={this.props.deleteAll}>
|
||||
<button className="btn btn-box-tool btn-danger" style={{color: "#fff"}}>
|
||||
Delete ALL Mods
|
||||
</button>
|
||||
</NativeListener>
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@ -125,6 +135,9 @@ ModOverview.propTypes = {
|
||||
uploadModSuccessHandler: React.PropTypes.func.isRequired,
|
||||
logged_in: React.PropTypes.bool.isRequired,
|
||||
factorioLogoutHandler: React.PropTypes.func.isRequired,
|
||||
updates_available: React.PropTypes.number.isRequired,
|
||||
updateAllMods: React.PropTypes.func.isRequired,
|
||||
updateCountAdd: React.PropTypes.func.isRequired,
|
||||
|
||||
modContentClass: instanceOfModsContent.isRequired,
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ class ModFoundOverview extends React.Component {
|
||||
</div>;
|
||||
|
||||
mods.push(
|
||||
<div className="list-group-item">
|
||||
<div className="list-group-item" key={mod.title}>
|
||||
<div style={{display: "flex"}}>
|
||||
{img}
|
||||
<div style={information_style.container}>
|
||||
|
@ -18,10 +18,15 @@ class ModsContent extends React.Component {
|
||||
this.uploadModSuccessHandler = this.uploadModSuccessHandler.bind(this);
|
||||
this.factorioLogoutHandler = this.factorioLogoutHandler.bind(this);
|
||||
this.deleteAllHandler = this.deleteAllHandler.bind(this);
|
||||
this.updateAllModsHandler = this.updateAllModsHandler.bind(this);
|
||||
this.updatesAvailable = this.updatesAvailable.bind(this);
|
||||
this.updateCountSubtract = this.updateCountSubtract.bind(this);
|
||||
this.updateCountAdd = this.updateCountAdd.bind(this);
|
||||
|
||||
this.state = {
|
||||
logged_in: false,
|
||||
installedMods: null,
|
||||
updates_available: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,6 +400,10 @@ class ModsContent extends React.Component {
|
||||
success: (data) => {
|
||||
toggleUpdateStatus();
|
||||
removeVersionAvailableStatus();
|
||||
|
||||
this_class.updatesAvailable();
|
||||
this_class.updateCountSubtract();
|
||||
|
||||
this_class.setState({
|
||||
installedMods: data.data.mods
|
||||
});
|
||||
@ -412,6 +421,35 @@ class ModsContent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
updatesAvailable() {
|
||||
this.setState({
|
||||
updates_available: true
|
||||
})
|
||||
}
|
||||
|
||||
updateAllModsHandler(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
let update_buttons = $('#manage-mods').find(".update-button");
|
||||
// $('.update-button').click();
|
||||
$.each(update_buttons, function(k, v) {
|
||||
v.click();
|
||||
});
|
||||
}
|
||||
|
||||
updateCountSubtract() {
|
||||
this.setState({
|
||||
updates_available: this.state.updates_available > 0 ? this.state.updates_available - 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
updateCountAdd() {
|
||||
this.setState({
|
||||
updates_available: this.state.updates_available + 1
|
||||
});
|
||||
}
|
||||
|
||||
uploadModSuccessHandler(event, data) {
|
||||
this.setState({
|
||||
installedMods: data.response.data.mods
|
||||
@ -441,7 +479,9 @@ class ModsContent extends React.Component {
|
||||
deleteMod={this.deleteModHandler}
|
||||
deleteAll={this.deleteAllHandler}
|
||||
updateMod={this.updateModHandler}
|
||||
updateCountAdd={this.updateCountAdd}
|
||||
uploadModSuccessHandler={this.uploadModSuccessHandler}
|
||||
updateAllMods={this.updateAllModsHandler}
|
||||
modContentClass={this}
|
||||
factorioLogoutHandler={this.factorioLogoutHandler}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user