From 786404a8a692448b04fd8df5dbca8013631a0abd Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 9 Mar 2021 17:50:09 +0100 Subject: adding episodes to projects --- .../app/views/dashboard/dashboard.container.js | 127 +++++++++++++++++++++ .../frontend/app/views/dashboard/dashboard.css | 52 +++++++++ 2 files changed, 179 insertions(+) create mode 100644 animism-align/frontend/app/views/dashboard/dashboard.container.js create mode 100644 animism-align/frontend/app/views/dashboard/dashboard.css (limited to 'animism-align/frontend/app/views/dashboard') diff --git a/animism-align/frontend/app/views/dashboard/dashboard.container.js b/animism-align/frontend/app/views/dashboard/dashboard.container.js new file mode 100644 index 0000000..6befaae --- /dev/null +++ b/animism-align/frontend/app/views/dashboard/dashboard.container.js @@ -0,0 +1,127 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' + +import './dashboard.css' + +// import actions from 'app/actions' +import { Loader } from 'app/common' +import { groupResponseBy } from 'app/utils/api.utils' + +class DashboardContainer extends Component { + state = { + ready: false, + episodes: {}, + venues: {}, + } + + constructor(props) { + super(props) + } + + componentDidMount() { + this.build() + } + + componentDidUpdate(prevProps) { + if ( + !this.state.ready || + (this.props.project !== prevProps.project) || + (this.props.episode !== prevProps.episode) || + (this.props.venue !== prevProps.venue) + ) { + this.build() + } + } + + build() { + if (this.props.loading) return + const episodes = groupResponseBy(this.props.episodes, 'project_id') + const venues = groupResponseBy(this.props.venues, 'project_id') + this.setState({ ready: true, episodes, venues }) + } + + render() { + const { loading, projects } = this.props + const { episodes, venues, ready } = this.state + if (loading || !ready) { + return ( +
+ +
+ ) + } + return ( +
+
+
+
+

Projects

+
+
+ + Add Project +
+
+
+ {projects.order.map((project_id) => { + const project = projects.lookup[project_id] + console.log(project) + return ( +
+
+
+

{project.title}

+ {project.is_live && {"(published)"}} +
+
+ + Add Episode + Venues + Settings +
+
+ {(episodes[project.id] || []).map(episode => ( +
+
+
+ + {'Episode #' + episode.episode_number} + + {episode.is_live && {"(published)"}} +
+
+ Viewer + Timeline + Transcript + Settings +
+
+
+
+ {episode.title} +
+
+
+ ))} +
+ ) + })} +
+ ) + } +} + +const mapStateToProps = state => ({ + loading: ( + !state.project.index.lookup || + !state.episode.index.lookup || + !state.venue.index.lookup || + state.project.index.loading || + state.episode.index.loading || + state.venue.index.loading + ), + projects: state.project.index, + episodes: state.episode.index, + venues: state.venue.index, +}) + +export default connect(mapStateToProps)(DashboardContainer) diff --git a/animism-align/frontend/app/views/dashboard/dashboard.css b/animism-align/frontend/app/views/dashboard/dashboard.css new file mode 100644 index 0000000..34bcb66 --- /dev/null +++ b/animism-align/frontend/app/views/dashboard/dashboard.css @@ -0,0 +1,52 @@ +.dashboard { + padding: 1.5rem; +} + +.project-top { + padding: 1rem; +} +.project-top h1 { + margin: 0; +} + +.dashboard .project-entry { + padding: 1rem; + margin: 0 0 1rem 0; + background: #111; +} + +.dashboard .episode-entry { + margin-bottom: 0.5rem; +} +.dashboard .project-entry .row.project-heading { + margin-bottom: 1rem; +} +.dashboard h2 { + display: inline-block; + margin: 0; +} +.dashboard .title { + width: 25rem; + color: #fff; + text-overflow: ellipsis; + white-space: pre; + overflow: hidden; +} +.dashboard .row { + margin-bottom: 0.25rem; + align-items: center; +} +.dashboard .links a { + margin-right: 0.5rem; + text-decoration: none; +} +.dashboard .links a:hover { + text-decoration: underline; +} +.dashboard .published { + color: #888; + margin-left: 0.5rem; +} +.dashboard i { + color: #bbb; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2