Commit 87b23f4989062595509fb1820a1906fce5a8aae5

Authored by Valerii Sosliuk
1 parent 52bed174

Display sorted metadata keys in rule nodes

... ... @@ -150,7 +150,8 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
150 150 customTranslation: customTranslation,
151 151 objToBase64: objToBase64,
152 152 base64toObj: base64toObj,
153   - loadImageAspect: loadImageAspect
  153 + loadImageAspect: loadImageAspect,
  154 + sortObjectKeys: sortObjectKeys
154 155 }
155 156
156 157 return service;
... ... @@ -605,4 +606,14 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
605 606 return deferred.promise;
606 607 }
607 608
  609 + function sortObjectKeys(obj) {
  610 + var sortedObj = {};
  611 + var keys = Object.keys(obj).sort();
  612 + for (var i = 0; i < keys.length; i++) {
  613 + var key = keys[i];
  614 + sortedObj[key] = obj[key];
  615 + }
  616 + return sortedObj;
  617 + }
  618 +
608 619 }
... ...
... ... @@ -25,7 +25,7 @@ import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html';
25 25 /* eslint-enable import/no-unresolved, import/default */
26 26
27 27 /*@ngInject*/
28   -export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types) {
  28 +export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types, utils) {
29 29
30 30 var linker = function (scope, element, attrs) {
31 31
... ... @@ -71,11 +71,18 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $
71 71 if (!contentType) {
72 72 contentType = null;
73 73 }
  74 + var sortedContent;
  75 + try {
  76 + sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content)));
  77 + }
  78 + catch(err) {
  79 + sortedContent = content;
  80 + }
74 81 $mdDialog.show({
75 82 controller: 'EventContentDialogController',
76 83 controllerAs: 'vm',
77 84 templateUrl: eventErrorDialogTemplate,
78   - locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback},
  85 + locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback},
79 86 parent: angular.element($document[0].body),
80 87 fullscreen: true,
81 88 targetEvent: $event,
... ...
... ... @@ -20,7 +20,7 @@ import nodeScriptTestTemplate from './node-script-test.tpl.html';
20 20 /* eslint-enable import/no-unresolved, import/default */
21 21
22 22 /*@ngInject*/
23   -export default function NodeScriptTest($q, $mdDialog, $document, ruleChainService) {
  23 +export default function NodeScriptTest($q, $mdDialog, $document, ruleChainService, utils) {
24 24
25 25 var service = {
26 26 testNodeScript: testNodeScript
... ... @@ -89,6 +89,8 @@ export default function NodeScriptTest($q, $mdDialog, $document, ruleChainServic
89 89 deviceName: "Test Device",
90 90 ts: new Date().getTime() + ""
91 91 };
  92 + } else {
  93 + metadata = utils.sortObjectKeys(metadata);
92 94 }
93 95 if (!msgType) {
94 96 msgType = "POST_TELEMETRY_REQUEST";
... ...