fix using linter.
This commit is contained in:
@@ -7,11 +7,11 @@ import {ApexOptions, ChartComponent} from 'ng-apexcharts';
|
||||
import { DashboardService } from 'app/modules/dashboard/dashboard.service';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import { DashboardSettingsComponent } from 'app/layout/common/dashboard-settings/dashboard-settings.component';
|
||||
import {AppConfig} from "app/core/config/app.config";
|
||||
import {TreoConfigService} from "@treo/services/config";
|
||||
import {Router} from "@angular/router";
|
||||
import {TemperaturePipe} from "app/shared/temperature.pipe";
|
||||
import {DeviceTitlePipe} from "app/shared/device-title.pipe";
|
||||
import {AppConfig} from 'app/core/config/app.config';
|
||||
import {TreoConfigService} from '@treo/services/config';
|
||||
import {Router} from '@angular/router';
|
||||
import {TemperaturePipe} from 'app/shared/temperature.pipe';
|
||||
import {DeviceTitlePipe} from 'app/shared/device-title.pipe';
|
||||
|
||||
@Component({
|
||||
selector : 'example',
|
||||
@@ -25,12 +25,12 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
data: any;
|
||||
hostGroups: { [hostId: string]: string[] } = {}
|
||||
temperatureOptions: ApexOptions;
|
||||
tempDurationKey: string = "forever"
|
||||
tempDurationKey = 'forever'
|
||||
config: AppConfig;
|
||||
|
||||
// Private
|
||||
private _unsubscribeAll: Subject<any>;
|
||||
@ViewChild("tempChart", { static: false }) tempChart: ChartComponent;
|
||||
@ViewChild('tempChart', { static: false }) tempChart: ChartComponent;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -64,17 +64,17 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
.pipe(takeUntil(this._unsubscribeAll))
|
||||
.subscribe((config: AppConfig) => {
|
||||
|
||||
//check if the old config and the new config do not match.
|
||||
let oldConfig = JSON.stringify(this.config)
|
||||
let newConfig = JSON.stringify(config)
|
||||
// check if the old config and the new config do not match.
|
||||
const oldConfig = JSON.stringify(this.config)
|
||||
const newConfig = JSON.stringify(config)
|
||||
|
||||
if(oldConfig != newConfig){
|
||||
if(oldConfig !== newConfig){
|
||||
console.log(`Configuration updated: ${newConfig} vs ${oldConfig}`)
|
||||
// Store the config
|
||||
this.config = config;
|
||||
|
||||
if(oldConfig){
|
||||
console.log("reloading component...")
|
||||
console.log('reloading component...')
|
||||
this.refreshComponent()
|
||||
}
|
||||
}
|
||||
@@ -88,10 +88,10 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
// Store the data
|
||||
this.data = data;
|
||||
|
||||
//generate group data.
|
||||
for(let wwn in this.data.data.summary){
|
||||
let hostid = this.data.data.summary[wwn].device.host_id
|
||||
let hostDeviceList = this.hostGroups[hostid] || []
|
||||
// generate group data.
|
||||
for(const wwn in this.data.data.summary){
|
||||
const hostid = this.data.data.summary[wwn].device.host_id
|
||||
const hostDeviceList = this.hostGroups[hostid] || []
|
||||
hostDeviceList.push(wwn)
|
||||
this.hostGroups[hostid] = hostDeviceList
|
||||
}
|
||||
@@ -121,34 +121,34 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Private methods
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
private refreshComponent(){
|
||||
private refreshComponent(): void {
|
||||
|
||||
let currentUrl = this.router.url;
|
||||
const currentUrl = this.router.url;
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.router.onSameUrlNavigation = 'reload';
|
||||
this.router.navigate([currentUrl]);
|
||||
}
|
||||
|
||||
private _deviceDataTemperatureSeries() {
|
||||
var deviceTemperatureSeries = []
|
||||
private _deviceDataTemperatureSeries(): any[] {
|
||||
const deviceTemperatureSeries = []
|
||||
|
||||
console.log("DEVICE DATA SUMMARY", this.data)
|
||||
console.log('DEVICE DATA SUMMARY', this.data)
|
||||
|
||||
for(const wwn in this.data.data.summary){
|
||||
var deviceSummary = this.data.data.summary[wwn]
|
||||
const deviceSummary = this.data.data.summary[wwn]
|
||||
if (!deviceSummary.temp_history){
|
||||
continue
|
||||
}
|
||||
|
||||
let deviceName = DeviceTitlePipe.deviceTitleWithFallback(deviceSummary.device, this.config.dashboardDisplay)
|
||||
const deviceName = DeviceTitlePipe.deviceTitleWithFallback(deviceSummary.device, this.config.dashboardDisplay)
|
||||
|
||||
var deviceSeriesMetadata = {
|
||||
const deviceSeriesMetadata = {
|
||||
name: deviceName,
|
||||
data: []
|
||||
}
|
||||
|
||||
for(let tempHistory of deviceSummary.temp_history){
|
||||
let newDate = new Date(tempHistory.date);
|
||||
for(const tempHistory of deviceSummary.temp_history){
|
||||
const newDate = new Date(tempHistory.date);
|
||||
deviceSeriesMetadata.data.push({
|
||||
x: newDate,
|
||||
y: TemperaturePipe.formatTemperature(tempHistory.temp, this.config.temperatureUnit, false)
|
||||
@@ -216,9 +216,9 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
// @ Public methods
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
deviceSummariesForHostGroup(hostGroupWWNs: string[]) {
|
||||
let deviceSummaries = []
|
||||
for(let wwn of hostGroupWWNs){
|
||||
deviceSummariesForHostGroup(hostGroupWWNs: string[]): any[] {
|
||||
const deviceSummaries = []
|
||||
for(const wwn of hostGroupWWNs){
|
||||
if(this.data.data.summary[wwn]){
|
||||
deviceSummaries.push(this.data.data.summary[wwn])
|
||||
}
|
||||
@@ -226,7 +226,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
return deviceSummaries
|
||||
}
|
||||
|
||||
openDialog() {
|
||||
openDialog(): void {
|
||||
const dialogRef = this.dialog.open(DashboardSettingsComponent);
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
@@ -234,7 +234,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
});
|
||||
}
|
||||
|
||||
onDeviceDeleted(wwn: string) {
|
||||
onDeviceDeleted(wwn: string): void {
|
||||
delete this.data.data.summary[wwn] // remove the device from the summary list.
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { NgApexchartsModule } from 'ng-apexcharts';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip'
|
||||
import { DashboardSettingsModule } from "app/layout/common/dashboard-settings/dashboard-settings.module";
|
||||
import { DashboardDeviceModule } from "app/layout/common/dashboard-device/dashboard-device.module";
|
||||
import { DashboardSettingsModule } from 'app/layout/common/dashboard-settings/dashboard-settings.module';
|
||||
import { DashboardDeviceModule } from 'app/layout/common/dashboard-device/dashboard-device.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Route } from '@angular/router';
|
||||
import { DashboardComponent } from 'app/modules/dashboard/dashboard.component';
|
||||
import {DashboardResolver} from "./dashboard.resolvers";
|
||||
import {DashboardResolver} from 'app/modules/dashboard/dashboard.resolvers';
|
||||
|
||||
export const dashboardRoutes: Route[] = [
|
||||
{
|
||||
|
||||
@@ -55,9 +55,9 @@ export class DashboardService
|
||||
|
||||
getSummaryTempData(durationKey: string): Observable<any>
|
||||
{
|
||||
let params = {}
|
||||
const params = {}
|
||||
if(durationKey){
|
||||
params["duration_key"] = durationKey
|
||||
params['duration_key'] = durationKey
|
||||
}
|
||||
|
||||
return this._httpClient.get(getBasePath() + '/api/summary/temp', {params: params});
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {ApexOptions} from "ng-apexcharts";
|
||||
import {MatTableDataSource} from "@angular/material/table";
|
||||
import {MatSort} from "@angular/material/sort";
|
||||
import {Subject} from "rxjs";
|
||||
import {DetailService} from "./detail.service";
|
||||
import {takeUntil} from "rxjs/operators";
|
||||
import {fadeOut} from "../../../@treo/animations/fade";
|
||||
import {DetailSettingsComponent} from "app/layout/common/detail-settings/detail-settings.component";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {ApexOptions} from 'ng-apexcharts';
|
||||
import {MatTableDataSource} from '@angular/material/table';
|
||||
import {MatSort} from '@angular/material/sort';
|
||||
import {Subject} from 'rxjs';
|
||||
import {DetailService} from './detail.service';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {DetailSettingsComponent} from 'app/layout/common/detail-settings/detail-settings.component';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import humanizeDuration from 'humanize-duration';
|
||||
import {TreoConfigService} from "../../../@treo/services/config";
|
||||
import {AppConfig} from "../../core/config/app.config";
|
||||
import {TreoConfigService} from '@treo/services/config';
|
||||
import {AppConfig} from 'app/core/config/app.config';
|
||||
import {animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {formatDate} from "@angular/common";
|
||||
import {formatDate} from '@angular/common';
|
||||
import { LOCALE_ID, Inject } from '@angular/core';
|
||||
|
||||
// from Constants.go - these must match
|
||||
@@ -37,27 +36,6 @@ const AttributeStatusFailedScrutiny = 4
|
||||
|
||||
export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
config: AppConfig;
|
||||
|
||||
onlyCritical: boolean = true;
|
||||
// data: any;
|
||||
expandedAttribute: any | null;
|
||||
|
||||
metadata: any;
|
||||
device: any;
|
||||
smart_results: any[];
|
||||
|
||||
commonSparklineOptions: Partial<ApexOptions>;
|
||||
smartAttributeDataSource: MatTableDataSource<any>;
|
||||
smartAttributeTableColumns: string[];
|
||||
|
||||
@ViewChild('smartAttributeTable', {read: MatSort})
|
||||
smartAttributeTableMatSort: MatSort;
|
||||
|
||||
// Private
|
||||
private _unsubscribeAll: Subject<any>;
|
||||
private systemPrefersDark: boolean;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -79,10 +57,33 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
// this.recentTransactionsTableColumns = ['status', 'id', 'name', 'value', 'worst', 'thresh'];
|
||||
this.smartAttributeTableColumns = ['status', 'id', 'name', 'value', 'worst', 'thresh','ideal', 'failure', 'history'];
|
||||
|
||||
this.systemPrefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
this.systemPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
|
||||
}
|
||||
|
||||
config: AppConfig;
|
||||
|
||||
onlyCritical = true;
|
||||
// data: any;
|
||||
expandedAttribute: any | null;
|
||||
|
||||
metadata: any;
|
||||
device: any;
|
||||
smart_results: any[];
|
||||
|
||||
commonSparklineOptions: Partial<ApexOptions>;
|
||||
smartAttributeDataSource: MatTableDataSource<any>;
|
||||
smartAttributeTableColumns: string[];
|
||||
|
||||
@ViewChild('smartAttributeTable', {read: MatSort})
|
||||
smartAttributeTableMatSort: MatSort;
|
||||
|
||||
// Private
|
||||
private _unsubscribeAll: Subject<any>;
|
||||
private systemPrefersDark: boolean;
|
||||
|
||||
readonly humanizeDuration = humanizeDuration;
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Lifecycle hooks
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
@@ -181,7 +182,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
getAttributeName(attribute_data): string {
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata){
|
||||
return 'Unknown Attribute Name'
|
||||
} else {
|
||||
@@ -189,7 +190,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
getAttributeDescription(attribute_data){
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata){
|
||||
return 'Unknown'
|
||||
} else {
|
||||
@@ -200,12 +201,12 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
getAttributeValue(attribute_data){
|
||||
if(this.isAta()) {
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata){
|
||||
return attribute_data.value
|
||||
} else if (attribute_metadata.display_type == "raw") {
|
||||
} else if (attribute_metadata.display_type == 'raw') {
|
||||
return attribute_data.raw_value
|
||||
} else if (attribute_metadata.display_type == "transformed" && attribute_data.transformed_value) {
|
||||
} else if (attribute_metadata.display_type == 'transformed' && attribute_data.transformed_value) {
|
||||
return attribute_data.transformed_value
|
||||
} else {
|
||||
return attribute_data.value
|
||||
@@ -218,7 +219,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
getAttributeValueType(attribute_data){
|
||||
if(this.isAta()) {
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata){
|
||||
return ''
|
||||
} else {
|
||||
@@ -231,25 +232,25 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
getAttributeIdeal(attribute_data){
|
||||
if(this.isAta()){
|
||||
return this.metadata[attribute_data.attribute_id]?.display_type == "raw" ? this.metadata[attribute_data.attribute_id]?.ideal : ''
|
||||
return this.metadata[attribute_data.attribute_id]?.display_type == 'raw' ? this.metadata[attribute_data.attribute_id]?.ideal : ''
|
||||
} else {
|
||||
return this.metadata[attribute_data.attribute_id]?.ideal
|
||||
}
|
||||
}
|
||||
|
||||
getAttributeWorst(attribute_data){
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata){
|
||||
return attribute_data.worst
|
||||
} else {
|
||||
return attribute_metadata?.display_type == "normalized" ? attribute_data.worst : ''
|
||||
return attribute_metadata?.display_type == 'normalized' ? attribute_data.worst : ''
|
||||
}
|
||||
}
|
||||
|
||||
getAttributeThreshold(attribute_data){
|
||||
if(this.isAta()){
|
||||
let attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata || attribute_metadata.display_type == "normalized"){
|
||||
const attribute_metadata = this.metadata[attribute_data.attribute_id]
|
||||
if(!attribute_metadata || attribute_metadata.display_type == 'normalized'){
|
||||
return attribute_data.thresh
|
||||
} else {
|
||||
// if(this.data.metadata[attribute_data.attribute_id].observed_thresholds){
|
||||
@@ -273,7 +274,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
let attributes_length = 0
|
||||
let attributes = this.smart_results[0]?.attrs
|
||||
const attributes = this.smart_results[0]?.attrs
|
||||
if (attributes) {
|
||||
attributes_length = Object.keys(attributes).length
|
||||
}
|
||||
@@ -292,12 +293,12 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
private _generateSmartAttributeTableDataSource(smart_results){
|
||||
var smartAttributeDataSource = [];
|
||||
const smartAttributeDataSource = [];
|
||||
|
||||
if(smart_results.length == 0){
|
||||
return smartAttributeDataSource
|
||||
}
|
||||
var latest_smart_result = smart_results[0];
|
||||
const latest_smart_result = smart_results[0];
|
||||
let attributes = {}
|
||||
if(this.isScsi()) {
|
||||
this.smartAttributeTableColumns = ['status', 'name', 'value', 'thresh', 'history'];
|
||||
@@ -306,20 +307,20 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.smartAttributeTableColumns = ['status', 'name', 'value', 'thresh', 'ideal', 'history'];
|
||||
attributes = latest_smart_result.attrs
|
||||
} else {
|
||||
//ATA
|
||||
// ATA
|
||||
attributes = latest_smart_result.attrs
|
||||
this.smartAttributeTableColumns = ['status', 'id', 'name', 'value', 'thresh','ideal', 'failure', 'history'];
|
||||
}
|
||||
|
||||
for(const attrId in attributes){
|
||||
var attr = attributes[attrId]
|
||||
const attr = attributes[attrId]
|
||||
|
||||
//chart history data
|
||||
// chart history data
|
||||
if (!attr.chartData) {
|
||||
|
||||
|
||||
var attrHistory = []
|
||||
for (let smart_result of smart_results){
|
||||
const attrHistory = []
|
||||
for (const smart_result of smart_results){
|
||||
// attrHistory.push(this.getAttributeValue(smart_result.attrs[attrId]))
|
||||
|
||||
const chartDatapoint = {
|
||||
@@ -342,12 +343,12 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
attributes[attrId].chartData = [
|
||||
{
|
||||
name: "chart-line-sparkline",
|
||||
name: 'chart-line-sparkline',
|
||||
data: attrHistory
|
||||
}
|
||||
]
|
||||
}
|
||||
//determine when to include the attributes in table.
|
||||
// determine when to include the attributes in table.
|
||||
|
||||
if(!this.onlyCritical || this.onlyCritical && this.metadata[attr.attribute_id]?.critical || attr.value < attr.thresh){
|
||||
smartAttributeDataSource.push(attr)
|
||||
@@ -367,7 +368,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
// Account balance
|
||||
this.commonSparklineOptions = {
|
||||
chart: {
|
||||
type: "bar",
|
||||
type: 'bar',
|
||||
width: 100,
|
||||
height: 25,
|
||||
sparkline: {
|
||||
@@ -392,7 +393,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
y: {
|
||||
title: {
|
||||
formatter: function(seriesName) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -421,7 +422,7 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
toHex(decimalNumb){
|
||||
return "0x" + Number(decimalNumb).toString(16).padStart(2, '0').toUpperCase()
|
||||
return '0x' + Number(decimalNumb).toString(16).padStart(2, '0').toUpperCase()
|
||||
}
|
||||
toggleOnlyCritical(){
|
||||
this.onlyCritical = !this.onlyCritical
|
||||
@@ -449,6 +450,4 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
// return item.id || index;
|
||||
}
|
||||
|
||||
readonly humanizeDuration = humanizeDuration;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip'
|
||||
import { NgApexchartsModule } from 'ng-apexcharts';
|
||||
import { TreoCardModule } from '@treo/components/card';
|
||||
import {DetailSettingsModule} from "app/layout/common/detail-settings/detail-settings.module";
|
||||
import {DetailSettingsModule} from 'app/layout/common/detail-settings/detail-settings.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Route } from '@angular/router';
|
||||
import { DetailComponent } from 'app/modules/detail/detail.component';
|
||||
import {DetailResolver} from "./detail.resolvers";
|
||||
import {DetailResolver} from './detail.resolvers';
|
||||
|
||||
export const detailRoutes: Route[] = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user