Display the loading spinner gif for all angular ajax requests
Remove the ajax-loader.gif which appeared only in unused styles.
This commit is contained in:
parent
8a81d7b9eb
commit
96aa1be2cf
6 changed files with 78 additions and 60 deletions
32
app/app.js
32
app/app.js
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/* Declare app level module */
|
/* Declare app level module */
|
||||||
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize', 'ui.keypress', 'angular-underscore/utils',
|
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'])
|
'jamstash.subsonic.controller', 'jamstash.archive.controller', 'jamstash.player.controller', 'jamstash.queue.controller', 'jamstash.settings.controller', 'jamstash.persistence', 'jamstash.loading'])
|
||||||
|
|
||||||
.config(['$routeProvider',function ($routeProvider) {
|
.config(['$routeProvider',function ($routeProvider) {
|
||||||
$routeProvider
|
$routeProvider
|
||||||
|
@ -19,8 +19,13 @@ angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize', 'ui.keypress',
|
||||||
.otherwise({ redirectTo: '/index' });
|
.otherwise({ redirectTo: '/index' });
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.config(['$httpProvider',function($httpProvider) {
|
.config(['$httpProvider', function httpConfig ($httpProvider) {
|
||||||
$httpProvider.interceptors.push(['$rootScope', '$location', '$q', 'globals', function ($rootScope, $location, $q, globals) {
|
$httpProvider.interceptors.push(authenticationInterceptor);
|
||||||
|
$httpProvider.interceptors.push(loadingInterceptor);
|
||||||
|
}]);
|
||||||
|
|
||||||
|
authenticationInterceptor.$inject = ['$rootScope', '$location', '$q', 'globals'];
|
||||||
|
function authenticationInterceptor($rootScope, $location, $q, globals) {
|
||||||
return {
|
return {
|
||||||
'request': function (request) {
|
'request': function (request) {
|
||||||
// if we're not logged-in to the AngularJS app, redirect to login page
|
// if we're not logged-in to the AngularJS app, redirect to login page
|
||||||
|
@ -47,5 +52,22 @@ angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize', 'ui.keypress',
|
||||||
return $q.reject(rejection);
|
return $q.reject(rejection);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}
|
||||||
}]);
|
|
||||||
|
loadingInterceptor.$inject = ['Loading'];
|
||||||
|
function loadingInterceptor(Loading) {
|
||||||
|
return {
|
||||||
|
request: function (request) {
|
||||||
|
Loading.isLoading = true;
|
||||||
|
return request;
|
||||||
|
},
|
||||||
|
response: function (response) {
|
||||||
|
Loading.isLoading = false;
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
responseError: function (error) {
|
||||||
|
Loading.isLoading = false;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
10
app/common/loading-service.js
Normal file
10
app/common/loading-service.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* jamstash.loading Module
|
||||||
|
*
|
||||||
|
* Keeps the loading state across the app in order to display the spinner gif
|
||||||
|
*/
|
||||||
|
angular.module('jamstash.loading', [])
|
||||||
|
|
||||||
|
.value('Loading', {
|
||||||
|
isLoading: false
|
||||||
|
});
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('JamStash')
|
angular.module('JamStash')
|
||||||
.controller('AppController', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player', 'persistence', 'Page', 'subsonic',
|
.controller('AppController', ['$scope', '$rootScope', '$document', '$window', '$location', '$cookieStore', '$http', 'utils', 'globals', 'model', 'notifications', 'player', 'persistence', 'Page', 'subsonic', 'Loading',
|
||||||
function ($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player, persistence, Page, subsonic) {
|
function ($scope, $rootScope, $document, $window, $location, $cookieStore, $http, utils, globals, model, notifications, player, persistence, Page, subsonic, Loading) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$rootScope.settings = globals.settings;
|
$rootScope.settings = globals.settings;
|
||||||
|
@ -27,6 +27,17 @@ angular.module('JamStash')
|
||||||
$location.path(path);
|
$location.path(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.loading = Loading;
|
||||||
|
// TODO: Hyz: remove when there are no longer jQuery ajax calls
|
||||||
|
$.ajaxSetup({
|
||||||
|
'beforeSend': function () {
|
||||||
|
$("#loading").removeClass('ng-hide');
|
||||||
|
},
|
||||||
|
'complete': function () {
|
||||||
|
$("#loading").addClass('ng-hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Reads cookies and sets globals.settings values
|
// Reads cookies and sets globals.settings values
|
||||||
$scope.loadSettings = function () {
|
$scope.loadSettings = function () {
|
||||||
// Temporary Code to Convert Cookies added 2/2/2014
|
// Temporary Code to Convert Cookies added 2/2/2014
|
||||||
|
@ -58,15 +69,6 @@ angular.module('JamStash')
|
||||||
notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
|
notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajaxSetup({
|
|
||||||
'beforeSend': function () {
|
|
||||||
$("#loading").show();
|
|
||||||
},
|
|
||||||
'complete': function () {
|
|
||||||
$("#loading").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var submenu_active = false;
|
var submenu_active = false;
|
||||||
$('div.submenu').mouseenter(function () {
|
$('div.submenu').mouseenter(function () {
|
||||||
submenu_active = true;
|
submenu_active = true;
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 723 B |
|
@ -29,7 +29,7 @@
|
||||||
<div id="messages">
|
<div id="messages">
|
||||||
<span ng-attr-id="{{ 'msg_' + $index }}" class="message" ng-repeat="item in Messages track by $index" ng-bind-html="item"></span>
|
<span ng-attr-id="{{ 'msg_' + $index }}" class="message" ng-repeat="item in Messages track by $index" ng-bind-html="item"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="loading"></div>
|
<div id="loading" ng-show="loading.isLoading"></div>
|
||||||
<a id="jslogo" title="Jamstash" class="showQueue" href=""></a>
|
<a id="jslogo" title="Jamstash" class="showQueue" href=""></a>
|
||||||
<a id="sslogo" target="_blank" ng-show="settings.Server" ng-href="{{settings.Server}}" title="{{settings.Server}}"></a>
|
<a id="sslogo" target="_blank" ng-show="settings.Server" ng-href="{{settings.Server}}" title="{{settings.Server}}"></a>
|
||||||
<div id="globalactions">
|
<div id="globalactions">
|
||||||
|
@ -106,6 +106,7 @@
|
||||||
<script src="common/model-service.js"></script>
|
<script src="common/model-service.js"></script>
|
||||||
<script src="common/utils-service.js"></script>
|
<script src="common/utils-service.js"></script>
|
||||||
<script src="common/page-service.js"></script>
|
<script src="common/page-service.js"></script>
|
||||||
|
<script src="common/loading-service.js"></script>
|
||||||
<script src="common/notification-service.js"></script>
|
<script src="common/notification-service.js"></script>
|
||||||
<script src="common/persistence-service.js"></script>
|
<script src="common/persistence-service.js"></script>
|
||||||
<script src="common/main-controller.js"></script>
|
<script src="common/main-controller.js"></script>
|
||||||
|
|
|
@ -349,16 +349,8 @@ span.apiversion
|
||||||
.leftsubsection {
|
.leftsubsection {
|
||||||
border-top: 1px solid #DDDDDD;
|
border-top: 1px solid #DDDDDD;
|
||||||
}
|
}
|
||||||
.loading
|
|
||||||
{
|
|
||||||
display: none;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
background: url('../images/ajax-loader.gif') no-repeat center center #f4f4f4;
|
|
||||||
}
|
|
||||||
#loading
|
#loading
|
||||||
{
|
{
|
||||||
display: none;
|
|
||||||
width: 64px;
|
width: 64px;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
@ -374,15 +366,6 @@ span.apiversion
|
||||||
-ms-border-radius: 8px;
|
-ms-border-radius: 8px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
#toploading
|
|
||||||
{
|
|
||||||
display: none;
|
|
||||||
height: 35px;
|
|
||||||
width: 40px;
|
|
||||||
margin: 0 0 0 2px;
|
|
||||||
background: url('../images/ajax-loader.gif') no-repeat center center;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
#messages
|
#messages
|
||||||
{
|
{
|
||||||
display: none;
|
display: none;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue