
see: https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub The files are now grouped by view / component. Tests are located beside tested js files. The Grunt build will be responsible for only distributing actual files without the tests. Each partial is at the same level as the js files related to it. Ideally css files should be at the same level, maybe I'll refactor this later. Moves all non-bower plugins to app/vendor. Moves all images to app/images and styles to app/styles. Merges the test and non-test jshintrc files. Adds all the Jamstash contributors to the package.json file while I was refactoring. Conflicts: app/app.js app/images/vgrabber.gif app/images/vgrabber2-active.gif app/images/vgrabber2-normal.gif app/index.html
51 lines
2.7 KiB
JavaScript
Executable file
51 lines
2.7 KiB
JavaScript
Executable file
'use strict';
|
|
|
|
/* Declare app level module */
|
|
var jamstash = angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
|
|
'jamstash.subsonic.ctrl']);
|
|
|
|
jamstash.config(function ($routeProvider) {
|
|
$routeProvider
|
|
.when('/index', { redirectTo: '/library' })
|
|
.when('/settings', { templateUrl: 'settings/settings.html', controller: 'SettingsCtrl' })
|
|
.when('/queue', { templateUrl: 'queue/queue.html', controller: 'QueueCtrl' })
|
|
.when('/library', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl' })
|
|
.when('/library/:artistId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
|
|
.when('/library/:artistId/:albumId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
|
|
.when('/podcasts', { templateUrl: 'podcasts/podcasts.html', controller: 'PodcastCtrl' })
|
|
.when('/archive', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
|
.when('/archive/:artist', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
|
.when('/archive/:artist/:album', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
|
.otherwise({ redirectTo: '/index' });
|
|
});
|
|
|
|
jamstash.config(function ($httpProvider) {
|
|
$httpProvider.interceptors.push(function ($rootScope, $location, $q, globals) {
|
|
return {
|
|
'request': function (request) {
|
|
// if we're not logged-in to the AngularJS app, redirect to login page
|
|
//$rootScope.loggedIn = $rootScope.loggedIn || globals.settings.Username;
|
|
$rootScope.loggedIn = false;
|
|
if (globals.settings.Username != "" && globals.settings.Password != "" && globals.settings.Server != "") {
|
|
$rootScope.loggedIn = true;
|
|
}
|
|
var path = '';
|
|
path = $location.path();
|
|
if (globals.settings.Debug) { console.log('Logged In: ' + $rootScope.loggedIn); }
|
|
if (globals.settings.Debug) { console.log('Current Path: ' + path); }
|
|
if (!$rootScope.loggedIn && path != '/settings' && path.search('archive') < 0) {
|
|
$location.path('/settings');
|
|
}
|
|
return request;
|
|
},
|
|
'responseError': function (rejection) {
|
|
// if we're not logged-in to the web service, redirect to login page
|
|
if (rejection.status === 401 && $location.path() != '/settings') {
|
|
$rootScope.loggedIn = false;
|
|
$location.path('/settings');
|
|
}
|
|
return $q.reject(rejection);
|
|
}
|
|
};
|
|
});
|
|
});
|