Commit graph

9 commits

Author SHA1 Message Date
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)