Added push for extra Defaults, Added Artist Search

This commit is contained in:
Trevor Squillario 2014-01-12 19:40:48 -05:00
parent 0db50559e7
commit ff10d7779c
7 changed files with 79 additions and 69 deletions

View file

@ -23,44 +23,32 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.selectedAutoAlbum; $scope.selectedAutoAlbum;
$scope.selectedArtist; $scope.selectedArtist;
$scope.selectedAlbum; $scope.selectedAlbum;
$scope.selectedSubsonicAlbumSort = 'default'; $scope.SelectedAlbumSort = globals.settings.DefaultAlbumSort;
$scope.SubsonicSort = []; $scope.AlbumSort = globals.AlbumSorts;
$scope.SubsonicAlbumSort = [
{ id: "default", name: "Default Sort" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "createdate desc", name: "Date Added" },
];
$scope.SubsonicSongSort = [
{ id: "default", name: "Default Sort" },
{ id: "track", name: "Track" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "createdate desc", name: "Date Added" },
];
$scope.BreadCrumbs = []; $scope.BreadCrumbs = [];
$scope.$watch("selectedSubsonicAlbumSort", function (newValue, oldValue) { $scope.$watch("SelectedAlbumSort.id", function (newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
if ($rootScope.song.length > 0) { if ($rootScope.song.length > 0) {
$scope.sortSubsonicSongs(newValue); $scope.sortSubsonicSongs(newValue);
} else if ($scope.album.length > 0) { } else if ($scope.album.length > 0) {
$scope.sortSubsonicAlbums(newValue); $scope.sortSubsonicAlbums(newValue);
indexes = $.map(globals.AlbumSorts, function (obj, index) {
if (obj.id == newValue) {
return index;
}
})
globals.settings.DefaultAlbumSort = globals.AlbumSorts[indexes];
} }
} }
}); });
$rootScope.$watch("selectedMusicFolder", function (newValue, oldValue) { $rootScope.$watch("SelectedMusicFolder", function (newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
utils.setValue('MusicFolders', angular.toJson(newValue), true); utils.setValue('MusicFolders', angular.toJson(newValue), true);
$scope.getArtists(newValue.id); $scope.getArtists(newValue.id);
} }
}); });
$scope.selectedLayout = globals.settings.DefaultLibraryLayout; $scope.SearchType = globals.settings.DefaultSearchType;
//not sure how to just grab the layouts hash from the settings controller $scope.SearchTypes = globals.SearchTypes;
$scope.Layouts = [
{ id: "list", name: "List" },
{ id: "grid", name: "Grid" },
];
$scope.rescanLibrary = function (data, event) { $scope.rescanLibrary = function (data, event) {
$.ajax({ $.ajax({
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username, url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
@ -121,12 +109,16 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
} }
// TODO: AZIndex, build letters here. Make it a click button somewhere then a larger popup with letters finger friendly size // TODO: AZIndex, build letters here. Make it a click button somewhere then a larger popup with letters finger friendly size
$scope.shortcut = []; $scope.shortcut = [];
var items = [];
if (typeof data["subsonic-response"].indexes.shortcut != 'undefined') { if (typeof data["subsonic-response"].indexes.shortcut != 'undefined') {
if (data["subsonic-response"].indexes.shortcut.length > 0) { if (data["subsonic-response"].indexes.shortcut.length > 0) {
$scope.shortcut = data["subsonic-response"].indexes.shortcut; items = data["subsonic-response"].indexes.shortcut;
} else { } else {
$scope.shortcut[0] = data["subsonic-response"].indexes.shortcut; items[0] = data["subsonic-response"].indexes.shortcut;
} }
angular.forEach(items, function (item, key) {
$scope.shortcut.push(item);
});
} }
$scope.index = []; $scope.index = [];
angular.forEach(indexes, function (item, key) { angular.forEach(indexes, function (item, key) {
@ -187,10 +179,9 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$rootScope.song.push(utils.mapSong(item)); $rootScope.song.push(utils.mapSong(item));
} }
}); });
if ($scope.selectedSubsonicAlbumSort != "default") { if ($scope.SelectedAlbumSort.id != "default") {
$scope.sortSubsonicAlbums($scope.selectedSubsonicAlbumSort); $scope.sortSubsonicAlbums($scope.SelectedAlbumSort.id);
} }
$scope.SubsonicSort = $scope.SubsonicAlbumSort;
$scope.$apply(); $scope.$apply();
} else { } else {
notifications.updateMessage('No Albums Returned :(', true); notifications.updateMessage('No Albums Returned :(', true);
@ -307,7 +298,9 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$rootScope.song.push($scope.mapAlbum(item)); $rootScope.song.push($scope.mapAlbum(item));
} }
}); });
$scope.SubsonicSort = $scope.SubsonicAlbumSort; if ($scope.SelectedAlbumSort.id != "default") {
$scope.sortSubsonicAlbums($scope.SelectedAlbumSort.id);
}
$scope.$apply(); $scope.$apply();
} else { } else {
notifications.updateMessage('No Albums Returned :(', true); notifications.updateMessage('No Albums Returned :(', true);
@ -376,8 +369,10 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}); });
if (albums.length > 0) { if (albums.length > 0) {
$scope.album = albums; $scope.album = albums;
if ($scope.SelectedAlbumSort.id != "default") {
$scope.sortSubsonicAlbums($scope.SelectedAlbumSort.id);
}
} }
$scope.SubsonicSort = $scope.SubsonicSongSort;
$scope.$apply(); $scope.$apply();
} }
} else { } else {
@ -399,7 +394,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (data["subsonic-response"].searchResult2 !== "") { if (data["subsonic-response"].searchResult2 !== "") {
var header; var header;
var items = []; var items = [];
if (type === 'song') { if (type === '0') {
if (data["subsonic-response"].searchResult2.song !== undefined) { if (data["subsonic-response"].searchResult2.song !== undefined) {
if (data["subsonic-response"].searchResult2.song.length > 0) { if (data["subsonic-response"].searchResult2.song.length > 0) {
items = data["subsonic-response"].searchResult2.song; items = data["subsonic-response"].searchResult2.song;
@ -413,7 +408,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.$apply(); $scope.$apply();
} }
} }
if (type === 'album') { if (type === '1') {
if (data["subsonic-response"].searchResult2.album !== undefined) { if (data["subsonic-response"].searchResult2.album !== undefined) {
if (data["subsonic-response"].searchResult2.album.length > 0) { if (data["subsonic-response"].searchResult2.album.length > 0) {
items = data["subsonic-response"].searchResult2.album; items = data["subsonic-response"].searchResult2.album;
@ -431,6 +426,19 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.$apply(); $scope.$apply();
} }
} }
if (type === '2') {
if (data["subsonic-response"].searchResult2.artist !== undefined) {
if (data["subsonic-response"].searchResult2.artist.length > 0) {
items = data["subsonic-response"].searchResult2.artist;
} else {
items[0] = data["subsonic-response"].searchResult2.artist;
}
angular.forEach(items, function (item, key) {
$scope.shortcut.push(item);
});
$scope.$apply();
}
}
} }
} }
}); });

View file

@ -8,7 +8,7 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$rootScope.Genres = []; $rootScope.Genres = [];
$rootScope.selectedPlaylist = ""; $rootScope.selectedPlaylist = "";
$rootScope.selectedAutoPlaylist = ""; $rootScope.selectedAutoPlaylist = "";
$rootScope.selectedMusicFolder = ""; $rootScope.SelectedMusicFolder = "";
$rootScope.unity; $rootScope.unity;
$rootScope.loggedIn = function () { $rootScope.loggedIn = function () {
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') { if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') {
@ -351,7 +351,7 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
} }
i++; i++;
}); });
$rootScope.selectedMusicFolder = $rootScope.MusicFolders[index]; $rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index];
} }
$scope.$apply(); $scope.$apply();
} }
@ -482,9 +482,9 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
if (typeof folder == 'number' && folder != '' && folder != 'all') { if (typeof folder == 'number' && folder != '' && folder != 'all') {
//alert(folder); //alert(folder);
folderParams = '&musicFolderId=' + folder; folderParams = '&musicFolderId=' + folder;
} else if (typeof $rootScope.selectedMusicFolder.id != 'undefined') { } else if (typeof $rootScope.SelectedMusicFolder.id != 'undefined') {
//alert($rootScope.selectedMusicFolder.id); //alert($rootScope.SelectedMusicFolder.id);
folderParams = '&musicFolderId=' + $rootScope.selectedMusicFolder.id; folderParams = '&musicFolderId=' + $rootScope.SelectedMusicFolder.id;
} }
$.ajax({ $.ajax({
url: globals.BaseURL() + '/getRandomSongs.view?' + globals.BaseParams() + '&size=' + size + genreParams + folderParams, url: globals.BaseURL() + '/getRandomSongs.view?' + globals.BaseParams() + '&size=' + size + genreParams + folderParams,

View file

@ -13,11 +13,9 @@ function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, not
]; ];
$scope.Protocols = ["json", "jsonp"]; $scope.Protocols = ["json", "jsonp"];
$scope.Themes = ["Default", "Dark"]; $scope.Themes = ["Default", "Dark"];
$scope.LibraryLayouts = [ $scope.SearchTypes = globals.SearchTypes;
{ id: "list", name: "List" }, $scope.Layouts = globals.Layouts;
{ id: "grid", name: "Grid" },
];
$scope.DefaultLibraryLayout = 'grid';
$scope.$watch('settings.HideAZ', function () { $scope.$watch('settings.HideAZ', function () {
if (globals.settings.HideAZ) { if (globals.settings.HideAZ) {
$('#AZIndex').hide(); $('#AZIndex').hide();

View file

@ -7,10 +7,7 @@
</div> </div>
<div id="search"> <div id="search">
<input type="text" id="Search" class="medium" title="Wildcards (*) supported" placeholder="Search..." ng-enter="search()"/> <input type="text" id="Search" class="medium" title="Wildcards (*) supported" placeholder="Search..." ng-enter="search()"/>
<select id="SearchType" name="SearchType"> <select id="SearchType" name="SearchType" ng-model="SearchType.id" ng-options="o.id as o.name for o in SearchTypes"></select>
<option value="song">Song</option>
<option value="album">Album</option>
</select>
<a href="" class="button" id="action_Search" title="Search" ng-click="search()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a> <a href="" class="button" id="action_Search" title="Search" ng-click="search()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a>
</div> </div>
<div class="subactions"> <div class="subactions">
@ -30,7 +27,7 @@
<div id="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed"> <div id="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed">
<a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a> <a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a>
</div> </div>
<select id="MusicFolders" class="folders" ng-model="$root.selectedMusicFolder" ng-options="o as o.name for o in MusicFolders"> <select id="MusicFolders" class="folders" ng-model="$root.SelectedMusicFolder" ng-options="o as o.name for o in MusicFolders">
<option value="">All Folders</option> <option value="">All Folders</option>
</select> </select>
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect"> <ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
@ -64,11 +61,9 @@
<ul class="actionlist"> <ul class="actionlist">
<li> <li>
<form class="form"> <form class="form">
<select id="selectedSubsonicAlbumSort" ng-model="selectedSubsonicAlbumSort" ng-show="SubsonicSort.length" ng-options="o.id as o.name for o in SubsonicSort"></select> <select id="SelectedAlbumSort" ng-model="SelectedAlbumSort.id" ng-show="AlbumSort.length" ng-options="o.id as o.name for o in AlbumSort"></select>
<!--<select id="selectedLayout" ng-model="selectedLayout" ng-options="o.id as o.name for o in Layouts"></select>-->
</form> </form>
<div id="BreadCrumb"> <div id="BreadCrumb">
<a href="#" id="BreadHome"><img src="images/home_gl_12x12.png"></a>
<div id="BreadCrumbs" class="floatleft"> <div id="BreadCrumbs" class="floatleft">
<div class="crumb" ng-repeat="o in BreadCrumbs | filter:{type:'artist'}"><a ng-click="getAlbums(o.id, o.name)">{{o.name}}</a> &gt;</div> <div class="crumb" ng-repeat="o in BreadCrumbs | filter:{type:'artist'}"><a ng-click="getAlbums(o.id, o.name)">{{o.name}}</a> &gt;</div>
<div class="crumb" ng-repeat="o in BreadCrumbs | filter:{type:'album'}"><a ng-click="getSongs(o.id, '')">{{o.name}}</a> &gt;</div> <div class="crumb" ng-repeat="o in BreadCrumbs | filter:{type:'album'}"><a ng-click="getSongs(o.id, '')">{{o.name}}</a> &gt;</div>
@ -79,7 +74,7 @@
<div class="clear"></div> <div class="clear"></div>
<ul class="simplelist songlist noselect"> <ul class="simplelist songlist noselect">
<div class="" ng-repeat="o in album" ng-switch on="o.type"> <div class="" ng-repeat="o in album" ng-switch on="o.type">
<li class="album" ng-switch-when="byfolder" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': selectedLayout == 'grid'}" ng-click="getSongs(o.id, '')" parentid="{{o.parentid}}"> <li class="album" ng-switch-when="byfolder" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': settings.DefaultLibraryLayout.id == 'grid'}" ng-click="getSongs(o.id, '')" parentid="{{o.parentid}}">
<div class="itemactions"> <div class="itemactions">
<a class="add" href="" title="Add To Play Queue" ng-click="getSongs(o.id, 'add')" stop-event="click"></a> <a class="add" href="" title="Add To Play Queue" ng-click="getSongs(o.id, 'add')" stop-event="click"></a>
<a class="play" href="" title="Play" ng-click="getSongs(o.id, 'play')" stop-event="click"></a> <a class="play" href="" title="Play" ng-click="getSongs(o.id, 'play')" stop-event="click"></a>
@ -94,7 +89,7 @@
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</li> </li>
<li class="album" ng-switch-when="bytag" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': selectedLayout == 'grid'}" ng-click="getAlbumByTag(o.id)"> <li class="album" ng-switch-when="bytag" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': settings.DefaultLibraryLayout.id == 'grid'}" ng-click="getAlbumByTag(o.id)">
<div class="albumart"><img ng-src="{{o.coverartthumb}}" src="images/albumdefault_160.jpg"></div> <div class="albumart"><img ng-src="{{o.coverartthumb}}" src="images/albumdefault_160.jpg"></div>
<div class="albuminfo"> <div class="albuminfo">
<div class="title" title="{{o.name}}" ng-bind-html-unsafe="o.name"></div> <div class="title" title="{{o.name}}" ng-bind-html-unsafe="o.name"></div>

View file

@ -48,15 +48,11 @@
<div class="clear"></div> <div class="clear"></div>
<label for="DefaultLibraryLayout">Default Library Layout</label> <label for="DefaultLibraryLayout">Default Library Layout</label>
<div class="clear"></div> <div class="clear"></div>
<select id="DefaultLibraryLayout" name="DefaultLibraryLayout" class="" ng-model="settings.DefaultLibraryLayout" ng-options="o.id as o.name for o in LibraryLayouts" title="AJAX Request Library Layout"></select> <select id="DefaultLibraryLayout" name="DefaultLibraryLayout" class="" ng-model="settings.DefaultLibraryLayout.id" ng-options="o.id as o.name for o in Layouts" title="Library Layout"></select>
<div class="clear"></div> <div class="clear"></div>
<label for="DefaultSubsonicAlbumSort">Default Album Sort Order</label>
<div class="clear"></div>
<select id="DefaultSubsonicAlbumSort" name="DefaultSubsonicAlbumSort" class="" ng-model="settings.DefaultSubsonicAlbumSort" ng-options="o.id as o.name for o in SubsonicAlbumSort" title="Subsonic Album Layout"></select>
<div class="clear"></div>
<label for="DefaultSearchType">Default Search Type</label> <label for="DefaultSearchType">Default Search Type</label>
<div class="clear"></div> <div class="clear"></div>
<select id="DefaultSearchType" name="DefaultSearchType" class="" ng-model="settings.DefaultSearchType" ng-options="o.id as o.name for o in SearchTypeLayout" title="Subsonic Album Layout"></select> <select id="DefaultSearchType" name="DefaultSearchType" class="" ng-model="settings.DefaultSearchType.id" ng-options="o.id as o.name for o in SearchTypes" title="Subsonic Album Layout"></select>
<div class="clear"></div> <div class="clear"></div>
</fieldset> </fieldset>
<div class="clear"></div> <div class="clear"></div>

View file

@ -1,4 +1,5 @@
JamStash.service('model', function () { JamStash.service('model', function () {
// Figure out how to move this, circular dependency with utils
secondsToTime = function (secs) { secondsToTime = function (secs) {
// secs = 4729 // secs = 4729
var times = new Array(3600, 60, 1); var times = new Array(3600, 60, 1);
@ -75,6 +76,22 @@
}); });
JamStash.service('globals', function () { JamStash.service('globals', function () {
this.SearchTypes = [
{ id: "song", name: "Song" },
{ id: "album", name: "Album" },
{ id: "artist", name: "Artist" },
];
this.Layouts = [
{ id: "grid", name: "Grid" },
{ id: "list", name: "List" }
];
this.AlbumSorts = [
{ id: "default", name: "Default Sort" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "track", name: "Track" },
{ id: "createdate desc", name: "Date Added" },
];
this.settings = { this.settings = {
// Subsonic // Subsonic
/* Demo Server /* Demo Server
@ -102,7 +119,9 @@ JamStash.service('globals', function () {
SaveTrackPosition: false, SaveTrackPosition: false,
ForceFlash: false, ForceFlash: false,
Theme: "Default", Theme: "Default",
DefaultLibraryLayout: "grid", DefaultLibraryLayout: this.Layouts[0],
DefaultSearchType: this.SearchTypes[0],
DefaultAlbumSort: this.AlbumSorts[0],
AutoPlay: false, AutoPlay: false,
LoopQueue: false, LoopQueue: false,
Repeat: false, Repeat: false,
@ -110,10 +129,10 @@ JamStash.service('globals', function () {
}; };
this.SavedCollections = []; this.SavedCollections = [];
this.SavedGenres = []; this.SavedGenres = [];
this.BaseURL = function () { return this.settings.Server + '/rest'; }; this.BaseURL = function () { return this.settings.Server + '/rest'; };
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; }; this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
}); });
// Directives // Directives
JamStash.directive('layout', function () { JamStash.directive('layout', function () {
return { return {

View file

@ -508,10 +508,9 @@ ul.mainlist li.item a.add:hover
#BreadCrumb #BreadCrumb
{ {
float: left; float: left;
margin: 13px 0 0 0; margin: 14px 0 0 0;
padding: 2px 8px; padding: 2px 0;
color: #AEAEA7; color: #AEAEA7;
background: #f6f6f6;
border-radius: .4em; border-radius: .4em;
} }
#BreadCrumb img #BreadCrumb img
@ -537,11 +536,6 @@ ul.mainlist li.item a.add:hover
{ {
float: left; float: left;
} }
#BreadHome a
{
padding: 0;
margin: 0;
}
#TrackContainer, #PodcastContainer #TrackContainer, #PodcastContainer
{ {