Skip to content

Commit

Permalink
fix(admin-ui): Fix display of string results in JobQueue list
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Mar 23, 2021
1 parent 6373d9f commit 10899f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,12 +25,19 @@ 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));
}

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 }));
}
}

0 comments on commit 10899f3

Please sign in to comment.