[ADF-4745] memory leak fixes (#4931)

* fix app-layout component

* fix card-view component

* fix cloud-layout service

* code fixes

* code fixes

* even more fixes

* even more fixes

* lint fixes

* test fixes

* fix code

* remove useless pipes

* fix code owners

* enable spellcheck for cloud components

* update test

* update test
This commit is contained in:
Denys Vuika
2019-07-16 15:56:00 +01:00
committed by Eugenio Romano
parent e2311ab045
commit 1abb9bfc89
98 changed files with 1581 additions and 1066 deletions

View File

@@ -15,36 +15,57 @@
* limitations under the License.
*/
import { Component, HostListener } from '@angular/core';
import { Component, HostListener, OnDestroy, OnInit } from '@angular/core';
import { LogService, ObjectDataTableAdapter } from '@alfresco/adf-core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-log',
templateUrl: './log.component.html',
styleUrls: ['./log.component.css']
})
export class LogComponent {
export class LogComponent implements OnInit, OnDestroy {
logs: any[] = [];
show = false;
ctrlLKey = 12;
logsData: ObjectDataTableAdapter;
constructor(public logService: LogService) {
private onDestroy$ = new Subject<boolean>();
logService.onMessage.subscribe((message) => {
let contentMessage = '';
try {
contentMessage = JSON.stringify(message.text);
} catch (error) {
return;
}
this.logs.push({ type: message.type, text: contentMessage});
this.logsData = new ObjectDataTableAdapter(this.logs, [
{ type: 'text', key: 'type', title: 'Log level', sortable: true },
{ type: 'text', key: 'text', title: 'Message', sortable: false }
]);
constructor(public logService: LogService) {}
});
ngOnInit() {
this.logService.onMessage
.pipe(takeUntil(this.onDestroy$))
.subscribe(message => {
let contentMessage = '';
try {
contentMessage = JSON.stringify(message.text);
} catch (error) {
return;
}
this.logs.push({ type: message.type, text: contentMessage });
this.logsData = new ObjectDataTableAdapter(this.logs, [
{
type: 'text',
key: 'type',
title: 'Log level',
sortable: true
},
{
type: 'text',
key: 'text',
title: 'Message',
sortable: false
}
]);
});
}
ngOnDestroy() {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}
@HostListener('document:keypress', ['$event'])
@@ -54,6 +75,5 @@ export class LogComponent {
if (key === this.ctrlLKey) {
this.show = !this.show;
}
}
}