Commit graph

36 commits

Author SHA1 Message Date
Hyzual
9c8c8cf6a8 Refactor getAlbumListBy()
- subsonic-service no longer computes the offset, it gets it as an int param and uses it.
- subsonic-controller is now in charge of computing the offset given a 'prev', 'next' or undefined param. It no longer allows the offset to go in the negatives, which made no sense.
- subsonic-controller's scope's AutoAlbums array is now a map indexed by the type of auto-album. It also contains each item's offset so we no longer share the offset between auto-albums, which avoids weird behaviours.
- Plus some minor code style fixes.
2015-07-07 22:09:12 +02:00
Hyzual
91dbb868ed Removes getAlbums(), replaced by getSongs()
getSongs() does the same thing, at the only exception of Breadcrumbs management. Breadcrumbs will be refactored in a following commit.

Also removed getSongTemplate() which appears unused.
2015-07-07 22:07:21 +02:00
Hyzual
0ba6b651b1 Fetch users' ID3 genres using Subsonic
Instead of using a predefined list.
2015-06-01 23:43:36 +02:00
Hyzual
e43c4c7655 Refactors the way music folders are handled
- Second part of the fix for tsquillario/Jamstash#212 - Fixes getIndexes
- Moved loading / saving / deleting the selected music folder to persistence-service.
- Moved the request to get all the music folders to subsonic-service.
- Moved SelectedMusicFolder to subsonic-controller's scope from the rootScope
- Fixes a bug where we would send a '-1' music folder id to Subsonic, causing an SQL error when choosing "All Folders" and refreshing the Artists list.
2015-05-21 23:54:43 +02:00
Hyzual
0bc1cea108 Updates jasmine-promise-matchers to v1.1.1
Removes all deprecated jshint rules. They are not yet replaced with a JSCS equivalent (though they might be in the future).
2015-05-20 23:07:31 +02:00
Hyzual
5fed2ed21e Partial fix for tsquillario/Jamstash#212 - Fix Search 2015-05-14 23:22:25 +02:00
Hyzual
d45db2a98f Fix a bug that prevented you from changing your server
If the new server had an older ApiVersion (e.g. 1.8.0 compared to 1.12.0), when saving the settings, the server would respond an error due to the api version and when dealing with that error, we didn't update the ApiVersion when we should have.
2015-05-14 23:01:29 +02:00
Hyzual
b96fe0ecf0 Move starring songs to subsonic-service
So we keep all requests to subsonic in the same place and all use subsonicRequest()
2015-05-14 13:39:59 +02:00
Hyzual
ee25f7046e Refactors subsonic's getSongs(), adds a recursiveGetSongs()
So that the separation between subsonic-service and subsonic-controller is clear: the service makes requests and deals with $http, the controller displays, add to the player queue, etc.
I've also added a recursive version of getSongs() which enables us to play all the songs in a directory recursively, e.g. all the songs of an artist regardless of their album.

- Adds unit-tests to the controller and service for getSongs() and recursiveGetSongs()
2015-05-03 22:12:16 +02:00
Hyzual
9fbd7bcf8e Removes jquery.base64.js (unused), replaced jquery.dateFormat-1.0.js with its bower version
- Adds a unit test in archive-service to test that we do use utils.formatDate
- Minor changes in subsonic-service.js to use a variable name rather than "this", which can change
2015-05-01 13:08:05 +02:00
Hyzual
d06eef9cad Fixes Madsonic-related problems with getPodcast()
subsonic-service now makes sure we get an array (and not an object) when we expect one.
2015-04-12 15:08:38 +02:00
Hyzual
71eede8784 Fixes Madsonic-related problems with getAlbumListBy(), getSongs()
subsonic-service now makes sure we get an array (and not an object) when we expect one.
2015-04-12 15:08:37 +02:00
Hyzual
ee798fde90 Fixes Madsonic-related problems with search(), getRandomSongs() and getRandomStarredSongs()
subsonic-service now makes sure we get an array (and not an object) when we expect one.

Also improved the wording of many unit-tests.
2015-04-12 15:08:37 +02:00
Hyzual
8fe241e329 Fixes Madsonic-related problems with getPlaylists() and getPlaylist()
subsonic-service now makes sure we get an array (and not an object) when we expect one.
2015-04-12 15:08:36 +02:00
Hyzual
874f59a03b Fixes Madsonic-related problems with getArtists() and getPodcasts()
subsonic-service now makes sure we get an array (and not an object) when we expect one, e.g. shortcuts, index for artists and channel for podcasts.
2015-04-12 15:08:36 +02:00
Hyzual
af14bc5663 Fixes tsquillario/jamstash#207
When there is only one child, Madsonic does not return an array when Subsonic does.
I've added a check to always have the subsonic-response.directory.child as an array.

Adds 2 unit-tests: one for Subsonic's behaviour and one for Madsonic's
2015-04-12 15:08:36 +02:00
Hyzual
cf95f962b3 Improves test naming 2015-03-24 18:35:49 +01:00
Hyzual
841336cafd Refactors subsonic-service's search() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's search().
- Adds a mapAlbumss() method to model-service.js. Just as mapSongs(), it maps an array of albums and returns it.
- Refactors the SearchTypes so their id is an int (0,1,2), just like we already expected it in subsonic-service. This means it might invalidate the existing setting saved in localStorage, so people would have an empty option selected by default until they save their settings.
- Adds unit-tests.
2015-03-24 18:35:48 +01:00
Hyzual
ef57aac043 Refactors subsonic-service's getPodcast() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's getPodcast().
- Also sets all the selected things (playlist, album, etc.) to null.
- Adds a mapPodcasts() method to model-service.js. Just as mapSongs(), it maps an array of podcast episodes and returns it.
- Adds unit-tests.
2015-03-24 18:35:48 +01:00
Hyzual
f4c37bc8dd Refactors subsonic-service's getPodcasts() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's getPodcasts().
- Adds unit-tests.
2015-03-24 18:35:48 +01:00
Hyzual
d5c6b45dba Refactors subsonic-service's savePlaylist() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's savePlaylist().
- Adds unit-tests.
2015-03-24 18:35:47 +01:00
Hyzual
715bf413d5 Refactors subsonic-service's deletePlaylist() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's deletePlaylist(). It uses $window.confirm instead of the custom function in utils which didn't seem to add value.
- Adds unit-tests.
2015-03-24 18:35:47 +01:00
Hyzual
af144cf795 Adds '+' signs to increase readability of parameters in subsonic service tests
Some parameters are always there, some aren't. I've added '+' sign to distinguish those that are special to this test case. The difficulty is that they need to be sorted because that's what Angular does with params.
2015-03-24 18:35:47 +01:00
Hyzual
56298e2521 Refactors subsonic-service's newPlaylist() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's newPlaylist()
- Adds unit-tests. Try using Gojko Adzic's tips for BDD tests with Given-When-Then. See http://gojko.net/2015/02/25/how-to-get-the-most-out-of-given-when-then/
- Adds $window to subsonic-controller's dependencies. This allows us to test $window.prompt()
2015-03-24 18:35:47 +01:00
Hyzual
728f86fda7 Refactors subsonic-service's getPlaylist() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
- refactors subonic-controller's getPlaylist()
- Adds unit-tests
- Renames all "deferred" vars to "promise" which is really what is returned by $http.
- Converts all tabs in subsonic.html to spaces.
2015-03-24 18:35:46 +01:00
Hyzual
93bb0dc584 Refactors subsonic-service's getPlaylists() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
Removed the "refresh" parameter, since it was always passed as true.
- Adds unit-tests
2015-03-24 18:35:45 +01:00
Hyzual
dae168c564 Refactors subsonic-service's getArtists() to use subsonicRequest()
So we can move closer to consistent error-reporting and protocol usage.
Removed the "refresh" parameter, since it was always passed as true.
- Adds unit-tests
2015-03-24 18:35:44 +01:00
Hyzual
7f84cf7b98 Fixes tsquillario/Jamstash#192
Adds a ping() function to the subsonic service, taking advantage of our new subsonicRequest wrapper. It works with both JSON and JSONP, catches errors, etc.
Errors from an incorrect parameter (missing password) or unreachable server should now be displayed to the user.
2015-01-17 19:15:10 +01:00
Hyzual
33f1a88d6b Adds the generic requestSongs function to subsonic.js.
It handles displaying, adding or playing songs, whatever their source. It also handles error notifications for subsonic, http or service errors.

- Changes all calls to getRandomSongs in the template so they provide the 'display' parameter and do not provide any param when they aren't needed.
- Adds genre and folder parameters to getRandomSongs
- getRandomStarredSongs now maps the songs (using model) before returning them
2015-01-17 19:15:08 +01:00
Hyzual
dc280594ab Refactor subsonic getRandomSongs() so that it returns a promise
I have now to fix the functions that called it from the scope (random autoplaylist and others)
This fixes the problem with AutoPlay not updating : since $q's promises are integrated with scope, we now see immediately the new songs being added.
2015-01-17 19:15:07 +01:00
Hyzual
446e653048 Refactor getStarred, getRandomStarred and scrobble in subsonic-service.js
They now use the new subsonicRequest() method which frees us from having to rebuild the complete URL with all the params. It handles JSONP/JSON and it also does most of the error-handling, so we can focus on displaying more specific messages in every request.

- Renamed playingIndex and playingSong in player-service.js to "private variables" starting with '_'. They only are public for testing purposes and are not meant to be manipulated directly.
2015-01-17 19:15:07 +01:00
Hyzual
2e97e25f25 Adds back AutoPlay, Loop Queue and Repeat support.
- AutoPlay still has a problem with scope apply. Since it's asynchronous, the directive needs to know when it's finisehd to use scope apply... That means more subsonic refactoring.
- Adds unit tests for Repeat song and Loop Queue
- Adds back a special function in the player Service to manage the end of a song.
2015-01-17 19:13:42 +01:00
Hyzual
834e67946c Adds back scrobbling and loading a track and the queue from localStorage.
- Splits loadTrackPosition into two functions : one for the track (which isn't finished), one for the queue.
- Adds main-controller.js' first unit tests for both these functions.
- Adds scrobbling functionnality. It is now a part of the Subsonic service, since we it's Subsonic that ultimately does the scroblling.
- Adds unit tests for both the service and the directive. The test for updatetime was crazy hard to do because I had to find a way to trigger my own fake event and it wasn't permitted by jplayer.
- Adds the load function to the player, it is used only when loading a song from localStorage.
- Removes ng-click from play/pause in the player template. jPlayer adds its own handlers on them, no need to do it twice.
2015-01-17 19:13:42 +01:00
Hyzual
a9b4150272 Adds the complete subsonic ctrl function getRandomStarredSongs.
It has one parameter with 3 possible values :
- display: to display in the view,
- add: adds to the queue
- play: plays the first song and adds to the queue.

It is now called from the subsonic template.

All these are tested, errors from the server (both subsonic and http) are relayed to the user through notifications.

Conflicts:
	app/subsonic/subsonic.html
2014-11-09 16:21:14 +01:00
Hyzual
e18fbe2c5b Refactors the subsonic service test with jasmine promise matchers.
It makes them easier to read.

Conflicts:
	bower.json
2014-11-09 16:12:29 +01:00
Hyzual
a1d48bbd30 Reorganizes the entire app to follow Google's best practice recommendations for Angular App Structure.
see: https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub

The files are now grouped by view / component.
Tests are located beside tested js files. The Grunt build will be responsible for only distributing actual files without the tests.
Each partial is at the same level as the js files related to it.
Ideally css files should be at the same level, maybe I'll refactor this later.

Moves all non-bower plugins to app/vendor.
Moves all images to app/images and styles to app/styles.
Merges the test and non-test jshintrc files.

Adds all the Jamstash contributors to the package.json file while I was refactoring.

Conflicts:
	app/app.js
	app/images/vgrabber.gif
	app/images/vgrabber2-active.gif
	app/images/vgrabber2-normal.gif
	app/index.html
2014-11-09 16:10:34 +01:00
Renamed from test/services/subsonic-service_test.js (Browse further)