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

Develop/2.6 edge Import edge
This commit is contained in:
VoBa 2020-12-18 08:24:05 +02:00 committed by GitHub
commit a63d6af6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 111 additions and 7 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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: {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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",