diff --git a/ui/src/app/api/edge.service.js b/ui/src/app/api/edge.service.js index 8cd7aa81c1..e8abec1fd9 100644 --- a/ui/src/app/api/edge.service.js +++ b/ui/src/app/api/edge.service.js @@ -31,6 +31,7 @@ function EdgeService($http, $q, customerService) { getCustomerEdges: getCustomerEdges, assignEdgeToCustomer: assignEdgeToCustomer, findByQuery: findByQuery, + findByName: findByName, unassignEdgeFromCustomer: unassignEdgeFromCustomer, makeEdgePublic: makeEdgePublic, setRootRuleChain: setRootRuleChain, @@ -95,10 +96,14 @@ function EdgeService($http, $q, customerService) { return deferred.promise; } - function saveEdge(edge) { + function saveEdge(edge, ignoreErrors, config) { var deferred = $q.defer(); var url = '/api/edge'; - $http.post(url, edge).then(function success(response) { + if (!config) { + config = {}; + } + config = Object.assign(config, { ignoreErrors: ignoreErrors }); + $http.post(url, edge, config).then(function success(response) { deferred.resolve(response.data); }, function fail(response) { deferred.reject(response.data); @@ -214,6 +219,18 @@ function EdgeService($http, $q, customerService) { return deferred.promise; } + function findByName(edgeName, config) { + config = config || {}; + var deferred = $q.defer(); + var url = '/api/tenant/edges?edgeName=' + edgeName; + $http.get(url, config).then(function success(response) { + deferred.resolve(response.data); + }, function fail() { + deferred.reject(); + }); + return deferred.promise; + } + function assignEdgeToCustomer(customerId, edgeId) { var deferred = $q.defer(); var url = '/api/customer/' + customerId + '/edge/' + edgeId; diff --git a/ui/src/app/api/entity.service.js b/ui/src/app/api/entity.service.js index 32fac7b5db..df684c334e 100644 --- a/ui/src/app/api/entity.service.js +++ b/ui/src/app/api/entity.service.js @@ -1277,6 +1277,17 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device }; } + if (entityType === types.entityType.edge) { + Object.assign(newEntity, + { + edgeLicenseKey: entityParameters.edgeLicenseKey, + cloudEndpoint: entityParameters.cloudEndpoint, + routingKey: entityParameters.routingKey, + secret: entityParameters.secret + } + ); + } + let saveEntityPromise = getEntitySavePromise(entityType, newEntity, config); saveEntityPromise.then(function success(response) { @@ -1301,6 +1312,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device case types.entityType.asset: findIdEntity = assetService.findByName(entityParameters.name, config); break; + case types.entityType.edge: + findIdEntity = edgeService.findByName(entityParameters.name, config); + break; } findIdEntity.then(function success(response) { let promises = []; @@ -1347,6 +1361,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device case types.entityType.asset: promise = assetService.saveAsset(newEntity, true, config); break; + case types.entityType.edge: + promise = edgeService.saveEdge(newEntity, true, config); + break; } return promise; } diff --git a/ui/src/app/common/types.constant.js b/ui/src/app/common/types.constant.js index 998e2b612e..a9a833bd7e 100644 --- a/ui/src/app/common/types.constant.js +++ b/ui/src/app/common/types.constant.js @@ -465,6 +465,22 @@ export default angular.module('thingsboard.types', []) description: { name: 'import.column-type.description', value: 'description' + }, + edgeLicenseKey: { + name: 'import.column-type.edgeLicenseKey', + value: 'edgeLicenseKey' + }, + cloudEndpoint: { + name: 'import.column-type.cloudEndpoint', + value: 'cloudEndpoint' + }, + routingKey: { + name: 'import.column-type.routingKey', + value: 'routingKey' + }, + secret: { + name: 'import.column-type.secret', + value: 'secret' } }, aliasEntityType: { diff --git a/ui/src/app/dashboard/dashboards.controller.js b/ui/src/app/dashboard/dashboards.controller.js index f5fc50d538..4186745ff4 100644 --- a/ui/src/app/dashboard/dashboards.controller.js +++ b/ui/src/app/dashboard/dashboards.controller.js @@ -383,7 +383,7 @@ export function DashboardsController(userService, dashboardService, customerServ } } else if (vm.dashboardsScope === 'edge') { fetchDashboardsFunction = function (pageLink) { - return dashboardService.getEdgeDashboards(edgeId, pageLink); + return dashboardService.getEdgeDashboards(edgeId, pageLink, null); }; deleteDashboardFunction = function (dashboardId) { return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId); diff --git a/ui/src/app/import-export/import-dialog-csv.controller.js b/ui/src/app/import-export/import-dialog-csv.controller.js index 4ae2a7a9f0..d109291bb7 100644 --- a/ui/src/app/import-export/import-dialog-csv.controller.js +++ b/ui/src/app/import-export/import-dialog-csv.controller.js @@ -135,7 +135,11 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo server: [], shared: [] }, - timeseries: [] + timeseries: [], + edgeLicenseKey: "", + cloudEndpoint: "", + routingKey: "", + secret: "" }; for (var j = 0; j < parameterColumns.length; j++) { switch (parameterColumns[j].type) { @@ -175,6 +179,18 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo case types.importEntityColumnType.description.value: entityData.description = importData.rows[i][j]; break; + case types.importEntityColumnType.edgeLicenseKey.value: + entityData.edgeLicenseKey = importData.rows[i][j]; + break; + case types.importEntityColumnType.cloudEndpoint.value: + entityData.cloudEndpoint = importData.rows[i][j]; + break; + case types.importEntityColumnType.routingKey.value: + entityData.routingKey = importData.rows[i][j]; + break; + case types.importEntityColumnType.secret.value: + entityData.secret = importData.rows[i][j]; + break; } } entitiesData.push(entityData); diff --git a/ui/src/app/import-export/table-columns-assignment.directive.js b/ui/src/app/import-export/table-columns-assignment.directive.js index a295621799..012f7afad5 100644 --- a/ui/src/app/import-export/table-columns-assignment.directive.js +++ b/ui/src/app/import-export/table-columns-assignment.directive.js @@ -58,6 +58,12 @@ function TableColumnsAssignmentController($scope, types, $timeout) { vm.columnTypes.serverAttribute = types.importEntityColumnType.serverAttribute; vm.columnTypes.timeseries = types.importEntityColumnType.timeseries; break; + case types.entityType.edge: + vm.columnTypes.edgeLicenseKey = types.importEntityColumnType.edgeLicenseKey; + vm.columnTypes.cloudEndpoint = types.importEntityColumnType.cloudEndpoint; + vm.columnTypes.routingKey = types.importEntityColumnType.routingKey; + vm.columnTypes.secret = types.importEntityColumnType.secret; + break; } $scope.isColumnTypeDiffers = function(columnType) { @@ -66,7 +72,11 @@ function TableColumnsAssignmentController($scope, types, $timeout) { columnType !== types.importEntityColumnType.label.value && columnType !== types.importEntityColumnType.accessToken.value&& columnType !== types.importEntityColumnType.isGateway.value&& - columnType !== types.importEntityColumnType.description.value; + columnType !== types.importEntityColumnType.description.value&& + columnType !== types.importEntityColumnType.edgeLicenseKey.value&& + columnType !== types.importEntityColumnType.cloudEndpoint.value&& + columnType !== types.importEntityColumnType.routingKey.value&& + columnType !== types.importEntityColumnType.secret.value; }; $scope.$watch('vm.columns', function(newVal){ @@ -77,6 +87,10 @@ function TableColumnsAssignmentController($scope, types, $timeout) { var isSelectCredentials = false; var isSelectGateway = false; var isSelectDescription = false; + var isSelectEdgeLicenseKey = false; + var isSelectCloudEndpoint = false; + var isSelectRoutingKey = false; + var isSelectSecret = false; for (var i = 0; i < newVal.length; i++) { switch (newVal[i].type) { case types.importEntityColumnType.name.value: @@ -94,6 +108,18 @@ function TableColumnsAssignmentController($scope, types, $timeout) { case types.importEntityColumnType.isGateway.value: isSelectGateway = true; break; + case types.importEntityColumnType.edgeLicenseKey.value: + isSelectEdgeLicenseKey = true; + break; + case types.importEntityColumnType.cloudEndpoint.value: + isSelectCloudEndpoint = true; + break; + case types.importEntityColumnType.routingKey.value: + isSelectRoutingKey = true; + break; + case types.importEntityColumnType.secret.value: + isSelectSecret = true; + break; case types.importEntityColumnType.description.value: isSelectDescription = true; } @@ -107,11 +133,19 @@ function TableColumnsAssignmentController($scope, types, $timeout) { vm.columnTypes.name.disable = isSelectName; vm.columnTypes.type.disable = isSelectType; vm.columnTypes.label.disable = isSelectLabel; - vm.columnTypes.gateway.disable = isSelectGateway; + if (angular.isDefined(vm.columnTypes.gateway)) { + vm.columnTypes.gateway.disable = isSelectGateway; + } vm.columnTypes.description.disable = isSelectDescription; if (angular.isDefined(vm.columnTypes.accessToken)) { vm.columnTypes.accessToken.disable = isSelectCredentials; } + if (vm.entityType === types.entityType.edge) { + vm.columnTypes.edgeLicenseKey.disable = isSelectEdgeLicenseKey; + vm.columnTypes.cloudEndpoint.disable = isSelectCloudEndpoint; + vm.columnTypes.routingKey.disable = isSelectRoutingKey; + vm.columnTypes.secret.disable = isSelectSecret; + } }); } }, true); diff --git a/ui/src/app/locale/locale.constant-en_US.json b/ui/src/app/locale/locale.constant-en_US.json index 4611500969..17fc467285 100644 --- a/ui/src/app/locale/locale.constant-en_US.json +++ b/ui/src/app/locale/locale.constant-en_US.json @@ -1405,7 +1405,11 @@ "entity-field": "Entity field", "access-token": "Access token", "isgateway": "Is Gateway", - "description": "Description" + "description": "Description", + "edgeLicenseKey": "License Key", + "cloudEndpoint": "Cloud Endpoint", + "routingKey": "Edge key", + "secret": "Edge secret" }, "stepper-text":{ "select-file": "Select a file",