aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/workspace/activity-log
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/workspace/activity-log')
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.html68
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.less8
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.spec.ts84
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.ts48
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.module.ts28
5 files changed, 236 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.html b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.html
new file mode 100644
index 0000000000..d7cf2f930a
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.html
@@ -0,0 +1,68 @@
+<!--
+ ~ Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+-->
+<div class="activity-log">
+ <div class="sdc-filter-bar-wrapper">
+ <sdc-filter-bar
+ [placeHolder]="'Search...'"
+ [testId]="activityLogSearchBar"
+ (keyup)="updateFilter($event)">
+ </sdc-filter-bar>
+ </div>
+ <ngx-datatable
+ columnMode="flex"
+ [footerHeight]="0"
+ [limit]="50"
+ [headerHeight]="40"
+ [rowHeight]="35"
+ #activityLogTable
+ [rows]="activities">
+
+ <ngx-datatable-column name="Time" [flexGrow]="2" [prop]="'TIMESTAMP'">
+ <ng-template ngx-datatable-cell-template let-row="row">
+ {{row.TIMESTAMP | date }} | {{row.TIMESTAMP | date:"HH:mm O"}}
+ </ng-template>
+ </ngx-datatable-column>
+ <ngx-datatable-column name="Action" [flexGrow]="3" [prop]="'ACTION'">
+ <ng-template ngx-datatable-cell-template let-row="row">
+ {{row.ACTION}}
+ </ng-template>
+ </ngx-datatable-column>
+ <ngx-datatable-column name="Comment" [flexGrow]="5" [prop]="'COMMENT'">
+ <ng-template ngx-datatable-cell-template let-row="row">
+ <span sdc-tooltip [tooltip-text]="row.COMMENT">{{ row.COMMENT }}</span>
+ </ng-template>
+ </ngx-datatable-column>
+ <ngx-datatable-column name="Modifier" [flexGrow]="3" [prop]="'MODIFIER'">
+ <ng-template ngx-datatable-cell-template let-row="row">
+ {{ row.MODIFIER }}
+ </ng-template>
+ </ngx-datatable-column>
+ <ngx-datatable-column name="Status" [flexGrow]="1" [prop]="'STATUS'">
+ <ng-template ngx-datatable-cell-template let-row="row">
+ <svg-icon-label
+ [name]="row.STATUS <= 399 ? 'success' : 'icons_close'"
+ [mode]="row.STATUS <= 399 ? 'success' : 'error'"
+ [size]="'medium'"
+ [label]="row.STATUS"
+ [labelPlacement]="'left'"
+ [labelClassName]="'label'"
+ >
+ </svg-icon-label>
+ </ng-template>
+ </ngx-datatable-column>
+ </ngx-datatable>
+
+</div> \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.less b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.less
new file mode 100644
index 0000000000..4845f4f606
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.less
@@ -0,0 +1,8 @@
+.sdc-filter-bar-wrapper {
+ sdc-filter-bar {
+ flex: 0 0 30%;
+ }
+ display: flex;
+ justify-content: flex-end;
+ margin-bottom: 10px;
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.spec.ts b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.spec.ts
new file mode 100644
index 0000000000..25651e0c1f
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.spec.ts
@@ -0,0 +1,84 @@
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture } from '@angular/core/testing';
+import { NgxDatatableModule } from '@swimlane/ngx-datatable';
+import { SdcUiServices } from 'onap-ui-angular';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+import { ConfigureFn, configureTests } from '../../../../../jest/test-config.helper';
+import { ComponentMetadata } from '../../../../models/component-metadata';
+import { ActivityLogService } from '../../../services/activity-log.service';
+import { WorkspaceService } from '../workspace.service';
+import { ActivityLogComponent } from './activity-log.component';
+
+describe('activity log component', () => {
+
+ let fixture: ComponentFixture<ActivityLogComponent>;
+ let activityLogServiceMock: Partial<ActivityLogService>;
+ let workspaceServiceMock: Partial<WorkspaceService>;
+ let loaderServiceMock: Partial<SdcUiServices.LoaderService>;
+ let componentMetadataMock: ComponentMetadata;
+
+ const mockLogs = '[' +
+ '{"MODIFIER":"Carlos Santana(m08740)","COMMENT":"comment","STATUS":"200","ACTION":"Checkout","TIMESTAMP":"2018-11-19 13:00:02.388 UTC"},' +
+ '{"MODIFIER":"John Doe(m08741)","COMMENT":"comment","STATUS":"200","ACTION":"Checkin","TIMESTAMP":"2018-11-20 13:00:02.388 UTC"},' +
+ '{"MODIFIER":"Jane Doe(m08742)","COMMENT":"comment","STATUS":"200","ACTION":"Checkout","TIMESTAMP":"2018-11-21 13:00:02.388 UTC"}' +
+ ']';
+
+ beforeEach(
+ async(() => {
+
+ componentMetadataMock = new ComponentMetadata();
+ componentMetadataMock.uniqueId = 'fake';
+ componentMetadataMock.componentType = 'SERVICE';
+
+ activityLogServiceMock = {
+ getActivityLog : jest.fn().mockImplementation((type, id) => Observable.of(JSON.parse(mockLogs)) )
+ };
+
+ workspaceServiceMock = {
+ metadata : componentMetadataMock
+ };
+
+ loaderServiceMock = {
+ activate : jest.fn(),
+ deactivate: jest.fn()
+ };
+
+ const configure: ConfigureFn = (testBed) => {
+ testBed.configureTestingModule({
+ declarations: [ActivityLogComponent],
+ imports: [NgxDatatableModule],
+ schemas: [NO_ERRORS_SCHEMA],
+ providers: [
+ { provide: WorkspaceService, useValue: workspaceServiceMock },
+ { provide: ActivityLogService, useValue: activityLogServiceMock },
+ { provide: SdcUiServices.LoaderService, useValue: loaderServiceMock }
+ ],
+ });
+ };
+
+ configureTests(configure).then((testBed) => {
+ fixture = testBed.createComponent(ActivityLogComponent);
+ });
+ })
+ );
+
+ it('should see exactly 3 activity logs', () => {
+ fixture.componentInstance.ngOnInit();
+ expect(fixture.componentInstance.activities.length).toBe(3);
+ });
+
+ it('should filter out 1 element when searching', () => {
+ fixture.componentInstance.ngOnInit();
+
+ const event = {
+ target : {
+ value : 'Checkin'
+ }
+ };
+
+ expect(fixture.componentInstance.activities.length).toBe(3);
+ fixture.componentInstance.updateFilter(event);
+ expect(fixture.componentInstance.activities.length).toBe(1);
+ });
+});
diff --git a/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.ts b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.ts
new file mode 100644
index 0000000000..84fb81a1ef
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.component.ts
@@ -0,0 +1,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;
+ }
+}
diff --git a/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.module.ts b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.module.ts
new file mode 100644
index 0000000000..39334d8cde
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/activity-log/activity-log.module.ts
@@ -0,0 +1,28 @@
+import {CommonModule} from "@angular/common";
+import {NgModule} from "@angular/core";
+import {SdcUiComponentsModule} from "onap-ui-angular";
+import {GlobalPipesModule} from "../../../pipes/global-pipes.module";
+import {ActivityLogComponent} from "./activity-log.component";
+import {ActivityLogService} from "../../../services/activity-log.service";
+import {NgxDatatableModule} from "@swimlane/ngx-datatable";
+
+@NgModule({
+ declarations: [
+ ActivityLogComponent
+ ],
+ imports: [
+ CommonModule,
+ SdcUiComponentsModule,
+ GlobalPipesModule,
+ NgxDatatableModule
+ ],
+ exports: [
+ ActivityLogComponent
+ ],
+ entryComponents: [
+ ActivityLogComponent
+ ],
+ providers: [ ActivityLogService ]
+})
+export class ActivityLogModule {
+}