Showing
3 changed files
with
18 additions
and
1 deletions
... | ... | @@ -23,6 +23,7 @@ import { |
23 | 23 | NodeScriptTestDialogComponent, |
24 | 24 | NodeScriptTestDialogData |
25 | 25 | } from '@shared/components/dialog/node-script-test-dialog.component'; |
26 | +import { sortObjectKeys } from '@core/utils'; | |
26 | 27 | |
27 | 28 | @Injectable({ |
28 | 29 | providedIn: 'root' |
... | ... | @@ -75,6 +76,8 @@ export class NodeScriptTestService { |
75 | 76 | deviceName: 'Test Device', |
76 | 77 | ts: new Date().getTime() + '' |
77 | 78 | }; |
79 | + } else { | |
80 | + metadata = sortObjectKeys(metadata) as {[key: string]: string}; | |
78 | 81 | } |
79 | 82 | if (!msgType) { |
80 | 83 | msgType = 'POST_TELEMETRY_REQUEST'; | ... | ... |
... | ... | @@ -510,3 +510,10 @@ export function padValue(val: any, dec: number): string { |
510 | 510 | strVal = (n ? '-' : '') + strVal; |
511 | 511 | return strVal; |
512 | 512 | } |
513 | + | |
514 | +export function sortObjectKeys(obj: object): object{ | |
515 | + return Object.keys(obj).sort().reduce((acc,key)=>{ | |
516 | + acc[key]=obj[key]; | |
517 | + return acc; | |
518 | + },{}); | |
519 | +} | ... | ... |
... | ... | @@ -38,6 +38,7 @@ import { |
38 | 38 | EventContentDialogComponent, |
39 | 39 | EventContentDialogData |
40 | 40 | } from '@home/components/event/event-content-dialog.component'; |
41 | +import { sortObjectKeys } from '@core/utils'; | |
41 | 42 | |
42 | 43 | export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { |
43 | 44 | |
... | ... | @@ -233,11 +234,17 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { |
233 | 234 | if ($event) { |
234 | 235 | $event.stopPropagation(); |
235 | 236 | } |
237 | + let sortedContent: string; | |
238 | + try { | |
239 | + sortedContent = JSON.stringify(sortObjectKeys(JSON.parse(content))); | |
240 | + } catch() { | |
241 | + sortedContent = content; | |
242 | + } | |
236 | 243 | this.dialog.open<EventContentDialogComponent, EventContentDialogData>(EventContentDialogComponent, { |
237 | 244 | disableClose: true, |
238 | 245 | panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], |
239 | 246 | data: { |
240 | - content, | |
247 | + constent: sortedContent, | |
241 | 248 | title, |
242 | 249 | contentType |
243 | 250 | } | ... | ... |