@@ -4,8 +4,6 @@ import {Input, InputNumber, Switch, message, TimePicker, Button, Icon, Select} f
4
4
import { post } from '~/helpers/api' ;
5
5
import * as Styles from './styles' ;
6
6
import LoadingAnimation from "~/components/LoadingAnimation" ;
7
- import GoogleDevices from "./GoogleDevices" ;
8
- import Users from "./Users" ;
9
7
import moment from 'moment' ;
10
8
import Text from "antd/es/typography/Text" ;
11
9
@@ -20,6 +18,8 @@ function Configuration({history}){
20
18
const [ quietHours , setQuietHours ] = useState ( ) ;
21
19
const [ loading , setLoading ] = useState ( true ) ;
22
20
const [ devices , setDevices ] = useState ( [ ] ) ;
21
+ const [ casting , setCasting ] = useState ( ) ;
22
+ const [ defaultCast , setDefaultCast ] = useState ( ) ;
23
23
const [ forceReboot , setForceReboot ] = useState ( false ) ;
24
24
25
25
useEffect ( ( ) => {
@@ -33,14 +33,28 @@ function Configuration({history}){
33
33
port,
34
34
quietHours,
35
35
devices,
36
- "conversation.lang" : language
36
+ "conversation.lang" : language ,
37
+ castEnabled : casting
37
38
} ;
38
39
await post ( obj , 'updateConfig' ) ;
39
- if ( forceReboot ) {
40
- message . success ( "Assistant Relay restarting" ) ;
41
- await post ( { } , 'restart' ) ;
42
- message . success ( `Restart Successful - Visit http://${ window . location . hostname } :${ port } to continue` )
40
+ if ( casting && ! defaultCast ) {
41
+ message . info ( "Please Wait - Installing Cast Dependencies" ) ;
42
+ await post ( { } , 'installCast' ) ;
43
+ message . success ( "Casting Enabled" ) ;
44
+ return rebootServer ( ) ;
43
45
}
46
+ if ( forceReboot ) rebootServer ( ) ;
47
+ } catch ( e ) {
48
+ console . log ( e . response ) ;
49
+ message . error ( e . response . data . message ) ;
50
+ }
51
+ }
52
+
53
+ async function rebootServer ( ) {
54
+ try {
55
+ message . success ( "Assistant Relay restarting" ) ;
56
+ await post ( { } , 'restart' ) ;
57
+ message . success ( `Restart Successful - Visit http://${ window . location . hostname } :${ port } to continue` )
44
58
} catch ( e ) {
45
59
message . error ( e . message ) ;
46
60
}
@@ -54,6 +68,8 @@ function Configuration({history}){
54
68
setQuietHours ( data . quietHours ) ;
55
69
setDevices ( data . devices ) ;
56
70
setLanguage ( data . language ) ;
71
+ setCasting ( data . castEnabled ) ;
72
+ setDefaultCast ( data . castEnabled ) ;
57
73
setInitGet ( false ) ;
58
74
setLoading ( false ) ;
59
75
} catch ( e ) {
@@ -96,8 +112,6 @@ function Configuration({history}){
96
112
return null ;
97
113
}
98
114
99
-
100
-
101
115
return (
102
116
< Styles . Container >
103
117
< Styles . Form >
@@ -106,10 +120,7 @@ function Configuration({history}){
106
120
< Switch checkedChildren = "On"
107
121
unCheckedChildren = "Off"
108
122
defaultChecked = { startupSound }
109
- onChange = { ( e ) => {
110
- console . log ( e )
111
- setStartupSound ( e )
112
- } } />
123
+ onChange = { ( e ) => { setStartupSound ( e ) } } />
113
124
</ Styles . Switch >
114
125
115
126
< Text > Port Number:</ Text >
@@ -147,14 +158,20 @@ function Configuration({history}){
147
158
< Option value = "pt-BR" > Portuguese (Brazil)</ Option >
148
159
</ Select >
149
160
161
+ < Text > Casting Enabled:</ Text >
162
+ < Styles . Switch >
163
+ < Switch checkedChildren = "On"
164
+ unCheckedChildren = "Off"
165
+ checked = { casting }
166
+ onChange = { ( e ) => {
167
+ setCasting ( e ) ;
168
+ setForceReboot ( true ) ;
169
+ } } />
170
+ </ Styles . Switch >
171
+
150
172
< div > </ div >
151
173
< Button type = "primary" onClick = { ( ) => updateConfig ( ) } > Save</ Button >
152
174
153
- { /*<Text>Users:</Text>*/ }
154
- { /*<Users />*/ }
155
-
156
- { /*<Text>Google Devices:</Text>*/ }
157
- { /*<GoogleDevices devices={devices} setDevices={(e) => setDevices(e)}/>*/ }
158
175
</ Styles . Form >
159
176
</ Styles . Container > )
160
177
}
0 commit comments