Renamed all controlles from 'Ctrl' to 'Controller' to better follow angular best practices.
This commit is contained in:
parent
91b112cb0a
commit
226a768987
12 changed files with 49 additions and 71 deletions
20
app/app.js
20
app/app.js
|
@ -1,22 +1,22 @@
|
||||||
|
|
||||||
/* Declare app level module */
|
/* Declare app level module */
|
||||||
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
|
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
|
||||||
'jamstash.subsonic.ctrl', 'jamstash.archive.ctrl', 'jamstash.player.ctrl', 'jamstash.queue.ctrl'])
|
'jamstash.subsonic.controller', 'jamstash.archive.controller', 'jamstash.player.controller', 'jamstash.queue.controller'])
|
||||||
|
|
||||||
.config(['$routeProvider',function($routeProvider) {
|
.config(['$routeProvider',function($routeProvider) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$routeProvider
|
$routeProvider
|
||||||
.when('/index', { redirectTo: '/library' })
|
.when('/index', { redirectTo: '/library' })
|
||||||
.when('/settings', { templateUrl: 'settings/settings.html', controller: 'SettingsCtrl' })
|
.when('/settings', { templateUrl: 'settings/settings.html', controller: 'SettingsController' })
|
||||||
.when('/queue', { templateUrl: 'queue/queue.html', controller: 'QueueCtrl' })
|
.when('/queue', { templateUrl: 'queue/queue.html', controller: 'QueueController' })
|
||||||
.when('/library', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl' })
|
.when('/library', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController' })
|
||||||
.when('/library/:artistId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
|
.when('/library/:artistId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController', reloadOnSearch: false })
|
||||||
.when('/library/:artistId/:albumId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
|
.when('/library/:artistId/:albumId', { templateUrl: 'subsonic/subsonic.html', controller: 'SubsonicController', reloadOnSearch: false })
|
||||||
.when('/podcasts', { templateUrl: 'podcasts/podcasts.html', controller: 'PodcastCtrl' })
|
.when('/podcasts', { templateUrl: 'podcasts/podcasts.html', controller: 'PodcastController' })
|
||||||
.when('/archive', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
.when('/archive', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
||||||
.when('/archive/:artist', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
.when('/archive/:artist', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
||||||
.when('/archive/:artist/:album', { templateUrl: 'archive/archive.html', controller: 'ArchiveCtrl' })
|
.when('/archive/:artist/:album', { templateUrl: 'archive/archive.html', controller: 'ArchiveController' })
|
||||||
.otherwise({ redirectTo: '/index' });
|
.otherwise({ redirectTo: '/index' });
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/**
|
/**
|
||||||
* jamstash.archive.ctrl Module
|
* jamstash.archive.controller Module
|
||||||
*
|
*
|
||||||
* Access Archive.org
|
* Access Archive.org
|
||||||
*/
|
*/
|
||||||
angular.module('jamstash.archive.ctrl', ['jamstash.archive.service'])
|
angular.module('jamstash.archive.controller', ['jamstash.archive.service'])
|
||||||
|
|
||||||
.controller('ArchiveCtrl', ['$scope', '$rootScope', '$location', '$routeParams', '$http', '$timeout', 'utils', 'globals', 'model', 'notifications', 'player', 'archive', 'json',
|
.controller('ArchiveController', ['$scope', '$rootScope', '$location', '$routeParams', '$http', '$timeout', 'utils', 'globals', 'model', 'notifications', 'player', 'archive', 'json',
|
||||||
function($scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json){
|
function($scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
angular.module('JamStash')
|
angular.module('JamStash')
|
||||||
.controller('AppCtrl', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player',
|
.controller('AppController', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player',
|
||||||
function($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player) {
|
function($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<link href="styles/Mobile.css" rel="stylesheet" type="text/css" data-name="main" />
|
<link href="styles/Mobile.css" rel="stylesheet" type="text/css" data-name="main" />
|
||||||
<link href="" rel="stylesheet" type="text/css" data-name="theme" />
|
<link href="" rel="stylesheet" type="text/css" data-name="theme" />
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="AppCtrl">
|
<body ng-controller="AppController">
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="messages">
|
<div id="messages">
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div><!-- end #content -->
|
</div><!-- end #content -->
|
||||||
<div id="SideBar" ng-controller="QueueCtrl">
|
<div id="SideBar" ng-controller="QueueController">
|
||||||
<div class="headeractions">
|
<div class="headeractions">
|
||||||
<a class="buttonimg" title="Shuffle Queue" ng-click="queueShuffle()"><img src="images/fork_gd_11x12.png"></a>
|
<a class="buttonimg" title="Shuffle Queue" ng-click="queueShuffle()"><img src="images/fork_gd_11x12.png"></a>
|
||||||
<a class="buttonimg" id="action_Empty" title="Delete Queue" ng-click="queueEmpty()"><img src="images/trash_fill_gd_12x12.png"></a>
|
<a class="buttonimg" id="action_Empty" title="Delete Queue" ng-click="queueEmpty()"><img src="images/trash_fill_gd_12x12.png"></a>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
-->
|
-->
|
||||||
</div>
|
</div>
|
||||||
<!-- Player -->
|
<!-- Player -->
|
||||||
<jamstash-player ng-controller="PlayerCtrl"></jamstash-player>
|
<jamstash-player ng-controller="PlayerController"></jamstash-player>
|
||||||
</div> <!-- End container -->
|
</div> <!-- End container -->
|
||||||
<script>
|
<script>
|
||||||
(function (i, s, o, g, r, a, m) {
|
(function (i, s, o, g, r, a, m) {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* Control the HTML5 player through jplayer.js
|
* Control the HTML5 player through jplayer.js
|
||||||
*/
|
*/
|
||||||
angular.module('jamstash.player.ctrl', ['jamstash.player.service', 'jamstash.player.directive'])
|
angular.module('jamstash.player.controller', ['jamstash.player.service', 'jamstash.player.directive'])
|
||||||
|
|
||||||
.controller('PlayerCtrl', ['$scope', 'player', function($scope, player){
|
.controller('PlayerController', ['$scope', 'player', function($scope, player){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$scope.previousTrack = function () {
|
$scope.previousTrack = function () {
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe("Player controller", function() {
|
||||||
var player, scope;
|
var player, scope;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
module('jamstash.player.ctrl');
|
module('jamstash.player.controller');
|
||||||
|
|
||||||
inject(function ($controller, $rootScope, _player_) {
|
inject(function ($controller, $rootScope, _player_) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
@ -15,7 +15,7 @@ describe("Player controller", function() {
|
||||||
spyOn(player, "previousTrack").and.stub();
|
spyOn(player, "previousTrack").and.stub();
|
||||||
spyOn(player, "defaultPlay").and.stub();
|
spyOn(player, "defaultPlay").and.stub();
|
||||||
|
|
||||||
$controller('PlayerCtrl', {
|
$controller('PlayerController', {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
player: player
|
player: player
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
angular.module('JamStash')
|
angular.module('JamStash')
|
||||||
|
|
||||||
.controller('PodcastCtrl', ['$scope', '$rootScope', function PodcastCtrl($scope, $rootScope) {
|
.controller('PodcastController', ['$scope', '$rootScope', function ($scope, $rootScope) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$rootScope.song = [];
|
$rootScope.song = [];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
angular.module('jamstash.queue.ctrl', ['jamstash.player.service'])
|
angular.module('jamstash.queue.controller', ['jamstash.player.service'])
|
||||||
|
|
||||||
.controller('QueueCtrl', ['$scope', '$rootScope', 'globals', 'player',
|
.controller('QueueController', ['$scope', '$rootScope', 'globals', 'player',
|
||||||
function QueueCtrl($scope, $rootScope, globals, player) {
|
function ($scope, $rootScope, globals, player) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$scope.settings = globals.settings;
|
$scope.settings = globals.settings;
|
||||||
$scope.song = $rootScope.queue;
|
$scope.song = $rootScope.queue;
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe("Queue controller", function() {
|
||||||
var player, $rootScope, scope, globals;
|
var player, $rootScope, scope, globals;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
module('jamstash.queue.ctrl');
|
module('jamstash.queue.controller');
|
||||||
|
|
||||||
inject(function ($controller, _$rootScope_, _globals_, _player_) {
|
inject(function ($controller, _$rootScope_, _globals_, _player_) {
|
||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_;
|
||||||
|
@ -15,7 +15,7 @@ describe("Queue controller", function() {
|
||||||
// Mock the functions of the services
|
// Mock the functions of the services
|
||||||
spyOn(player, "playSong").and.stub();
|
spyOn(player, "playSong").and.stub();
|
||||||
|
|
||||||
$controller('QueueCtrl', {
|
$controller('QueueController', {
|
||||||
$rootScope: $rootScope,
|
$rootScope: $rootScope,
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
globals: globals,
|
globals: globals,
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
angular.module('JamStash')
|
angular.module('JamStash')
|
||||||
|
|
||||||
.controller('SettingsCtrl', ['$rootScope', '$scope', '$routeParams', '$location', '$http', '$q', 'utils', 'globals', 'json', 'notifications', 'player',
|
.controller('SettingsController', ['$rootScope', '$scope', '$routeParams', '$location', 'utils', 'globals', 'json', 'notifications', 'player',
|
||||||
function ($rootScope, $scope, $routeParams, $location, $http, $q, utils, globals, json, notifications, player) {
|
function ($rootScope, $scope, $routeParams, $location, utils, globals, json, notifications, player) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$rootScope.hideQueue();
|
$rootScope.hideQueue();
|
||||||
$scope.settings = globals.settings; /* See service.js */
|
$scope.settings = globals.settings; /* See service.js */
|
||||||
$scope.ApiVersion = globals.settings.ApiVersion;
|
|
||||||
$scope.Timeouts = [
|
$scope.Timeouts = [
|
||||||
{ id: 10000, name: 10 },
|
{ id: 10000, name: 10 },
|
||||||
{ id: 20000, name: 20 },
|
{ id: 20000, name: 20 },
|
||||||
|
@ -28,34 +27,6 @@
|
||||||
$('#AZIndex').show();
|
$('#AZIndex').show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$scope.ping = function () {
|
|
||||||
var exception = {reason: 'Error when contacting the Subsonic server.'};
|
|
||||||
var deferred = $q.defer();
|
|
||||||
var httpPromise;
|
|
||||||
httpPromise = $http({
|
|
||||||
method: 'GET',
|
|
||||||
timeout: globals.settings.Timeout,
|
|
||||||
// 2015-1-5: This API call only works with json as of SS v5.0?!?
|
|
||||||
//url: globals.BaseURL() + '/ping.view?' + globals.BaseParams(),
|
|
||||||
url: globals.BaseURL() + '/ping.view?' + globals.BaseJSONParams()
|
|
||||||
});
|
|
||||||
httpPromise.success(function(data, status) {
|
|
||||||
var subsonicResponse = (data['subsonic-response'] !== undefined) ? data['subsonic-response'] : {status: 'failed'};
|
|
||||||
if (subsonicResponse.status === 'ok') {
|
|
||||||
$scope.ApiVersion = subsonicResponse.version;
|
|
||||||
globals.settings.ApiVersion = $scope.ApiVersion;
|
|
||||||
deferred.resolve(data);
|
|
||||||
} else {
|
|
||||||
if(subsonicResponse.status === 'failed' && subsonicResponse.error !== undefined) {
|
|
||||||
notifications.updateMessage(subsonicResponse.error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).error(function(data, status) {
|
|
||||||
exception.httpError = status;
|
|
||||||
deferred.reject(exception);
|
|
||||||
});
|
|
||||||
return deferred.promise;
|
|
||||||
};
|
|
||||||
$scope.reset = function () {
|
$scope.reset = function () {
|
||||||
utils.setValue('Settings', null, true);
|
utils.setValue('Settings', null, true);
|
||||||
$scope.loadSettings();
|
$scope.loadSettings();
|
||||||
|
@ -92,9 +63,16 @@
|
||||||
notifications.updateMessage('Settings Updated!', true);
|
notifications.updateMessage('Settings Updated!', true);
|
||||||
$scope.loadSettings();
|
$scope.loadSettings();
|
||||||
if (globals.settings.Server !== '' && globals.settings.Username !== '' && globals.settings.Password !== '') {
|
if (globals.settings.Server !== '' && globals.settings.Username !== '' && globals.settings.Password !== '') {
|
||||||
$scope.ping().then(function() {
|
$scope.ping().then(function(data) {
|
||||||
$location.path('/library').replace();
|
if (data["subsonic-response"].status == 'ok') {
|
||||||
$rootScope.showIndex = true;
|
globals.settings.ApiVersion = data["subsonic-response"].version;
|
||||||
|
$location.path('/library').replace();
|
||||||
|
$rootScope.showIndex = true;
|
||||||
|
} else {
|
||||||
|
if (typeof data["subsonic-response"].error != 'undefined') {
|
||||||
|
notifications.updateMessage(data["subsonic-response"].error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* jamstash.subsonic.ctrl Module
|
* jamstash.subsonic.controller Module
|
||||||
*
|
*
|
||||||
* Access and use the Subsonic Server. The Controller is in charge of relaying the Service's messages to the user through the
|
* Access and use the Subsonic Server. The Controller is in charge of relaying the Service's messages to the user through the
|
||||||
* notifications.
|
* notifications.
|
||||||
*/
|
*/
|
||||||
angular.module('jamstash.subsonic.ctrl', ['jamstash.subsonic.service', 'jamstash.player.service'])
|
angular.module('jamstash.subsonic.controller', ['jamstash.subsonic.service', 'jamstash.player.service'])
|
||||||
|
|
||||||
.controller('SubsonicCtrl', ['$scope', '$rootScope', '$routeParams', 'utils', 'globals', 'map', 'subsonic', 'notifications', 'player',
|
.controller('SubsonicController', ['$scope', '$rootScope', '$routeParams', 'utils', 'globals', 'map', 'subsonic', 'notifications', 'player',
|
||||||
function SubsonicCtrl($scope, $rootScope, $routeParams, utils, globals, map, subsonic, notifications, player) {
|
function ($scope, $rootScope, $routeParams, utils, globals, map, subsonic, notifications, player) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$scope.settings = globals.settings;
|
$scope.settings = globals.settings;
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe("Subsonic controller", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
jasmine.addCustomEqualityTester(angular.equals);
|
jasmine.addCustomEqualityTester(angular.equals);
|
||||||
|
|
||||||
module('jamstash.subsonic.ctrl');
|
module('jamstash.subsonic.controller');
|
||||||
|
|
||||||
inject(function ($controller, _$rootScope_, utils, globals, map, _subsonic_, _notifications_, $q, _player_) {
|
inject(function ($controller, _$rootScope_, utils, globals, map, _subsonic_, _notifications_, $q, _player_) {
|
||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_;
|
||||||
|
@ -26,7 +26,7 @@ describe("Subsonic controller", function() {
|
||||||
spyOn(player, 'playSong').and.stub();
|
spyOn(player, 'playSong').and.stub();
|
||||||
$rootScope.queue = [];
|
$rootScope.queue = [];
|
||||||
|
|
||||||
$controller('SubsonicCtrl', {
|
$controller('SubsonicController', {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
$rootScope: $rootScope,
|
$rootScope: $rootScope,
|
||||||
$routeParams: {},
|
$routeParams: {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue