mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
[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:
committed by
Eugenio Romano
parent
e2311ab045
commit
1abb9bfc89
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user