
- settings.js now has its own module : 'jamstash.settings.controller'. This makes it easier to test it and identify what dependencies it has. - Renames 'jamstash.settings' module into 'jamstash.settings.service' - Adds an angular constant to hold the current Jamstash version in app.js. - Adds a way to upgrade incrementally what was in localStorage : in 4.4.5, DefaultSearchType will no longer be an object but an int, so we must init it with an int value, otherwise a blank option will be displayed. We detect what version we are using and what version was stored using persistence-service.js and run the upgrade accordingly. - Refactors almost completely persistence-service_test.js - Unit-tests some of settings.js's methods.
53 lines
3 KiB
JavaScript
Executable file
53 lines
3 KiB
JavaScript
Executable file
'use strict';
|
|
|
|
/* Declare app level module */
|
|
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize', 'ui.keypress', 'angular-underscore/utils',
|
|
'jamstash.subsonic.controller', 'jamstash.archive.controller', 'jamstash.player.controller', 'jamstash.queue.controller', 'jamstash.settings.controller', 'jamstash.persistence'])
|
|
|
|
.config(['$routeProvider',function($routeProvider) {
|
|
$routeProvider
|
|
.when('/index', { redirectTo: '/library' })
|
|
.when('/settings', { templateUrl: 'settings/settings.html', controller: 'SettingsController' })
|
|
.when('/queue', { templateUrl: 'queue/queue.html', controller: 'QueueController' })
|
|
.when('/library', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController' })
|
|
.when('/library/:artistId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController', reloadOnSearch: false })
|
|
.when('/library/:artistId/:albumId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController', reloadOnSearch: false })
|
|
.when('/podcasts', { templateUrl: 'podcasts/podcasts.html', controller: 'PodcastController' })
|
|
.when('/archive', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
|
.when('/archive/:artist', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
|
.when('/archive/:artist/:album', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
|
.otherwise({ redirectTo: '/index' });
|
|
}])
|
|
|
|
.config(['$httpProvider',function($httpProvider) {
|
|
$httpProvider.interceptors.push(['$rootScope', '$location', '$q', 'globals', 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);
|
|
}
|
|
};
|
|
}]);
|
|
}])
|
|
|
|
.constant('jamstashVersion', '4.4.5');
|