From 1241a41bd20859311e7d27cc8f0275ebd1420c41 Mon Sep 17 00:00:00 2001 From: Paul Sori Date: Sun, 28 Apr 2019 23:28:59 -0400 Subject: [PATCH] better album/artist stuff --- cli-boot-wrapper.js | 10 +------ modules/db-read/database-public-loki.js | 14 ++++++--- package.json | 2 +- public/js/api2.js | 4 +-- public/js/mstream.js | 39 ++++++++++++++----------- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/cli-boot-wrapper.js b/cli-boot-wrapper.js index 7667870..6247d46 100755 --- a/cli-boot-wrapper.js +++ b/cli-boot-wrapper.js @@ -22,12 +22,10 @@ if (program.error) { return; } - -// Beg const colors = require('colors'); console.clear(); console.log(colors.bold(` - v4.1.1 ____ _ + v4.1.2 ____ _ _ __ ___ / ___|| |_ _ __ ___ __ _ _ __ ___ | '_ \` _ \\\\___ \\| __| '__/ _ \\/ _\` | '_ \` _ \\ | | | | | |___) | |_| | | __/ (_| | | | | | | @@ -38,12 +36,6 @@ console.log(colors.magenta.bold('Find a bug? Report it at:')); console.log(colors.underline('https://github.com/IrosTheBeggar/mStream/issues')); console.log(); -if (program.database_plugin || program.logs) { - console.log(colors.yellow('It appears you are using an old version of the JSON config file')); - console.log(colors.yellow('Support for the the `database_plugin` and `logs` fields have been removed as of v4')); - console.log(); -} - // Boot the server const serve = require("./mstream.js"); serve.serveIt(program); diff --git a/modules/db-read/database-public-loki.js b/modules/db-read/database-public-loki.js index 5221a76..4805375 100644 --- a/modules/db-read/database-public-loki.js +++ b/modules/db-read/database-public-loki.js @@ -370,12 +370,18 @@ exports.setup = function (mstream, program) { } } + var artistClause; + if(req.body.artist) { + artistClause = {'artist': { '$eq': String(req.body.artist) }} + } + + const album = req.body.album ? String(req.body.album) : null; var results = fileCollection.chain().find({ '$and': [ - orClause - , { - 'album': { '$eq': String(req.body.album) } - }] + orClause, + {'album': { '$eq': album }}, + artistClause + ] }).simplesort('track').data(); for (let row of results) { diff --git a/package.json b/package.json index 9e3ce65..39f86cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mstream", - "version": "4.1.1", + "version": "4.1.2", "description": "music streaming server", "main": "cli-boot-wrapper.js", "bin": { diff --git a/public/js/api2.js b/public/js/api2.js index aca981b..1bbae90 100644 --- a/public/js/api2.js +++ b/public/js/api2.js @@ -99,8 +99,8 @@ var MSTREAMAPI = (function () { makePOSTRequest("/db/artists-albums", { artist: artist }, callback); } - mstreamModule.albumSongs = function (album, callback) { - makePOSTRequest("/db/album-songs", { album: album }, callback); + mstreamModule.albumSongs = function (album, artist, callback) { + makePOSTRequest("/db/album-songs", { album: album, artist: artist }, callback); } mstreamModule.dbStatus = function (callback) { diff --git a/public/js/mstream.js b/public/js/mstream.js index 9ba2664..f0bc43e 100755 --- a/public/js/mstream.js +++ b/public/js/mstream.js @@ -516,7 +516,7 @@ $(document).ready(function () { var filelist = []; // This causes an error in the playlist display $.each(currentBrowsingList, function () { - var lowerCase = this.name.toLowerCase(); + var lowerCase = this.name !== null ? this.name.toLowerCase() : 'null'; if (lowerCase.indexOf(searchVal.toLowerCase()) !== -1) { if (this.type === 'directory') { @@ -524,10 +524,13 @@ $(document).ready(function () { } else if (this.type === 'playlist') { filelist.push('
' + escapeHtml(this.name) + '
Delete
'); } else if (this.type === 'album') { + var artistString = this.artist ? 'data-artist="' + this.artist + '"' : ''; + var albumString = this.name ? this.name : 'SINGLES'; + if (this.album_art_file) { - filelist.push('
' + this.name + '
'); + filelist.push('
' + albumString + '
'); } else { - filelist.push('
' + this.name + '
'); + filelist.push('
' + albumString + '
'); } } else if (this.type === 'artist') { filelist.push('
' + this.name + '
'); @@ -796,7 +799,7 @@ $(document).ready(function () { }); $('#filelist').html(files); - // update linked list plugin + // update lazy load plugin ll.update(); }); }); @@ -915,7 +918,7 @@ $(document).ready(function () { function getRecentlyAdded() { $('ul.left-nav-menu li').removeClass('selected'); $('.get_recent_songs').addClass('selected'); - resetPanel('Recently Added Songs', 'scrollBoxHeight1'); + resetPanel('Recently Added', 'scrollBoxHeight1'); $('#filelist').html('
'); $('.directoryName').html('Get last      songs'); @@ -988,7 +991,7 @@ $(document).ready(function () { }); $('#filelist').html(albums); - // update linked list plugin + // update lazy load plugin ll.update(); }); } @@ -996,10 +999,12 @@ $(document).ready(function () { // Load up album-songs $("#filelist").on('click', '.albumz', function () { var album = $(this).data('album'); - getAlbumSongs(album); + var artist = $(this).data('artist'); + + getAlbumSongs(album, artist); }); - function getAlbumSongs(album) { + function getAlbumSongs(album, artist) { $('#search_folders').val(''); $('.directoryName').html('Album: ' + album); //clear the list @@ -1011,7 +1016,7 @@ $(document).ready(function () { name: album }) - MSTREAMAPI.albumSongs(album, function (response, error) { + MSTREAMAPI.albumSongs(album, artist, function (response, error) { if (error !== false) { $('#filelist').html('
Server call failed
'); return boilerplateFailure(response, error); @@ -1023,8 +1028,7 @@ $(document).ready(function () { if (this.metadata.title) { currentBrowsingList.push({ type: 'file', name: this.metadata.title }) filelist.push('
' + this.metadata.title + '
'); - } - else { + } else { currentBrowsingList.push({ type: 'file', name: this.metadata.filename }) filelist.push('
' + this.metadata.filename + '
'); } @@ -1067,7 +1071,6 @@ $(document).ready(function () { }); } - $("#filelist").on('click', '.artistz', function () { var artist = $(this).data('artist'); programState.push({ @@ -1092,16 +1095,17 @@ $(document).ready(function () { var albums = []; $.each(response.albums, function (index, value) { + var albumString = value.name ? value.name : 'SINGLES'; if (value.album_art_file) { - albums.push('
' + value.name + '
'); + albums.push('
' + albumString + '
'); } else { - albums.push('
' + value.name + '
'); + albums.push('
' + albumString + '
'); } - currentBrowsingList.push({ type: 'album', name: value.name }) + currentBrowsingList.push({ type: 'album', name: value.name, artist: artist, album_art_file: value.album_art_file }) }); $('#filelist').html(albums); - // update linked list plugin + // update lazy load plugin ll.update(); }); } @@ -1109,6 +1113,7 @@ $(document).ready(function () { $('.get_rated_songs').on('click', function () { getRatedSongs(); }); + function getRatedSongs() { $('ul.left-nav-menu li').removeClass('selected'); $('.get_rated_songs').addClass('selected'); @@ -1148,7 +1153,7 @@ $(document).ready(function () { }); $('#filelist').html(files); - // update linked list plugin + // update lazy load plugin ll.update(); }); }