2017-07-07 09:59:16 +12:00
|
|
|
|
2019-02-10 19:51:33 +13:00
|
|
|
import React from 'react';
|
2019-01-16 16:46:40 +13:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
|
import Header from '../../components/Header';
|
|
|
|
|
import GridItem from '../../components/GridItem';
|
|
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import ErrorBoundary from '../../components/ErrorBoundary';
|
|
|
|
|
import * as uiActions from '../../services/ui/actions';
|
|
|
|
|
import * as mopidyActions from '../../services/mopidy/actions';
|
2020-03-05 21:32:54 +13:00
|
|
|
import { formatImages } from '../../util/format';
|
2020-07-19 20:41:14 +12:00
|
|
|
import { I18n, i18n } from '../../locale';
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2020-03-03 16:39:37 +13:00
|
|
|
class LibraryBrowse extends React.Component {
|
2019-09-05 15:36:11 +12:00
|
|
|
componentDidMount() {
|
|
|
|
|
this.loadDirectory();
|
2020-07-19 20:41:14 +12:00
|
|
|
this.props.uiActions.setWindowTitle(i18n('library.browse.title'));
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-08-12 08:06:24 +12:00
|
|
|
loadDirectory = () => {
|
|
|
|
|
const {
|
|
|
|
|
mopidyActions: {
|
|
|
|
|
getDirectory,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
getDirectory(null);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const grid_items = [];
|
|
|
|
|
if (this.props.directory) {
|
2020-03-03 16:39:37 +13:00
|
|
|
for (const subdirectory of this.props.directory.subdirectories) {
|
2019-09-05 15:36:11 +12:00
|
|
|
switch (subdirectory.name) {
|
|
|
|
|
case 'Dirble':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-dirble.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Files':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-folders.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Local media':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-folders.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Spotify':
|
|
|
|
|
case 'Spotify Browse':
|
|
|
|
|
case 'Spotify Web Browse':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-spotify.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Spotify Tunigo':
|
|
|
|
|
case 'Tunigo':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tunigo.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'TuneIn':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tunein.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'SoundCloud':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-soundcloud.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2020-07-05 21:16:31 +02:00
|
|
|
case 'Mixcloud':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-mixcloud.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
case 'iTunes Store: Podcasts':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-itunes.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Soma FM':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-somafm.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2020-04-30 15:45:55 +12:00
|
|
|
case 'Tidal':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tidal.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Google':
|
|
|
|
|
case 'Google Play':
|
|
|
|
|
case 'Google Play Music':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-google.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
default:
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-default.jpg'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid_items.push({
|
|
|
|
|
name: subdirectory.name,
|
|
|
|
|
link: `/library/browse/${encodeURIComponent(subdirectory.uri)}`,
|
2020-03-03 16:39:37 +13:00
|
|
|
icons: formatImages(subdirectory.icons),
|
2019-09-05 15:36:11 +12:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="view library-local-view">
|
|
|
|
|
<Header>
|
|
|
|
|
<Icon name="folder" type="material" />
|
2020-07-19 20:41:14 +12:00
|
|
|
<I18n path="library.browse.title" />
|
2019-09-05 15:36:11 +12:00
|
|
|
</Header>
|
|
|
|
|
<section className="content-wrapper">
|
|
|
|
|
<div className="grid grid--tiles">
|
|
|
|
|
<ErrorBoundary>
|
|
|
|
|
{
|
2018-10-04 21:07:25 +13:00
|
|
|
grid_items.map(
|
2019-09-05 15:36:11 +12:00
|
|
|
(item, index) => (
|
2020-03-10 07:56:33 +13:00
|
|
|
<GridItem
|
|
|
|
|
item={item}
|
|
|
|
|
key={index}
|
|
|
|
|
link={item.link}
|
|
|
|
|
mopidyActions={this.props.mopidyActions}
|
|
|
|
|
type="browse"
|
|
|
|
|
/>
|
2019-09-05 15:36:11 +12:00
|
|
|
),
|
2018-10-04 21:07:25 +13:00
|
|
|
)
|
|
|
|
|
}
|
2019-09-05 15:36:11 +12:00
|
|
|
</ErrorBoundary>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-07-07 09:59:16 +12:00
|
|
|
}
|
|
|
|
|
|
2020-08-12 08:06:24 +12:00
|
|
|
const mapStateToProps = (state) => ({
|
2019-09-05 15:36:11 +12:00
|
|
|
load_queue: state.ui.load_queue,
|
|
|
|
|
directory: state.mopidy.directory,
|
|
|
|
|
view: state.ui.library_directory_view,
|
|
|
|
|
});
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
});
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2020-03-03 16:39:37 +13:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(LibraryBrowse);
|