mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-24 22:18:00 +01:00
#7: Implement front-end handling of mixed losslessness track collections
This commit is contained in:
parent
63d4063ccc
commit
0ee7e4a315
7 changed files with 40 additions and 8 deletions
|
@ -152,7 +152,8 @@ class Album extends Model implements Searchable, Commentable, Favouritable
|
||||||
'extension' => $format['extension'],
|
'extension' => $format['extension'],
|
||||||
'url' => $album->getDownloadUrl($name),
|
'url' => $album->getDownloadUrl($name),
|
||||||
'size' => Helpers::formatBytes($album->getFilesize($name)),
|
'size' => Helpers::formatBytes($album->getFilesize($name)),
|
||||||
'isCacheable' => (in_array($name, Track::$CacheableFormats) ? true : false)
|
'isCacheable' => (in_array($name, Track::$CacheableFormats) ? true : false),
|
||||||
|
'isMixedLosslessness' => (in_array($name, Track::$LosslessFormats) && !$album->hasLosslessTracksOnly() && $album->hasLosslessTracks())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,8 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
|
||||||
'extension' => $format['extension'],
|
'extension' => $format['extension'],
|
||||||
'url' => $playlist->getDownloadUrl($name),
|
'url' => $playlist->getDownloadUrl($name),
|
||||||
'size' => Helpers::formatBytes($playlist->getFilesize($name)),
|
'size' => Helpers::formatBytes($playlist->getFilesize($name)),
|
||||||
'isCacheable' => (in_array($name, Track::$CacheableFormats) ? true : false)
|
'isCacheable' => (in_array($name, Track::$CacheableFormats) ? true : false),
|
||||||
|
'isMixedLosslessness' => (in_array($name, Track::$LosslessFormats) && !$playlist->hasLosslessTracksOnly() && $playlist->hasLosslessTracks())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" ng-show="::album.is_downloadable == 1">
|
<ul class="dropdown-menu" ng-show="::album.is_downloadable == 1">
|
||||||
<li ng-repeat="format in ::album.formats" ng-hide="isInProgress">
|
<li ng-repeat="format in ::album.formats" ng-hide="isInProgress">
|
||||||
<a target="_blank" ng-if="::!format.isCacheable" ng-href="{{::format.url}}">
|
<a target="_blank" ng-if="::!format.isCacheable" ng-click="checkMixedLosslessness(format);" ng-href="{{::format.url}}">
|
||||||
<span>{{::format.name}}</span>
|
<span>{{::format.name}}</span>
|
||||||
<small>({{::format.size}})</small>
|
<small>({{::format.size}})</small>
|
||||||
</a>
|
</a>
|
||||||
<a ng-if="::format.isCacheable" ng-click="getCachedAlbum(album.id, format.name);" href="">
|
<a ng-if="::format.isCacheable" ng-click="getCachedAlbum(album.id, format);" href="">
|
||||||
<span>{{::format.name}}</span>
|
<span>{{::format.name}}</span>
|
||||||
<small>({{::format.size}})</small>
|
<small>({{::format.size}})</small>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" ng-show="title">
|
||||||
|
<button type="button" class="close" ng-click="$hide()">×</button>
|
||||||
|
<h4 class="modal-title">Information</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Your download contains some tracks which are in lossy formats instead of your chosen lossless format ({{::format.name}}. This is because they were originally uploaded in a lossy format (e.g., MP3). As a result, these tracks have been replaced by their lossy files.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" ng-click="$hide()">OK</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -6,11 +6,11 @@
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li ng-repeat="format in ::playlist.formats" ng-hide="isInProgress">
|
<li ng-repeat="format in ::playlist.formats" ng-hide="isInProgress">
|
||||||
<a target="_blank" ng-if="::!format.isCacheable" ng-href="{{::format.url}}">
|
<a target="_blank" ng-if="::!format.isCacheable" ng-click="checkMixedLosslessness(format);" ng-href="{{::format.url}}">
|
||||||
<span>{{::format.name}}</span>
|
<span>{{::format.name}}</span>
|
||||||
<small>({{::format.size}})</small>
|
<small>({{::format.size}})</small>
|
||||||
</a>
|
</a>
|
||||||
<a ng-if="::format.isCacheable" ng-click="getCachedPlaylist(playlist.id, format.name);" href="">
|
<a ng-if="::format.isCacheable" ng-click="getCachedPlaylist(playlist.id, format);" href="">
|
||||||
<span>{{::format.name}}</span>
|
<span>{{::format.name}}</span>
|
||||||
<small>({{::format.size}})</small>
|
<small>({{::format.size}})</small>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -43,10 +43,16 @@ module.exports = angular.module('ponyfm').controller "album", [
|
||||||
playlists.refreshOwned().done (lists) ->
|
playlists.refreshOwned().done (lists) ->
|
||||||
$scope.playlists.push list for list in lists
|
$scope.playlists.push list for list in lists
|
||||||
|
|
||||||
|
$scope.checkMixedLosslessness = (format) ->
|
||||||
|
if format.isMixedLosslessness == true
|
||||||
|
$scope.format = format
|
||||||
|
$modal({scope: $scope, templateUrl: 'templates/partials/collection-mixed-losslessness-dialog.html', show: true})
|
||||||
|
|
||||||
|
|
||||||
$scope.getCachedAlbum = (id, format) ->
|
$scope.getCachedAlbum = (id, format) ->
|
||||||
$scope.isInProgress = true
|
$scope.isInProgress = true
|
||||||
|
|
||||||
cachedAlbum.download('albums', id, format).then (response) ->
|
cachedAlbum.download('albums', id, format.name).then (response) ->
|
||||||
$scope.albumUrl = response
|
$scope.albumUrl = response
|
||||||
if $scope.albumUrl == 'error'
|
if $scope.albumUrl == 'error'
|
||||||
$scope.isInProgress = false
|
$scope.isInProgress = false
|
||||||
|
@ -59,4 +65,5 @@ module.exports = angular.module('ponyfm').controller "album", [
|
||||||
else
|
else
|
||||||
$scope.isInProgress = false
|
$scope.isInProgress = false
|
||||||
$window.open $scope.albumUrl
|
$window.open $scope.albumUrl
|
||||||
|
$scope.checkMixedLosslessness(format)
|
||||||
]
|
]
|
||||||
|
|
|
@ -37,10 +37,16 @@ module.exports = angular.module('ponyfm').controller 'playlist', [
|
||||||
controller: ['$scope', ($scope) -> $scope.playlist = playlist; $scope.close = () -> dialog.close()],
|
controller: ['$scope', ($scope) -> $scope.playlist = playlist; $scope.close = () -> dialog.close()],
|
||||||
show: true
|
show: true
|
||||||
|
|
||||||
|
$scope.checkMixedLosslessness = (format) ->
|
||||||
|
if format.isMixedLosslessness == true
|
||||||
|
$scope.format = format
|
||||||
|
$modal({scope: $scope, templateUrl: 'templates/partials/collection-mixed-losslessness-dialog.html', show: true})
|
||||||
|
|
||||||
|
|
||||||
$scope.getCachedPlaylist = (id, format) ->
|
$scope.getCachedPlaylist = (id, format) ->
|
||||||
$scope.isInProgress = true
|
$scope.isInProgress = true
|
||||||
|
|
||||||
cachedPlaylist.download('playlists', id, format).then (response) ->
|
cachedPlaylist.download('playlists', id, format.name).then (response) ->
|
||||||
$scope.playlistUrl = response
|
$scope.playlistUrl = response
|
||||||
if $scope.playlistUrl == 'error'
|
if $scope.playlistUrl == 'error'
|
||||||
$scope.isInProgress = false
|
$scope.isInProgress = false
|
||||||
|
@ -53,4 +59,5 @@ module.exports = angular.module('ponyfm').controller 'playlist', [
|
||||||
else
|
else
|
||||||
$scope.isInProgress = false
|
$scope.isInProgress = false
|
||||||
$window.open $scope.playlistUrl
|
$window.open $scope.playlistUrl
|
||||||
|
$scope.checkMixedLosslessness(format)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue