<cd-alert-panel type="warning">{{ device.value.userMessage }}</cd-alert-panel>
</ng-container>
<ng-template #noError>
+ <ng-container *ngIf="device.value.smart.data.self_test.status.passed; else selfTestFailed">
+ <cd-alert-panel
+ size="slim"
+ type="info"
+ i18n-title
+ title="SMART overall-health self-assessment test result">
+ {{ device.value.smart.data.self_test.status.string }}
+ </cd-alert-panel>
+ </ng-container>
+ <ng-template #selfTestFailed>
+ <cd-alert-panel
+ size="slim"
+ type="warning"
+ i18n-title
+ title="SMART overall-health self-assessment test result">
+ {{ device.value.smart.data.self_test.status.string }}
+ </cd-alert-panel>
+ </ng-template>
<tabset>
<tab i18n-heading
heading="Device Information">
<tab i18n-heading
heading="S.M.A.R.T">
- <cd-table [data]="device.value.smart.table"
+ <cd-table [data]="device.value.smart.attributes.table"
updateSelectionOnRefresh="never"
[columns]="columns"></cd-table>
</tab>
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { SimpleChange, SimpleChanges } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { TabsModule } from 'ngx-bootstrap/tabs';
+import { By } from '@angular/platform-browser';
+import { TabsetComponent, TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
import _ = require('lodash');
import { of } from 'rxjs';
configureTestBed({
declarations: [OsdSmartListComponent],
imports: [TabsModule, SharedModule, HttpClientTestingModule],
- providers: [i18nProviders]
+ providers: [i18nProviders, TabsetComponent, TabsetConfig]
});
beforeEach(() => {
expect(component.data).toEqual({});
expect(component.incompatible).toBeTruthy();
});
+
+ it('should display info panel for passed self test', () => {
+ initializeComponentWithData();
+ fixture.detectChanges();
+ const alertPanel = fixture.debugElement.query(By.css('cd-alert-panel'));
+ expect(component.incompatible).toBe(false);
+ expect(component.loading).toBe(false);
+ expect(alertPanel.attributes.size).toBe('slim');
+ expect(alertPanel.attributes.title).toBe('SMART overall-health self-assessment test result');
+ expect(alertPanel.attributes.type).toBe('info');
+ });
+
+ it('should display warning panel for failed self test', () => {
+ initializeComponentWithData(patchData('ata_smart_data.self_test.status.passed', false));
+ fixture.detectChanges();
+ const alertPanel = fixture.debugElement.query(By.css('cd-alert-panel'));
+ expect(component.incompatible).toBe(false);
+ expect(component.loading).toBe(false);
+ expect(alertPanel.attributes.size).toBe('slim');
+ expect(alertPanel.attributes.title).toBe('SMART overall-health self-assessment test result');
+ expect(alertPanel.attributes.type).toBe('warning');
+ });
});
// Build result
result[deviceId] = {
info: info,
- smart: smartData.ata_smart_attributes,
+ smart: {
+ attributes: smartData.ata_smart_attributes,
+ data: smartData.ata_smart_data
+ },
device: info.device.name,
identifier: info.serial_number
};
<alert type="{{ bootstrapClass }}">
<table>
- <tr>
- <td rowspan="2" class="alert-panel-icon">
- <i [ngClass]="[icons.large3x]" class="alert-{{ bootstrapClass }} {{ typeIcon }}"
- aria-hidden="true"></i>
- </td>
- <td class="alert-panel-title">{{ title }}</td>
- </tr>
- <tr>
- <td class="alert-panel-text">
- <ng-content></ng-content>
- </td>
- </tr>
+ <ng-container *ngIf="size === 'normal'; else slim">
+ <tr>
+ <td *ngIf="showIcon"
+ rowspan="2" class="alert-panel-icon">
+ <i [ngClass]="[icons.large3x]" class="alert-{{ bootstrapClass }} {{ typeIcon }}"
+ aria-hidden="true"></i>
+ </td>
+ <td class="alert-panel-title">{{ title }}</td>
+ </tr>
+ <tr>
+ <td class="alert-panel-text">
+ <ng-container *ngTemplateOutlet="content"></ng-container>
+ </td>
+ </tr>
+ </ng-container>
+ <ng-template #slim>
+ <tr>
+ <td *ngIf="showIcon" class="alert-panel-icon">
+ <i class="alert-{{ bootstrapClass }} {{ typeIcon }}"
+ aria-hidden="true"></i>
+ </td>
+ <td class="alert-panel-title">{{ title }}</td>
+ <td class="alert-panel-text">
+ <ng-container *ngTemplateOutlet="content"></ng-container>
+ </td>
+ </tr>
+ </ng-template>
</table>
</alert>
+<ng-template #content>
+ <ng-content></ng-content>
+</ng-template>
+
<div class="button-group text-right"
*ngIf="backAction.observers.length > 0">
<button class="btn btn-light tc_backButton"
.alert-panel-icon {
vertical-align: top;
- padding-right: 15px; // See @alert-padding in bootstrap/less/variables.less
+ padding-right: 0.5em;
}
.alert-panel-title {
bootstrapClass = '';
@Output()
backAction = new EventEmitter();
-
@Input()
- type: 'warning' | 'error' | 'info';
+ type: 'warning' | 'error' | 'info' | 'success';
@Input()
typeIcon: Icons | string;
+ @Input()
+ size: 'slim' | 'normal' = 'normal';
+ @Input()
+ showIcon = true;
icons = Icons;