Fixed bug on loading spinner
This commit is contained in:
parent
9e6e11ecae
commit
46719a5e62
|
@ -45,7 +45,7 @@ describe('ConfigurationComponent', () => {
|
||||||
name: 'server.ports',
|
name: 'server.ports',
|
||||||
properties: {
|
properties: {
|
||||||
'local.server.port': {
|
'local.server.port': {
|
||||||
value: '8080',
|
value: '9000',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -55,7 +55,7 @@ describe('Logs Service', () => {
|
||||||
name: 'server.ports',
|
name: 'server.ports',
|
||||||
properties: {
|
properties: {
|
||||||
'local.server.port': {
|
'local.server.port': {
|
||||||
value: '8080',
|
value: '9000',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<div class="row" >
|
<div class="row" >***{{isLoading}}***
|
||||||
|
<!--
|
||||||
<div *ngIf="loading" class="loader-container">
|
<div *ngIf="loading" class="loader-container">
|
||||||
<mat-spinner mode="indeterminate" style="top: 50%; left: 50%;"></mat-spinner>
|
<mat-spinner mode="indeterminate" style="top: 50%; left: 50%;"></mat-spinner>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<div class="d-flex flex-row py-4">
|
<div class="d-flex flex-row py-4">
|
||||||
<div id="btn-group" class="col-md-3 mt-3">
|
<div id="btn-group" class="col-md-3 mt-3">
|
||||||
<button mat-raised-button color="primary"><mat-icon>source</mat-icon> <span>File</span></button>
|
<button mat-raised-button color="primary"><mat-icon>source</mat-icon> <span>File</span></button>
|
||||||
|
|
|
@ -10,9 +10,9 @@ import { Component, OnInit } from '@angular/core';
|
||||||
import { LoginService } from 'app/login/login.service';
|
import { LoginService } from 'app/login/login.service';
|
||||||
import { AccountService } from 'app/core/auth/account.service';
|
import { AccountService } from 'app/core/auth/account.service';
|
||||||
import { Account } from 'app/core/auth/account.model';
|
import { Account } from 'app/core/auth/account.model';
|
||||||
import { AbstractControl, FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
|
||||||
import { Clipboard } from '@angular/cdk/clipboard'
|
import { Clipboard } from '@angular/cdk/clipboard'
|
||||||
import { BehaviorSubject, Observable, delay, map, startWith } from 'rxjs';
|
import { Observable, delay, map, startWith } from 'rxjs';
|
||||||
import { ContextsLoaderService } from 'app/services/contexts-loader.service';
|
import { ContextsLoaderService } from 'app/services/contexts-loader.service';
|
||||||
import { IContextNode } from 'app/services/i-context-node';
|
import { IContextNode } from 'app/services/i-context-node';
|
||||||
import { AutofillValidator, instanceOfContext } from './autofill-validator';
|
import { AutofillValidator, instanceOfContext } from './autofill-validator';
|
||||||
|
@ -23,7 +23,7 @@ import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
|
||||||
selector: 'jhi-home',
|
selector: 'jhi-home',
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
styleUrls: ['./home.component.scss'],
|
styleUrls: ['./home.component.scss'],
|
||||||
providers: [ContextsLoaderService, SpinnerLoadingService],
|
providers: [ContextsLoaderService],
|
||||||
})
|
})
|
||||||
|
|
||||||
export class HomeComponent implements OnInit {
|
export class HomeComponent implements OnInit {
|
||||||
|
@ -35,7 +35,7 @@ export class HomeComponent implements OnInit {
|
||||||
//public filteredContextsStr: Observable<string[]>| undefined;
|
//public filteredContextsStr: Observable<string[]>| undefined;
|
||||||
chooseContextForm: FormGroup | any;
|
chooseContextForm: FormGroup | any;
|
||||||
resType: string;
|
resType: string;
|
||||||
loading: boolean = false;
|
isLoading: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -68,13 +68,10 @@ export class HomeComponent implements OnInit {
|
||||||
uidfield: [''],
|
uidfield: [''],
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: DEBUG HERE
|
|
||||||
//sembra tutto giusto, ma non viene rilevato l'aggiornamento del valore booleano
|
|
||||||
|
|
||||||
this.progressService.getState()
|
this.progressService.getState()
|
||||||
.subscribe((loading) => {
|
.pipe(delay(0))
|
||||||
this.loading = loading;
|
.subscribe(res => {
|
||||||
console.debug("**********this.loading..."+this.loading);
|
this.isLoading = res;
|
||||||
});
|
});
|
||||||
|
|
||||||
// per la form dei contesti
|
// per la form dei contesti
|
||||||
|
|
|
@ -11,17 +11,21 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
|
|
||||||
export class SpinnerLoadingService {
|
export class SpinnerLoadingService {
|
||||||
|
|
||||||
private state: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
//TODO: a regime inizializzare a true
|
||||||
|
private state: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
||||||
|
|
||||||
constructor() { }
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
getState():Observable<boolean>{
|
getState():Observable<boolean>{
|
||||||
console.debug("*******Getting observable state in SpinnerLoadingService");
|
// console.debug("*******Getting observable state in SpinnerLoadingService");
|
||||||
return this.state.asObservable();
|
return this.state.asObservable();
|
||||||
};
|
};
|
||||||
|
|
||||||
setState(newState : boolean) : void{
|
setState(newState : boolean) : void{
|
||||||
console.debug("******Setting state in SpinnerLoadingService: ");
|
// console.debug("******Setting state in SpinnerLoadingService: ");
|
||||||
|
// console.debug(newState);
|
||||||
|
// console.debug("******");
|
||||||
this.state.next(newState);
|
this.state.next(newState);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('Alert Error Component', () => {
|
||||||
it('Should display an alert on status 400 for generic error', () => {
|
it('Should display an alert on status 400 for generic error', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const response = new HttpErrorResponse({
|
const response = new HttpErrorResponse({
|
||||||
url: 'http://localhost:8080/api/foos',
|
url: 'http://localhost:9000/api/foos',
|
||||||
headers: new HttpHeaders(),
|
headers: new HttpHeaders(),
|
||||||
status: 400,
|
status: 400,
|
||||||
statusText: 'Bad Request',
|
statusText: 'Bad Request',
|
||||||
|
@ -87,7 +87,7 @@ describe('Alert Error Component', () => {
|
||||||
it('Should display an alert on status 400 for generic error without message', () => {
|
it('Should display an alert on status 400 for generic error without message', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const response = new HttpErrorResponse({
|
const response = new HttpErrorResponse({
|
||||||
url: 'http://localhost:8080/api/foos',
|
url: 'http://localhost:9000/api/foos',
|
||||||
headers: new HttpHeaders(),
|
headers: new HttpHeaders(),
|
||||||
status: 400,
|
status: 400,
|
||||||
error: 'Bad Request',
|
error: 'Bad Request',
|
||||||
|
@ -101,7 +101,7 @@ describe('Alert Error Component', () => {
|
||||||
it('Should display an alert on status 400 for invalid parameters', () => {
|
it('Should display an alert on status 400 for invalid parameters', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const response = new HttpErrorResponse({
|
const response = new HttpErrorResponse({
|
||||||
url: 'http://localhost:8080/api/foos',
|
url: 'http://localhost:9000/api/foos',
|
||||||
headers: new HttpHeaders(),
|
headers: new HttpHeaders(),
|
||||||
status: 400,
|
status: 400,
|
||||||
statusText: 'Bad Request',
|
statusText: 'Bad Request',
|
||||||
|
@ -123,7 +123,7 @@ describe('Alert Error Component', () => {
|
||||||
it('Should display an alert on status 400 for error headers', () => {
|
it('Should display an alert on status 400 for error headers', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const response = new HttpErrorResponse({
|
const response = new HttpErrorResponse({
|
||||||
url: 'http://localhost:8080/api/foos',
|
url: 'http://localhost:9000/api/foos',
|
||||||
headers: new HttpHeaders().append('app-error', 'Error Message').append('app-params', 'foo'),
|
headers: new HttpHeaders().append('app-error', 'Error Message').append('app-params', 'foo'),
|
||||||
status: 400,
|
status: 400,
|
||||||
statusText: 'Bad Request',
|
statusText: 'Bad Request',
|
||||||
|
@ -141,7 +141,7 @@ describe('Alert Error Component', () => {
|
||||||
it('Should display an alert on status 500 with detail', () => {
|
it('Should display an alert on status 500 with detail', () => {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
const response = new HttpErrorResponse({
|
const response = new HttpErrorResponse({
|
||||||
url: 'http://localhost:8080/api/foos',
|
url: 'http://localhost:9000/api/foos',
|
||||||
headers: new HttpHeaders(),
|
headers: new HttpHeaders(),
|
||||||
status: 500,
|
status: 500,
|
||||||
statusText: 'Internal server error',
|
statusText: 'Internal server error',
|
||||||
|
|
|
@ -13,26 +13,30 @@ import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpinnercontrolInterceptor implements HttpInterceptor {
|
export class SpinnercontrolInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
/*
|
|
||||||
Like intercept(), the handle() method transforms an HTTP request into an Observable
|
|
||||||
of HttpEvents which ultimately include the server's response.
|
|
||||||
The intercept() method could inspect that observable and alter it before returning
|
|
||||||
it to the caller.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private myService : SpinnerLoadingService;
|
constructor(private myService: SpinnerLoadingService) {
|
||||||
|
|
||||||
constructor(private spinnerLoaderServ: SpinnerLoadingService) {
|
|
||||||
this.myService = spinnerLoaderServ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
intercept(request: HttpRequest<any>,next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
|
//console.log('********Outgoing HTTP request', request);
|
||||||
|
if(request.url.includes('resourceinstances')){
|
||||||
|
finalize(() => {
|
||||||
|
console.debug("***setting to false");
|
||||||
|
this.myService.setState(false);
|
||||||
|
})
|
||||||
|
return next.handle(request);
|
||||||
|
}
|
||||||
|
return next.handle(request);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
let ok: string;
|
let ok: string;
|
||||||
// extend server response observable with logging
|
// extend server response observable with logging
|
||||||
return next.handle(req)
|
if(request.url.includes('resourceinstances')){
|
||||||
|
return next.handle(request)
|
||||||
.pipe(
|
.pipe(
|
||||||
tap({
|
tap({
|
||||||
// Succeeds when there is a response; ignore other events
|
// Succeeds when there is a response; ignore other events
|
||||||
|
@ -43,46 +47,18 @@ export class SpinnercontrolInterceptor implements HttpInterceptor {
|
||||||
// Log when response observable either completes or errors
|
// Log when response observable either completes or errors
|
||||||
finalize(() => {
|
finalize(() => {
|
||||||
const elapsed = Date.now() - started;
|
const elapsed = Date.now() - started;
|
||||||
const msg = `${req.method} "${req.urlWithParams}"
|
const msg = `${request.method} "${request.urlWithParams}"
|
||||||
${ok} in ${elapsed} ms.`;
|
${ok} in ${elapsed} ms.`;
|
||||||
console.debug("***** MSG INIZIO ******");
|
console.debug("***** MSG INIZIO ******");
|
||||||
console.debug(msg);
|
console.debug(msg);
|
||||||
console.debug("***** MSG FINE ******");
|
console.debug("***** MSG FINE - ORA METTO A FALSE ******");
|
||||||
this.spinnerLoaderServ.setState(false);
|
this.myService.setState(false);
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
intercept(
|
|
||||||
request: HttpRequest<any>,next: HttpHandler): Observable<HttpEvent<Response>> {
|
|
||||||
let ok: string;
|
|
||||||
//console.log('********Outgoing HTTP request', request);
|
|
||||||
if(request.url.includes('resourceinstances')){
|
|
||||||
return next.handle(request).pipe(
|
|
||||||
tap({
|
|
||||||
// Succeeds when there is a response; ignore other events
|
|
||||||
next: (event) => (ok = event instanceof HttpResponse ? 'succeeded' : ''),
|
|
||||||
// Operation failed; error is an HttpErrorResponse
|
|
||||||
error: (_error) => (ok = 'failed')
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Log when response observable either completes or errors
|
|
||||||
//TODO: aggiungere booleano per gestione errore risposta REST (div errore con messaggio)
|
|
||||||
finalize(() => {
|
|
||||||
/*
|
|
||||||
const msg = '${request.method} "${request.urlWithParams}"';
|
|
||||||
console.debug("***** MSG INIZIO ******");
|
|
||||||
console.debug(msg);
|
|
||||||
console.debug("***** MSG FINE ******");
|
|
||||||
*/
|
|
||||||
this.spinnerLoaderServ.setState(false);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
return new Observable<HttpEvent<any>>();
|
return next.handle(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue