Skip to content

Commit

Permalink
Merge pull request primefaces#417 from atretyak1985/issue_#NNTR-350
Browse files Browse the repository at this point in the history
[NNTR-350]Change column name and content in Asset list (Benchmark Sco…
  • Loading branch information
Gunnsteinn Hall authored Jan 12, 2020
2 parents 278dff2 + c152fc5 commit 8cd31dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/organization/device/base/base_device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export class BaseDevice extends BaseList {
return (item.cis * 100).toFixed(2) + '%';
}

getComplianceScore(item: DeviceListItem) {
if (!item.compliance_score) {
return '-';
}
return (item.compliance_score * 100).toFixed(2) + '%';
}

getBaselineScore(item: DeviceListItem) {
if (item.num_benchmarks == 0 || (!item.baseline)) {
return '-';
Expand Down
6 changes: 4 additions & 2 deletions src/organization/device/device_detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ <h2>Credentials2</h2>
<tr valign="top" class="defence" width="100%">
<th *ngFor="let col of columns" class="table-header-cell" [pSortableColumn]="col.field"
[pSortableColumnDisabled]="col.disabled" [ngStyle]="{'width': col.width}">
<div>{{col.field === 'cis' ? primaryFrameworkName : col.header}}<p-sortIcon *ngIf="!col.disabled" [field]="col.field"></p-sortIcon></div>
<div>{{ col.field === 'cis' ? primaryFrameworkName : col.header }}
<p-sortIcon *ngIf="!col.disabled" [field]="col.field"></p-sortIcon>
</div>
</th>
<th *ngIf="isCurrentOrgAdmin()" class="table-header-cell" style="width: 140px"></th>
</tr>
Expand Down Expand Up @@ -287,7 +289,7 @@ <h2>Credentials2</h2>
</div>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth(columns, 'cis')}">
<span class="">{{ getCisScore(rowData) }}</span>
<span class="">{{ getCisORComplianceScore(rowData) }}</span>
</td>
<td class="table-cell" [ngStyle]="{'width': getColumnWidth(columns, 'last_checkin_at')}">
{{ rowData.last_checkin_at*1000 | moment:'MMM Do YYYY HH:mm' }}
Expand Down
15 changes: 14 additions & 1 deletion src/organization/device/device_detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class DeviceDetailComponent implements OnInit {
public stringUtils = StringUtils;
public labelItemsApply: Array<ApplyLabelListItem>;
public primaryFrameworkName: string;
private isPrimaryFrameworkName = false;

constructor(
public serviceDeviceGroupPolicy: DeviceGroupPolicyService,
Expand Down Expand Up @@ -354,7 +355,8 @@ export class DeviceDetailComponent implements OnInit {
this.isIssueTabActive = this.response.num_issues > 0;
this.isActivityLogTabActive = true;
this.hostName = this.response.item.hostname || this.deviceId;
this.primaryFrameworkName = this.response.hasOwnProperty('primary_framework_name') ? `${this.response.primary_framework_name} Score` : 'Benchmark Score';
this.isPrimaryFrameworkName = this.response.primary_framework_name ? true : false;
this.primaryFrameworkName = this.isPrimaryFrameworkName ? `${this.response.primary_framework_name} Score` : 'Benchmark Score';
this.setBreadcrumb();
}

Expand Down Expand Up @@ -447,13 +449,24 @@ export class DeviceDetailComponent implements OnInit {
return false;
}

getCisORComplianceScore(item: DeviceAssigmentItem) {
return this.isPrimaryFrameworkName ? this.getComplianceScore(item) : this.getCisScore(item);
}

getCisScore(item: DeviceAssigmentItem) {
if (!this.assignmentCheckedIn(item)) {
return '-';
}
return (item.cis * 100).toFixed(2) + '%';
}

getComplianceScore(item: DeviceAssigmentItem) {
if (!item.compliance_score) {
return '-';
}
return (item.compliance_score * 100).toFixed(2) + '%';
}

getBaselineScore(item: DeviceAssigmentItem) {
if (!this.assignmentCheckedIn(item)) {
return '-';
Expand Down
4 changes: 3 additions & 1 deletion src/organization/device/device_list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ <h1 class="panel-title">
<div class="text-center" [class.nanitor-cursor-help]="getBenchmarkTitles(rowData) != null" pTooltip="{{ getBenchmarkTitles(rowData) }}" tooltipPosition="bottom" showDelay="500">{{ rowData.num_benchmarks|mynumber }}</div>
</td>
<td *ngIf="col.field === 'baseline' && needDisplay(col.field)" class="table-cell text-center" [ngStyle]="{'width': getColumnWidth('baseline')}">{{ getBaselineScore(rowData) }}</td>
<td *ngIf="col.field === 'cis' && needDisplay(col.field)" class="table-cell text-center" [ngStyle]="{'width': getColumnWidth('cis')}">{{ getCisScore(rowData) }}</td>
<td *ngIf="col.field === 'cis' && needDisplay(col.field)" class="table-cell text-center" [ngStyle]="{'width': getColumnWidth('cis')}">
{{ getCisORComplianceScore(rowData) }}
</td>
<td *ngIf="col.field === 'group' && needDisplay(col.field)" class="table-cell" [ngStyle]="{'width': getColumnWidth('group')}">
<div class="table-cell text-center" [class.nanitor-cursor-help]="rowData.dn !== ''" pTooltip="{{ rowData.dn }}" tooltipPosition="bottom" showDelay="500">
{{ rowData.group }}
Expand Down
8 changes: 7 additions & 1 deletion src/organization/device/device_list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class DeviceListComponent extends BaseDevice {
];
public isUpgrade: boolean = false;
public primaryFrameworkName: string;
private isPrimaryFrameworkName = false;

constructor(
service: DeviceService,
Expand Down Expand Up @@ -97,7 +98,8 @@ export class DeviceListComponent extends BaseDevice {

listResponseHandler(response: DeviceListResponse) {
super.listResponseHandler(response);
this.primaryFrameworkName = response.hasOwnProperty('primary_framework_name') ? `${response.primary_framework_name} Score` : 'Benchmark Score';
this.isPrimaryFrameworkName = response.primary_framework_name ? true : false;
this.primaryFrameworkName = this.isPrimaryFrameworkName ? `${response.primary_framework_name} Score` : 'Benchmark Score';
}

refresh() {
Expand Down Expand Up @@ -288,6 +290,10 @@ export class DeviceListComponent extends BaseDevice {
this.labelApplyForm.controls[label.name].setValue(null);
}
}

getCisORComplianceScore(item: any) {
return this.isPrimaryFrameworkName ? this.getComplianceScore(item) : this.getCisScore(item);
}
}

interface ApplyLabelListItem extends LabelListItem {
Expand Down
2 changes: 2 additions & 0 deletions src/organization/device/device_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface DeviceListItem {
risc_rating_c: number;
risc_rating_i: number;
risc_rating_a: number;
compliance_score: number;
}

export interface DeviceDetailResponse {
Expand Down Expand Up @@ -145,6 +146,7 @@ export interface DeviceAssigmentItem {
is_excluded: boolean;
can_exclude: boolean;
excluded_info: string;
compliance_score: number;
}

export interface RequestCheckinForm {
Expand Down

0 comments on commit 8cd31dc

Please sign in to comment.