Load playlists
This commit is contained in:
parent
156f06bc20
commit
0bc8f06c3e
6 changed files with 50 additions and 35 deletions
|
@ -38,35 +38,7 @@
|
|||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
<div class="container">
|
||||
<h1>Duplicates finder
|
||||
<button class="btn btn-default has-spinner" id="obtain-new-token">
|
||||
Refresh token <span class="spinner"><i class="icon-spin icon-refresh"></i></span>
|
||||
</button>
|
||||
<span id="login">
|
||||
<a href="/login" class="btn btn-lg btn-success">Log in with Spotify</a>
|
||||
</span>
|
||||
</h1>
|
||||
<div id="error"></div>
|
||||
<div id="loggedin">
|
||||
<div id="user-profile">
|
||||
</div>
|
||||
|
||||
<div class="media">
|
||||
<div class="pull-left">
|
||||
<h2 id="playlists-title">Playlists
|
||||
<button class="btn btn-default has-spinner" id="get-playlists">
|
||||
Refresh <span class="spinner"><i class="icon-spin icon-refresh"></i></span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="playlists">
|
||||
</div>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<div id="dups">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ui-view></ui-view>
|
||||
</div>
|
||||
|
||||
<script id="playlists-template" type="text/x-handlebars-template">
|
||||
|
|
2
public/partials/dups.html
Normal file
2
public/partials/dups.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>UID: {{uid}}</p>
|
||||
<p>ID: {{id}}</p>
|
1
public/partials/home.html
Normal file
1
public/partials/home.html
Normal file
|
@ -0,0 +1 @@
|
|||
<p>Please connect to Spotify to access to the app.</p>
|
4
public/partials/logged.html
Normal file
4
public/partials/logged.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
<div class="container row">
|
||||
<div class="col-md-3" ui-view="playlist"></div>
|
||||
<div class="col-md-9" ui-view="dups"></div>
|
||||
</div>
|
9
public/partials/playlist.html
Normal file
9
public/partials/playlist.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<div>
|
||||
<h2 class="pull-left">Playlist</h2>
|
||||
<a class="btn btn-default pull-right" ng-click="load()">Load</a>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item" ng-repeat="playlist in playlists" ng-click="open(playlist)">
|
||||
{{playlist.name}}
|
||||
</div>
|
||||
</div>
|
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
})
|
||||
.state('finder.playlist.dups',{
|
||||
url: '/playlist/:id',
|
||||
url: '/playlist/:uid/:id',
|
||||
views: {
|
||||
dups: {
|
||||
templateUrl: 'partials/dups.html',
|
||||
|
@ -37,9 +37,20 @@
|
|||
$urlRouterProvider.otherwise("/");
|
||||
}]);
|
||||
|
||||
app.run(['$rootScope',function($rootScope){
|
||||
app.run(['$rootScope', '$state',function($rootScope, $state){
|
||||
$rootScope.access_token = "";
|
||||
$rootScope.refresh_token = "";
|
||||
$rootScope.$watch('access_token',function(newVal, oldVal, scope){
|
||||
if(oldVal == "" && newVal != ""){
|
||||
$state.go('finder.playlist');
|
||||
} else if (oldVal != "" && newVal == ""){
|
||||
$state.go('finder_public');
|
||||
}
|
||||
});
|
||||
if($rootScope.access_token == "")
|
||||
$state.go('finder_public');
|
||||
else
|
||||
$state.go('finder.playlist');
|
||||
}]);
|
||||
|
||||
app.controller("HomeCtrl",['$scope',function($scope){
|
||||
|
@ -50,12 +61,28 @@
|
|||
|
||||
}]);
|
||||
|
||||
app.controller("PlaylistCtrl",['$scope',function($scope){
|
||||
|
||||
app.controller("PlaylistCtrl",['$scope', '$http', '$state',function($scope, $http, $state){
|
||||
$scope.playlists = [];
|
||||
$scope.load = function(){
|
||||
$http.get('/get_playlists', {
|
||||
params:{
|
||||
access_token: $scope.access_token
|
||||
}
|
||||
}).then(function(result){
|
||||
var r = result.data;
|
||||
if(r.data){
|
||||
$scope.playlists = r.data;
|
||||
}
|
||||
})
|
||||
};
|
||||
$scope.open = function(playlist) {
|
||||
$state.go('finder.playlist.dups',{uid: playlist.owner.id, id: playlist.id})
|
||||
}
|
||||
}]);
|
||||
|
||||
app.controller("DupsCtrl",['$scope',function($scope){
|
||||
|
||||
app.controller("DupsCtrl",['$scope', '$stateParams',function($scope, $stateParams){
|
||||
$scope.uid = $stateParams['uid'];
|
||||
$scope.id = $stateParams['id'];
|
||||
}]);
|
||||
|
||||
app.controller('AuthCtrl',['$scope', '$rootScope', '$interval', '$http', function($scope, $rootScope, $interval, $http){
|
||||
|
|
Loading…
Reference in a new issue