From e5318f395b5887ce0b349feee6fdc822e2d6c24f Mon Sep 17 00:00:00 2001 From: Trevor Squillario Date: Mon, 5 May 2014 18:50:17 -0400 Subject: [PATCH] 3.4.2 Archive tab updates --- js/controllers/archive.js | 27 +++-- js/controllers/library.js | 1 + js/controllers/main.js | 35 ++++++- js/json_changelog.js | 2 +- js/partials/archive.html | 14 ++- js/service.js | 204 ++++++++++++++++++++------------------ js/utils.js | 4 +- style/Style.css | 8 ++ 8 files changed, 183 insertions(+), 112 deletions(-) diff --git a/js/controllers/archive.js b/js/controllers/archive.js index 905c1bc..38ffba7 100644 --- a/js/controllers/archive.js +++ b/js/controllers/archive.js @@ -1,5 +1,5 @@ JamStash.controller('ArchiveCtrl', -function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, archive, json) { +function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json) { $scope.settings = globals.settings; $scope.itemType = 'archive'; $rootScope.song = []; @@ -35,6 +35,8 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, if ($scope.SavedCollections.indexOf(newValue) == -1) { $scope.SavedCollections.push(newValue); $scope.writeSavedCollection(); + var index = $scope.AllArtists.indexOf(newValue); + $scope.AllArtists.splice(index, 1); } }; $scope.deleteSavedCollection = function (index) { @@ -79,7 +81,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, } else { utils.setValue('AlbumSort', null, true); } - $scope.getAlbums(''); + $scope.getAlbums($scope.selectedArtist); } }); $scope.getYears = function (startYear) { @@ -98,7 +100,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, }; $scope.filterSave = function () { if ($scope.selectedArtist) { - $scope.getAlbums('', ''); + $scope.getAlbums($scope.selectedArtist, $scope.filter); } }; /* End Filter */ @@ -118,14 +120,23 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, $scope.song = data.song; $scope.album = data.album; $scope.selectedArtist = data.selectedArtist; + $scope.BreadCrumbs = data.breadcrumb; }); }; - $scope.getSongs = function (id, action) { archive.getSongs(id, action).then(function (data) { - $scope.song = data.song; $scope.album = data.album; + $scope.song = data.song; $scope.selectedAlbum = data.selectedAlbum; + $scope.BreadCrumbs = data.breadcrumb; + //$rootScope.showSongs(); + //alert($("#songs").html()) + //utils.safeApply(); + $timeout( + function () { + $.fancybox.update(); + } + ); }); }; $scope.scrollToTop = function () { @@ -149,13 +160,13 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, /* Launch on Startup */ //$scope.getArtists(); - //$scope.getCollections(); + $scope.getAlbums(); if ($routeParams.artist) { if ($routeParams.album) { //collection:(GreenskyBluegrass) AND format:(MP3) AND identifier:(gsbg2013-09-20.flac16) - $scope.getAlbums('', $routeParams.album); + $scope.getSongs($routeParams.album); } else { - $scope.getAlbums($routeParams.artist, ''); + $scope.getAlbums($routeParams.artist); } $scope.addSavedCollection($routeParams.artist); } diff --git a/js/controllers/library.js b/js/controllers/library.js index 1111a55..f7ea5aa 100644 --- a/js/controllers/library.js +++ b/js/controllers/library.js @@ -391,6 +391,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, $htt $scope.getGenres(); $scope.getPodcasts(); $scope.openDefaultSection(); + $scope.getMusicFolders(); if ($routeParams.artistId && $routeParams.albumId) { $scope.getAlbumByTag($routeParams.albumId); } else if ($routeParams.artistId) { diff --git a/js/controllers/main.js b/js/controllers/main.js index cf8aae0..01028cb 100644 --- a/js/controllers/main.js +++ b/js/controllers/main.js @@ -160,6 +160,38 @@ function AppCtrl($scope, $rootScope, $document, $window, $location, $cookieStore title: null } }); + /* + $('.showSongs').fancybox({ + href: '#songs', + autoWidth: false, + width: '100%', + //margin: [50, 10, 50, 10], // top, right, bottom, left + openEffect: 'none', + closeEffect: 'none', + beforeLoad: function () { + if ($rootScope.queue == 0) { + //this.close(); + } + }, + helpers: { + title: null + } + }); + $rootScope.showSongs = function () { + alert($("#songs").html()) + $.fancybox({ + type: 'inline', + content: $("#songs").html(), + autoWidth: false, + width: '100%', + transitionIn: 'elastic', + transitionOut: 'elastic', + helpers: { + title: null + } + }); + } + */ $('#audiocontainer .scrubber').mouseover(function (e) { $('.audiojs .scrubber').stop().animate({ height: '8px' }); @@ -507,8 +539,7 @@ function AppCtrl($scope, $rootScope, $document, $window, $location, $cookieStore $scope.loadSettings(); utils.switchTheme(globals.settings.Theme); if ($scope.loggedIn()) { - $scope.ping(); - $scope.getMusicFolders(); + //$scope.ping(); if (globals.settings.SaveTrackPosition) { player.loadTrackPosition(); player.startSaveTrackPosition(); diff --git a/js/json_changelog.js b/js/json_changelog.js index a4ac3a3..76b29a9 100644 --- a/js/json_changelog.js +++ b/js/json_changelog.js @@ -3,7 +3,7 @@ "date": "5/4/2014", "version": "3.4.1", "changes": [ { "text": "- Tab state saved, consolidated Subsonic artists, playlist and podcasts" }, - { "text": "- Archive.org tab, expanded Collection search" } + { "text": "- Archive.org tab, Collection search, added breadcrumb" } ] }, { diff --git a/js/partials/archive.html b/js/partials/archive.html index cdbb570..124f306 100644 --- a/js/partials/archive.html +++ b/js/partials/archive.html @@ -28,7 +28,7 @@
diff --git a/js/service.js b/js/service.js index 01d026c..dc62638 100644 --- a/js/service.js +++ b/js/service.js @@ -1341,110 +1341,122 @@ JamStash.factory('archive', function ($rootScope, $http, $q, $sce, globals, mode }, getAlbums: function (name, filter) { var deferred = $q.defer(); - var url = globals.archiveUrl + 'advancedsearch.php?q='; - if (name !== '') { - content.selectedArtist = name; - url += 'collection:(' + name + ') AND format:(MP3)'; - } else if (content.selectedArtist) { - name = content.selectedArtist; - url += 'collection:(' + content.selectedArtist + ') AND format:(MP3)'; - } else { - url += 'collection:(' + name + ')'; - } - - if (filter.Source) { - url += ' AND source:(' + filter.Source + ')'; - } - if (filter.Year) { - if (parseInt(filter.Year)) { - url += ' AND year:(' + filter.Year + ')'; + if (name) { + var url = globals.archiveUrl + 'advancedsearch.php?q='; + if (name !== '') { + content.selectedArtist = name; + url += 'collection:(' + name + ') AND format:(MP3)'; + } else if (content.selectedArtist) { + name = content.selectedArtist; + url += 'collection:(' + content.selectedArtist + ') AND format:(MP3)'; + } else { + url += 'collection:(' + name + ')'; } - } - if (filter.Description) { - url += ' AND description:(' + filter.Description + ')'; - } - if (content.selectedArtist) { - url += '&sort[]=' + globals.settings.DefaultArchiveAlbumSort; - } - url += '&fl[]=avg_rating,collection,date,description,downloads,headerImage,identifier,publisher,publicdate,source,subject,title,year'; - url += '&rows=50&page=1&output=json'; - $.ajax({ - url: url, - method: 'GET', - dataType: globals.settings.Protocol, - timeout: globals.settings.Timeout, - success: function (data) { - var items = []; - if (data.response.docs.length > 0) { - items = data.response.docs; - //alert(JSON.stringify(data["response"])); - content.album = []; - content.song = []; - angular.forEach(items, function (item, key) { - content.album.push(mapAlbum(item)); - }); - notifications.updateMessage(content.album.length, true); - } else { - notifications.updateMessage("Sorry :(", true); + content.breadcrumb = []; + content.breadcrumb.push({ 'type': 'artist', 'id': name, 'name': name }); + + if (filter.Source) { + url += ' AND source:(' + filter.Source + ')'; + } + if (filter.Year) { + if (parseInt(filter.Year)) { + url += ' AND year:(' + filter.Year + ')'; } - deferred.resolve(content); - }, - error: function () { - notifications.updateMessage('Archive.org service down :('); } - }); + if (filter.Description) { + url += ' AND description:(' + filter.Description + ')'; + } + if (content.selectedArtist) { + url += '&sort[]=' + globals.settings.DefaultArchiveAlbumSort; + } + url += '&fl[]=avg_rating,collection,date,description,downloads,headerImage,identifier,publisher,publicdate,source,subject,title,year'; + url += '&rows=50&page=1&output=json'; + $.ajax({ + url: url, + method: 'GET', + dataType: globals.settings.Protocol, + timeout: globals.settings.Timeout, + success: function (data) { + var items = []; + if (data.response.docs.length > 0) { + items = data.response.docs; + //alert(JSON.stringify(data["response"])); + content.album = []; + content.song = []; + angular.forEach(items, function (item, key) { + content.album.push(mapAlbum(item)); + }); + notifications.updateMessage(content.album.length, true); + } else { + notifications.updateMessage("Sorry :(", true); + } + deferred.resolve(content); + }, + error: function () { + notifications.updateMessage('Archive.org service down :('); + } + }); + } else { + deferred.resolve(content); + } return deferred.promise; }, getSongs: function (id, action) { var deferred = $q.defer(); - content.selectedAlbum = id; - var url = globals.archiveUrl + 'details/' + id + '?output=json'; - $.ajax({ - url: url, - method: 'GET', - dataType: globals.settings.Protocol, - timeout: globals.settings.Timeout, - success: function (data) { - var coverart = ''; - var server = data.server; - var dir = data.dir; - var identifier = data.metadata.identifier[0]; - if (typeof data.misc.image != 'undefined') { - coverart = data.misc.image; + if (id) { + content.selectedAlbum = id; + if (content.breadcrumb.length > 0) { content.breadcrumb.splice(1, (content.breadcrumb.length - 1)); } + content.breadcrumb.push({ 'type': 'album', 'id': id, 'name': id }); + var url = globals.archiveUrl + 'details/' + id + '?output=json'; + $.ajax({ + url: url, + method: 'GET', + dataType: globals.settings.Protocol, + timeout: globals.settings.Timeout, + success: function (data) { + var coverart = ''; + var server = data.server; + var dir = data.dir; + var identifier = data.metadata.identifier[0]; + if (typeof data.misc.image != 'undefined') { + coverart = data.misc.image; + } + var items = data.files; + if (action == 'add') { + angular.forEach(items, function (item, key) { + var song = mapSong(key, item, server, dir, identifier, coverart); + if (song) { + $rootScope.queue.push(song); + } + }); + notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); + } else if (action == 'play') { + $rootScope.queue = []; + angular.forEach(items, function (item, key) { + var song = mapSong(key, item, server, dir, identifier, coverart); + if (song) { + $rootScope.queue.push(song); + } + }); + var next = $rootScope.queue[0]; + $rootScope.playSong(false, next); + notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); + } else { + content.album = []; + content.song = []; + angular.forEach(items, function (item, key) { + var song = mapSong(key, item, server, dir, identifier, coverart); + if (song) { + content.song.push(song); + } + }); + } + deferred.resolve(content); } - var items = data.files; - if (action == 'add') { - angular.forEach(items, function (item, key) { - var song = mapSong(key, item, server, dir, identifier, coverart); - if (song) { - $rootScope.queue.push(song); - } - }); - notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); - } else if (action == 'play') { - $rootScope.queue = []; - angular.forEach(items, function (item, key) { - var song = mapSong(key, item, server, dir, identifier, coverart); - if (song) { - $rootScope.queue.push(song); - } - }); - var next = $rootScope.queue[0]; - $rootScope.playSong(false, next); - notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); - } else { - content.album = []; - content.song = []; - angular.forEach(items, function (item, key) { - var song = mapSong(key, item, server, dir, identifier, coverart); - if (song) { - content.song.push(song); - } - }); - } - deferred.resolve(content); - } - }); + }); + } else { + deferred.resolve(content); + } return deferred.promise; } }; diff --git a/js/utils.js b/js/utils.js index 16257f5..000f26e 100644 --- a/js/utils.js +++ b/js/utils.js @@ -1,6 +1,6 @@ -JamStash.service('utils', function ($cookieStore, globals, model) { +JamStash.service('utils', function ($rootScope, $cookieStore, globals, model) { this.safeApply = function (fn) { - var phase = this.$root.$$phase; + var phase = $rootScope.$root.$$phase; if (phase == '$apply' || phase == '$digest') { if (fn && (typeof (fn) === 'function')) { fn(); diff --git a/style/Style.css b/style/Style.css index e4cf271..3041d36 100755 --- a/style/Style.css +++ b/style/Style.css @@ -1175,6 +1175,14 @@ ul.songlist li:hover position: fixed; } +#songs { + width: 1200px; + display: none; +} +#songs .songlist { + padding: 35px 0 0 0; +} + /* Player Style */ #player {