mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-26 05:27:21 +02:00
base mod show methods
This commit is contained in:
parent
98ba7bc9e5
commit
12561a1b0f
@ -4,7 +4,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Mod struct {
|
type Mod struct {
|
||||||
@ -22,20 +21,16 @@ func listInstalledMods(modDir string) ([]Mod, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
os.Exit(1)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print(file)
|
|
||||||
|
|
||||||
var result ModsList
|
var result ModsList
|
||||||
err_json := json.Unmarshal(file, &result)
|
err_json := json.Unmarshal(file, &result)
|
||||||
|
|
||||||
if err_json != nil {
|
if err_json != nil {
|
||||||
log.Println(err_json.Error())
|
log.Println(err_json.Error())
|
||||||
os.Exit(1)
|
return result.Mods, err_json
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%v", result)
|
|
||||||
|
|
||||||
return result.Mods, nil
|
return result.Mods, nil
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
class Mod extends React.Component {
|
class Mod extends React.Component {
|
||||||
togglePress(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log(this.refs.modName);
|
|
||||||
const node = this.refs.modName;
|
|
||||||
const modName = node.name;
|
|
||||||
this.props.toggleMod(modName);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.mod.enabled === "false") {
|
if (this.props.mod.enabled === "false") {
|
||||||
this.modStatus = <span className="label label-danger">Disabled</span>
|
this.modStatus = <span className="label label-danger">Disabled</span>
|
||||||
@ -20,14 +12,12 @@ class Mod extends React.Component {
|
|||||||
<td>{this.props.mod.name}</td>
|
<td>{this.props.mod.name}</td>
|
||||||
<td>{this.modStatus}</td>
|
<td>{this.modStatus}</td>
|
||||||
<td>
|
<td>
|
||||||
<form onSubmit={this.togglePress.bind(this)}>
|
<input className='btn btn-default btn-sm'
|
||||||
<input className='btn btn-default btn-sm'
|
ref='modName'
|
||||||
ref='modName'
|
type='submit'
|
||||||
type='submit'
|
value='Toggle'
|
||||||
value='Toggle'
|
name={this.props.mod.name}
|
||||||
name={this.props.mod.name}
|
/>
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
@ -35,8 +25,7 @@ class Mod extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mod.propTypes = {
|
Mod.propTypes = {
|
||||||
mod: React.PropTypes.object.isRequired,
|
mod: React.PropTypes.object.isRequired
|
||||||
toggleMod: React.PropTypes.func.isRequired
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Mod
|
export default Mod
|
||||||
|
43
ui/App/components/Mods/overview.jsx
Normal file
43
ui/App/components/Mods/overview.jsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Mod from './Mod';
|
||||||
|
|
||||||
|
class ModOverview extends React.Component {
|
||||||
|
render() {
|
||||||
|
<div className="box">
|
||||||
|
<div className="box-header">
|
||||||
|
<h3 className="box-title">Manage Mods</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="box-body">
|
||||||
|
<div className="table-responsive">
|
||||||
|
<table className="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Toggle Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{this.props.installedMods.map ( (mod, i) => {
|
||||||
|
return(
|
||||||
|
<Mod
|
||||||
|
key={i}
|
||||||
|
mod={mod}
|
||||||
|
{...this.props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ModOverview.propTypes = {
|
||||||
|
installedMods: React.PropTypes.array.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ModOverview;
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {IndexLink} from 'react-router';
|
import {IndexLink} from 'react-router';
|
||||||
|
import ModOverview from './Mods/overview';
|
||||||
|
|
||||||
class ModsContent extends React.Component {
|
class ModsContent extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -46,7 +47,9 @@ class ModsContent extends React.Component {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="content">
|
<section className="content">
|
||||||
Test
|
<ModOverview
|
||||||
|
{...this.state}
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user