Pony.fm/public/scripts/app/services/taxonomies.coffee

26 lines
621 B
CoffeeScript
Raw Normal View History

2013-07-25 23:33:04 +02:00
angular.module('ponyfm').factory('taxonomies', [
2013-07-30 06:53:57 +02:00
'$rootScope', '$http'
($rootScope, $http) ->
2013-07-25 23:33:04 +02:00
def = null
self =
2013-07-28 06:37:32 +02:00
trackTypes: []
2013-07-25 23:33:04 +02:00
licenses: []
genres: []
2013-07-28 06:37:32 +02:00
showSongs: []
2013-07-25 23:33:04 +02:00
refresh: () ->
2013-07-30 06:53:57 +02:00
return def.promise() if def != null
2013-07-25 23:33:04 +02:00
def = new $.Deferred()
2013-07-30 06:53:57 +02:00
$http.get('/api/web/taxonomies/all')
.success (taxonomies) ->
2013-07-25 23:33:04 +02:00
self.trackTypes.push t for t in taxonomies.track_types
self.licenses.push t for t in taxonomies.licenses
self.genres.push t for t in taxonomies.genres
2013-07-28 06:37:32 +02:00
self.showSongs.push t for t in taxonomies.show_songs
2013-07-25 23:33:04 +02:00
def.resolve self
2013-07-30 06:53:57 +02:00
def.promise()
2013-07-25 23:33:04 +02:00
self
])