Browse Source

fix(admin-ui): Fix display of string results in JobQueue list

Michael Bromley 4 years ago
parent
commit
10899f34bd

+ 1 - 1
packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.html

@@ -9,7 +9,7 @@
     [class.expanded]="expanded"
 >
     <li *ngFor="let entry of entries">
-        <span class="key">{{ entry.key }}:</span>
+        <span class="key" *ngIf="entry.key">{{ entry.key }}:</span>
         <ng-container *ngIf="isObject(entry.value)">
             <vdr-object-tree [value]="entry.value" [isArrayItem]="valueIsArray"></vdr-object-tree>
         </ng-container>

+ 9 - 2
packages/admin-ui/src/lib/core/src/shared/components/object-tree/object-tree.component.ts

@@ -10,7 +10,7 @@ import { ChangeDetectionStrategy, Component, Input, OnInit, Optional, SkipSelf }
     changeDetection: ChangeDetectionStrategy.OnPush,
 })
 export class ObjectTreeComponent implements OnInit {
-    @Input() value: { [key: string]: any };
+    @Input() value: { [key: string]: any } | string;
     @Input() isArrayItem = false;
     depth: number;
     expanded: boolean;
@@ -25,7 +25,7 @@ export class ObjectTreeComponent implements OnInit {
     }
 
     ngOnInit() {
-        this.entries = Object.entries(this.value).map(([key, value]) => ({ key, value }));
+        this.entries = this.getEntries(this.value);
         this.expanded = this.depth === 0 || this.isArrayItem;
         this.valueIsArray = Object.keys(this.value).every(v => Number.isInteger(+v));
     }
@@ -33,4 +33,11 @@ export class ObjectTreeComponent implements OnInit {
     isObject(value: any): boolean {
         return typeof value === 'object' && value !== null;
     }
+
+    private getEntries(inputValue: { [key: string]: any } | string): Array<{ key: string; value: any }> {
+        if (typeof inputValue === 'string') {
+            return [{ key: '', value: inputValue }];
+        }
+        return Object.entries(inputValue).map(([key, value]) => ({ key, value }));
+    }
 }