diff --git a/dashboard-ui/scripts/alphapicker.js b/dashboard-ui/scripts/alphapicker.js
index 627292d68e..fd20f65a31 100644
--- a/dashboard-ui/scripts/alphapicker.js
+++ b/dashboard-ui/scripts/alphapicker.js
@@ -90,4 +90,9 @@
return this;
};
+ $.fn.alphaClear = function (val) {
+
+ return this.alphaValue('');
+ };
+
})(window, document, jQuery);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js
index 23a1bffafb..f4ba597833 100644
--- a/dashboard-ui/scripts/librarybrowser.js
+++ b/dashboard-ui/scripts/librarybrowser.js
@@ -236,6 +236,35 @@
return html;
},
+ getSongHeaderCellHtml: function (text, cssClass, enableSorting, sortField, selectedSortField, sortDirection) {
+
+ var html = cssClass ? '
' : ' | ';
+
+ if (text && enableSorting) {
+ html += '';
+ }
+
+ html += text;
+
+ if (text && enableSorting) {
+
+ html += '';
+
+ if (sortField == selectedSortField) {
+
+ if (sortDirection == "Descending") {
+ html += '↓';
+ } else {
+ html += '↑';
+ }
+ }
+ }
+
+ html += ' | ';
+
+ return html;
+ },
+
getSongTableHtml: function (items, options) {
options = options || {};
@@ -248,24 +277,21 @@
html += '';
- html += ' | ';
- html += ' | ';
-
- html += 'Track | ';
+ html += LibraryBrowser.getSongHeaderCellHtml('', '', options.enableColumnSorting);
+ html += LibraryBrowser.getSongHeaderCellHtml('', '', options.enableColumnSorting);
+ html += LibraryBrowser.getSongHeaderCellHtml('Track', '', options.enableColumnSorting, 'Name', options.sortBy, options.sortOrder);
if (options.showAlbum) {
- html += 'Album | ';
+ html += LibraryBrowser.getSongHeaderCellHtml('Album', '', options.enableColumnSorting, 'Album,SortName', options.sortBy, options.sortOrder);
}
if (options.showArtist) {
- html += 'Album Artist | ';
- }
- if (options.showArtist) {
- html += 'Artist | ';
+ html += LibraryBrowser.getSongHeaderCellHtml('Album Artist', '', options.enableColumnSorting, 'AlbumArtist,Album,SortName', options.sortBy, options.sortOrder);
+ html += LibraryBrowser.getSongHeaderCellHtml('Artist', '', options.enableColumnSorting, 'Artist,Album,SortName', options.sortBy, options.sortOrder);
}
- html += 'Runtime | ';
- html += 'Play Count | ';
- html += ' | ';
+ html += LibraryBrowser.getSongHeaderCellHtml('Runtime', 'tabletColumn', options.enableColumnSorting, 'Runtime,AlbumArtist,Album,SortName', options.sortBy, options.sortOrder);
+ html += LibraryBrowser.getSongHeaderCellHtml('Play Count', 'tabletColumn', options.enableColumnSorting, 'PlayCount,AlbumArtist,Album,SortName', options.sortBy, options.sortOrder);
+ html += LibraryBrowser.getSongHeaderCellHtml('', 'tabletColumn userDataCell', options.enableColumnSorting);
html += '
';
diff --git a/dashboard-ui/scripts/musicalbums.js b/dashboard-ui/scripts/musicalbums.js
index 308e2e87b9..e96658ac1a 100644
--- a/dashboard-ui/scripts/musicalbums.js
+++ b/dashboard-ui/scripts/musicalbums.js
@@ -77,19 +77,31 @@
var page = this;
- $('.radioSortBy', this).on('click', function () {
+ $('.radioSortBy', page).on('click', function () {
query.SortBy = this.getAttribute('data-sortby');
query.StartIndex = 0;
+
+ // Clear this
+ $('.alphabetPicker', page).alphaClear();
+ query.NameStartsWithOrGreater = '';
+ query.AlbumArtistStartsWithOrGreater = '';
+
reloadItems(page);
});
- $('.radioSortOrder', this).on('click', function () {
+ $('.radioSortOrder', page).on('click', function () {
query.SortOrder = this.getAttribute('data-sortorder');
query.StartIndex = 0;
+
+ // Clear this
+ $('.alphabetPicker', page).alphaClear();
+ query.NameStartsWithOrGreater = '';
+ query.AlbumArtistStartsWithOrGreater = '';
+
reloadItems(page);
});
- $('.chkStandardFilter', this).on('change', function () {
+ $('.chkStandardFilter', page).on('change', function () {
var filterName = this.getAttribute('data-filter');
var filters = query.Filters || "";
@@ -106,7 +118,7 @@
reloadItems(page);
});
- $('#selectView', this).on('change', function () {
+ $('#selectView', page).on('change', function () {
view = this.value;
@@ -121,9 +133,16 @@
}
});
- $('.alphabetPicker', this).on('alphaselect', function (e, character) {
+ $('.alphabetPicker', page).on('alphaselect', function (e, character) {
- query.NameStartsWithOrGreater = character;
+ if (query.SortBy.indexOf('AlbumArtist') == -1) {
+ query.NameStartsWithOrGreater = character;
+ query.AlbumArtistStartsWithOrGreater = '';
+ } else {
+ query.AlbumArtistStartsWithOrGreater = character;
+ query.NameStartsWithOrGreater = '';
+ }
+
query.StartIndex = 0;
reloadItems(page);
@@ -131,6 +150,7 @@
}).on('alphaclear', function (e) {
query.NameStartsWithOrGreater = '';
+ query.AlbumArtistStartsWithOrGreater = '';
reloadItems(page);
});
diff --git a/dashboard-ui/scripts/songs.js b/dashboard-ui/scripts/songs.js
index 8f270f383c..c8d9573a9c 100644
--- a/dashboard-ui/scripts/songs.js
+++ b/dashboard-ui/scripts/songs.js
@@ -1,9 +1,11 @@
(function ($, document) {
+ var defaultSortBy = "Album,SortName";
+
// The base query options
var query = {
- SortBy: "Album,SortName",
+ SortBy: defaultSortBy,
SortOrder: "Ascending",
IncludeItemTypes: "Audio",
Recursive: true,
@@ -12,6 +14,22 @@
StartIndex: 0
};
+ function updateFilterControls(page) {
+
+ // Reset form values using the last used query
+ $('.radioSortBy', page).each(function () {
+
+ this.checked = query.SortBy == this.getAttribute('data-sortby');
+
+ }).checkboxradio('refresh');
+
+ $('.radioSortOrder', page).each(function () {
+
+ this.checked = query.SortOrder == this.getAttribute('data-sortorder');
+
+ }).checkboxradio('refresh');
+ }
+
function reloadItems(page) {
Dashboard.showLoadingMsg();
@@ -27,7 +45,10 @@
html += LibraryBrowser.getSongTableHtml(result.Items, {
showAlbum: true,
- showArtist: true
+ showArtist: true,
+ enableColumnSorting: true,
+ sortBy: query.SortBy,
+ sortOrder: query.SortOrder
});
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
@@ -55,7 +76,37 @@
reloadItems(page);
});
+ $('.lnkColumnSort', page).on('click', function () {
+
+ var order = this.getAttribute('data-sortfield');
+
+ if (query.SortBy == order) {
+
+ if (query.SortOrder == "Descending") {
+
+ query.SortOrder = "Ascending";
+ query.SortBy = defaultSortBy;
+
+ } else {
+
+ query.SortOrder = "Descending";
+ query.SortBy = order;
+ }
+
+ } else {
+
+ query.SortOrder = "Ascending";
+ query.SortBy = order;
+ }
+
+ query.StartIndex = 0;
+
+ reloadItems(page);
+ });
+
Dashboard.hideLoadingMsg();
+
+ $(page).trigger('itemsreloaded');
});
}
@@ -98,18 +149,11 @@
}).on('pageshow', "#songsPage", function () {
- // Reset form values using the last used query
- $('.radioSortBy', this).each(function () {
+ updateFilterControls(this);
- this.checked = query.SortBy == this.getAttribute('data-sortby');
+ }).on('itemsreloaded', "#songsPage", function () {
- }).checkboxradio('refresh');
-
- $('.radioSortOrder', this).each(function () {
-
- this.checked = query.SortOrder == this.getAttribute('data-sortorder');
-
- }).checkboxradio('refresh');
+ updateFilterControls(this);
});
})(jQuery, document);
\ No newline at end of file
diff --git a/dashboard-ui/songs.html b/dashboard-ui/songs.html
index 5d326f8397..33820a7cb9 100644
--- a/dashboard-ui/songs.html
+++ b/dashboard-ui/songs.html
@@ -32,6 +32,9 @@
Sort By:
+
+
+
@@ -41,19 +44,19 @@
-
+
-
+
-
+
-
+
-
+