Browse Source

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

Develop/2.6 edge Import edge
pull/3693/head
VoBa 6 years ago
committed by GitHub
parent
commit
a63d6af6ba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      ui/src/app/api/edge.service.js
  2. 17
      ui/src/app/api/entity.service.js
  3. 16
      ui/src/app/common/types.constant.js
  4. 2
      ui/src/app/dashboard/dashboards.controller.js
  5. 18
      ui/src/app/import-export/import-dialog-csv.controller.js
  6. 38
      ui/src/app/import-export/table-columns-assignment.directive.js
  7. 6
      ui/src/app/locale/locale.constant-en_US.json

21
ui/src/app/api/edge.service.js

@ -31,6 +31,7 @@ function EdgeService($http, $q, customerService) {
getCustomerEdges: getCustomerEdges, getCustomerEdges: getCustomerEdges,
assignEdgeToCustomer: assignEdgeToCustomer, assignEdgeToCustomer: assignEdgeToCustomer,
findByQuery: findByQuery, findByQuery: findByQuery,
findByName: findByName,
unassignEdgeFromCustomer: unassignEdgeFromCustomer, unassignEdgeFromCustomer: unassignEdgeFromCustomer,
makeEdgePublic: makeEdgePublic, makeEdgePublic: makeEdgePublic,
setRootRuleChain: setRootRuleChain, setRootRuleChain: setRootRuleChain,
@ -95,10 +96,14 @@ function EdgeService($http, $q, customerService) {
return deferred.promise; return deferred.promise;
} }
function saveEdge(edge) { function saveEdge(edge, ignoreErrors, config) {
var deferred = $q.defer(); var deferred = $q.defer();
var url = '/api/edge'; 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); deferred.resolve(response.data);
}, function fail(response) { }, function fail(response) {
deferred.reject(response.data); deferred.reject(response.data);
@ -214,6 +219,18 @@ function EdgeService($http, $q, customerService) {
return deferred.promise; 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) { function assignEdgeToCustomer(customerId, edgeId) {
var deferred = $q.defer(); var deferred = $q.defer();
var url = '/api/customer/' + customerId + '/edge/' + edgeId; var url = '/api/customer/' + customerId + '/edge/' + edgeId;

17
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); let saveEntityPromise = getEntitySavePromise(entityType, newEntity, config);
saveEntityPromise.then(function success(response) { saveEntityPromise.then(function success(response) {
@ -1301,6 +1312,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
case types.entityType.asset: case types.entityType.asset:
findIdEntity = assetService.findByName(entityParameters.name, config); findIdEntity = assetService.findByName(entityParameters.name, config);
break; break;
case types.entityType.edge:
findIdEntity = edgeService.findByName(entityParameters.name, config);
break;
} }
findIdEntity.then(function success(response) { findIdEntity.then(function success(response) {
let promises = []; let promises = [];
@ -1347,6 +1361,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
case types.entityType.asset: case types.entityType.asset:
promise = assetService.saveAsset(newEntity, true, config); promise = assetService.saveAsset(newEntity, true, config);
break; break;
case types.entityType.edge:
promise = edgeService.saveEdge(newEntity, true, config);
break;
} }
return promise; return promise;
} }

16
ui/src/app/common/types.constant.js

@ -465,6 +465,22 @@ export default angular.module('thingsboard.types', [])
description: { description: {
name: 'import.column-type.description', name: 'import.column-type.description',
value: '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: { aliasEntityType: {

2
ui/src/app/dashboard/dashboards.controller.js

@ -383,7 +383,7 @@ export function DashboardsController(userService, dashboardService, customerServ
} }
} else if (vm.dashboardsScope === 'edge') { } else if (vm.dashboardsScope === 'edge') {
fetchDashboardsFunction = function (pageLink) { fetchDashboardsFunction = function (pageLink) {
return dashboardService.getEdgeDashboards(edgeId, pageLink); return dashboardService.getEdgeDashboards(edgeId, pageLink, null);
}; };
deleteDashboardFunction = function (dashboardId) { deleteDashboardFunction = function (dashboardId) {
return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId); return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);

18
ui/src/app/import-export/import-dialog-csv.controller.js

@ -135,7 +135,11 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
server: [], server: [],
shared: [] shared: []
}, },
timeseries: [] timeseries: [],
edgeLicenseKey: "",
cloudEndpoint: "",
routingKey: "",
secret: ""
}; };
for (var j = 0; j < parameterColumns.length; j++) { for (var j = 0; j < parameterColumns.length; j++) {
switch (parameterColumns[j].type) { switch (parameterColumns[j].type) {
@ -175,6 +179,18 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
case types.importEntityColumnType.description.value: case types.importEntityColumnType.description.value:
entityData.description = importData.rows[i][j]; entityData.description = importData.rows[i][j];
break; 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); entitiesData.push(entityData);

38
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.serverAttribute = types.importEntityColumnType.serverAttribute;
vm.columnTypes.timeseries = types.importEntityColumnType.timeseries; vm.columnTypes.timeseries = types.importEntityColumnType.timeseries;
break; 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) { $scope.isColumnTypeDiffers = function(columnType) {
@ -66,7 +72,11 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
columnType !== types.importEntityColumnType.label.value && columnType !== types.importEntityColumnType.label.value &&
columnType !== types.importEntityColumnType.accessToken.value&& columnType !== types.importEntityColumnType.accessToken.value&&
columnType !== types.importEntityColumnType.isGateway.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){ $scope.$watch('vm.columns', function(newVal){
@ -77,6 +87,10 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
var isSelectCredentials = false; var isSelectCredentials = false;
var isSelectGateway = false; var isSelectGateway = false;
var isSelectDescription = false; var isSelectDescription = false;
var isSelectEdgeLicenseKey = false;
var isSelectCloudEndpoint = false;
var isSelectRoutingKey = false;
var isSelectSecret = false;
for (var i = 0; i < newVal.length; i++) { for (var i = 0; i < newVal.length; i++) {
switch (newVal[i].type) { switch (newVal[i].type) {
case types.importEntityColumnType.name.value: case types.importEntityColumnType.name.value:
@ -94,6 +108,18 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
case types.importEntityColumnType.isGateway.value: case types.importEntityColumnType.isGateway.value:
isSelectGateway = true; isSelectGateway = true;
break; 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: case types.importEntityColumnType.description.value:
isSelectDescription = true; isSelectDescription = true;
} }
@ -107,11 +133,19 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
vm.columnTypes.name.disable = isSelectName; vm.columnTypes.name.disable = isSelectName;
vm.columnTypes.type.disable = isSelectType; vm.columnTypes.type.disable = isSelectType;
vm.columnTypes.label.disable = isSelectLabel; 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; vm.columnTypes.description.disable = isSelectDescription;
if (angular.isDefined(vm.columnTypes.accessToken)) { if (angular.isDefined(vm.columnTypes.accessToken)) {
vm.columnTypes.accessToken.disable = isSelectCredentials; 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); }, true);

6
ui/src/app/locale/locale.constant-en_US.json

@ -1405,7 +1405,11 @@
"entity-field": "Entity field", "entity-field": "Entity field",
"access-token": "Access token", "access-token": "Access token",
"isgateway": "Is Gateway", "isgateway": "Is Gateway",
"description": "Description" "description": "Description",
"edgeLicenseKey": "License Key",
"cloudEndpoint": "Cloud Endpoint",
"routingKey": "Edge key",
"secret": "Edge secret"
}, },
"stepper-text":{ "stepper-text":{
"select-file": "Select a file", "select-file": "Select a file",

Loading…
Cancel
Save