mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-10 09:02:49 +00:00
added soundlist to client
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Navbar from './components/Navbar/Navbar';
|
import Navbar from './components/Navbar/Navbar.component';
|
||||||
|
|
||||||
//styling
|
//styling
|
||||||
import './scss/index.scss';
|
import './scss/index.scss';
|
||||||
|
|||||||
78
app/pages/Soundboard/SoundList.component.js
Normal file
78
app/pages/Soundboard/SoundList.component.js
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
import './SoundList.scss';
|
||||||
|
|
||||||
|
let soundListCache;
|
||||||
|
|
||||||
|
export default class SoundList extends React.Component {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.state = {
|
||||||
|
soundList: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.getSoundList();
|
||||||
|
}
|
||||||
|
|
||||||
|
getSoundList() {
|
||||||
|
if (!soundListCache) {
|
||||||
|
axios.get("/soundlist")
|
||||||
|
.then((response) => {
|
||||||
|
soundListCache = response.data;
|
||||||
|
this.setState({
|
||||||
|
soundList: response.data,
|
||||||
|
});
|
||||||
|
}).catch((error) => {
|
||||||
|
console.warn(error.response.data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
soundList: soundListCache,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkExtension(extension) {
|
||||||
|
console.log(extension);
|
||||||
|
switch(extension) {
|
||||||
|
case "wav":
|
||||||
|
return true;
|
||||||
|
case "wav":
|
||||||
|
return true;
|
||||||
|
case "wav":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
console.log("not working");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="Card">
|
||||||
|
<div className="Card__header">
|
||||||
|
Sounds
|
||||||
|
<i className="fa fa fa-volume-up" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{this.state.soundList.length > 0 ? this.state.soundList.map((sound, index) => {
|
||||||
|
return <div key={index} className="SoundList__item">
|
||||||
|
<div>
|
||||||
|
{sound.prefix + sound.name}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{this.checkExtension(sound.extension) ?
|
||||||
|
<audio controls src={"/sounds/" + sound.name + "." + sound.extension}
|
||||||
|
type={"audio/" + sound.extension}
|
||||||
|
style={{width: "100px"}}/>
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
}) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
app/pages/Soundboard/SoundList.scss
Normal file
12
app/pages/Soundboard/SoundList.scss
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
@import "../../scss/variables";
|
||||||
|
|
||||||
|
.SoundList__item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
height: 50px;
|
||||||
|
|
||||||
|
& + .SoundList__item {
|
||||||
|
border-top: 1px solid $gray3;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import React from 'react';
|
|||||||
import Dropzone from 'react-dropzone';
|
import Dropzone from 'react-dropzone';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
import SoundList from './SoundList.component';
|
||||||
|
|
||||||
import './Soundboard.scss';
|
import './Soundboard.scss';
|
||||||
|
|
||||||
let self;
|
let self;
|
||||||
@@ -11,9 +13,10 @@ export default class Soundboard extends React.Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
uploaded: false,
|
|
||||||
percentCompleted: 0,
|
percentCompleted: 0,
|
||||||
password: "",
|
password: "",
|
||||||
|
uploaded: false,
|
||||||
|
uploadError: " ",
|
||||||
}
|
}
|
||||||
self = this;
|
self = this;
|
||||||
}
|
}
|
||||||
@@ -49,14 +52,13 @@ export default class Soundboard extends React.Component {
|
|||||||
password: "",
|
password: "",
|
||||||
percentCompleted: 0,
|
percentCompleted: 0,
|
||||||
uploaded: true,
|
uploaded: true,
|
||||||
uploadError: undefined,
|
uploadError: " ",
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
password: "",
|
|
||||||
percentCompleted: 0,
|
percentCompleted: 0,
|
||||||
uploaded: false,
|
uploaded: false,
|
||||||
uploadError: "Upload error.",
|
uploadError: err.response.data,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -70,25 +72,33 @@ export default class Soundboard extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="Soundboard">
|
<div className="Soundboard">
|
||||||
|
<div className="column">
|
||||||
|
<SoundList/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<input className="Soundboard__input"
|
<div className="column">
|
||||||
type="password"
|
<div>
|
||||||
placeholder="Password"
|
<Dropzone className="Dropzone"
|
||||||
value={this.state.password}
|
activeClassName="Dropzone--active"
|
||||||
onChange={this.passwordOnChange.bind(this)}></input>
|
onDrop={this.onDrop}
|
||||||
<div>
|
multiple={false}
|
||||||
<Dropzone className="Dropzone"
|
disableClick={true}
|
||||||
activeClassName="Dropzone--active"
|
maxSize={10000000000}
|
||||||
onDrop={this.onDrop}
|
accept={"audio/*"}>
|
||||||
multiple={false}
|
|
||||||
accept={"audio/*"}>
|
<input className="Soundboard__input"
|
||||||
|
type="password"
|
||||||
<div>Drop file here to upload.</div>
|
placeholder="Password"
|
||||||
{this.state.percentCompleted > 0 ? <div>Progress: {this.state.percentCompleted}</div> : ""}
|
value={this.state.password}
|
||||||
{this.state.uploaded ? <div>File uploded!</div> : ""}
|
onChange={this.passwordOnChange.bind(this)}/>
|
||||||
{this.state.uploadError ? <div>{this.state.uploadError}</div> : ""}
|
|
||||||
</Dropzone>
|
<div style={{fontSize: "20px"}}>Drop file here to upload.</div>
|
||||||
</div>
|
{this.state.percentCompleted > 0 ? <div>Uploading: {this.state.percentCompleted}</div> : ""}
|
||||||
|
{this.state.uploaded ? <div style={{color: 'green'}}>File uploded!</div> : ""}
|
||||||
|
<div style={{color: '#f95f59'}}>{this.state.uploadError}</div>
|
||||||
|
</Dropzone>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,21 @@
|
|||||||
|
|
||||||
.Soundboard {
|
.Soundboard {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
padding: 10px;
|
||||||
align-items: center;
|
}
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
.Soundboard__column {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Soundboard__input {
|
.Soundboard__input {
|
||||||
|
display: block;
|
||||||
|
width: 200px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 1px solid lighten($gray1, 5%);
|
border: 1px solid lighten($gray1, 5%);
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
@@ -22,16 +27,19 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
border: 2px solid lighten($gray1, 10%);
|
border: 2px solid $primaryBlue;
|
||||||
padding: 20px;
|
|
||||||
color: lighten($gray1, 15%);
|
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
width: 300px;
|
padding: 20px;
|
||||||
height: 300px;
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
color: lighten($gray1, 15%);
|
||||||
|
width: 400px;
|
||||||
|
height: 400px;
|
||||||
background-color: $gray2;
|
background-color: $gray2;
|
||||||
transition: background-color 0.1s linear;
|
transition: box-shadow 0.1s linear, background-color 0.1s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Dropzone--active {
|
.Dropzone--active {
|
||||||
background-color: $primaryBlue;
|
background-color: $gray3;
|
||||||
|
box-shadow: 0px 0px 5px 1px $primaryBlue;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,9 @@ body {
|
|||||||
.Card {
|
.Card {
|
||||||
background-color: $gray2;
|
background-color: $gray2;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
max-width: 800px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
border: 1px solid $gray3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Card__header {
|
.Card__header {
|
||||||
@@ -39,4 +41,12 @@ body {
|
|||||||
border-radius: 5px 5px 0 0;
|
border-radius: 5px 5px 0 0;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
background-color: $gray3;
|
background-color: $gray3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
& + .column {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ $white: darken(white, 10%);
|
|||||||
|
|
||||||
$gray1: #2e3136;
|
$gray1: #2e3136;
|
||||||
$gray2: #2a2d32;
|
$gray2: #2a2d32;
|
||||||
$gray3: #282b30;
|
$gray3: #23262a;
|
||||||
$gray4: #2e3136;
|
$gray4: #2e3136;
|
||||||
$gray5: #282b30;
|
$gray5: #282b30;
|
||||||
$gray6: #1e2124;
|
$gray6: #1e2124;
|
||||||
|
|||||||
BIN
dist/GoBot-linux
vendored
BIN
dist/GoBot-linux
vendored
Binary file not shown.
BIN
dist/index.html.fasthttp.gz
vendored
BIN
dist/index.html.fasthttp.gz
vendored
Binary file not shown.
4
dist/static/app.css
vendored
4
dist/static/app.css
vendored
File diff suppressed because one or more lines are too long
6
dist/static/app.js
vendored
6
dist/static/app.js
vendored
File diff suppressed because one or more lines are too long
12
dist/static/vendor.js
vendored
12
dist/static/vendor.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user