Commit f8e80aa94b604e8b55c4dad7477e57ec27730332

Authored by Artem Babak
1 parent 226f7f4e

Fix import edges, update() is not working

... ... @@ -104,4 +104,8 @@ export class EdgeService {
104 104 public findMissingToRelatedRuleChains(edgeId: string, config?: RequestConfig): Observable<string> {
105 105 return this.http.get<string>(`/api/edge/missingToRelatedRuleChains/${edgeId}`, defaultHttpOptionsFromConfig(config));
106 106 }
  107 +
  108 + public findByName(edgeName: string, config?: RequestConfig): Observable<Edge> {
  109 + return this.http.get<Edge>(`/api/tenant/edges?edgeName=${edgeName}`, defaultHttpOptionsFromConfig(config));
  110 + }
107 111 }
... ...
... ... @@ -70,6 +70,7 @@ import {
70 70 import { alarmFields } from '@shared/models/alarm.models';
71 71 import { EdgeService } from "@core/http/edge.service";
72 72 import { ruleChainType } from "@shared/models/rule-chain.models";
  73 +import { Edge } from '@shared/models/edge.models';
73 74
74 75 @Injectable({
75 76 providedIn: 'root'
... ... @@ -888,6 +889,21 @@ export class EntityService {
888 889 };
889 890 saveEntityObservable = this.assetService.saveAsset(asset, config);
890 891 break;
  892 + case EntityType.EDGE:
  893 + const edge: Edge = {
  894 + name: entityData.name,
  895 + type: entityData.type,
  896 + label: entityData.label,
  897 + additionalInfo: {
  898 + description: entityData.description
  899 + },
  900 + edgeLicenseKey: entityData.edgeLicenseKey,
  901 + cloudEndpoint: entityData.cloudEndpoint,
  902 + routingKey: entityData.routingKey,
  903 + secret: entityData.secret
  904 + }
  905 + saveEntityObservable = this.edgeService.saveEdge(edge, config);
  906 + break;
891 907 }
892 908 return saveEntityObservable.pipe(
893 909 mergeMap((entity) => {
... ...
... ... @@ -203,7 +203,11 @@ export class ImportDialogCsvComponent extends DialogComponent<ImportDialogCsvCom
203 203 server: [],
204 204 shared: []
205 205 },
206   - timeseries: []
  206 + timeseries: [],
  207 + edgeLicenseKey: '',
  208 + cloudEndpoint: '',
  209 + routingKey: '',
  210 + secret: ''
207 211 };
208 212 const i = row;
209 213 for (let j = 0; j < parameterColumns.length; j++) {
... ... @@ -244,6 +248,18 @@ export class ImportDialogCsvComponent extends DialogComponent<ImportDialogCsvCom
244 248 case ImportEntityColumnType.description:
245 249 entityData.description = importData.rows[i][j];
246 250 break;
  251 + case ImportEntityColumnType.edgeLicenseKey:
  252 + entityData.edgeLicenseKey = importData.rows[i][j];
  253 + break;
  254 + case ImportEntityColumnType.cloudEndpoint:
  255 + entityData.cloudEndpoint = importData.rows[i][j];
  256 + break;
  257 + case ImportEntityColumnType.routingKey:
  258 + entityData.routingKey = importData.rows[i][j];
  259 + break;
  260 + case ImportEntityColumnType.secret:
  261 + entityData.secret = importData.rows[i][j];
  262 + break;
247 263 }
248 264 }
249 265 entitiesData.push(entityData);
... ...
... ... @@ -49,7 +49,11 @@ export enum ImportEntityColumnType {
49 49 entityField = 'ENTITY_FIELD',
50 50 accessToken = 'ACCESS_TOKEN',
51 51 isGateway = 'IS_GATEWAY',
52   - description = 'DESCRIPTION'
  52 + description = 'DESCRIPTION',
  53 + edgeLicenseKey = 'EDGE_LICENSE_KEY',
  54 + cloudEndpoint = 'CLOUD_ENDPOINT',
  55 + routingKey = 'ROUTING_KEY',
  56 + secret = 'SECRET'
53 57 }
54 58
55 59 export const importEntityObjectColumns =
... ... @@ -68,6 +72,10 @@ export const importEntityColumnTypeTranslations = new Map<ImportEntityColumnType
68 72 [ImportEntityColumnType.accessToken, 'import.column-type.access-token'],
69 73 [ImportEntityColumnType.isGateway, 'import.column-type.isgateway'],
70 74 [ImportEntityColumnType.description, 'import.column-type.description'],
  75 + [ImportEntityColumnType.edgeLicenseKey, 'import.column-type.edgeLicenseKey'],
  76 + [ImportEntityColumnType.cloudEndpoint, 'import.column-type.cloudEndpoint'],
  77 + [ImportEntityColumnType.routingKey, 'import.column-type.routingKey'],
  78 + [ImportEntityColumnType.secret, 'import.column-type.secret']
71 79 ]
72 80 );
73 81
... ...
... ... @@ -93,6 +93,14 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
93 93 { value: ImportEntityColumnType.timeseries }
94 94 );
95 95 break;
  96 + case EntityType.EDGE:
  97 + this.columnTypes.push(
  98 + { value: ImportEntityColumnType.edgeLicenseKey },
  99 + { value: ImportEntityColumnType.cloudEndpoint },
  100 + { value: ImportEntityColumnType.routingKey },
  101 + { value: ImportEntityColumnType.secret }
  102 + );
  103 + break;
96 104 }
97 105 }
98 106
... ...
... ... @@ -36,6 +36,8 @@ export class HomeDialogsService {
36 36 return this.openImportDialogCSV(entityType, 'device.import', 'device.device-file');
37 37 case EntityType.ASSET:
38 38 return this.openImportDialogCSV(entityType, 'asset.import', 'asset.asset-file');
  39 + case EntityType.EDGE:
  40 + return this.openImportDialogCSV(entityType, 'edge.import', 'edge.edge-file');
39 41 }
40 42 }
41 43
... ...
... ... @@ -43,6 +43,10 @@ export interface ImportEntityData {
43 43 shared: AttributeData[]
44 44 };
45 45 timeseries: AttributeData[];
  46 + secret: string;
  47 + routingKey: string;
  48 + cloudEndpoint: string;
  49 + edgeLicenseKey: string;
46 50 }
47 51
48 52 export interface ImportEntitiesResultInfo {
... ...