conflict resolution
This commit is contained in:
commit
8e9ca7e4e6
@ -31,7 +31,7 @@ import { EntityId } from '@shared/models/id/entity-id';
|
||||
import { AttributeService } from '@core/http/attribute.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { forkJoin, Observable, of, Subject, Subscription } from 'rxjs';
|
||||
import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
||||
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
||||
import { PageComponent } from '@shared/components/page.component';
|
||||
import { PageLink } from '@shared/models/page/page-link';
|
||||
import { AttributeDatasource } from '@home/models/datasource/attribute-datasource';
|
||||
@ -54,6 +54,7 @@ import {
|
||||
ConnectorBaseInfo,
|
||||
ConnectorConfigurationModes,
|
||||
ConnectorType,
|
||||
GatewayAttributeData,
|
||||
GatewayConnector,
|
||||
GatewayConnectorDefaultTypesTranslatesMap,
|
||||
GatewayLogLevel,
|
||||
@ -99,7 +100,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
readonly ConnectorConfigurationModes = ConnectorConfigurationModes;
|
||||
|
||||
pageLink: PageLink;
|
||||
dataSource: MatTableDataSource<AttributeData>;
|
||||
dataSource: MatTableDataSource<GatewayAttributeData>;
|
||||
connectorForm: FormGroup;
|
||||
activeConnectors: Array<string>;
|
||||
mode: ConnectorConfigurationModes = this.ConnectorConfigurationModes.BASIC;
|
||||
@ -111,7 +112,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
private serverDataSource: AttributeDatasource;
|
||||
private activeData: Array<any> = [];
|
||||
private inactiveData: Array<any> = [];
|
||||
private sharedAttributeData: Array<AttributeData> = [];
|
||||
private sharedAttributeData: Array<GatewayAttributeData> = [];
|
||||
private basicConfigSub: Subscription;
|
||||
private jsonConfigSub: Subscription;
|
||||
private subscriptionOptions: WidgetSubscriptionOptions = {
|
||||
@ -126,7 +127,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
};
|
||||
private destroy$ = new Subject<void>();
|
||||
private subscription: IWidgetSubscription;
|
||||
private attributeUpdateSubject = new Subject<AttributeData>();
|
||||
private attributeUpdateSubject = new Subject<GatewayAttributeData>();
|
||||
|
||||
constructor(protected store: Store<AppState>,
|
||||
private fb: FormBuilder,
|
||||
@ -264,7 +265,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
});
|
||||
}
|
||||
|
||||
isConnectorSynced(attribute: AttributeData) {
|
||||
isConnectorSynced(attribute: GatewayAttributeData) {
|
||||
const connectorData = attribute.value;
|
||||
if (!connectorData.ts || attribute.skipSync) {
|
||||
return false;
|
||||
@ -346,7 +347,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
this.connectorForm.markAsPristine();
|
||||
}
|
||||
|
||||
selectConnector($event: Event, attribute: AttributeData): void {
|
||||
selectConnector($event: Event, attribute: GatewayAttributeData): void {
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
@ -360,7 +361,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
}
|
||||
}
|
||||
|
||||
isSameConnector(attribute: AttributeData): boolean {
|
||||
isSameConnector(attribute: GatewayAttributeData): boolean {
|
||||
if (!this.initialConnector) {
|
||||
return false;
|
||||
}
|
||||
@ -381,12 +382,12 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
}));
|
||||
}
|
||||
|
||||
returnType(attribute: AttributeData): string {
|
||||
returnType(attribute: GatewayAttributeData): string {
|
||||
const value = attribute.value;
|
||||
return this.GatewayConnectorTypesTranslatesMap.get(value.type);
|
||||
}
|
||||
|
||||
deleteConnector(attribute: AttributeData, $event: Event): void {
|
||||
deleteConnector(attribute: GatewayAttributeData, $event: Event): void {
|
||||
$event?.stopPropagation();
|
||||
|
||||
const title = `Delete connector \"${attribute.key}\"?`;
|
||||
@ -419,7 +420,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
});
|
||||
}
|
||||
|
||||
connectorLogs(attribute: AttributeData, $event: Event): void {
|
||||
connectorLogs(attribute: GatewayAttributeData, $event: Event): void {
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
@ -429,7 +430,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
this.ctx.stateController.openState('connector_logs', params);
|
||||
}
|
||||
|
||||
connectorRpc(attribute: AttributeData, $event: Event): void {
|
||||
connectorRpc(attribute: GatewayAttributeData, $event: Event): void {
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
@ -440,7 +441,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
}
|
||||
|
||||
|
||||
onEnableConnector(attribute: AttributeData): void {
|
||||
onEnableConnector(attribute: GatewayAttributeData): void {
|
||||
attribute.value.ts = new Date().getTime();
|
||||
|
||||
this.updateActiveConnectorKeys(attribute.key);
|
||||
@ -448,7 +449,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
this.attributeUpdateSubject.next(attribute);
|
||||
}
|
||||
|
||||
getErrorsCount(attribute: AttributeData): string {
|
||||
getErrorsCount(attribute: GatewayAttributeData): string {
|
||||
const connectorName = attribute.key;
|
||||
const connector = this.subscription && this.subscription.data
|
||||
.find(data => data && data.dataKey.name === `${connectorName}_ERRORS_COUNT`);
|
||||
@ -512,7 +513,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
this.attributeDataSource = new AttributeDatasource(this.attributeService, this.telemetryWsService, this.zone, this.translate);
|
||||
this.inactiveConnectorsDataSource = new AttributeDatasource(this.attributeService, this.telemetryWsService, this.zone, this.translate);
|
||||
this.serverDataSource = new AttributeDatasource(this.attributeService, this.telemetryWsService, this.zone, this.translate);
|
||||
this.dataSource = new MatTableDataSource<AttributeData>([]);
|
||||
this.dataSource = new MatTableDataSource<GatewayAttributeData>([]);
|
||||
}
|
||||
|
||||
private initConnectorForm(): void {
|
||||
@ -541,8 +542,8 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
.subscribe(name => this.connectorForm.get('basicConfig').get('broker.name')?.setValue(name));
|
||||
}
|
||||
|
||||
private getSortingDataAccessor(): (data: AttributeData, sortHeaderId: string) => string | number {
|
||||
return (data: AttributeData, sortHeaderId: string) => {
|
||||
private getSortingDataAccessor(): (data: GatewayAttributeData, sortHeaderId: string) => string | number {
|
||||
return (data: GatewayAttributeData, sortHeaderId: string) => {
|
||||
switch (sortHeaderId) {
|
||||
case 'syncStatus':
|
||||
return this.isConnectorSynced(data) ? 1 : 0;
|
||||
@ -579,7 +580,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
});
|
||||
}
|
||||
|
||||
private parseConnectors(attribute: AttributeData[]): string[] {
|
||||
private parseConnectors(attribute: GatewayAttributeData[]): string[] {
|
||||
const connectors = attribute?.[0]?.value || [];
|
||||
return isString(connectors) ? JSON.parse(connectors) : connectors;
|
||||
}
|
||||
@ -593,7 +594,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
private observeAttributeChange(): void {
|
||||
this.attributeUpdateSubject.pipe(
|
||||
debounceTime(300),
|
||||
tap((attribute: AttributeData) => this.executeAttributeUpdates(attribute)),
|
||||
tap((attribute: GatewayAttributeData) => this.executeAttributeUpdates(attribute)),
|
||||
takeUntil(this.destroy$),
|
||||
).subscribe();
|
||||
}
|
||||
@ -615,7 +616,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
}
|
||||
}
|
||||
|
||||
private executeAttributeUpdates(attribute: AttributeData): void {
|
||||
private executeAttributeUpdates(attribute: GatewayAttributeData): void {
|
||||
forkJoin(this.getAttributeExecutionTasks(attribute))
|
||||
.pipe(
|
||||
take(1),
|
||||
@ -625,7 +626,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
private getAttributeExecutionTasks(attribute: AttributeData): Observable<any>[] {
|
||||
private getAttributeExecutionTasks(attribute: GatewayAttributeData): Observable<any>[] {
|
||||
const isActive = this.activeConnectors.includes(attribute.key);
|
||||
const scopeOld = isActive ? AttributeScope.SERVER_SCOPE : AttributeScope.SHARED_SCOPE;
|
||||
const scopeNew = isActive ? AttributeScope.SHARED_SCOPE : AttributeScope.SERVER_SCOPE;
|
||||
@ -762,7 +763,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
||||
this.createJsonConfigWatcher();
|
||||
}
|
||||
|
||||
private setClientData(data: PageData<AttributeData>): void {
|
||||
private setClientData(data: PageData<GatewayAttributeData>): void {
|
||||
if (this.initialConnector) {
|
||||
const clientConnectorData = data.data.find(attr => attr.key === this.initialConnector.name);
|
||||
if (clientConnectorData) {
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
import { ResourcesService } from '@core/services/resources.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { helpBaseUrl, ValueTypeData } from '@shared/models/constants';
|
||||
import { AttributeData } from '@shared/models/telemetry/telemetry.models';
|
||||
|
||||
export const noLeadTrailSpacesRegex = /^\S+(?: \S+)*$/;
|
||||
export const integerRegex = /^[-+]?\d+$/;
|
||||
@ -109,6 +110,10 @@ export const GecurityTypesTranslationsMap = new Map<SecurityTypes, string>(
|
||||
]
|
||||
);
|
||||
|
||||
export interface GatewayAttributeData extends AttributeData {
|
||||
skipSync?: boolean;
|
||||
}
|
||||
|
||||
export interface GatewayConnector {
|
||||
name: string;
|
||||
type: ConnectorType;
|
||||
|
||||
@ -118,7 +118,6 @@ export const timeseriesDeleteStrategyTranslations = new Map<TimeseriesDeleteStra
|
||||
|
||||
export interface AttributeData {
|
||||
lastUpdateTs?: number;
|
||||
skipSync?: boolean;
|
||||
key: string;
|
||||
value: any;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user