Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 892ffa7

Browse files
committed
V3.2.0
1 parent c1b297f commit 892ffa7

File tree

14 files changed

+486
-265
lines changed

14 files changed

+486
-265
lines changed

client/src/App.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import MenuNav from '~/views/dash/Menu';
1313
import Home from '~/views/dash/Home';
1414
import Configuration from '~/views/dash/Configuration';
1515
import AddUser from '~/views/dash/AddUser';
16+
import RemoveUser from '~/views/dash/RemoveUser';
1617
import Sandbox from '~/views/dash/Sandbox';
17-
import Override from '~/views/override';
1818
import About from '~/views/dash/About';
1919

2020
import {post} from '~/helpers/api';
@@ -31,29 +31,13 @@ function App({history}) {
3131
async function getUserCount() {
3232
try {
3333
const response = await post({}, 'userCount');
34-
// if(response.data.size <= 0) await post({}, 'init');
3534
setUserCount(response.data.size);
3635
setLoading(false)
3736
} catch (e) {
38-
// if(e.message === "Network Error" ||
39-
// e.message === "Failed to execute 'open' on 'XMLHttpRequest': Invalid URL" ||
40-
// e.response.status === 404) {
41-
// return setOverride(true)
42-
// }
4337
message.error(e.message);
4438
}
4539
}
4640

47-
// function OverrideReload() {
48-
// getUserCount();
49-
// setOverride($ => !$);
50-
// }
51-
//
52-
// if(override) return (
53-
// <Setup>
54-
// <Override setReload={() => OverrideReload()} />
55-
// </Setup>
56-
// );
5741

5842
if(loading) return <Loading/>;
5943

@@ -65,6 +49,7 @@ function App({history}) {
6549
<Route path="/home" component={Home}/>
6650
<Route path="/configuration" component={Configuration}/>
6751
<Route path="/addUser" component={AddUser}/>
52+
<Route path="/removeUser" component={RemoveUser}/>
6853
<Route path="/sandbox" component={Sandbox}/>
6954
<Route path="/about" component={About}/>
7055
<Redirect to="/home" />

client/src/components/PlayButton/index.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,12 @@ import {Button, Icon} from "antd";
44

55
function PlayButton({timestamp, url}) {
66
const [status, setStatus] = useState("STOPPED");
7-
const [port, setPort] = useState();
8-
const [ip, setIp] = useState();
9-
const [loading, setLoading] = useState(true);
10-
11-
12-
useEffect(() => {
13-
getPort()
14-
},[]);
15-
16-
async function getPort() {
17-
const p = await localStorage.getItem('port');
18-
const i = localStorage.getItem('ip');
19-
20-
const port = p ? p : '3000';
21-
const ip = i ? i : '127.0.0.1';
22-
setPort(port);
23-
setIp(ip);
24-
setLoading(false)
25-
}
267

278
function PlayStop() {
289
if(status === "STOPPED") return setStatus("PLAYING");
2910
return setStatus("STOPPED")
3011
}
3112

32-
if(loading) return (<div></div>);
33-
3413
return (
3514
<div>
3615
<Sound

client/src/helpers/api.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ export const post = async function(data, url) {
44
if(process.env.REACT_APP_DEV_SERVER) {
55
return axios.post(`${process.env.REACT_APP_DEV_SERVER}/server/${url}`, data);
66
}
7-
87
return axios.post(`/server/${url}`, data);
98
};
109

10+
export const get = async function(data, url) {
11+
if(process.env.REACT_APP_DEV_SERVER) {
12+
return axios.get(`${process.env.REACT_APP_DEV_SERVER}/server/${url}`, data);
13+
}
14+
return axios.get(`/server/${url}`, data);
15+
};
16+
1117
export const sandbox = async function(data) {
1218
if(process.env.REACT_APP_DEV_SERVER) {
1319
return axios.post(`${process.env.REACT_APP_DEV_SERVER}/assistant`, data);

client/src/views/dash/About/index.js

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React, {useEffect, useState} from "react";
22
import {message, Typography, Alert} from "antd";
3-
import {post} from '~/helpers/api';
3+
import {post, get} from '~/helpers/api';
44

55
import * as Styles from './styles';
66

77
const {Text, Paragraph, Title} = Typography;
88

99
function About(){
1010
const [isUpdate, setIsUpdate] = useState(false);
11+
const [v, setV] = useState(null);
1112

1213
useEffect(() => {
1314
checkUpdate();
@@ -16,67 +17,55 @@ function About(){
1617
async function checkUpdate() {
1718
try {
1819
const resp = await post({}, 'checkUpdate');
19-
setIsUpdate(resp.data)
20+
const v = await get({}, 'version');
21+
setIsUpdate(resp.data);
22+
setV(v.data.version)
2023
} catch (e) {
2124
message.error(e.message);
2225
}
2326
}
2427

2528
return (
2629
<Styles.Container>
27-
<Styles.Text>
30+
<div>
2831
<AlertBox update={isUpdate}/>
29-
<Title level={3}>About Assistant Relay</Title>
30-
<Paragraph>
31-
<Text>
32-
Assistant Relay is a Node.js server that exposes the Google Assistant as a REST API.
33-
Send Assistant Relay any query you would send the Google Assistant SDK, and get a response back.
34-
</Text>
35-
</Paragraph>
36-
<Paragraph>
37-
<Text>
38-
It also supports the Google Home Broadcast command so you can send audio notifications to your Google Home devices, without interrupting music.
39-
</Text>
40-
</Paragraph>
41-
<Paragraph>
42-
<Text strong>
43-
Please Note: Assistant Relay is restricted by the Google Assistant SDK. Some commands are not supported.
44-
</Text>
45-
</Paragraph>
46-
<Paragraph>
47-
<Text>
48-
Assistant Relay is not affiliated with Google or Google Assistant.
49-
</Text>
50-
</Paragraph>
51-
52-
<Title level={3}>License</Title>
53-
54-
<Text>
55-
Assistant Relay is distributed with the GNU General Public License v3.0
56-
</Text>
57-
58-
<Title level={3}>Found an issue?</Title>
59-
<Paragraph>
60-
<Text>
61-
If you find an issue, you can check existing issues or submit a new issue here: <a href="https://github.com/greghesp/assistant-relay/issues" target="_blank">Github Issues</a>
62-
</Text>
63-
</Paragraph>
64-
65-
<Title level={3}>Want to buy me a coffee?</Title>
66-
<Text>Any donations are greatly appreciated, but certainly not required!</Text>
32+
<Styles.Title>About Assistant Relay</Styles.Title>
33+
34+
<p>Assistant Relay is a Node.js server that exposes the Google Assistant as a REST API.
35+
Send Assistant Relay any query you would send the Google Assistant SDK, and get a response back.</p>
36+
<p>It also supports the Google Home Broadcast command so you can send audio notifications to your Google Home devices, without interrupting music. </p>
37+
<p>Please Note: Assistant Relay is restricted by the Google Assistant SDK. Some commands are not supported.</p>
38+
<p>Assistant Relay is not affiliated with Google or Google Assistant.</p>
39+
40+
<Styles.Title>Found an issue?</Styles.Title>
41+
<p>If you find an issue, you can check existing issues or submit a new issue here: <a href="https://github.com/greghesp/assistant-relay/issues" target="_blank">Github Issues</a></p>
42+
43+
44+
<Styles.Title>Want to buy me a coffee?</Styles.Title>
45+
<p>Any donations are greatly appreciated, but certainly not required!</p>
6746
<Styles.Form>
6847
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
6948
<input type="hidden" name="cmd" value="_s-xclick" />
7049
<input type="hidden" name="hosted_button_id" value="YK2LXAHNTSVLC" />
7150
<input width="200" type="image" src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
7251
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1" />
7352
</form>
74-
7553
</Styles.Form>
54+
</div>
55+
56+
57+
<div>
58+
<Styles.Title>Want to chat?</Styles.Title>
59+
<Styles.Frame><iframe src="https://discordapp.com/widget?id=671664792896798720&theme=dark" width="350"
60+
height="300" allowTransparency="true" frameBorder="0"/></Styles.Frame>
7661

77-
</Styles.Text>
62+
<Styles.Title>License</Styles.Title>
63+
<p>Assistant Relay is distributed with the GNU General Public License v3.0</p>
7864

65+
<Styles.Title>Version</Styles.Title>
66+
<p>You are running version {v ? v : "...Fetching..."}</p>
7967

68+
</div>
8069
</Styles.Container>
8170
)
8271
}

client/src/views/dash/About/styles.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ export const Loading = styled.div`
66
justify-content: center;
77
`;
88

9+
export const Title = styled.h2`
10+
text-align: center;
11+
margin-top: 20px;
12+
`;
13+
14+
export const Frame = styled.div`
15+
text-align: center;
16+
`
17+
918
export const Container = styled.div`
10-
margin-top: 20px;
1119
display: flex;
12-
align-items: center;
13-
justify-content: center;
20+
flex-wrap: wrap;
21+
>div {
22+
flex: 0 50%;
23+
padding: 20px;
24+
}
1425
`;
1526

1627
export const Text = styled.div`
@@ -20,9 +31,9 @@ text-align: center;
2031

2132
export const Form = styled.div`
2233
text-align: center;
23-
display: flex;
24-
align-items: center;
25-
justify-content: center;
34+
display: flex;
35+
align-items: center;
36+
justify-content: center;
2637
`;
2738

2839
export const Alert = styled.div`

client/src/views/dash/Home/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Home(){
4040
}
4141

4242
function Responses({data}) {
43-
if(data.length === 0) return <p>No responses yet</p>
43+
if(data.length === 0) return <p>No responses yet</p>;
4444
return (
4545
data.map(r => {
4646
return (

client/src/views/dash/Menu/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ function MenuContainer({history, location}) {
2020
Configuration
2121
</Menu.Item>
2222
<Menu.Item key="addUser">
23-
<Icon type="user-add" />
23+
<Icon type="user-delete" />
2424
Add New User
2525
</Menu.Item>
26+
<Menu.Item key="removeUser">
27+
<Icon type="user-add" />
28+
Remove User
29+
</Menu.Item>
2630
<Menu.Item key="sandbox">
2731
<Icon type="code" />
2832
Sandbox
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, {useEffect, useState} from "react";
2+
import {message, Select, Button, Popconfirm} from "antd";
3+
import {get, post} from '~/helpers/api';
4+
5+
import * as Styles from './styles';
6+
7+
8+
function RemoveUser(){
9+
const [users, setUsers] = useState(false);
10+
const [loading, setLoading] = useState(true);
11+
const [userToDelete, setToDelete] = useState(null);
12+
13+
useEffect(() => {
14+
getUsers();
15+
},[]);
16+
17+
async function getUsers() {
18+
try {
19+
const resp = await get({}, 'users');
20+
setUsers(resp.data.users);
21+
setLoading(false)
22+
} catch (e) {
23+
message.error(e.message);
24+
}
25+
}
26+
27+
function onChange(i) {
28+
setToDelete(i)
29+
}
30+
31+
async function deleteUser() {
32+
try {
33+
await post({name: userToDelete}, 'deleteUser');
34+
message.success(`User ${userToDelete} has been removed`);
35+
getUsers();
36+
} catch (e) {
37+
message.error(e.message);
38+
}
39+
}
40+
41+
if(loading) return null;
42+
43+
return (
44+
<Styles.Container>
45+
<Styles.Item>
46+
<Select
47+
style={{ width: 200 }}
48+
placeholder="Select a person"
49+
onChange={onChange}
50+
>
51+
{users.map(u => {
52+
return <Select.Option value={u}>{u}</Select.Option>
53+
})}
54+
</Select>
55+
</Styles.Item>
56+
<Styles.Item>
57+
<Popconfirm
58+
title="Are you sure delete this user?"
59+
onConfirm={deleteUser}
60+
okText="Yes"
61+
cancelText="No">
62+
<Button type="danger">Remove User</Button>
63+
</Popconfirm>
64+
</Styles.Item>
65+
</Styles.Container>
66+
)
67+
}
68+
69+
70+
71+
export default RemoveUser;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import styled from 'styled-components';
2+
3+
export const Loading = styled.div`
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
7+
`;
8+
9+
export const Container = styled.div`
10+
margin-top: 20px;
11+
display: flex;
12+
align-items: center;
13+
justify-content:center;
14+
`;
15+
16+
export const Item = styled.div`
17+
margin: 0 10px;
18+
`;
19+
20+

readMe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Send Assistant Relay any query you would send the Google Assistant SDK, and get
1212

1313
It also supports the Google Home Broadcast command so you can send audio notifications to your Google Home devices, without interrupting music.
1414

15+
## New in V3.2.0
16+
- Added the ability to [delete a user](https://github.com/greghesp/assistant-relay/issues/142)
17+
- Added version information to About page
18+
- Updated About page
19+
1520
## New in V3.1.4
1621
- Merged [Pull Request](https://github.com/greghesp/assistant-relay/pull/149) to fix play button not working remotely
1722

relay/bin/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v3.1.4"
2+
"version": "v3.2.0"
33
}

0 commit comments

Comments
 (0)