Skip to content

Commit

Permalink
Add loading gif and fix some issues (#130)
Browse files Browse the repository at this point in the history
- Fix missing subSidebar on course final inscr show
- Fix final inscription redirection
- Fix footer load with ng-cloak
  • Loading branch information
MatiasComercio committed Feb 6, 2017
1 parent f5ff3f6 commit ee26734
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
Binary file added app/images/spin.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
</head>
<body ng-controller='BodyCtrl as controller'>

<div class='loader-container' ng-show='showLoader' prevent-scroll>
<img src='images/spin.gif' class='no-select'>
</div>

<!-- site navigation elements -->
<xnavbar></xnavbar>
<xsidebar></xsidebar>
Expand Down Expand Up @@ -42,7 +46,7 @@
<!-- \content -->

<!-- footer -->
<div class='footer'>
<div class='footer' ng-cloak>
<span translate='i18nFooterCopyright'></span>
</div>
<!-- \footer -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function(paw) {
Courses.qualifyFinalInscription(_this.course, inscriptionId, qualifiedStudents).then(function(response) {
flashMessages.setSuccess('i18nQualifySuccessfully');
if (response.status === 204) {
Paths.get().courses(_this.course).finalInscriptions().go();
Paths.get().courses(_this.course).go();
} else {
$route.reload();
}
Expand All @@ -44,6 +44,7 @@ function(paw) {

Courses.get(courseId).then(function(course) {
_this.course = course;
Courses.setOnSubSidebar(course);
_this.course.all('finalInscriptions').get(inscriptionId).then(function(finalInscription) {
_this.course.inscription = finalInscription;
_this.course.inscription.students = finalInscription.history;
Expand Down
34 changes: 34 additions & 0 deletions app/scripts/paw.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,40 @@ function(config, dependencyResolverFor, i18n, authenticationService, pathsServic
}
});

// Code taken & adapted from:
// http://stackoverflow.com/questions/24088610/restangular-spinner
var pendingRequests = 0;

Restangular.addRequestInterceptor(
function (element, operation, what, url) {
if (pendingRequests === 0) {
$rootScope.showLoader = true;
}
pendingRequests++;
return element;
}
);

Restangular.addResponseInterceptor(
function (data, operation, what, url, response, deferred) {
pendingRequests--;
if (pendingRequests === 0) {
$rootScope.showLoader = false;
}
return data;
}
);

Restangular.addErrorInterceptor(
function(response, deferred, responseHandler) {
pendingRequests--;
if (pendingRequests === 0) {
$rootScope.showLoader = false;
}
return true; // error not handled
}
);

Restangular.setErrorInterceptor(
function(response, deferred, responseHandler) {
var propagateError = true;
Expand Down
5 changes: 5 additions & 0 deletions app/styles/modules/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ hr {
.sym-button {
cursor: pointer;
}

// https://docs.angularjs.org/api/ng/directive/ngCloak
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
1 change: 1 addition & 0 deletions app/styles/modules/variables/sizes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ $sidebarWidth: 240px;
$sidebarButtonHeight: 50px;
$navbarZIndex: 1001;
$sidebarZIndex: 1002;
$loaderZIndex: 1003;
$containerPadding: 30px;
$bootstrapMobileMaxWidth: 767px;
16 changes: 16 additions & 0 deletions app/styles/partials/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
@import 'modules/variables/importer';

.loader-container {
background: $black;
opacity: 0.48;
height: 100%;
width: 100%;
z-index: $loaderZIndex;
position: fixed;
padding: 0;
margin: 0;
top: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center
}

.container {
margin-top: $navbarHeight;
margin-left: $sidebarWidth;
Expand Down

0 comments on commit ee26734

Please sign in to comment.