From c09052a2a590cea2138a1fe1b65ac28d71af4ba4 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Thu, 22 Jun 2017 21:23:26 +0200 Subject: [PATCH] fixing network and network test error --- frontend/app/gallery/grid/grid.gallery.component.ts | 10 +++++++--- frontend/app/model/network/network.service.spec.ts | 6 +++++- frontend/app/model/network/network.service.ts | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/app/gallery/grid/grid.gallery.component.ts b/frontend/app/gallery/grid/grid.gallery.component.ts index 3c4c1f88..6a3587d0 100644 --- a/frontend/app/gallery/grid/grid.gallery.component.ts +++ b/frontend/app/gallery/grid/grid.gallery.component.ts @@ -131,14 +131,18 @@ export class GalleryGridComponent implements OnChanges, AfterViewInit { private renderedPhotoIndex: number = 0; private renderPhotos(numberOfPhotos: number = 0) { - if (this.containerWidth == 0 || this.renderedPhotoIndex >= this.photos.length || !this.shouldRenderMore()) { + if (this.containerWidth == 0 || + this.renderedPhotoIndex >= this.photos.length || + !this.shouldRenderMore()) { return; } let renderedContentHeight = 0; - while (this.renderedPhotoIndex < this.photos.length && (this.shouldRenderMore(renderedContentHeight) === true || this.renderedPhotoIndex < numberOfPhotos)) { + while (this.renderedPhotoIndex < this.photos.length && + (this.shouldRenderMore(renderedContentHeight) === true || + this.renderedPhotoIndex < numberOfPhotos)) { let ret = this.renderARow(); if (ret === null) { throw new Error("Gridphotos rendering failed"); @@ -150,7 +154,7 @@ export class GalleryGridComponent implements OnChanges, AfterViewInit { /** * Returns true, if scroll is >= 70% to render more images. - * Or of onscroll renderin is off: return always to render all the images at once + * Or of onscroll rendering is off: return always to render all the images at once * @param offset Add height to the client height (conent is not yet added to the dom, but calculate with it) * @returns {boolean} */ diff --git a/frontend/app/model/network/network.service.spec.ts b/frontend/app/model/network/network.service.spec.ts index b1979daa..d9b90e57 100644 --- a/frontend/app/model/network/network.service.spec.ts +++ b/frontend/app/model/network/network.service.spec.ts @@ -4,6 +4,7 @@ import {MockBackend, MockConnection} from "@angular/http/testing"; import "rxjs/Rx"; import {NetworkService} from "./network.service"; import {Message} from "../../../../common/entities/Message"; +import {SlimLoadingBarService} from "ng2-slim-loading-bar"; describe('NetworkService Success tests', () => { @@ -20,6 +21,7 @@ describe('NetworkService Success tests', () => { providers: [ MockBackend, BaseRequestOptions, + SlimLoadingBarService, { provide: Http, useFactory: (backend, options) => { return new Http(backend, options); @@ -108,6 +110,8 @@ describe('NetworkService Fail tests', () => { providers: [ MockBackend, BaseRequestOptions, + SlimLoadingBarService, + { provide: Http, useFactory: (backend, options) => { return new Http(backend, options); @@ -172,4 +176,4 @@ describe('NetworkService Fail tests', () => { expect(err).toBe(testError); }); })); -}); +}); diff --git a/frontend/app/model/network/network.service.ts b/frontend/app/model/network/network.service.ts index c842729d..592797c8 100644 --- a/frontend/app/model/network/network.service.ts +++ b/frontend/app/model/network/network.service.ts @@ -1,9 +1,9 @@ import {Injectable} from "@angular/core"; import {Headers, Http, RequestOptions} from "@angular/http"; import {Message} from "../../../../common/entities/Message"; +import {SlimLoadingBarService} from "ng2-slim-loading-bar"; import "rxjs/Rx"; -import {SlimLoadingBarService} from "ng2-slim-loading-bar"; @Injectable() export class NetworkService { @@ -28,8 +28,8 @@ export class NetworkService { }; const err = (err) => { - NetworkService.handleError(err); this.slimLoadingBarService.complete(); + return NetworkService.handleError(err); }; if (method == "get" || method == "delete") {