Merge branch 'feature/sortable-sources' into develop

This commit is contained in:
James Barnsley
2017-12-30 22:44:19 +13:00
14 changed files with 3407 additions and 1548 deletions

View File

@ -1 +1 @@
3.9.0
3.10.0

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1513798726";
var build = "1513886354";
var version = "3.9.0";
// Construct the script tag

View File

@ -1,50 +1,52 @@
{
"name": "mopidy-iris",
"version": "3.9.0",
"description": "Mopidy HTTP interface",
"repository": "https://github.com/jaedb/iris",
"author": "James Barnsley <james@barnsley.nz>",
"license": "ISC",
"bugs": {
"url": "https://github.com/jaedb/Iris/issues"
},
"main": "app.js",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
"copy-dir": "^0.3.0",
"css-loader": "^0.28.7",
"expose-loader": "0.7.3",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "^0.11.2",
"flux": "^3.1.3",
"jquery": "^3.2.1",
"mopidy": "^0.5.0",
"node-sass": "^4.5.3",
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react-fontawesome": "*",
"react-ga": "^2.3.4",
"react-lazyload": "2.2.7",
"react-redux": "^5.0.6",
"react-router": "^3.2.0",
"redux": "3.7.2",
"redux-devtools": "3.4.0",
"redux-thunk": "2.2.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.13.2",
"url-loader": "^0.5.9",
"webpack": "^3.6.0",
"webpack-strip": "0.1.0"
},
"scripts": {
"build": "node build_tools/build.js",
"dev": "node build_tools/build.js && NODE_ENV=development webpack --watch",
"prod": "node build_tools/build.js && NODE_ENV=development webpack && NODE_ENV=production webpack --watch",
"release": "node build_tools/build.js && NODE_ENV=production webpack && NODE_ENV=development webpack && python setup.py sdist upload -r pypi && build_tools/release.sh"
}
"name": "mopidy-iris",
"version": "3.9.0",
"description": "Mopidy HTTP interface",
"repository": "https://github.com/jaedb/iris",
"author": "James Barnsley <james@barnsley.nz>",
"license": "ISC",
"bugs": {
"url": "https://github.com/jaedb/Iris/issues"
},
"main": "app.js",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
"copy-dir": "^0.3.0",
"css-loader": "^0.28.7",
"expose-loader": "0.7.3",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "^0.11.2",
"flux": "^3.1.3",
"jquery": "^3.2.1",
"mopidy": "^0.5.0",
"node-sass": "^4.5.3",
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react-fontawesome": "*",
"react-ga": "^2.3.4",
"react-lazyload": "2.2.7",
"react-redux": "^5.0.6",
"react-router": "^3.2.0",
"react-sortablejs": "^1.3.6",
"redux": "3.7.2",
"redux-devtools": "3.4.0",
"redux-thunk": "2.2.0",
"sass-loader": "^6.0.6",
"sortablejs": "^1.7.0",
"style-loader": "^0.13.2",
"url-loader": "^0.5.9",
"webpack": "^3.6.0",
"webpack-strip": "0.1.0"
},
"scripts": {
"build": "node build_tools/build.js",
"dev": "node build_tools/build.js && NODE_ENV=development webpack --watch",
"prod": "node build_tools/build.js && NODE_ENV=development webpack && NODE_ENV=production webpack --watch",
"release": "node build_tools/build.js && NODE_ENV=production webpack && NODE_ENV=development webpack && python setup.py sdist upload -r pypi && build_tools/release.sh"
}
}

View File

@ -168,7 +168,7 @@ export default class EditRadioModal extends React.Component{
{seed.unresolved ? <span className="grey-text">{seed.uri}</span> : <span>{seed.name}</span> }
{!seed.unresolved ? <span className="grey-text">&nbsp;({seed.type})</span> : null}
<button className="discrete remove-uri no-hover" onClick={e => this.removeSeed(seed.uri)}>
<FontAwesome name="close" />&nbsp;Remove
<FontAwesome name="trash" />
</button>
</div>
)

View File

@ -1,6 +1,7 @@
import React, { PropTypes } from 'react'
import FontAwesome from 'react-fontawesome'
import Sortable from 'react-sortablejs';
import Icon from '../Icon'
import * as helpers from '../../helpers'
@ -10,7 +11,8 @@ export default class SearchURISchemesModal extends React.Component{
constructor(props){
super(props)
this.state = {
schemes: []
schemes: [],
available_schemes: this.props.available_uri_schemes
}
}
@ -37,30 +39,60 @@ export default class SearchURISchemesModal extends React.Component{
}
render(){
var unselected_schemes = [];
for (var i = 0; i < this.props.available_uri_schemes.length; i++){
var scheme = this.props.available_uri_schemes[i];
if (!this.state.schemes.includes(scheme)){
unselected_schemes.push(scheme);
}
}
return (
<div>
<h1 className="no-bottom-padding">Search sources</h1>
<h2 className="grey-text bottom-padding">Customise the providers used when searching. Reduce the number of providers to speed up your searches. Please note that not all backends support searching by artist, album or playlist.</h2>
<h2 className="grey-text bottom-padding">Customise the providers used when searching. Reduce the number of providers to speed up your searches.</h2>
<form onSubmit={e => this.handleSubmit(e)}>
<div className="list small">
<Sortable
className="list"
options={{
handle: '.drag-handle'
}}
onChange={(order, sortable, e) => {
this.setState({schemes: order})
}}>
{
this.state.schemes.map(scheme => {
return (
<div className="list-item draggable" key={scheme} data-id={scheme}>
<FontAwesome className="grey-text drag-handle" name="bars" />
{scheme.replace(':','')}
<button className="discrete remove-uri no-hover" onClick={e => this.handleToggle(scheme)}>
<FontAwesome name="trash" />
</button>
</div>
)
})
}
</Sortable>
<div className="available-schemes">
<h4>Add more schemes</h4>
{
this.props.available_uri_schemes.map(scheme => {
return (
<div className="list-item field checkbox white" key={scheme}>
<label>
<input
type="checkbox"
name={scheme}
checked={this.state.schemes.indexOf(scheme) > -1}
onChange={ e => this.handleToggle(scheme)} />
<span className="label">{scheme.replace(':','')} &nbsp;<FontAwesome className="grey-text" name={helpers.sourceIcon(scheme)} /></span>
</label>
unselected_schemes.map(scheme => {
return (
<div
className="scheme flag large blue"
key={scheme}
onClick={e => this.handleToggle(scheme)}>
{scheme.replace(':','')}
&nbsp;&nbsp;
<FontAwesome name="plus" />
</div>
)
})
}
</div>
</div>
<div className="actions centered-text">
<button type="submit" className="primary wide">Save</button>

View File

@ -595,55 +595,76 @@ export let createRange = function (indexes){
* @param array = array to sort
* @param property = string to sort by
* @param reverse = boolean
* @param sort_map = array of value ordering (rather than alphabetical, numerical, etc)
* @return array
**/
export let sortItems = function (array, property, reverse = false){
export let sortItems = function (array, property, reverse = false, sort_map = null){
function compare(a,b){
var a_value = a
var a_property_split = property.split('.')
var a_value = a;
var a_property_split = property.split('.');
for (var i = 0; i < a_property_split.length; i++){
if (typeof(a_value[a_property_split[i]]) === 'undefined'){
a_value = false
break
a_value = false;
break;
} else {
a_value = a_value[a_property_split[i]]
a_value = a_value[a_property_split[i]];
}
}
var b_value = b
var b_property_split = property.split('.')
for(var i = 0; i < b_property_split.length; i++){
var b_value = b;
var b_property_split = property.split('.');
for (var i = 0; i < b_property_split.length; i++){
if (typeof(b_value[b_property_split[i]]) === 'undefined'){
b_value = false
break
b_value = false;
break;
} else {
b_value = b_value[b_property_split[i]]
b_value = b_value[b_property_split[i]];
}
}
if (typeof(a_value) === 'boolean'){
if (a_value && !b_value) return -1
if (!a_value && b_value) return 1
// Sorting by URI as a reference for sorting by uri source (first component of URI)
if (property == 'uri'){
a_value = uriSource(a_value);
b_value = uriSource(b_value);
}
// Map sorting
// Use the index of the string as a sorting mechanism
if (sort_map){
var a_index = sort_map.indexOf(a_value+':');
var b_index = sort_map.indexOf(b_value+':');
if (a_index < b_index) return 1;
if (a_index > b_index) return -1;
// Boolean sorting
} else if (typeof(a_value) === 'boolean'){
if (a_value && !b_value) return -1;
if (!a_value && b_value) return 1;
return 0
}else if (typeof(a_value) === 'string'){
if (!a_value || !b_value ) return 0
if (a_value.toLowerCase() > b_value.toLowerCase()) return 1
if (a_value.toLowerCase() < b_value.toLowerCase()) return -1
// Alphabetic sorting
} else if (typeof(a_value) === 'string'){
if (!a_value || !b_value ) return 0;
if (a_value.toLowerCase() > b_value.toLowerCase()) return 1;
if (a_value.toLowerCase() < b_value.toLowerCase()) return -1;
return 0
// Numeric sorting
} else {
if (parseInt(a_value) > parseInt(b_value)) return 1
if (parseInt(a_value) < parseInt(b_value)) return -1
if (parseInt(a_value) > parseInt(b_value)) return 1;
if (parseInt(a_value) < parseInt(b_value)) return -1;
return 0
}
}
var sorted = Object.assign([], array.sort(compare))
if (reverse ) sorted.reverse()
return sorted
var sorted = Object.assign([], array.sort(compare));
if (reverse){
sorted.reverse();
}
return sorted;
}
/**

View File

@ -247,7 +247,7 @@ export function albumsLoaded(albums){
export function artistsLoaded(artists){
return {
type: 'ALBUMS_LOADED',
type: 'ARTISTS_LOADED',
artists: artists
}
}

View File

@ -85,44 +85,50 @@ class Search extends React.Component{
}
renderResults(){
var spotify_search_enabled = (this.props.search_settings && this.props.search_settings.spotify)
var spotify_search_enabled = (this.props.search_settings && this.props.search_settings.spotify);
var artists = []
if (this.props.sort == 'uri'){
var sort_map = this.props.search_uri_schemes;
} else {
var sort_map = null;
}
var artists = [];
if (this.props.mopidy_search_results.artists){
artists = [...artists, ...helpers.getIndexedRecords(this.props.artists,this.props.mopidy_search_results.artists)]
artists = [...artists, ...helpers.getIndexedRecords(this.props.artists,this.props.mopidy_search_results.artists)];
}
if (this.props.spotify_search_results.artists){
artists = [...artists, ...helpers.getIndexedRecords(this.props.artists,this.props.spotify_search_results.artists)]
artists = [...artists, ...helpers.getIndexedRecords(this.props.artists,this.props.spotify_search_results.artists)];
}
artists = helpers.sortItems(artists, this.props.sort, this.props.sort_reverse);
artists = helpers.sortItems(artists, this.props.sort, this.props.sort_reverse, sort_map);
var albums = []
var albums = [];
if (this.props.mopidy_search_results.albums){
albums = [...albums, ...helpers.getIndexedRecords(this.props.albums,this.props.mopidy_search_results.albums)];
}
if (this.props.spotify_search_results.albums){
albums = [...albums, ...helpers.getIndexedRecords(this.props.albums,this.props.spotify_search_results.albums)]
}
albums = helpers.sortItems(albums, this.props.sort, this.props.sort_reverse);
albums = helpers.sortItems(albums, this.props.sort, this.props.sort_reverse, sort_map);
var playlists = []
if (this.props.mopidy_search_results.playlists){
playlists = [...playlists, ...helpers.getIndexedRecords(this.props.playlists,this.props.mopidy_search_results.playlists)]
playlists = [...playlists, ...helpers.getIndexedRecords(this.props.playlists,this.props.mopidy_search_results.playlists)];
}
if (this.props.spotify_search_results.playlists){
playlists = [...playlists, ...helpers.getIndexedRecords(this.props.playlists,this.props.spotify_search_results.playlists)]
playlists = [...playlists, ...helpers.getIndexedRecords(this.props.playlists,this.props.spotify_search_results.playlists)];
}
playlists = helpers.sortItems(playlists, this.props.sort, this.props.sort_reverse);
playlists = helpers.sortItems(playlists, this.props.sort, this.props.sort_reverse, sort_map);
var tracks = []
var tracks = [];
if (this.props.mopidy_search_results.tracks){
tracks = [...tracks, ...this.props.mopidy_search_results.tracks]
tracks = [...tracks, ...this.props.mopidy_search_results.tracks];
}
if (this.props.spotify_search_results.tracks){
tracks = [...tracks, ...this.props.spotify_search_results.tracks]
tracks = [...tracks, ...this.props.spotify_search_results.tracks];
}
tracks = helpers.sortItems(tracks, this.props.sort, this.props.sort_reverse);
tracks = helpers.sortItems(tracks, this.props.sort, this.props.sort_reverse, sort_map);
switch (this.props.view){
case 'artists':
@ -134,7 +140,7 @@ class Search extends React.Component{
</section>
</div>
)
break
break;
case 'albums':
return (
@ -145,7 +151,7 @@ class Search extends React.Component{
</section>
</div>
)
break
break;
case 'playlists':
return (
@ -156,7 +162,7 @@ class Search extends React.Component{
</section>
</div>
)
break
break;
case 'tracks':
return (
@ -167,7 +173,7 @@ class Search extends React.Component{
</section>
</div>
)
break
break;
default:
@ -181,7 +187,7 @@ class Search extends React.Component{
</section>
)
} else {
var artists_section = null
var artists_section = null;
}
if (albums.length > 0){
@ -194,7 +200,7 @@ class Search extends React.Component{
</section>
)
} else {
var albums_section = null
var albums_section = null;
}
if (playlists.length > 0){
@ -207,7 +213,7 @@ class Search extends React.Component{
</section>
)
} else {
var playlists_section = null
var playlists_section = null;
}
if (tracks.length > 0){
@ -219,7 +225,7 @@ class Search extends React.Component{
</section>
)
} else {
var tracks_section = null
var tracks_section = null;
}
return (
@ -273,7 +279,7 @@ class Search extends React.Component{
label: 'Duration'
},
{
value: 'source',
value: 'uri',
label: 'Source'
}
]

View File

@ -144,18 +144,18 @@
height: 1px;
padding: 0;
margin: 0;
background: lighten($grey, 8%);
background: lighten($grey, 5%);
}
& > span {
display: block;
margin-bottom: -1px;
button,
.button,
.dropdown-field {
text-decoration: none;
display: block;
border: 0;
margin: 0;
min-width: 100% !important;
max-width: 100% !important;
@ -165,10 +165,7 @@
text-transform: none;
font-weight: 300;
color: inherit;
&:not(:first-child):not(.dropdown-field){
border-top: 1px solid lighten($dark_grey, 8%);
}
border-bottom: 1px solid lighten($grey, 5%) !important;
.fa {
display: none;
@ -187,29 +184,34 @@
}
.dropdown-field {
padding: 0;
box-shadow: none;
padding: 16px 20px;
.label {
padding: 16px 20px;
padding: 0 0 3px 0;
font-weight: 800;
}
.options {
display: block;
position: static;
background: $darkest_grey;
background: transparent;
border-radius: 0;
border: 0;
color: $white !important;
box-shadow: none;
.option {
padding: 12px 20px 12px 50px;
display: inline-block;
padding: 3px 5px;
border-radius: 0;
opacity: 0.6;
.fa {
display: inline-block;
left: 25px;
top: 14px;
position: relative;
padding-right: 5px;
top: auto;
left: auto;
}
}

View File

@ -44,6 +44,7 @@
#context-menu {
.filter-field {
display: block;
border-bottom: 1px solid lighten($grey, 5%);
.fa {
top: 17px;
@ -51,10 +52,14 @@
color: $white !important;
}
input {
padding: 14px 18px 14px 42px;
form {
width: 100%;
box-sizing: border-box;
input {
padding: 14px 18px 14px 42px;
width: 100%;
box-sizing: border-box;
}
}
}
}

View File

@ -104,6 +104,30 @@
}
}
.add-uri,
.remove-uri {
position: absolute;
top: 6px;
right: 6px;
padding: 8px;
margin: 0;
min-width: 0;
color: #FFFFFF;
background: transparent;
&:before {
display: none !important;
}
&:hover {
color: $turquoise;
&.remove-uri {
color: $red;
}
}
}
.list {
@include clearfix();
@ -111,7 +135,7 @@
@include animate();
box-sizing: border-box;
display: block;
padding: 14px 12px;
padding: 14px 12px 12px;
position: relative;
border: 0;
border-radius: 3px;
@ -127,6 +151,17 @@
&:hover {
background: rgba(255,255,255,0.1);
}
&.draggable {
padding-left: 35px !important;
.drag-handle {
position: absolute;
top: 0;
left: 0;
padding: 16px 12px;
}
}
}
&.playlists {
@ -188,30 +223,6 @@
}
}
}
.add-uri,
.remove-uri {
position: absolute;
top: 5px;
right: 0;
padding: 8px;
margin: 0;
min-width: 0;
color: #FFFFFF;
background: transparent;
&:before {
display: none !important;
}
&:hover {
color: $turquoise;
&.remove-uri {
color: $red;
}
}
}
}
&.kiosk_mode {
@ -289,6 +300,23 @@
}
}
&.search_uri_schemes {
.available-schemes {
padding-top: 40px;
.scheme {
@include animate();
margin-left: 0;
margin-bottom: 8px;
&:hover {
cursor: pointer;
background: darken($blue, 8%);
}
}
}
}
.actions {
padding-top: 50px;
text-align: center;
@ -313,9 +341,15 @@
border-top: 0;
width: auto !important;
margin: 0;
&.draggable {
.drag-handle {
padding-top: 14px;
padding-bottom: 14px;
}
}
}
}
}
}
}

View File

@ -394,6 +394,11 @@ footer {
color: $mid_grey;
}
&.large {
padding: 8px 10px 7px;
font-size: 12px;
}
h1 &,
h2 & {
line-height: 1.4em;