Skip to content

Commit cb83451

Browse files
authored
Merge branch 'main' into next
2 parents 8d8f7ce + b980fc6 commit cb83451

12 files changed

Lines changed: 774 additions & 45 deletions

File tree

adminforth/dataConnectors/postgres.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import pkg from 'pg';
66
import { afLogger, dbLogger } from '../modules/logger.js';
77

88
const { Pool } = pkg;
9+
const { Client, types } = pkg;
10+
11+
// postgres-date (used by pg for OID 1114/1082) parses no-TZ strings with new Date(y,m,d,...)
12+
// which treats them as LOCAL server time. Return raw strings so getFieldValue can parse as UTC.
13+
types.setTypeParser(1114, (val) => val); // TIMESTAMP WITHOUT TIME ZONE
14+
types.setTypeParser(1082, (val) => val); // DATE
915

1016

1117
class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
@@ -200,7 +206,7 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
200206
return null;
201207
}
202208
if (field._underlineType == 'timestamp' || field._underlineType == 'int') {
203-
return dayjs(value).toISOString();
209+
return dayjs(value.replace(' ', 'T') + 'Z').toISOString();
204210
} else if (field._underlineType == 'varchar') {
205211
return dayjs(value).toISOString();
206212
} else {
@@ -212,7 +218,7 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
212218
if (!value) {
213219
return null;
214220
}
215-
return dayjs(value).toISOString().split('T')[0];
221+
return value;
216222
}
217223

218224
if (field.type == AdminForthDataTypes.BOOLEAN) {

adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ When user clicks the "Save" button on edit page, AdminForth makes a request to t
5252

5353
![Saving data on edit page](image-27.png)
5454

55-
Practically you can use `edit.beforeSave` hook to modify the data or populate new fields before it is saved to the database.
55+
Practically you can use `hooks.edit.beforeSave` hook to modify the data or populate new fields before it is saved to the database.
5656

57-
> 👆 Note: according to diagram you should understand that interrupting flow from `edit.afterSave` does not prevent data modification in DB
57+
> 👆 Note: according to diagram you should understand that interrupting flow from `hooks.edit.afterSave` does not prevent data modification in DB
5858
5959
## Saving data on create page
6060

@@ -266,4 +266,4 @@ always performed before any hooks and any database requests.
266266

267267
## All hooks
268268

269-
Check all hooks in the [API reference](/docs/api/Back/interfaces/AdminForthResource).
269+
Check all hooks in the [API reference](/docs/api/Back/interfaces/AdminForthResource).

adminforth/spa/src/components/Filters.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const props = defineProps<{
195195
filters?: AdminforthFilterStore['filters'],
196196
show: Boolean,
197197
columnsMinMax: ColumnMinMaxValue,
198+
resourceId?: string,
198199
filtersStore: AdminforthFilterStoreUnwrapped
199200
}>();
200201
@@ -235,7 +236,7 @@ async function loadMoreOptions(columnName: string, searchTerm = '') {
235236
columnName,
236237
searchTerm,
237238
columns: props.columns,
238-
resourceId: router.currentRoute.value.params.resourceId as string,
239+
resourceId: props.resourceId ?? router.currentRoute.value.params.resourceId as string,
239240
columnOptions,
240241
columnLoadingState,
241242
columnOffsets,

adminforth/spa/src/views/ListView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:show="filtersShow"
88
@hide="filtersShow = false"
99
:filtersStore="filtersStore"
10+
:resourceId="coreStore.resource?.resourceId"
1011
/>
1112
</Teleport>
1213

live-demo/app/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import auditLogsResource from "./resources/auditLogs"
88
import translations from "./resources/translations";
99
import sessionsResource from './resources/agent_resources/sessions';
1010
import turnsResource from './resources/agent_resources/turns';
11+
import jobs_resource from './resources/jobs';
1112
import { randomUUID } from 'crypto';
1213
try { fs.mkdirSync('db') } catch (e) {}
1314

@@ -65,6 +66,7 @@ new AdminForth({
6566
translations,
6667
sessionsResource,
6768
turnsResource,
69+
jobs_resource,
6870
],
6971
menu: [
7072

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- CreateTable
2+
CREATE TABLE "jobs" (
3+
"id" TEXT NOT NULL PRIMARY KEY,
4+
"created_at" DATETIME NOT NULL,
5+
"finished_at" DATETIME,
6+
"started_by" TEXT NOT NULL,
7+
"name" TEXT NOT NULL,
8+
"state" TEXT,
9+
"progress" TEXT NOT NULL,
10+
"status" TEXT NOT NULL,
11+
"job_handler_name" TEXT NOT NULL
12+
);
13+
14+
-- CreateIndex
15+
CREATE INDEX "translations_completedLangs_idx" ON "translations"("completedLangs");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Please do not edit this file manually
22
# It should be added in your version-control system (e.g., Git)
3-
provider = "sqlite"
3+
provider = "sqlite"

0 commit comments

Comments
 (0)