diff --git a/src/App.js b/src/App.js index 71a37c4..7edfd9c 100644 --- a/src/App.js +++ b/src/App.js @@ -11,7 +11,7 @@ class App extends Component { super(props); this.state = { discoveries: [], - groups: [], // Currently duscovered patterns and their controllers + groups: [], // Currently discovered patterns and their controllers runningPatternName: null, playlist: [], // Browser-persisted single playlist singleton playlistIndex: 0, @@ -19,9 +19,10 @@ class App extends Component { cloneSource: null, cloneDest: {}, cloneInProgress: false, - showDevControls: false + showDevControls: false, + showCurrentPlaylist: false, } - // The playlist is the only thing currently persisted and it is per-broswer + // The playlist is the only thing currently persisted, and it is per-browser this.state.playlist = JSON.parse(localStorage.getItem(PLAYLIST_KEY)) || [] if (this.state.playlist.length) { @@ -33,6 +34,7 @@ class App extends Component { this._playlistInterval = null this.cloneDialogRef = React.createRef(); + this.playlistDialogRef = React.createRef(); } async poll() { @@ -207,7 +209,20 @@ class App extends Component { this.cloneDialogRef.current && this.cloneDialogRef.current.scrollIntoView(true); }, 100) } - + openPlaylistDialog = async (event) => { + event.preventDefault(); + this.setState({ + showCurrentPlaylist: true + }); + setTimeout(() => { + this.playlistDialogRef.current && this.playlistDialogRef.current.scrollIntoView(true); + }, 100) + if( this.state.showCurrentPlaylist === true ) { + this.setState({ + showCurrentPlaylist: false + }); + } + } closeCloneDialog = async (event) => { event.preventDefault(); this.setState({ @@ -260,7 +275,6 @@ class App extends Component { } } - render() { let cloneDialog = null; if (this.state.cloneSource) { @@ -309,6 +323,44 @@ class App extends Component { ) } + let playlistDialog = null + if (this.state.showCurrentPlaylist) { + playlistDialog = ( +
+
+
+
+
Current Playlist
+
+
+

Pattern

+
+
+

Duration(seconds)

+
+
+ {(this.state.playlist).map( (pattern, index) => +
+
+
+
+ {pattern.name} +
+
+
+
+ {pattern.duration} +
+
+
+
+ )} +
+
+
+
+ ) + } return (
@@ -350,8 +402,15 @@ class App extends Component {
{cloneDialog} - -

Patterns

+ {playlistDialog} +

+ Patterns + +

{this.state.groups.map((pattern) => { const getStatus = () => { @@ -363,7 +422,7 @@ class App extends Component { return 'available' } } - const getDuraton = () => { + const getDuration = () => { const playlistIndex = _(this.state.playlist).findIndex(['name', pattern.name]) if (playlistIndex === -1) return '' return this.state.playlist[playlistIndex].duration @@ -378,7 +437,7 @@ class App extends Component { handleAddClick={this._handleAddClick} status={getStatus()} showDurations={(this.state.playlist.length > 1)} - duration={getDuraton()} + duration={getDuration()} /> ) })}