aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.ts
blob: 84fb81a1ef9559f578bfaf88d0e343d8fce5e232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Component, OnInit, ViewChild } from '@angular/core';
import { SdcUiServices } from 'onap-ui-angular';
import { Activity } from '../../../../models/activity';
import { ActivityLogService } from '../../../services/activity-log.service';
import { WorkspaceService } from '../workspace.service';

@Component({
    selector: 'activity-log',
    templateUrl: './activity-log.component.html',
    styleUrls: ['./activity-log.component.less', '../../../../../assets/styles/table-style.less']
})
export class ActivityLogComponent implements OnInit {

    activities: Activity[] = [];
    temp: Activity[] = [];

    constructor(private workspaceService: WorkspaceService,
                private activityLogService: ActivityLogService,
                private loaderService: SdcUiServices.LoaderService) {
    }

    ngOnInit(): void {
        this.loaderService.activate();
        const componentId: string = this.workspaceService.metadata.uniqueId;
        const componentType: string = this.workspaceService.metadata.componentType;
        this.activityLogService.getActivityLog(componentType, componentId).subscribe((logs) => {
            this.activities = logs;
            this.temp = [...logs];
            this.loaderService.deactivate();
        }, (error) => { this.loaderService.deactivate(); });
    }

    updateFilter(event) {
        const val = event.target.value.toLowerCase();

        // filter our data
        const temp = this.temp.filter((activity: Activity) => {
            return !val ||
                activity.COMMENT.toLowerCase().indexOf(val) !== -1 ||
                activity.STATUS.toLowerCase().indexOf(val) !== -1 ||
                activity.ACTION.toLowerCase().indexOf(val) !== -1 ||
                activity.MODIFIER.toLowerCase().indexOf(val) !== -1;
        });

        // update the rows
        this.activities = temp;
    }
}