Merge pull request #3277 from mp-loki/feature/sorted-metadata-keys
Display sorted metadata keys in rule nodes
This commit is contained in:
commit
2202ef7814
@ -150,7 +150,8 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
|
||||
customTranslation: customTranslation,
|
||||
objToBase64: objToBase64,
|
||||
base64toObj: base64toObj,
|
||||
loadImageAspect: loadImageAspect
|
||||
loadImageAspect: loadImageAspect,
|
||||
sortObjectKeys: sortObjectKeys
|
||||
}
|
||||
|
||||
return service;
|
||||
@ -605,4 +606,14 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function sortObjectKeys(obj) {
|
||||
var sortedObj = {};
|
||||
var keys = Object.keys(obj).sort();
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
sortedObj[key] = obj[key];
|
||||
}
|
||||
return sortedObj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html';
|
||||
/* eslint-enable import/no-unresolved, import/default */
|
||||
|
||||
/*@ngInject*/
|
||||
export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types) {
|
||||
export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types, utils) {
|
||||
|
||||
var linker = function (scope, element, attrs) {
|
||||
|
||||
@ -71,11 +71,18 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $
|
||||
if (!contentType) {
|
||||
contentType = null;
|
||||
}
|
||||
var sortedContent;
|
||||
try {
|
||||
sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content)));
|
||||
}
|
||||
catch(err) {
|
||||
sortedContent = content;
|
||||
}
|
||||
$mdDialog.show({
|
||||
controller: 'EventContentDialogController',
|
||||
controllerAs: 'vm',
|
||||
templateUrl: eventErrorDialogTemplate,
|
||||
locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback},
|
||||
locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback},
|
||||
parent: angular.element($document[0].body),
|
||||
fullscreen: true,
|
||||
targetEvent: $event,
|
||||
|
||||
@ -20,7 +20,7 @@ import nodeScriptTestTemplate from './node-script-test.tpl.html';
|
||||
/* eslint-enable import/no-unresolved, import/default */
|
||||
|
||||
/*@ngInject*/
|
||||
export default function NodeScriptTest($q, $mdDialog, $document, ruleChainService) {
|
||||
export default function NodeScriptTest($q, $mdDialog, $document, ruleChainService, utils) {
|
||||
|
||||
var service = {
|
||||
testNodeScript: testNodeScript
|
||||
@ -89,6 +89,8 @@ export default function NodeScriptTest($q, $mdDialog, $document, ruleChainServic
|
||||
deviceName: "Test Device",
|
||||
ts: new Date().getTime() + ""
|
||||
};
|
||||
} else {
|
||||
metadata = utils.sortObjectKeys(metadata);
|
||||
}
|
||||
if (!msgType) {
|
||||
msgType = "POST_TELEMETRY_REQUEST";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user