Skip to content

Commit

Permalink
Merge pull request primefaces#390 from atretyak1985/issue_#NNTR-349
Browse files Browse the repository at this point in the history
[NNTR-349]Asset details -> Activity log, remove parenthesis from the item.
  • Loading branch information
Gunnsteinn Hall authored Jan 2, 2020
2 parents dbb71a3 + c6d71d9 commit 38e859d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 67 deletions.
4 changes: 3 additions & 1 deletion src/common/list/base-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export abstract class BaseList implements OnInit {

ngAfterViewInit() {
this.refresh();
this.ptable.first = 0;
if (this.ptable) {
this.ptable.first = 0;
}
let subscribeFunction = (d: any) => {
if (this.route.snapshot.url == d.url) {
this.selectedId = this.getQueryParam('id');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,56 @@
<p-table #ptable class="p-table" [columns]="cols" [value]="items" [paginator]="true" [rows]="ROWS"
[totalRecords]="totalRecords" scrollable="true" [scrollHeight]="listHeight" sortMode="multiple" [lazy]="true"
(onLazyLoad)="sortingChanged($event)" (onPage)="onPage()">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" [ngStyle]="{'width': col.width}">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr valign="top" class="defence" width="100%">
<th *ngFor="let col of columns" class="table-header-cell" [pSortableColumn]="col.field" [ngStyle]="{'width': col.width}">
<div>{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</div>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr #row id="item-{{ rowData.id }}" class="table-row" [ngClass]="{'flash-row': flashRow && row.id === 'item-' + selectedId }">
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('time')}">
{{ rowData.time*1000 | moment:"MMM Do YYYY HH:mm" }}
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_type')}">{{ rowData.event_type|titlecase }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_trigger')}">{{ rowData.event_trigger|titlecase }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_name')}">
<h2>{{ rowData.event_name }}</h2>
{{ rowData.message }}
<ul class="event-data">
<li *ngFor="let item of eventData(rowData.event_data)">
<b>{{item.key}}:</b>
<span *ngIf="typeOf(item.value) == 'other'"> {{item.value}}</span>
<span *ngIf="typeOf(item.value) == 'array'"> {{joinArray(item.value)}}</span>
<ul *ngIf="typeOf(item.value) == 'object'" class="event-data">
<li *ngFor="let subitem of eventData(item.value)">
<b>{{subitem.key}}:</b> {{subitem.value}}
</li>
</ul>
</li>
</ul>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('severity')}">{{ stringUtils.eventSeverityToString(rowData.severity) }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('hostname')}">
<a *ngIf="rowData.device_id" href="#" (click)="itemSelected($event, rowData, true)">{{ rowData.hostname }}</a>
<span *ngIf="!rowData.device_id">{{ rowData.hostname }}</span>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('address')}">{{ rowData.address }}</td>
</tr>
</ng-template>
</p-table>
<ng-container>
<div class="no-data" *ngIf="emptyResponse">
<p>There is currently nothing to display.</p>
</div>
</ng-container>
<ng-container *ngIf="!emptyResponse">
<p-table #ptable class="p-table" [columns]="cols" [value]="items" [paginator]="true" [rows]="ROWS"
[totalRecords]="totalRecords" scrollable="true" [scrollHeight]="listHeight" sortMode="multiple" [lazy]="true"
(onLazyLoad)="sortingChanged($event)" (onPage)="onPage()">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" [ngStyle]="{'width': col.width}">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr valign="top" class="defence" width="100%">
<th *ngFor="let col of columns" class="table-header-cell" [pSortableColumn]="col.field" [ngStyle]="{'width': col.width}">
<div>{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</div>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr #row id="item-{{ rowData.id }}" class="table-row" [ngClass]="{'flash-row': flashRow && row.id === 'item-' + selectedId }">
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('time')}">
{{ rowData.time*1000 | moment:"MMM Do YYYY HH:mm" }}
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_type')}">{{ rowData.event_type|titlecase }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_trigger')}">{{ rowData.event_trigger|titlecase }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('event_name')}">
<h2>{{ rowData.event_name }}</h2>
{{ rowData.message }}
<ul class="event-data">
<li *ngFor="let item of eventData(rowData.event_data)">
<b>{{item.key}}:</b>
<span *ngIf="typeOf(item.value) == 'other'"> {{item.value}}</span>
<span *ngIf="typeOf(item.value) == 'array'"> {{joinArray(item.value)}}</span>
<ul *ngIf="typeOf(item.value) == 'object'" class="event-data">
<li *ngFor="let subitem of eventData(item.value)">
<b>{{subitem.key}}:</b> {{subitem.value}}
</li>
</ul>
</li>
</ul>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('severity')}">{{ stringUtils.eventSeverityToString(rowData.severity) }}</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('hostname')}">
<a *ngIf="rowData.device_id" href="#" (click)="itemSelected($event, rowData, true)">{{ rowData.hostname }}</a>
<span *ngIf="!rowData.device_id">{{ rowData.hostname }}</span>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth('address')}">{{ rowData.address }}</td>
</tr>
</ng-template>
</p-table>
</ng-container>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Injector, Input, Output, EventEmitter } from '@angular/core';
import { Component, Injector, Input } from '@angular/core';
import { BaseList } from 'common/list/base-list';
import { DeviceActivityLogService } from './device-activity_log.service';
import { DeviceActivityLogResponse, DeviceActivityLogItem } from './device-activity_log.response';
import { DeviceActivityLogItem } from './device-activity_log.response';
import { MomentPipe } from 'pipes/moment.pipe';


Expand All @@ -13,8 +13,6 @@ import { MomentPipe } from 'pipes/moment.pipe';
export class DeviceActivityLogComponent extends BaseList {
@Input() deviceId;
@Input() listHeight;
@Output() countChanged = new EventEmitter<number>();
public selectedItem: number;

constructor(
service: DeviceActivityLogService,
Expand Down Expand Up @@ -42,11 +40,6 @@ export class DeviceActivityLogComponent extends BaseList {
];
}

listResponseHandler(response: DeviceActivityLogResponse) {
super.listResponseHandler(response);
this.countChanged.next(response.total);
}

itemSelected(event, item: DeviceActivityLogItem) {
event.preventDefault();
let subPath = `/device/${item.device_id}`;
Expand Down
6 changes: 3 additions & 3 deletions src/organization/device/device_detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ <h2>Credentials2</h2>
<div class="nav-tabs-nanitor nav-device-detail">
<ul class="list-inline" style="width: inherit;">
<li id="tab1" class="active"><a (click)="setTabSelected(CONFIGURATION_TAB_INDEX)">Benchmarks</a></li>
<li id="tab2" *ngIf="numIssues >= 0 || isIssueTabActive"><a (click)="setTabSelected(ISSUE_TAB_INDEX)">Issues ({{ numIssues }})</a></li>
<li id="tab2" *ngIf="numIssues > 0 || isIssueTabActive"><a (click)="setTabSelected(ISSUE_TAB_INDEX)">Issues ({{ numIssues }})</a></li>
<li id="tab3" *ngIf="numLoggedinusers > 0 || isLoggedinusersTabActive"><a (click)="setTabSelected(USER_TAB_INDEX)">Users ({{ numLoggedinusers }})</a></li>
<li id="tab4" *ngIf="numGpos > 0 || isGposTabActive"><a (click)="setTabSelected(GROUP_POLICY_TAB_INDEX)">Group Policies ({{ numGpos }})</a></li>
<li id="tab5" *ngIf="numSoftware > 0 || isSoftwareTabActive"><a (click)="setTabSelected(SOFTWARE_TAB_INDEX)">Software ({{ numSoftware }})</a></li>
<li id="tab6" *ngIf="numSubnets > 0 || isSubnetsTabActive"><a (click)="setTabSelected(SUBNET_TAB_INDEX)">Subnets ({{ numSubnets }})</a></li>
<li id="tab7"><a (click)="setTabSelected(ACTIVITY_LOG_TAB_INDEX)">Activity log ({{ numActivityLog }})</a></li>
<li id="tab7" *ngIf="isActivityLogTabActive"><a (click)="setTabSelected(ACTIVITY_LOG_TAB_INDEX)">Activity log</a></li>
</ul>
<div>
<button class="btn btn-sm btn-recheck-color" (click)="clickRechecks($event)" id="recheck-button" [disabled]="response.recheck_requested" title="Request Recheck">Request Recheck</button>
Expand Down Expand Up @@ -327,7 +327,7 @@ <h2>Credentials2</h2>
<device-subnet #subnetId [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-subnet>
</div>
<div class="container-fluid white-wrapper device-detail" *ngIf="isTabSelected(ACTIVITY_LOG_TAB_INDEX)">
<device-activity-log #activityLogId [listHeight]="listHeight" (countChanged)="countChanged($event)"></device-activity-log>
<device-activity-log #activityLogId [listHeight]="listHeight"></device-activity-log>
</div>
</div>
</div>
Expand Down
6 changes: 1 addition & 5 deletions src/organization/device/device_detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class DeviceDetailComponent implements OnInit {
public numSoftware = 0;
public numSubnets = 0;
public numIssues = 0;
public numActivityLog = 0;
public isIssueTabActive = false;
public isGposTabActive = false;
public isLoggedinusersTabActive = false;
Expand Down Expand Up @@ -347,13 +346,12 @@ export class DeviceDetailComponent implements OnInit {
this.numSoftware = this.isTabSelected(this.SOFTWARE_TAB_INDEX) ? this.numSoftware : this.response.num_software || 0;
this.numSubnets = this.isTabSelected(this.SUBNET_TAB_INDEX) ? this.numSubnets : this.response.num_subnets || 0;
this.numIssues = this.isTabSelected(this.ISSUE_TAB_INDEX) ? this.numIssues : this.response.num_issues || 0;
this.numActivityLog = this.isTabSelected(this.ACTIVITY_LOG_TAB_INDEX) ? this.numActivityLog : this.response.num_activity || 0;
this.isGposTabActive = this.response.num_gpos > 0;
this.isLoggedinusersTabActive = this.response.num_loggedinusers > 0;
this.isSoftwareTabActive = this.response.num_software > 0;
this.isSubnetsTabActive = this.response.num_subnets > 0;
this.isActivityLogTabActive = this.response.num_software > 0;
this.isIssueTabActive = this.response.num_issues > 0;
this.isActivityLogTabActive = true;
this.hostName = this.response.item.hostname || this.deviceId;
this.setBreadcrumb();
}
Expand Down Expand Up @@ -642,8 +640,6 @@ export class DeviceDetailComponent implements OnInit {
this.numSubnets = event;
} else if (this.isTabSelected(this.ISSUE_TAB_INDEX)) {
this.numIssues = event;
} else if (this.isTabSelected(this.ACTIVITY_LOG_TAB_INDEX)) {
this.numActivityLog = event;
}
}

Expand Down

0 comments on commit 38e859d

Please sign in to comment.