added OnDestroy method
This commit is contained in:
parent
46719a5e62
commit
aff4df706b
|
@ -1,9 +1,7 @@
|
||||||
<div class="row" >***{{isLoading}}***
|
<div class="row" >
|
||||||
<!--
|
<div *ngIf="isLoading" 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>
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
||||||
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, 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 { 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 { Observable, delay, map, startWith } from 'rxjs';
|
import { Observable, Subject, Subscription, delay, map, startWith, takeUntil } 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';
|
||||||
|
@ -26,7 +26,7 @@ import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
|
||||||
providers: [ContextsLoaderService],
|
providers: [ContextsLoaderService],
|
||||||
})
|
})
|
||||||
|
|
||||||
export class HomeComponent implements OnInit {
|
export class HomeComponent implements OnInit, OnDestroy {
|
||||||
account: Account | null = null;
|
account: Account | null = null;
|
||||||
myContext: IContextNode | null = null;
|
myContext: IContextNode | null = null;
|
||||||
//stringCtxs: string[];
|
//stringCtxs: string[];
|
||||||
|
@ -36,6 +36,8 @@ export class HomeComponent implements OnInit {
|
||||||
chooseContextForm: FormGroup | any;
|
chooseContextForm: FormGroup | any;
|
||||||
resType: string;
|
resType: string;
|
||||||
isLoading: boolean = false;
|
isLoading: boolean = false;
|
||||||
|
subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -68,11 +70,11 @@ export class HomeComponent implements OnInit {
|
||||||
uidfield: [''],
|
uidfield: [''],
|
||||||
});
|
});
|
||||||
|
|
||||||
this.progressService.getState()
|
this.subscriptions.push(this.progressService.getState()
|
||||||
.pipe(delay(0))
|
.pipe()
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
this.isLoading = res;
|
this.isLoading = res;
|
||||||
});
|
}));
|
||||||
|
|
||||||
// per la form dei contesti
|
// per la form dei contesti
|
||||||
this.ctxLoaderService.fetchAll().subscribe(res => {
|
this.ctxLoaderService.fetchAll().subscribe(res => {
|
||||||
|
@ -85,6 +87,11 @@ export class HomeComponent implements OnInit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: CHECK WHY UNSUBSCRIBE DOES NOT WORK
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
//alert(this.subscriptions.length);
|
||||||
|
this.subscriptions.forEach(sub => sub.unsubscribe());
|
||||||
|
}
|
||||||
|
|
||||||
//mettere ANY come tipo dell'argomento per evitare errore TypeScript nella map!!
|
//mettere ANY come tipo dell'argomento per evitare errore TypeScript nella map!!
|
||||||
filterContexts(/*ctx: IContextNode,*/ item: any): IContextNode[] {
|
filterContexts(/*ctx: IContextNode,*/ item: any): IContextNode[] {
|
||||||
|
|
|
@ -36,6 +36,7 @@ export class SpinnercontrolInterceptor implements HttpInterceptor {
|
||||||
let ok: string;
|
let ok: string;
|
||||||
// extend server response observable with logging
|
// extend server response observable with logging
|
||||||
if(request.url.includes('resourceinstances')){
|
if(request.url.includes('resourceinstances')){
|
||||||
|
this.myService.setState(true);
|
||||||
return next.handle(request)
|
return next.handle(request)
|
||||||
.pipe(
|
.pipe(
|
||||||
tap({
|
tap({
|
||||||
|
@ -46,12 +47,13 @@ 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 = `${request.method} "${request.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 - ORA METTO A FALSE ******");
|
*/
|
||||||
this.myService.setState(false);
|
this.myService.setState(false);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue