Adding 'Reset Defaults' for Snapcast server-configured values
This commit is contained in:
@ -6,6 +6,7 @@ import SnapcastGroups from './SnapcastGroups';
|
||||
import * as uiActions from '../services/ui/actions';
|
||||
import * as actions from '../services/snapcast/actions';
|
||||
import { I18n } from '../locale';
|
||||
import Button from './Button';
|
||||
|
||||
const Snapcast = (props) => {
|
||||
const {
|
||||
@ -14,6 +15,7 @@ const Snapcast = (props) => {
|
||||
uiActions,
|
||||
match,
|
||||
history,
|
||||
config,
|
||||
snapcast: {
|
||||
host,
|
||||
port,
|
||||
@ -23,6 +25,17 @@ const Snapcast = (props) => {
|
||||
},
|
||||
} = props;
|
||||
|
||||
const restoreDefaults = () => {
|
||||
const {
|
||||
snapcast_enabled = false,
|
||||
snapcast_host = 'localhost',
|
||||
snapcast_port = '1780',
|
||||
} = config || {};
|
||||
|
||||
actions.setEnabled(snapcast_enabled);
|
||||
actions.setConnection({ host: snapcast_host, port: snapcast_port });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="snapcast">
|
||||
|
||||
@ -65,6 +78,9 @@ const Snapcast = (props) => {
|
||||
<I18n path="snapcast.show_disconnected_clients" />
|
||||
</span>
|
||||
</label>
|
||||
<Button onClick={restoreDefaults} size="small" className="no-margin">
|
||||
<I18n path="services.restore_defaults" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -102,6 +118,7 @@ const Snapcast = (props) => {
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
snapcast: state.snapcast,
|
||||
config: state.pusher.config,
|
||||
show_disconnected_clients: (
|
||||
state.ui.snapcast_show_disconnected_clients !== undefined
|
||||
? state.ui.snapcast_show_disconnected_clients
|
||||
|
||||
Reference in New Issue
Block a user