|
|
@ -21,21 +21,26 @@ type CargoBikeDataRow = CargoBikeResult & {
|
|
|
|
styleUrls: ['./bikes.component.scss'],
|
|
|
|
styleUrls: ['./bikes.component.scss'],
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class BikesComponent {
|
|
|
|
export class BikesComponent {
|
|
|
|
displayedColumns: string[] = [
|
|
|
|
columnInfo = [
|
|
|
|
'select',
|
|
|
|
{ name: 'name', header: 'Name', type: 'string', sticky: true },
|
|
|
|
'name',
|
|
|
|
{ name: 'id', header: 'ID', type: 'number', readonly: true },
|
|
|
|
'id',
|
|
|
|
{ name: 'group', header: 'Gruppe', type: 'enum', enumValues: [] },
|
|
|
|
'group',
|
|
|
|
|
|
|
|
'frameNumber',
|
|
|
|
|
|
|
|
'forChildren',
|
|
|
|
|
|
|
|
'numberOfChildren',
|
|
|
|
|
|
|
|
'numberOfWheels',
|
|
|
|
|
|
|
|
'forCargo',
|
|
|
|
|
|
|
|
'buttons',
|
|
|
|
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blacklistedColumns = [
|
|
|
|
|
|
|
|
'__typename',
|
|
|
|
|
|
|
|
'isLocked',
|
|
|
|
|
|
|
|
'isLockedByMe',
|
|
|
|
|
|
|
|
'lockedBy',
|
|
|
|
|
|
|
|
'lockedUntil',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataColumns: string[] = [];
|
|
|
|
|
|
|
|
additionalColumnsFront: string[] = ['select'];
|
|
|
|
|
|
|
|
additionalColumnsBack: string[] = ['buttons'];
|
|
|
|
|
|
|
|
displayedColumns: string[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
bikes = <Array<any>>[];
|
|
|
|
bikes = <Array<any>>[];
|
|
|
|
groupEnum: string[] = [];
|
|
|
|
|
|
|
|
selection = new SelectionModel<CargoBikeDataRow>(true, []);
|
|
|
|
selection = new SelectionModel<CargoBikeDataRow>(true, []);
|
|
|
|
|
|
|
|
|
|
|
|
reloadingTable = false;
|
|
|
|
reloadingTable = false;
|
|
|
@ -44,9 +49,14 @@ export class BikesComponent {
|
|
|
|
relockingDuration = 1000 * 60 * 1;
|
|
|
|
relockingDuration = 1000 * 60 * 1;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private bikesService: BikesService) {
|
|
|
|
constructor(private bikesService: BikesService) {
|
|
|
|
bikesService.groupEnum.subscribe(groupEnum => {
|
|
|
|
this.displayedColumns.unshift(this.additionalColumnsFront[0]);
|
|
|
|
this.groupEnum = groupEnum;
|
|
|
|
this.displayedColumns.push(this.additionalColumnsBack[0]);
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.groupEnum.subscribe((groupEnum) => {
|
|
|
|
|
|
|
|
this.columnInfo.find(
|
|
|
|
|
|
|
|
(column) => column.name === 'group'
|
|
|
|
|
|
|
|
).enumValues = groupEnum;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
bikesService.bikes.subscribe((bikes) => {
|
|
|
|
this.reloadingTable = false;
|
|
|
|
this.reloadingTable = false;
|
|
|
@ -57,6 +67,27 @@ export class BikesComponent {
|
|
|
|
unlocking: false,
|
|
|
|
unlocking: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (bikes[0]) {
|
|
|
|
|
|
|
|
this.displayedColumns = [];
|
|
|
|
|
|
|
|
this.dataColumns = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.addColumnsFromObject('', bikes[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.dataColumns.sort((columnA, columnB) => {
|
|
|
|
|
|
|
|
const indexA = this.columnInfo.findIndex((c) => c.name == columnA);
|
|
|
|
|
|
|
|
const indexB = this.columnInfo.findIndex((c) => c.name == columnB);
|
|
|
|
|
|
|
|
if (indexA == -1) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
} else if (indexB == -1) {
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return indexA - indexB;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.displayedColumns.push(...this.dataColumns);
|
|
|
|
|
|
|
|
this.displayedColumns.unshift(...this.additionalColumnsFront);
|
|
|
|
|
|
|
|
this.displayedColumns.push(...this.additionalColumnsBack);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
bikesService.loadBikes();
|
|
|
|
bikesService.loadBikes();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,6 +106,54 @@ export class BikesComponent {
|
|
|
|
clearInterval(this.relockingInterval);
|
|
|
|
clearInterval(this.relockingInterval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addColumnsFromObject(prefix: string, object: Object) {
|
|
|
|
|
|
|
|
for (const prop in object) {
|
|
|
|
|
|
|
|
let propName = prefix + prop;
|
|
|
|
|
|
|
|
console.log(typeof object[prop]);
|
|
|
|
|
|
|
|
if (typeof object[prop] === 'object') {
|
|
|
|
|
|
|
|
console.log(object);
|
|
|
|
|
|
|
|
this.addColumnsFromObject(prefix + prop + '.', object[prop]);
|
|
|
|
|
|
|
|
} else if (!this.blacklistedColumns.includes(propName)) {
|
|
|
|
|
|
|
|
this.dataColumns.push(propName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getHeader(propertyName: string) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.header ||
|
|
|
|
|
|
|
|
propertyName
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getType(propertyName: string) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.type ||
|
|
|
|
|
|
|
|
'string'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isReadonly(propertyName: string) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.readonly ||
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isStickyColumn(propertyName: string) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.sticky ||
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getEnumValues(propertyName: string) {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
this.columnInfo.find((column) => column.name === propertyName)?.enumValues ||
|
|
|
|
|
|
|
|
[]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reloadTable() {
|
|
|
|
reloadTable() {
|
|
|
|
this.reloadingTable = true;
|
|
|
|
this.reloadingTable = true;
|
|
|
|
this.bikesService.loadBikes();
|
|
|
|
this.bikesService.loadBikes();
|
|
|
|