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