From 66a1784e5aea0052bf62c8b91dba86d2e9190f78 Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Sun, 6 Jul 2025 20:33:42 +0300 Subject: [PATCH 1/2] interval component: fix form field and filter --- .../time-interval/time-interval.component.ts | 62 ++++++++++++++++--- .../time-interval/time-interval.component.ts | 2 +- frontend/src/app/lib/format-field-value.ts | 3 +- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/components/ui-components/filter-fields/time-interval/time-interval.component.ts b/frontend/src/app/components/ui-components/filter-fields/time-interval/time-interval.component.ts index 56d4c124f..fd024cf4a 100644 --- a/frontend/src/app/components/ui-components/filter-fields/time-interval/time-interval.component.ts +++ b/frontend/src/app/components/ui-components/filter-fields/time-interval/time-interval.component.ts @@ -16,21 +16,22 @@ import { MatInputModule } from '@angular/material/input'; }) export class TimeIntervalFilterComponent extends BaseFilterFieldComponent { @Input() value; + static type = 'number'; public interval = { - years: '', - months: '', - days: '', - hours: '', - minutes: '', - seconds: '', - milliseconds: '' + years: 0, + months: 0, + days: 0, + hours: 0, + minutes: 0, + seconds: 0, + milliseconds: 0 }; ngOnInit(): void { super.ngOnInit(); - // @ts-ignore - if (this.value) this.interval = {...pgInterval.parse(this.value)}; + + if (this.value) this.interval = this.parseIntervalString(this.value); } onInputChange() { @@ -38,4 +39,47 @@ export class TimeIntervalFilterComponent extends BaseFilterFieldComponent { const currentInterval = pgInterval.prototype.toPostgres.call(this.interval); this.onFieldChange.emit(currentInterval); } + + parseIntervalString(input) { + const units = { + year: 'years', + years: 'years', + month: 'months', + months: 'months', + day: 'days', + days: 'days', + hour: 'hours', + hours: 'hours', + minute: 'minutes', + minutes: 'minutes', + second: 'seconds', + seconds: 'seconds', + millisecond: 'milliseconds', + milliseconds: 'milliseconds', + }; + + const result = { + years: 0, + months: 0, + days: 0, + hours: 0, + minutes: 0, + seconds: 0, + milliseconds: 0, + }; + + const regex = /(\d+(?:\.\d+)?)\s*(years?|months?|days?|hours?|minutes?|seconds?|milliseconds?)/gi; + + let match; + while ((match = regex.exec(input)) !== null) { + const value = parseFloat(match[1]); + const unit = match[2].toLowerCase(); + const key = units[unit]; + + if (key) result[key] += value; + } + + return result; + } + } diff --git a/frontend/src/app/components/ui-components/row-fields/time-interval/time-interval.component.ts b/frontend/src/app/components/ui-components/row-fields/time-interval/time-interval.component.ts index a6bf50bb0..56a61ce7f 100644 --- a/frontend/src/app/components/ui-components/row-fields/time-interval/time-interval.component.ts +++ b/frontend/src/app/components/ui-components/row-fields/time-interval/time-interval.component.ts @@ -31,7 +31,7 @@ export class TimeIntervalRowComponent extends BaseRowFieldComponent { ngOnInit(): void { super.ngOnInit(); // @ts-ignore - if (this.value) this.interval = {...pgInterval.parse(this.value)}; + if (this.value) this.interval = this.value; } onInputChange() { diff --git a/frontend/src/app/lib/format-field-value.ts b/frontend/src/app/lib/format-field-value.ts index 066719466..068ef15d5 100644 --- a/frontend/src/app/lib/format-field-value.ts +++ b/frontend/src/app/lib/format-field-value.ts @@ -22,8 +22,9 @@ export function formatFieldValue(value, type) { if (value || value === 1) return '✓' else if (value === false || value === 0) return '✕' else return '—' - } else if (type === 'json' || type === 'jsonb' || type === 'object' || type === 'array') { + } else if (type === 'json' || type === 'jsonb' || type === 'object' || type === 'array' || type === 'interval') { return JSON.stringify(value) } + return value; } From a388604c2537df16eb015137764ba26848d1673a Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Sun, 6 Jul 2025 21:08:29 +0300 Subject: [PATCH 2/2] records view: fix foreign key on record view of foreign key; open related records in new tab --- .../db-table-row-view/db-table-row-view.component.html | 3 ++- .../db-table-row-view/db-table-row-view.component.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/dashboard/db-table-row-view/db-table-row-view.component.html b/frontend/src/app/components/dashboard/db-table-row-view/db-table-row-view.component.html index b8e7f95f3..83d608b23 100644 --- a/frontend/src/app/components/dashboard/db-table-row-view/db-table-row-view.component.html +++ b/frontend/src/app/components/dashboard/db-table-row-view/db-table-row-view.component.html @@ -38,12 +38,13 @@

Preview

Absent settings -