initial commit
This commit is contained in:
commit
ebf9e1b78b
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
1
README.md
Normal file
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
Quick and **dirty** way to display users and channels in Teamspeak 3. Requires some backend for the API.
|
38
package.json
Normal file
38
package.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "ts3-status",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
18
public/index.html
Normal file
18
public/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<!-- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<title>Teamspeak 3 Status</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
24
src/App.css
Normal file
24
src/App.css
Normal file
@ -0,0 +1,24 @@
|
||||
*{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.container{
|
||||
|
||||
}
|
||||
|
||||
.channel{
|
||||
|
||||
}
|
||||
|
||||
.children{
|
||||
margin-left: 1rem
|
||||
}
|
||||
|
||||
.clients{
|
||||
margin-left: 1rem
|
||||
}
|
||||
|
||||
.client{
|
||||
|
||||
}
|
||||
|
25
src/App.jsx
Normal file
25
src/App.jsx
Normal file
@ -0,0 +1,25 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import './App.css';
|
||||
import Channel from './Channel';
|
||||
|
||||
function App() {
|
||||
let [status,setStatus] = useState([])
|
||||
|
||||
useEffect(()=>{
|
||||
(async ()=>{
|
||||
const res = await fetch("https://node.kapelle.org/pub/ts3");
|
||||
const json = await res.json();
|
||||
setStatus(json);
|
||||
})();
|
||||
},[]);
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
{status.map(c => {
|
||||
return <Channel channel={c} />
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
37
src/Channel.jsx
Normal file
37
src/Channel.jsx
Normal file
@ -0,0 +1,37 @@
|
||||
import React from "react"
|
||||
|
||||
function userIcon(client) {
|
||||
if (client.muted) {
|
||||
return "🔇"
|
||||
}
|
||||
|
||||
if (client.micMuted) {
|
||||
return "🎤"
|
||||
}
|
||||
|
||||
return "👤"
|
||||
}
|
||||
|
||||
function Channel(props) {
|
||||
return (
|
||||
<div className="channel">
|
||||
<div>
|
||||
✅ {props.channel.name}
|
||||
</div>
|
||||
<div className="clients">
|
||||
{props.channel.clients.map(c =>{
|
||||
return <div key={c.nickname} className="client">
|
||||
{userIcon(c)} {c.nickname}
|
||||
</div>
|
||||
})}
|
||||
</div>
|
||||
<div className="children">
|
||||
{props.channel.children.map(c => {
|
||||
return <Channel channel={c} />
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Channel
|
10
src/index.js
Normal file
10
src/index.js
Normal file
@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
Loading…
Reference in New Issue
Block a user