2013-07-25 23:33:04 +02:00
|
|
|
angular.module('ponyfm').factory('taxonomies', [
|
|
|
|
'$rootScope'
|
|
|
|
($rootScope) ->
|
|
|
|
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: () ->
|
|
|
|
return def if def != null
|
|
|
|
|
|
|
|
def = new $.Deferred()
|
|
|
|
$.getJSON('/api/web/taxonomies/all')
|
|
|
|
.done (taxonomies) -> $rootScope.$apply ->
|
|
|
|
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
|
|
|
|
def
|
|
|
|
|
|
|
|
self
|
|
|
|
])
|