Add machine category lookup

This commit is contained in:
2026-06-07 13:40:12 +02:00
parent cd89a30631
commit 24c6c9e017
9 changed files with 65 additions and 4 deletions
+18
View File
@@ -263,6 +263,21 @@ class AgrarmonitorConnector {
}
throw new Error('Ungueltige Agrarmonitor Kunden-API-Antwort');
}
async getMaschinenKategorien() {
const response = await this.http.get('/maschinen/kategorien');
await this.saveSession();
const document = this.parseHtmlDocument(response.data);
const rows = Array.from(document.querySelectorAll('table#kategorien tbody tr'));
return rows.map(row => {
const cells = Array.from(row.querySelectorAll('td'));
return {
id: this.parseNumber(row.id),
name: cells[0]?.textContent?.trim() ?? '',
zugmaschine: this.parseJaNein(cells[2]?.textContent ?? ''),
mobilSichtbar: Boolean(cells[4]?.querySelector('input[type="checkbox"]')?.checked),
};
});
}
createHttpClient() {
const client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
baseURL: this.baseUrl,
@@ -441,6 +456,9 @@ class AgrarmonitorConnector {
const numberValue = Number(String(value ?? '').trim());
return Number.isFinite(numberValue) ? numberValue : 0;
}
parseJaNein(value) {
return value.trim().toLowerCase() === 'ja';
}
parseGermanShortDate(value) {
const match = value.trim().match(/^(\d{2})\.(\d{2})\.(\d{2})$/);
if (!match) {