diff --git a/ui-ngx/src/app/shared/components/device/gateway-configuration.component.ts b/ui-ngx/src/app/shared/components/device/gateway-configuration.component.ts index 828d577855..541e149311 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-configuration.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-configuration.component.ts @@ -28,9 +28,9 @@ import { GatewayRemoteConfigurationDialogData } from '@shared/components/dialog/gateway-remote-configuration-dialog'; import { DeviceService } from '@core/http/device.service'; -import { of } from "rxjs"; -import { mergeMap } from "rxjs/operators"; -import { DeviceCredentialsType } from "@shared/models/device.models"; +import { of } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; +import { DeviceCredentialsType } from '@shared/models/device.models'; export enum StorageTypes { MEMORY = 'memory', diff --git a/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts b/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts index a3d5dea0bf..eff5e67f19 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-logs.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, ViewChild } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { Router } from '@angular/router'; @@ -24,18 +24,18 @@ import { AttributeService } from '@core/http/attribute.service'; import { DeviceService } from '@core/http/device.service'; import { TranslateService } from '@ngx-translate/core'; import { AttributeData, DataKeyType } from '@shared/models/telemetry/telemetry.models'; -import { PageComponent } from "@shared/components/page.component"; -import { PageLink } from "@shared/models/page/page-link"; +import { PageComponent } from '@shared/components/page.component'; +import { PageLink } from '@shared/models/page/page-link'; import { AttributeDatasource } from "@home/models/datasource/attribute-datasource"; import { Direction, SortOrder } from "@shared/models/page/sort-order"; -import { MatSort } from "@angular/material/sort"; -import { MatTableDataSource } from "@angular/material/table"; -import { GatewayLogLevel } from "@shared/components/device/gateway-configuration.component"; +import { MatSort } from '@angular/material/sort'; +import { MatTableDataSource } from '@angular/material/table'; +import { GatewayLogLevel } from '@shared/components/device/gateway-configuration.component'; import { DialogService } from '@app/core/services/dialog.service'; -import { WidgetContext } from "@home/models/widget-component.models"; +import { WidgetContext } from '@home/models/widget-component.models'; -export interface gatewayConnector { +export interface GatewayConnector { name: string; type: string; configuration?: string; @@ -90,7 +90,7 @@ export class GatewayLogsComponent extends PageComponent implements AfterViewInit logLinks: Array; - initialConnector: gatewayConnector; + initialConnector: GatewayConnector; activeLink: LogLink; @@ -139,10 +139,7 @@ export class GatewayLogsComponent extends PageComponent implements AfterViewInit return timewindow; } if (this.ctx.settings.isConnectorLog && this.ctx.settings.connectorLogState) { - console.log(this.ctx.settings.connectorLogState) - const connector = this.ctx.stateController.getStateParams()[this.ctx.settings.connectorLogState]; - console.log(connector) this.logLinks = [{ key: `${connector.key}_LOGS`, name: "Connector", @@ -166,7 +163,6 @@ export class GatewayLogsComponent extends PageComponent implements AfterViewInit updateData(sort?) { if (this.ctx.defaultSubscription.data.length) { - console.log(this.ctx.defaultSubscription.data[0].dataKey.name === "LOGS") let attrData = this.ctx.defaultSubscription.data[0].data.map(data => { let result = { ts: data[0], diff --git a/ui-ngx/src/app/shared/components/device/gateway-service-rpc.component.ts b/ui-ngx/src/app/shared/components/device/gateway-service-rpc.component.ts index f4a9655cc0..52e687b3a9 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-service-rpc.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-service-rpc.component.ts @@ -30,7 +30,7 @@ import { ContentType } from '@shared/models/constants'; import { JsonObjectEditDialogComponent, JsonObjectEditDialogData -} from "@shared/components/dialog/json-object-edit-dialog.component"; +} from '@shared/components/dialog/json-object-edit-dialog.component'; @Component({ @@ -70,7 +70,6 @@ export class GatewayServiceRPCComponent extends PageComponent implements AfterVi protected attributeService: AttributeService, protected deviceService: DeviceService, protected dialogService: DialogService, - private cd: ChangeDetectorRef, public dialog: MatDialog) { super(store); this.commandForm = this.fb.group({ diff --git a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.html b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.html index 7a7581ab29..b98d481f6d 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.html +++ b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.html @@ -45,13 +45,13 @@ - + Timestamp {{row[0]| date:'yyyy-MM-dd HH:mm:ss' }} - + Message {{ row[1] }} diff --git a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts index a65e56e2a3..93945f69c9 100644 --- a/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts +++ b/ui-ngx/src/app/shared/components/device/gateway-statistics.component.ts @@ -35,10 +35,10 @@ import { DatasourceType, LegendConfig, LegendData, LegendPosition, widgetType } import { EntityType } from '@shared/models/entity-type.models'; import { EntityId } from '@shared/models/id/entity-id'; import { BaseData } from '@shared/models/base-data'; -import { PageLink } from "@shared/models/page/page-link"; -import { Direction, SortOrder } from "@shared/models/page/sort-order"; -import { MatTableDataSource } from "@angular/material/table"; -import { MatSort } from "@angular/material/sort"; +import { PageLink } from '@shared/models/page/page-link'; +import { Direction, SortOrder } from '@shared/models/page/sort-order'; +import { MatTableDataSource } from '@angular/material/table'; +import { MatSort } from '@angular/material/sort'; @Component({ @@ -56,6 +56,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi @Input() public general: boolean; + public isNumericData: boolean = true; public chartInited: boolean; private flot: TbFlot; @@ -98,9 +99,9 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi private utils: UtilsService, public dialog: MatDialog) { super(store); - const sortOrder: SortOrder = {property: 'ts', direction: Direction.DESC}; + const sortOrder: SortOrder = {property: '0', direction: Direction.DESC}; this.pageLink = new PageLink(Number.POSITIVE_INFINITY, 0, null, sortOrder); - this.displayedColumns = ['ts', 'message']; + this.displayedColumns = ['0', '1']; this.dataSource = new MatTableDataSource([]); this.statisticForm = this.fb.group({ statisticKey: [null, []] @@ -118,6 +119,9 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi ngAfterViewInit() { this.dataSource.sort = this.sort; + this.sort.sortChange.subscribe(_=>{ + this.sortData(); + }) this.init(); if (this.ctx.defaultSubscription.datasources.length) { @@ -147,6 +151,10 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi } } + public sortData () { + this.dataSource.sortData(this.dataSource.data, this.sort); + } + public onLegendKeyHiddenChange(index: number) { this.legendData.keys[index].dataKey.hidden = !this.legendData.keys[index].dataKey.hidden; this.subscription.updateDataVisibility(index); @@ -225,7 +233,7 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi } } - private onDataUpdateError( e: any) { + private onDataUpdateError(e: any) { const exceptionData = this.utils.parseException(e); let errorText = exceptionData.name; if (exceptionData.message) { @@ -256,6 +264,10 @@ export class GatewayStatisticsComponent extends PageComponent implements AfterVi } private checkDataToBeNumeric() { + if (this.general) { + this.isNumericData = true; + return; + } this.dataSource.data = this.subscription.data.length ? this.subscription.data[0].data : []; this.isNumericData = this.dataSource.data.every(data => isNaN(data[1]) === false); }