|
|
@ -55,24 +55,24 @@ export class BikesComponent {
|
|
|
|
).enumValues = groupEnum;
|
|
|
|
).enumValues = groupEnum;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.loadingRowIds.subscribe(rowIds => {
|
|
|
|
bikesService.loadingRowIds.subscribe((rowIds) => {
|
|
|
|
this.loadingRowIds = rowIds;
|
|
|
|
this.loadingRowIds = rowIds;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
this.reloadingTable = false;
|
|
|
|
this.reloadingTable = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.data = bikes;
|
|
|
|
this.data = bikes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.data[0]) {
|
|
|
|
if (this.data[0]) {
|
|
|
|
this.displayedColumns = [];
|
|
|
|
this.displayedColumns = [];
|
|
|
|
this.dataColumns = [];
|
|
|
|
this.dataColumns = [];
|
|
|
|
|
|
|
|
|
|
|
|
this.addColumnsFromObject('', this.data[0]);
|
|
|
|
this.addColumnsFromObject('', this.data[0]);
|
|
|
|
|
|
|
|
|
|
|
|
for (const bike of this.data)
|
|
|
|
for (let row of this.data) {
|
|
|
|
|
|
|
|
row = this.flatten(row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//sort, so the displayedColumns array is in the same order as the columnInfo
|
|
|
|
//sort, so the displayedColumns array is in the same order as the columnInfo
|
|
|
|
this.dataColumns.sort((columnA, columnB) => {
|
|
|
|
this.dataColumns.sort((columnA, columnB) => {
|
|
|
@ -119,8 +119,24 @@ export class BikesComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
flatten(object: Object) {
|
|
|
|
flatten(object: Object, prefix: string = '') {
|
|
|
|
return object;
|
|
|
|
let newObject = new Object();
|
|
|
|
|
|
|
|
for (const prop in object) {
|
|
|
|
|
|
|
|
let propName = prefix + prop;
|
|
|
|
|
|
|
|
if (typeof object[prop] === 'object' && object[prop] !== null) {
|
|
|
|
|
|
|
|
const flattenedObject = this.flatten(object[prop], propName + '.');
|
|
|
|
|
|
|
|
console.log(flattenedObject);
|
|
|
|
|
|
|
|
for (const flattenedProperty in flattenedObject) {
|
|
|
|
|
|
|
|
console.log(flattenedProperty);
|
|
|
|
|
|
|
|
Object.defineProperty(newObject, flattenedProperty, {
|
|
|
|
|
|
|
|
value: object[flattenedProperty],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Object.defineProperty(newObject, propName, { value: object[prop] });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return newObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getHeader(propertyName: string) {
|
|
|
|
getHeader(propertyName: string) {
|
|
|
|