Commit a63d6af6ba05956c7ba63d579102fcabeb141be5

Authored by VoBa
Committed by GitHub
2 parents 36b8bc45 e23d2c74

Merge pull request #65 from deaflynx/develop/2.6-edge

Develop/2.6 edge Import edge
... ... @@ -31,6 +31,7 @@ function EdgeService($http, $q, customerService) {
31 31 getCustomerEdges: getCustomerEdges,
32 32 assignEdgeToCustomer: assignEdgeToCustomer,
33 33 findByQuery: findByQuery,
  34 + findByName: findByName,
34 35 unassignEdgeFromCustomer: unassignEdgeFromCustomer,
35 36 makeEdgePublic: makeEdgePublic,
36 37 setRootRuleChain: setRootRuleChain,
... ... @@ -95,10 +96,14 @@ function EdgeService($http, $q, customerService) {
95 96 return deferred.promise;
96 97 }
97 98
98   - function saveEdge(edge) {
  99 + function saveEdge(edge, ignoreErrors, config) {
99 100 var deferred = $q.defer();
100 101 var url = '/api/edge';
101   - $http.post(url, edge).then(function success(response) {
  102 + if (!config) {
  103 + config = {};
  104 + }
  105 + config = Object.assign(config, { ignoreErrors: ignoreErrors });
  106 + $http.post(url, edge, config).then(function success(response) {
102 107 deferred.resolve(response.data);
103 108 }, function fail(response) {
104 109 deferred.reject(response.data);
... ... @@ -214,6 +219,18 @@ function EdgeService($http, $q, customerService) {
214 219 return deferred.promise;
215 220 }
216 221
  222 + function findByName(edgeName, config) {
  223 + config = config || {};
  224 + var deferred = $q.defer();
  225 + var url = '/api/tenant/edges?edgeName=' + edgeName;
  226 + $http.get(url, config).then(function success(response) {
  227 + deferred.resolve(response.data);
  228 + }, function fail() {
  229 + deferred.reject();
  230 + });
  231 + return deferred.promise;
  232 + }
  233 +
217 234 function assignEdgeToCustomer(customerId, edgeId) {
218 235 var deferred = $q.defer();
219 236 var url = '/api/customer/' + customerId + '/edge/' + edgeId;
... ...
... ... @@ -1277,6 +1277,17 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
1277 1277 };
1278 1278 }
1279 1279
  1280 + if (entityType === types.entityType.edge) {
  1281 + Object.assign(newEntity,
  1282 + {
  1283 + edgeLicenseKey: entityParameters.edgeLicenseKey,
  1284 + cloudEndpoint: entityParameters.cloudEndpoint,
  1285 + routingKey: entityParameters.routingKey,
  1286 + secret: entityParameters.secret
  1287 + }
  1288 + );
  1289 + }
  1290 +
1280 1291 let saveEntityPromise = getEntitySavePromise(entityType, newEntity, config);
1281 1292
1282 1293 saveEntityPromise.then(function success(response) {
... ... @@ -1301,6 +1312,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
1301 1312 case types.entityType.asset:
1302 1313 findIdEntity = assetService.findByName(entityParameters.name, config);
1303 1314 break;
  1315 + case types.entityType.edge:
  1316 + findIdEntity = edgeService.findByName(entityParameters.name, config);
  1317 + break;
1304 1318 }
1305 1319 findIdEntity.then(function success(response) {
1306 1320 let promises = [];
... ... @@ -1347,6 +1361,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
1347 1361 case types.entityType.asset:
1348 1362 promise = assetService.saveAsset(newEntity, true, config);
1349 1363 break;
  1364 + case types.entityType.edge:
  1365 + promise = edgeService.saveEdge(newEntity, true, config);
  1366 + break;
1350 1367 }
1351 1368 return promise;
1352 1369 }
... ...
... ... @@ -465,6 +465,22 @@ export default angular.module('thingsboard.types', [])
465 465 description: {
466 466 name: 'import.column-type.description',
467 467 value: 'description'
  468 + },
  469 + edgeLicenseKey: {
  470 + name: 'import.column-type.edgeLicenseKey',
  471 + value: 'edgeLicenseKey'
  472 + },
  473 + cloudEndpoint: {
  474 + name: 'import.column-type.cloudEndpoint',
  475 + value: 'cloudEndpoint'
  476 + },
  477 + routingKey: {
  478 + name: 'import.column-type.routingKey',
  479 + value: 'routingKey'
  480 + },
  481 + secret: {
  482 + name: 'import.column-type.secret',
  483 + value: 'secret'
468 484 }
469 485 },
470 486 aliasEntityType: {
... ...
... ... @@ -383,7 +383,7 @@ export function DashboardsController(userService, dashboardService, customerServ
383 383 }
384 384 } else if (vm.dashboardsScope === 'edge') {
385 385 fetchDashboardsFunction = function (pageLink) {
386   - return dashboardService.getEdgeDashboards(edgeId, pageLink);
  386 + return dashboardService.getEdgeDashboards(edgeId, pageLink, null);
387 387 };
388 388 deleteDashboardFunction = function (dashboardId) {
389 389 return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);
... ...
... ... @@ -135,7 +135,11 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
135 135 server: [],
136 136 shared: []
137 137 },
138   - timeseries: []
  138 + timeseries: [],
  139 + edgeLicenseKey: "",
  140 + cloudEndpoint: "",
  141 + routingKey: "",
  142 + secret: ""
139 143 };
140 144 for (var j = 0; j < parameterColumns.length; j++) {
141 145 switch (parameterColumns[j].type) {
... ... @@ -175,6 +179,18 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
175 179 case types.importEntityColumnType.description.value:
176 180 entityData.description = importData.rows[i][j];
177 181 break;
  182 + case types.importEntityColumnType.edgeLicenseKey.value:
  183 + entityData.edgeLicenseKey = importData.rows[i][j];
  184 + break;
  185 + case types.importEntityColumnType.cloudEndpoint.value:
  186 + entityData.cloudEndpoint = importData.rows[i][j];
  187 + break;
  188 + case types.importEntityColumnType.routingKey.value:
  189 + entityData.routingKey = importData.rows[i][j];
  190 + break;
  191 + case types.importEntityColumnType.secret.value:
  192 + entityData.secret = importData.rows[i][j];
  193 + break;
178 194 }
179 195 }
180 196 entitiesData.push(entityData);
... ...
... ... @@ -58,6 +58,12 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
58 58 vm.columnTypes.serverAttribute = types.importEntityColumnType.serverAttribute;
59 59 vm.columnTypes.timeseries = types.importEntityColumnType.timeseries;
60 60 break;
  61 + case types.entityType.edge:
  62 + vm.columnTypes.edgeLicenseKey = types.importEntityColumnType.edgeLicenseKey;
  63 + vm.columnTypes.cloudEndpoint = types.importEntityColumnType.cloudEndpoint;
  64 + vm.columnTypes.routingKey = types.importEntityColumnType.routingKey;
  65 + vm.columnTypes.secret = types.importEntityColumnType.secret;
  66 + break;
61 67 }
62 68
63 69 $scope.isColumnTypeDiffers = function(columnType) {
... ... @@ -66,7 +72,11 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
66 72 columnType !== types.importEntityColumnType.label.value &&
67 73 columnType !== types.importEntityColumnType.accessToken.value&&
68 74 columnType !== types.importEntityColumnType.isGateway.value&&
69   - columnType !== types.importEntityColumnType.description.value;
  75 + columnType !== types.importEntityColumnType.description.value&&
  76 + columnType !== types.importEntityColumnType.edgeLicenseKey.value&&
  77 + columnType !== types.importEntityColumnType.cloudEndpoint.value&&
  78 + columnType !== types.importEntityColumnType.routingKey.value&&
  79 + columnType !== types.importEntityColumnType.secret.value;
70 80 };
71 81
72 82 $scope.$watch('vm.columns', function(newVal){
... ... @@ -77,6 +87,10 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
77 87 var isSelectCredentials = false;
78 88 var isSelectGateway = false;
79 89 var isSelectDescription = false;
  90 + var isSelectEdgeLicenseKey = false;
  91 + var isSelectCloudEndpoint = false;
  92 + var isSelectRoutingKey = false;
  93 + var isSelectSecret = false;
80 94 for (var i = 0; i < newVal.length; i++) {
81 95 switch (newVal[i].type) {
82 96 case types.importEntityColumnType.name.value:
... ... @@ -94,6 +108,18 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
94 108 case types.importEntityColumnType.isGateway.value:
95 109 isSelectGateway = true;
96 110 break;
  111 + case types.importEntityColumnType.edgeLicenseKey.value:
  112 + isSelectEdgeLicenseKey = true;
  113 + break;
  114 + case types.importEntityColumnType.cloudEndpoint.value:
  115 + isSelectCloudEndpoint = true;
  116 + break;
  117 + case types.importEntityColumnType.routingKey.value:
  118 + isSelectRoutingKey = true;
  119 + break;
  120 + case types.importEntityColumnType.secret.value:
  121 + isSelectSecret = true;
  122 + break;
97 123 case types.importEntityColumnType.description.value:
98 124 isSelectDescription = true;
99 125 }
... ... @@ -107,11 +133,19 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
107 133 vm.columnTypes.name.disable = isSelectName;
108 134 vm.columnTypes.type.disable = isSelectType;
109 135 vm.columnTypes.label.disable = isSelectLabel;
110   - vm.columnTypes.gateway.disable = isSelectGateway;
  136 + if (angular.isDefined(vm.columnTypes.gateway)) {
  137 + vm.columnTypes.gateway.disable = isSelectGateway;
  138 + }
111 139 vm.columnTypes.description.disable = isSelectDescription;
112 140 if (angular.isDefined(vm.columnTypes.accessToken)) {
113 141 vm.columnTypes.accessToken.disable = isSelectCredentials;
114 142 }
  143 + if (vm.entityType === types.entityType.edge) {
  144 + vm.columnTypes.edgeLicenseKey.disable = isSelectEdgeLicenseKey;
  145 + vm.columnTypes.cloudEndpoint.disable = isSelectCloudEndpoint;
  146 + vm.columnTypes.routingKey.disable = isSelectRoutingKey;
  147 + vm.columnTypes.secret.disable = isSelectSecret;
  148 + }
115 149 });
116 150 }
117 151 }, true);
... ...
... ... @@ -1405,7 +1405,11 @@
1405 1405 "entity-field": "Entity field",
1406 1406 "access-token": "Access token",
1407 1407 "isgateway": "Is Gateway",
1408   - "description": "Description"
  1408 + "description": "Description",
  1409 + "edgeLicenseKey": "License Key",
  1410 + "cloudEndpoint": "Cloud Endpoint",
  1411 + "routingKey": "Edge key",
  1412 + "secret": "Edge secret"
1409 1413 },
1410 1414 "stepper-text":{
1411 1415 "select-file": "Select a file",
... ...