Commit a63d6af6ba05956c7ba63d579102fcabeb141be5
Committed by
GitHub
Merge pull request #65 from deaflynx/develop/2.6-edge
Develop/2.6 edge Import edge
Showing
7 changed files
with
111 additions
and
7 deletions
@@ -31,6 +31,7 @@ function EdgeService($http, $q, customerService) { | @@ -31,6 +31,7 @@ function EdgeService($http, $q, customerService) { | ||
31 | getCustomerEdges: getCustomerEdges, | 31 | getCustomerEdges: getCustomerEdges, |
32 | assignEdgeToCustomer: assignEdgeToCustomer, | 32 | assignEdgeToCustomer: assignEdgeToCustomer, |
33 | findByQuery: findByQuery, | 33 | findByQuery: findByQuery, |
34 | + findByName: findByName, | ||
34 | unassignEdgeFromCustomer: unassignEdgeFromCustomer, | 35 | unassignEdgeFromCustomer: unassignEdgeFromCustomer, |
35 | makeEdgePublic: makeEdgePublic, | 36 | makeEdgePublic: makeEdgePublic, |
36 | setRootRuleChain: setRootRuleChain, | 37 | setRootRuleChain: setRootRuleChain, |
@@ -95,10 +96,14 @@ function EdgeService($http, $q, customerService) { | @@ -95,10 +96,14 @@ function EdgeService($http, $q, customerService) { | ||
95 | return deferred.promise; | 96 | return deferred.promise; |
96 | } | 97 | } |
97 | 98 | ||
98 | - function saveEdge(edge) { | 99 | + function saveEdge(edge, ignoreErrors, config) { |
99 | var deferred = $q.defer(); | 100 | var deferred = $q.defer(); |
100 | var url = '/api/edge'; | 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 | deferred.resolve(response.data); | 107 | deferred.resolve(response.data); |
103 | }, function fail(response) { | 108 | }, function fail(response) { |
104 | deferred.reject(response.data); | 109 | deferred.reject(response.data); |
@@ -214,6 +219,18 @@ function EdgeService($http, $q, customerService) { | @@ -214,6 +219,18 @@ function EdgeService($http, $q, customerService) { | ||
214 | return deferred.promise; | 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 | function assignEdgeToCustomer(customerId, edgeId) { | 234 | function assignEdgeToCustomer(customerId, edgeId) { |
218 | var deferred = $q.defer(); | 235 | var deferred = $q.defer(); |
219 | var url = '/api/customer/' + customerId + '/edge/' + edgeId; | 236 | var url = '/api/customer/' + customerId + '/edge/' + edgeId; |
@@ -1277,6 +1277,17 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | @@ -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 | let saveEntityPromise = getEntitySavePromise(entityType, newEntity, config); | 1291 | let saveEntityPromise = getEntitySavePromise(entityType, newEntity, config); |
1281 | 1292 | ||
1282 | saveEntityPromise.then(function success(response) { | 1293 | saveEntityPromise.then(function success(response) { |
@@ -1301,6 +1312,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | @@ -1301,6 +1312,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | ||
1301 | case types.entityType.asset: | 1312 | case types.entityType.asset: |
1302 | findIdEntity = assetService.findByName(entityParameters.name, config); | 1313 | findIdEntity = assetService.findByName(entityParameters.name, config); |
1303 | break; | 1314 | break; |
1315 | + case types.entityType.edge: | ||
1316 | + findIdEntity = edgeService.findByName(entityParameters.name, config); | ||
1317 | + break; | ||
1304 | } | 1318 | } |
1305 | findIdEntity.then(function success(response) { | 1319 | findIdEntity.then(function success(response) { |
1306 | let promises = []; | 1320 | let promises = []; |
@@ -1347,6 +1361,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | @@ -1347,6 +1361,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | ||
1347 | case types.entityType.asset: | 1361 | case types.entityType.asset: |
1348 | promise = assetService.saveAsset(newEntity, true, config); | 1362 | promise = assetService.saveAsset(newEntity, true, config); |
1349 | break; | 1363 | break; |
1364 | + case types.entityType.edge: | ||
1365 | + promise = edgeService.saveEdge(newEntity, true, config); | ||
1366 | + break; | ||
1350 | } | 1367 | } |
1351 | return promise; | 1368 | return promise; |
1352 | } | 1369 | } |
@@ -465,6 +465,22 @@ export default angular.module('thingsboard.types', []) | @@ -465,6 +465,22 @@ export default angular.module('thingsboard.types', []) | ||
465 | description: { | 465 | description: { |
466 | name: 'import.column-type.description', | 466 | name: 'import.column-type.description', |
467 | value: 'description' | 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 | aliasEntityType: { | 486 | aliasEntityType: { |
@@ -383,7 +383,7 @@ export function DashboardsController(userService, dashboardService, customerServ | @@ -383,7 +383,7 @@ export function DashboardsController(userService, dashboardService, customerServ | ||
383 | } | 383 | } |
384 | } else if (vm.dashboardsScope === 'edge') { | 384 | } else if (vm.dashboardsScope === 'edge') { |
385 | fetchDashboardsFunction = function (pageLink) { | 385 | fetchDashboardsFunction = function (pageLink) { |
386 | - return dashboardService.getEdgeDashboards(edgeId, pageLink); | 386 | + return dashboardService.getEdgeDashboards(edgeId, pageLink, null); |
387 | }; | 387 | }; |
388 | deleteDashboardFunction = function (dashboardId) { | 388 | deleteDashboardFunction = function (dashboardId) { |
389 | return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId); | 389 | return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId); |
@@ -135,7 +135,11 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo | @@ -135,7 +135,11 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo | ||
135 | server: [], | 135 | server: [], |
136 | shared: [] | 136 | shared: [] |
137 | }, | 137 | }, |
138 | - timeseries: [] | 138 | + timeseries: [], |
139 | + edgeLicenseKey: "", | ||
140 | + cloudEndpoint: "", | ||
141 | + routingKey: "", | ||
142 | + secret: "" | ||
139 | }; | 143 | }; |
140 | for (var j = 0; j < parameterColumns.length; j++) { | 144 | for (var j = 0; j < parameterColumns.length; j++) { |
141 | switch (parameterColumns[j].type) { | 145 | switch (parameterColumns[j].type) { |
@@ -175,6 +179,18 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo | @@ -175,6 +179,18 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo | ||
175 | case types.importEntityColumnType.description.value: | 179 | case types.importEntityColumnType.description.value: |
176 | entityData.description = importData.rows[i][j]; | 180 | entityData.description = importData.rows[i][j]; |
177 | break; | 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 | entitiesData.push(entityData); | 196 | entitiesData.push(entityData); |
@@ -58,6 +58,12 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | @@ -58,6 +58,12 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | ||
58 | vm.columnTypes.serverAttribute = types.importEntityColumnType.serverAttribute; | 58 | vm.columnTypes.serverAttribute = types.importEntityColumnType.serverAttribute; |
59 | vm.columnTypes.timeseries = types.importEntityColumnType.timeseries; | 59 | vm.columnTypes.timeseries = types.importEntityColumnType.timeseries; |
60 | break; | 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 | $scope.isColumnTypeDiffers = function(columnType) { | 69 | $scope.isColumnTypeDiffers = function(columnType) { |
@@ -66,7 +72,11 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | @@ -66,7 +72,11 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | ||
66 | columnType !== types.importEntityColumnType.label.value && | 72 | columnType !== types.importEntityColumnType.label.value && |
67 | columnType !== types.importEntityColumnType.accessToken.value&& | 73 | columnType !== types.importEntityColumnType.accessToken.value&& |
68 | columnType !== types.importEntityColumnType.isGateway.value&& | 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 | $scope.$watch('vm.columns', function(newVal){ | 82 | $scope.$watch('vm.columns', function(newVal){ |
@@ -77,6 +87,10 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | @@ -77,6 +87,10 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | ||
77 | var isSelectCredentials = false; | 87 | var isSelectCredentials = false; |
78 | var isSelectGateway = false; | 88 | var isSelectGateway = false; |
79 | var isSelectDescription = false; | 89 | var isSelectDescription = false; |
90 | + var isSelectEdgeLicenseKey = false; | ||
91 | + var isSelectCloudEndpoint = false; | ||
92 | + var isSelectRoutingKey = false; | ||
93 | + var isSelectSecret = false; | ||
80 | for (var i = 0; i < newVal.length; i++) { | 94 | for (var i = 0; i < newVal.length; i++) { |
81 | switch (newVal[i].type) { | 95 | switch (newVal[i].type) { |
82 | case types.importEntityColumnType.name.value: | 96 | case types.importEntityColumnType.name.value: |
@@ -94,6 +108,18 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | @@ -94,6 +108,18 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | ||
94 | case types.importEntityColumnType.isGateway.value: | 108 | case types.importEntityColumnType.isGateway.value: |
95 | isSelectGateway = true; | 109 | isSelectGateway = true; |
96 | break; | 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 | case types.importEntityColumnType.description.value: | 123 | case types.importEntityColumnType.description.value: |
98 | isSelectDescription = true; | 124 | isSelectDescription = true; |
99 | } | 125 | } |
@@ -107,11 +133,19 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | @@ -107,11 +133,19 @@ function TableColumnsAssignmentController($scope, types, $timeout) { | ||
107 | vm.columnTypes.name.disable = isSelectName; | 133 | vm.columnTypes.name.disable = isSelectName; |
108 | vm.columnTypes.type.disable = isSelectType; | 134 | vm.columnTypes.type.disable = isSelectType; |
109 | vm.columnTypes.label.disable = isSelectLabel; | 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 | vm.columnTypes.description.disable = isSelectDescription; | 139 | vm.columnTypes.description.disable = isSelectDescription; |
112 | if (angular.isDefined(vm.columnTypes.accessToken)) { | 140 | if (angular.isDefined(vm.columnTypes.accessToken)) { |
113 | vm.columnTypes.accessToken.disable = isSelectCredentials; | 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 | }, true); | 151 | }, true); |
@@ -1405,7 +1405,11 @@ | @@ -1405,7 +1405,11 @@ | ||
1405 | "entity-field": "Entity field", | 1405 | "entity-field": "Entity field", |
1406 | "access-token": "Access token", | 1406 | "access-token": "Access token", |
1407 | "isgateway": "Is Gateway", | 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 | "stepper-text":{ | 1414 | "stepper-text":{ |
1411 | "select-file": "Select a file", | 1415 | "select-file": "Select a file", |