Started building the general settings tab

This commit is contained in:
Henry Whitaker
2020-12-19 20:13:53 +00:00
parent 71e132e513
commit 1637e66bef
4 changed files with 286 additions and 1 deletions

View File

@@ -1,20 +1,82 @@
import Axios from 'axios';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Navbar from '../Navbar';
import SettingsTabs from './SettingsTabs';
export default class SettingsIndex extends Component {
constructor(props) {
super(props)
this.state = {
data: null,
loading: true,
}
}
getData = () => {
var url = 'api/settings/?token=' + window.token;
Axios.get(url)
.then((resp) => {
this.setState({
data: this.sortSettings(resp.data),
loading: false,
});
})
.catch((err) => {
//
})
}
sortSettings = (data) => {
return {
General: [
{
obj: data.schedule,
type: 'text',
},
{
obj: data.server,
type: 'text',
},
{
obj: data.show_average,
type: 'checkbox',
},
{
obj: data.show_max,
type: 'checkbox',
},
{
obj: data.show_min,
type: 'checkbox',
}
],
Graphs: {}
};
}
componentDidMount() {
this.getData();
}
render() {
var data = this.state.data;
var loading = this.state.loading;
if(loading) {
return (
<div>Loading</div>
);
}
return (
<div>
<Navbar />
<div className="container my-5">
<SettingsTabs data={data} />
</div>
</div>
);
}