mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 14:37:59 +01:00
Passing stats data to the front end
This commit is contained in:
parent
4ca904667b
commit
152e1e1fb6
5 changed files with 66 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
<li>Plays: <strong>{{::track.stats.plays}}</strong></li>
|
<li>Plays: <strong>{{::track.stats.plays}}</strong></li>
|
||||||
<li>Downloads: <strong>{{::track.stats.downloads}}</strong></li>
|
<li>Downloads: <strong>{{::track.stats.downloads}}</strong></li>
|
||||||
<li>Favourites: <strong>{{::track.stats.favourites}}</strong></li>
|
<li>Favourites: <strong>{{::track.stats.favourites}}</strong></li>
|
||||||
|
<li><strong><a href="{{::track.url}}/stats">View more stats</a></strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
|
|
1
public/templates/tracks/stats.html
Normal file
1
public/templates/tracks/stats.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h1>THERE ARE NO STATS HERE BECAUSE I HAVEN'T CODED THAT YET BUT AT LEAST YOU'RE READING THIS WHICH MEANS NOT EVERYTHING IS BROKEN</h1>
|
|
@ -174,6 +174,11 @@ ponyfm.config [
|
||||||
templateUrl: '/templates/tracks/edit.html'
|
templateUrl: '/templates/tracks/edit.html'
|
||||||
controller: 'track-edit'
|
controller: 'track-edit'
|
||||||
|
|
||||||
|
state.state 'content.track.stats',
|
||||||
|
url: '/stats'
|
||||||
|
templateUrl: '/templates/tracks/stats.html'
|
||||||
|
controller: 'track-stats'
|
||||||
|
|
||||||
|
|
||||||
# Albums
|
# Albums
|
||||||
|
|
||||||
|
|
27
resources/assets/scripts/app/controllers/track-stats.coffee
Normal file
27
resources/assets/scripts/app/controllers/track-stats.coffee
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Pony.fm - A community for pony fan music.
|
||||||
|
# Copyright (C) 2016 Peter Deltchev
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = angular.module('ponyfm').controller "track-stats", [
|
||||||
|
'$scope', '$state', 'track-stats'
|
||||||
|
($scope, $state, statsService) ->
|
||||||
|
$scope.trackId = parseInt($state.params.id)
|
||||||
|
|
||||||
|
statsLoaded = (stats) ->
|
||||||
|
console.log(stats)
|
||||||
|
|
||||||
|
statsService.loadStats($scope.trackId).done statsLoaded
|
||||||
|
]
|
32
resources/assets/scripts/app/services/track-stats.coffee
Normal file
32
resources/assets/scripts/app/services/track-stats.coffee
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Pony.fm - A community for pony fan music.
|
||||||
|
# Copyright (C) 2016 Peter Deltchev
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module.exports = angular.module('ponyfm').factory('track-stats', [
|
||||||
|
'$rootScope', '$http'
|
||||||
|
($rootScope, $http) ->
|
||||||
|
stats = []
|
||||||
|
|
||||||
|
self =
|
||||||
|
loadStats: (id) ->
|
||||||
|
return def if def
|
||||||
|
def = new $.Deferred()
|
||||||
|
$http.get('/api/web/tracks/' + id + '/stats').success (stats) ->
|
||||||
|
def.resolve stats
|
||||||
|
|
||||||
|
def.promise()
|
||||||
|
|
||||||
|
self
|
||||||
|
])
|
Loading…
Reference in a new issue