@@ -69,4 +69,34 @@
+
+
+
+
+
+
+
+
+ {{ 'edge.copy-edge-key' | translate }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ 'edge.copy-edge-secret' | translate }}
+
+
+
diff --git a/ui/src/app/edge/edge.directive.js b/ui/src/app/edge/edge.directive.js
index cbc4d6d10f..5eed24e823 100644
--- a/ui/src/app/edge/edge.directive.js
+++ b/ui/src/app/edge/edge.directive.js
@@ -20,7 +20,7 @@ import edgeFieldsetTemplate from './edge-fieldset.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
/*@ngInject*/
-export default function EdgeDirective($compile, $templateCache, $translate, $mdDialog, $document, toast, types, customerService) {
+export default function EdgeDirective($compile, $templateCache, $translate, $mdDialog, $document, utils, toast, types, customerService) {
var linker = function (scope, element) {
var template = $templateCache.get(edgeFieldsetTemplate);
element.html(template);
@@ -32,6 +32,10 @@ export default function EdgeDirective($compile, $templateCache, $translate, $mdD
scope.$watch('edge', function(newVal) {
if (newVal) {
+ if (!scope.edge.id) {
+ scope.edge.routingKey = utils.guid('');
+ scope.edge.secret = generateSecret(20);
+ }
if (scope.edge.customerId && scope.edge.customerId.id !== types.id.nullUid) {
scope.isAssignedToCustomer = true;
customerService.getShortCustomerInfo(scope.edge.customerId.id).then(
@@ -48,12 +52,38 @@ export default function EdgeDirective($compile, $templateCache, $translate, $mdD
}
});
+ function generateSecret(length) {
+ if (angular.isUndefined(length) || length == null) {
+ length = 1;
+ }
+ var l = length > 10 ? 10 : length;
+ var str = Math.random().toString(36).substr(2, l);
+ if(str.length >= length){
+ return str;
+ }
+ return str.concat(generateSecret(length - str.length));
+ }
+
scope.onEdgeIdCopied = function() {
toast.showSuccess($translate.instant('edge.id-copied-message'), 750, angular.element(element).parent().parent(), 'bottom left');
};
$compile(element.contents())(scope);
+ scope.onEdgeInfoCopied = function(type) {
+ let translateInstant = "";
+ switch (type) {
+ case 'key':
+ translateInstant = "edge.edge-key-copied-message";
+ break;
+ case 'secret':
+ translateInstant = "edge.edge-secret-copied-message";
+ break;
+ }
+ toast.showSuccess($translate.instant(translateInstant), 750, angular.element(element).parent().parent(), 'top left');
+ };
+
+
};
return {
restrict: "E",
diff --git a/ui/src/app/import-export/import-export.service.js b/ui/src/app/import-export/import-export.service.js
index 610a5afdea..1a130a71ef 100644
--- a/ui/src/app/import-export/import-export.service.js
+++ b/ui/src/app/import-export/import-export.service.js
@@ -602,6 +602,16 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document,
}
);
return deferred.promise;
+ case types.entityType.edge:
+ openImportDialogCSV($event, entityType, 'edge.import', 'edge.edge-file').then(
+ function success() {
+ deferred.resolve();
+ },
+ function fail() {
+ deferred.reject();
+ }
+ );
+ return deferred.promise;
}
}
diff --git a/ui/src/app/locale/locale.constant-en_US.json b/ui/src/app/locale/locale.constant-en_US.json
index 8add2421dd..f20a324129 100644
--- a/ui/src/app/locale/locale.constant-en_US.json
+++ b/ui/src/app/locale/locale.constant-en_US.json
@@ -777,7 +777,13 @@
"unassign-from-edge": "Unassign from edge",
"dashboards": "Edge Dashboards",
"manage-edge-rulechains": "Manage edge rule chains",
- "rulechains": "Edge Rule Chains"
+ "rulechains": "Edge Rule Chains",
+ "edge-key": "Edge key",
+ "copy-edge-key": "Copy edge key",
+ "edge-key-copied-message": "Edge key has been copied to clipboard",
+ "edge-secret": "Edge secret",
+ "copy-edge-secret": "Copy edge secret",
+ "edge-secret-copied-message": "Edge secret has been copied to clipboard"
},
"error": {
"unable-to-connect": "Unable to connect to the server! Please check your internet connection.",