@@ -33176,8 +33176,8 @@ angular.module('spotmop.discover', [])
3317633176 $scope.sections = [];
3317733177
3317833178 // get my old favorites
33179- SpotifyService.getMyFavorites('artists', false , false, 'long_term').then( function(response){
33180- $scope.favorites.items = response.items;
33179+ SpotifyService.getMyFavorites('artists', 50 , false, 'long_term').then( function(response){
33180+ $scope.favorites.items = $filter('shuffle')( response.items) ;
3318133181 });
3318233182
3318333183
@@ -33300,10 +33300,10 @@ angular.module('spotmop.library', [])
3330033300 templateUrl: "app/library/albums.template.html",
3330133301 controller: 'LibraryAlbumsController'
3330233302 })
33303- .state('library.files ', {
33304- url: "/files/:folder ",
33305- templateUrl: "app/library/files .template.html",
33306- controller: 'LibraryFilesController '
33303+ .state('library.local ', {
33304+ url: "/local/:uri ",
33305+ templateUrl: "app/library/local .template.html",
33306+ controller: 'LibraryLocalController '
3330733307 });
3330833308}])
3330933309
@@ -33662,37 +33662,89 @@ angular.module('spotmop.library', [])
3366233662/**
3366333663 * Local files
3366433664 **/
33665- .controller('LibraryFilesController ', ['$scope', '$rootScope', '$filter', '$stateParams', '$localStorage', 'SpotifyService', 'SettingsService', 'DialogService', 'MopidyService', function ( $scope, $rootScope, $filter, $stateParams, $localStorage, SpotifyService, SettingsService, DialogService, MopidyService ){
33665+ .controller('LibraryLocalController ', ['$scope', '$rootScope', '$filter', '$stateParams', '$localStorage', 'SpotifyService', 'SettingsService', 'DialogService', 'MopidyService', function ( $scope, $rootScope, $filter, $stateParams, $localStorage, SpotifyService, SettingsService, DialogService, MopidyService ){
3366633666
33667- $scope.folders = [];
33668- $scope.tracklist = {tracks: []};
33669- var folder, parentFolder;
33667+ $scope.path = [{title: 'Files', uri: 'local:directory'}];
33668+ $scope.allFolders = [];
33669+ $scope.allTracks = [];
33670+ var uri;
3367033671
33672+ // watch for filter input
33673+ $scope.$watch('filterTerm', function(val){
33674+ $scope.tracks = $filter('filter')($scope.allTracks, val);
33675+ $scope.folders = $filter('filter')($scope.allFolders, val);
33676+ });
3367133677
33672- // rip out any slashes and pipes
33673- if( $stateParams.folder ){
33674- folder = $stateParams.folder.replace('|','/');
33675- }
3367633678
33677- // figure out our parent folder (provided we're not at the top-level already)
33678- if( !folder || folder != 'local:directory' ){
33679+ if( $stateParams.uri ){
3367933680
33680- // viewing top-level folders
33681- if(
33682- folder == 'local:directory?type=track' ||
33683- folder.indexOf('local:directory?type=date&') > -1 ||
33684- folder.indexOf('local:directory?max-age=') > -1 ){
33685- parentFolder = 'local:directory';
33686- }
33681+ uri = $stateParams.uri;
3368733682
33688- // release years
33689- if( folder.indexOf('local:directory?date=') > -1 ){
33690- parentFolder = 'local:directory?type=date&format=%25Y';
33683+ // handle use of pipes to separate actual folders
33684+ // this method is used by the json backend library, but is not needed for local-sqlite
33685+ if( uri.indexOf('|') > -1 || uri.indexOf('local:directory:') > -1 ){
33686+
33687+ // drop the local:directory: bit
33688+ var path = uri.substring(16,uri.length);
33689+
33690+ // split string into array elements (provided we're not viewing the root level already)
33691+ if( path != '' ) path = path.split('|');
33692+
33693+ // loop each 'folder' within the uri string
33694+ if( path.length > 0 ){
33695+ for( var i = 0; i < path.length; i++ ){
33696+
33697+ var uri = 'local:directory:';
33698+
33699+ // loop the whole path to re-build the uri
33700+ for( var j = 0; j <= i; j++ ){
33701+ if( uri != 'local:directory:' ) uri += '|';
33702+ uri += path[j];
33703+ }
33704+
33705+ // plug our path into the template array
33706+ $scope.path.push({
33707+ title: decodeURIComponent( path[i] ),
33708+ uri: uri
33709+ });
33710+ }
33711+ }
33712+
33713+ uri = uri.replace('|','/');
3369133714 }
3369233715
33716+ // manually setup path structure
33717+ if(uri == 'local:directory?type=track' ){
33718+ $scope.path.push({title: 'Tracks', uri: 'local:directory'});
33719+ }else if( uri.indexOf('local:directory?date=') > -1 ){
33720+ $scope.path.push({title: 'History', uri: 'local:directory'});
33721+
33722+ // albums
33723+ }else if( uri.indexOf('local:directory?type=album') > -1 ){
33724+ $scope.path.push({title: 'Albums'});
33725+
33726+ // individual album
33727+ }else if( uri.indexOf('album=') > -1 || uri.indexOf('local:album:') > -1 ){
33728+ $scope.path.push({title: 'Albums', uri: 'local:directory?type=album'});
33729+ $scope.path.push({title: 'Album'});
33730+
3369333731 // artist
33694- if( folder.indexOf('local:directory?artist=') > -1 ){
33695- parentFolder = 'local:directory?type=artist';
33732+ }else if( uri.indexOf('local:directory?type=artist') > -1 ){
33733+ $scope.path.push({title: 'Artists'});
33734+
33735+ // individual artist
33736+ }else if( uri.indexOf('local:artist:') > -1 ){
33737+ $scope.path.push({title: 'Artists', uri: 'local:directory?type=artist'});
33738+ $scope.path.push({title: 'Artist'});
33739+
33740+ // genre
33741+ }else if( uri.indexOf('local:directory?type=genre') > -1 ){
33742+ $scope.path.push({title: 'Genres'});
33743+
33744+ // individual genre
33745+ }else if( uri.indexOf('genre=') > -1 ){
33746+ $scope.path.push({title: 'Genres', uri: 'local:directory?type=genre'});
33747+ $scope.path.push({title: 'Genre'});
3369633748 }
3369733749 }
3369833750
@@ -33705,8 +33757,8 @@ angular.module('spotmop.library', [])
3370533757
3370633758 // go get em
3370733759 function getItems(){
33708-
33709- MopidyService.getLibraryItems( folder )
33760+
33761+ MopidyService.getLibraryItems( uri )
3371033762 .then( function( response ){
3371133763
3371233764 // load tracks
@@ -33732,21 +33784,23 @@ angular.module('spotmop.library', [])
3373233784 tracks.push( track );
3373333785 }
3373433786
33735- $scope.tracklist.tracks = tracks;
33736-
33737- console.table( tracks );
33787+ $scope.tracks = tracks;
33788+ $scope.allTracks = tracks;
3373833789 });
3373933790 }
3374033791
33741- // fetch the folders
33742- var folders = formatFolders( $filter('filter')(response, {type: 'directory'}) );
33792+ // organise the folders
33793+ var folders = [];
33794+ for( i = 0; i < response.length; i++ ){
33795+ if( response[i].type != 'track' )
33796+ folders.push( response[i] );
33797+ }
3374333798
33744- // plug in our parent folder item
33745- if( parentFolder )
33746- folders.unshift({ name: '..', uri: parentFolder, type: 'directory', isParentFolder: true });
33799+ var folders = formatFolders( folders );
3374733800
3374833801 // store our folders to the template-accessible variable
3374933802 $scope.folders = folders;
33803+ $scope.allFolders = folders;
3375033804 });
3375133805 }
3375233806
0 commit comments