Add a router

This commit is contained in:
Philippe Vienne 2016-04-17 20:05:11 +02:00
parent a13c1491e6
commit 9bc6e1b477
2 changed files with 65 additions and 2 deletions

View file

@ -8,6 +8,35 @@
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">DuplicateFinder</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Finder</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li ng-if="access_token == ''">
<a href="#/login" class="dropdown-toggle" data-toggle="dropdown"><b>Login With Spotify</b></a>
</li>
<li ng-if="access_token != ''">
<a href="#/refresh-token" class="dropdown-toggle" data-toggle="dropdown"><b>Refresh my token</b></a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<h1>Duplicates finder
<button class="btn btn-default has-spinner" id="obtain-new-token">
@ -72,6 +101,7 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.4/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.js"></script>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"

View file

@ -2,10 +2,43 @@
(function(){
var app = angular.module('app',[]);
var app = angular.module('app',['ui.router']);
app.controller('AuthCtrl',['$scope', function($scope){
app.config(['$stateProvider','$urlRouterProvider',function($stateProvider, $urlRouterProvider){
$stateProvider
.state('finder_public',{
templateUrl:'partials/home.html',
url: '/',
controller: 'HomeCtrl'
})
.state('finder',{
templateUrl:'partials/logged.html',
url: '/finder',
controller: 'MainCtrl'
})
.state('finder.playlist',{
url: '/playlist',
views: {
playlist:{
templateUrl: 'partials/playlist.html',
controller: 'PlaylistCtrl'
}
}
})
.state('finder.playlist.dups',{
url: '/playlist/:id',
views: {
dups: {
templateUrl: 'partials/dups.html',
controller: 'DupsCtrl'
}
}
})
}]);
app.controller('AuthCtrl',['$scope', '$rootScope', function($scope, $rootScope){
$rootScope.access_token = "Bonjour";
$rootScope.refresh_token = "Bonjour2";
}])
})();