Skip to content

Next #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 206 commits into from
Aug 13, 2025
Merged

Next #315

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
82245c8
feat: add searchable fields and search functionality for foreign reso…
SerVitasik Jun 25, 2025
186ae54
fix: handle unexpected API responses in Filters component
SerVitasik Jun 25, 2025
844148b
fix: fix clear all button in filters, when we use date range
Jul 23, 2025
e4656a8
fix: fix form background color
Jul 23, 2025
398c243
docs: update migration commands in plugin tutorials to use npm scripts
Romper9 Jul 23, 2025
ca8d86c
docs: update migration commands in tutorials to use semicolon instead…
Romper9 Jul 23, 2025
8282f67
feat: add possibility to pass function into the loginPromptHTML
Jul 23, 2025
8fccf23
fix: update loginPromptHTML function call to remove unnecessary param…
Jul 23, 2025
463e62d
Merge pull request #272 from devforth/AdminForth/721
ivictbor Jul 23, 2025
1ddbeae
fix: update image in Limiting actions access
Jul 24, 2025
3044532
fix: add correct blog post link in deployment documentation and fixe…
Jul 24, 2025
9a7e327
Merge branch 'email-invite' into next
SerVitasik Jul 24, 2025
d8d47f3
Merge branch 'next' of github.com:devforth/adminforth into next
SerVitasik Jul 24, 2025
3dc104a
fix: fix error message in console on the login page
Jul 24, 2025
b893496
fix: improve input validity handling for username and password fields
Jul 24, 2025
5caec4c
fix: fix error message in console on the login page
Jul 24, 2025
dc0bf52
fix: fix error message in console on the login page
Jul 24, 2025
b8521ed
fix: fix clear all button in filters, when we use date range
Jul 24, 2025
721b556
Merge pull request #271 from devforth/AdminForth/719
SerVitasik Jul 24, 2025
ff7667f
fix: removed white background from the country flag
Jul 25, 2025
5a729ee
fix: fix bug with different sizes of country flags
Jul 25, 2025
9abab70
feat: validate ADMIN_BASE_URL and warn when VITE_ADMINFORTH_PUBLIC_PA…
Jul 25, 2025
2826e56
Merge pull request #275 from devforth/docs-update
SerVitasik Jul 28, 2025
51d0c0c
fix: remove unused parametr from the /get_public_config
Jul 28, 2025
3007041
fix: add shadow to the flag background
Jul 28, 2025
af84a99
feat: add custom class for the bool icons. Fix darkForm styling
Jul 28, 2025
37fd817
feat: add support for single theme configuration in AdminForth
SerVitasik Jul 28, 2025
f325691
Merge pull request #281 from devforth/add-single-theme-support
ivictbor Jul 28, 2025
d9da154
feat: add ability to add cutoms items to head
Jul 28, 2025
ff5c721
Merge pull request #280 from devforth/AdminForth/730
SerVitasik Jul 28, 2025
2686e9b
Merge pull request #277 from devforth/AdminForth/678
SerVitasik Jul 28, 2025
d6dcd70
fix: don't validate optional empty fields as invalid
Jul 28, 2025
5277727
Revert "fix: don't validate optional empty fields as invalid"
Jul 28, 2025
0cf7a4a
fix: don't validate optional empty fields as invalid
Jul 28, 2025
36c59ea
feat: add docs for the customHeadItems
Jul 28, 2025
18f3457
fix: prevent error when customHeadItems is not provided
Jul 28, 2025
70d2c73
fix: remove setCustomValidity
Jul 28, 2025
e9b0557
chore: rename variables k and v to the key and value
Jul 29, 2025
a2c0ac3
fix: fix incorrect position of dropdown content
Jul 29, 2025
699f314
fix: add correct dark theme for the checkboxes
Jul 30, 2025
6fe976c
fix: remove background blend mode from LoginView
SerVitasik Jul 30, 2025
bf335dd
fix: unsubscribe before subscribing in adminforth.menu.refreshMenuBad…
Jul 30, 2025
2cf899d
feat: add option to disable background blend mode for login image
SerVitasik Jul 30, 2025
810b938
Merge pull request #283 from devforth/AdminForth/552
SerVitasik Jul 30, 2025
780a733
Merge pull request #286 from devforth/AdminForth/637
SerVitasik Jul 30, 2025
c5630a7
chore: use nextTick insted of setTimeout in Select.vue
Jul 30, 2025
c4c1486
chore: remove space in Select.vue
Jul 30, 2025
100d012
Merge pull request #284 from devforth/AdminForth/727
SerVitasik Jul 30, 2025
788291f
chore: synchronize with next branch
Jul 30, 2025
a0ec20a
Merge pull request #278 from devforth/AdminForth/726
ivictbor Jul 30, 2025
69c4b17
Merge pull request #285 from devforth/AdminForth/732
ivictbor Jul 30, 2025
cd38fd1
feat: add possibility to customize select colors
Jul 30, 2025
2c3c930
fix: correctly detect Decimal128 fields as DECIMAL in create resource
NoOne7135 Jul 30, 2025
e04f223
chore: fix possibility to insert in header invalid tags
Jul 30, 2025
de09faa
Merge branch 'next' into AdminForth/676
yaroslav8765 Jul 30, 2025
1ba495b
fix: avoid TypeScript error by casting value to any before checking _…
NoOne7135 Jul 30, 2025
f1c91a0
Merge branch 'next' into AdminForth/735
yaroslav8765 Jul 30, 2025
6cf2d98
Merge pull request #287 from devforth/AdminForth/735
ivictbor Jul 30, 2025
9a02564
Merge branch 'next' into AdminForth/676
yaroslav8765 Jul 30, 2025
31c62ea
Merge pull request #282 from devforth/AdminForth/676
yaroslav8765 Jul 30, 2025
02e683d
fix: add possibility to pass void functions to the loginPromptHTML
Jul 30, 2025
9adc56b
fix: fix incorrect position of the dropdown without teleportToBody prop
Jul 31, 2025
b0b1998
chore: separating static and dynamic classes in ShowTable.vue
Jul 31, 2025
49c3756
Merge pull request #288 from devforth/AdminForth/727
NoOne7135 Jul 31, 2025
147bc28
fix: fix incorrect dropdown position with teleportToBody prop
Jul 31, 2025
00093c9
Merge pull request #290 from devforth/AdminForth/727
yaroslav8765 Jul 31, 2025
0849d53
feat: add primary color support to the Checkbox.vue
Jul 31, 2025
36d87c9
chore: use Checkbox.vue into the ResourceListTables
Jul 31, 2025
01d614b
feat: add new styles params for the checkbox
Jul 31, 2025
a195ab9
chore: test
yaroslav8765 Jul 31, 2025
de888ed
chore: use modelValue instead of v-model
yaroslav8765 Jul 31, 2025
6c76b49
feat: new Toggle.vue component
yaroslav8765 Jul 31, 2025
86be7a9
feat: add primary styles to the Toggle.vue
yaroslav8765 Jul 31, 2025
22d0826
chore: remove unused setCustomValidity
yaroslav8765 Jul 31, 2025
e6df849
Merge branch 'next' into AdminForth/620
yaroslav8765 Jul 31, 2025
5697a5e
Merge pull request #289 from devforth/AdminForth/620
ivictbor Jul 31, 2025
0bcbabf
Merge pull request #276 from devforth/AdminForth/720
ivictbor Aug 1, 2025
3f67dee
feat: enhance foreign resource handling with pagination and search ca…
SerVitasik Aug 1, 2025
9d2fdda
Merge branch 'next' of github.com:devforth/adminforth into dynamic-fi…
SerVitasik Aug 1, 2025
411e662
refactor: change inputClick function to async for improved handling
SerVitasik Aug 1, 2025
06ca513
feat: add primary color support to the edit form
yaroslav8765 Aug 1, 2025
7d1e8d1
refactor: extract duplicate functions to utils
SerVitasik Aug 1, 2025
cc6ae1b
introduce constants for pagination limits and update logic in utils a…
SerVitasik Aug 1, 2025
0317650
docs: add readonly prop to component props definition
ivictbor Aug 1, 2025
397d35e
Merge branch 'next' of github.com:devforth/adminforth into next
ivictbor Aug 1, 2025
b38c21d
feat: add BoolToggle.vue and new folder controls
yaroslav8765 Aug 1, 2025
39d7037
Merge pull request #231 from devforth/dynamic-filter
ivictbor Aug 1, 2025
203b804
feat: add custom classes to the date and time select buttons
yaroslav8765 Aug 3, 2025
e9574b1
docs: add docs for the Toggle.vue
yaroslav8765 Aug 3, 2025
38dd8bb
feat: support interrupting create/edit via beforeSave hook
NoOne7135 Aug 4, 2025
7d49dfa
Merge pull request #293 from devforth/interrupt-by-beforeSave
ivictbor Aug 4, 2025
2a7c484
docs: clarify beforeSave usage and return contract in create hook
NoOne7135 Aug 4, 2025
550aa1a
Merge branch 'next' of https://github.com/devforth/adminforth into next
NoOne7135 Aug 4, 2025
8816ed9
chore: hardcoded default theme in styles.ts
yaroslav8765 Aug 4, 2025
67baf10
Merge pull request #292 from devforth/AdminForth/744
SerVitasik Aug 4, 2025
8c59709
chore: dev-demo customization fix
yaroslav8765 Aug 4, 2025
98b53a0
chore: change toggle colors
yaroslav8765 Aug 4, 2025
7fc89e7
fix: add missing debounce import
SerVitasik Aug 4, 2025
29fcb48
chore: fix incorrect toggle form
yaroslav8765 Aug 4, 2025
70de7a2
chore: update docs toggle image
yaroslav8765 Aug 4, 2025
bb7d058
chore: update toggle style and docs image
yaroslav8765 Aug 4, 2025
6d697d0
chore: create test page with all afcl components
yaroslav8765 Aug 4, 2025
dff60f0
fix: update inputClick logic to only check readonly prop
SerVitasik Aug 4, 2025
1ef4500
Merge pull request #291 from devforth/AdminForth/742
ivictbor Aug 4, 2025
5ae8910
docs: fix docs
yaroslav8765 Aug 4, 2025
30b8fbf
Merge pull request #294 from devforth/AdminForth/748
ivictbor Aug 4, 2025
7071761
chore: update response.error condition to exclude hook-aborted case
NoOne7135 Aug 4, 2025
632ea35
feat: add unique classes to the af logo, title and resource parent
yaroslav8765 Aug 5, 2025
5cabf47
chore: add new styling classes
yaroslav8765 Aug 5, 2025
dcc5097
chore: move getLoginPromptHTML to the utils
yaroslav8765 Aug 5, 2025
26ec9cc
Merge pull request #295 from devforth/AdminForth/749
IhorStorozhok Aug 5, 2025
a76338d
chore: change getLoginPromptHTML
yaroslav8765 Aug 5, 2025
7658d56
fix: Initialize dotenv before logger initialization
yaroslav8765 Aug 5, 2025
141cf85
Merge pull request #273 from devforth/AdminForth/711
SerVitasik Aug 5, 2025
9476faa
chore: styles for tooltip and vertical tabs
yaroslav8765 Aug 6, 2025
08b98b4
chore: update Dash.vue
yaroslav8765 Aug 6, 2025
7ce788b
feat: add unique classes for the sidebar items
yaroslav8765 Aug 6, 2025
1328747
chore: add styles for dialog
yaroslav8765 Aug 6, 2025
087f73f
chore: add styles for dropzone
yaroslav8765 Aug 6, 2025
f04d94d
Merge pull request #297 from devforth/AdminForth/753
IhorStorozhok Aug 6, 2025
e44a8f5
chore: add styles for table
yaroslav8765 Aug 6, 2025
154daa3
chore: add styles for progress bar
yaroslav8765 Aug 6, 2025
7dee341
chore: add styles for skeleton
yaroslav8765 Aug 6, 2025
b4cdfec
chore: change requestes resource in index.ts.hbs
yaroslav8765 Aug 6, 2025
afc3e0b
chore: add loadPublicConfig to the LoginView
yaroslav8765 Aug 6, 2025
351261f
chore: add new endpoind - /get_login_form_config
yaroslav8765 Aug 6, 2025
0e46e39
Merge branch 'next' into AdminForth/711
yaroslav8765 Aug 6, 2025
7bc6eb4
fix: fix loginPromptHTML
yaroslav8765 Aug 6, 2025
658f585
Merge branch 'AdminForth/711' of https://github.com/devforth/adminfor…
yaroslav8765 Aug 6, 2025
cf09549
Merge pull request #298 from devforth/AdminForth/711
SerVitasik Aug 6, 2025
2317525
chore: add styles for accept modal
yaroslav8765 Aug 6, 2025
3647bd4
feat: add conditional class bindings for sidebar dropdown
yaroslav8765 Aug 7, 2025
0a6b60f
feat: add custom class to the header
yaroslav8765 Aug 7, 2025
407c204
chore: add stylest for breadcrumbs
yaroslav8765 Aug 7, 2025
0bee1c4
chore: add styles for datepicker
yaroslav8765 Aug 7, 2025
819fc62
Merge pull request #299 from devforth/AdminForth/756
IhorStorozhok Aug 7, 2025
1fa0700
chore: add styles for range picker
yaroslav8765 Aug 7, 2025
c39ed72
Merge pull request #300 from devforth/AdminForth/755
IhorStorozhok Aug 7, 2025
fefdec9
feat: add styles for the filters
yaroslav8765 Aug 7, 2025
9d935d7
chore: add styles for the resource list table
yaroslav8765 Aug 7, 2025
a1c8964
chore: add styles to the resource list table virtual
yaroslav8765 Aug 7, 2025
8a023b8
chore: update styles for the resource list table
yaroslav8765 Aug 7, 2025
2619a68
chore: add styles for show table
yaroslav8765 Aug 7, 2025
d4dcab3
chore: add styles for the skeleton loaders
yaroslav8765 Aug 7, 2025
43ad820
chore: add styles for three dots menu
yaroslav8765 Aug 7, 2025
7118495
chore: add styles for toast
yaroslav8765 Aug 7, 2025
a240d1b
chore: add styles for create view
yaroslav8765 Aug 8, 2025
056f334
chore: add styles for edit view
yaroslav8765 Aug 8, 2025
1cbae46
chore: reduse amound of styles for the edit and create views
yaroslav8765 Aug 8, 2025
93760f9
chore: add styles for the list view buttons. Remove prop state from b…
yaroslav8765 Aug 8, 2025
1d786cc
chore: add styles for the login view
yaroslav8765 Aug 8, 2025
228ac64
chore: add styles for the show view
yaroslav8765 Aug 8, 2025
40175c4
chore: add styles for date picker. fix resource list tablse styles
yaroslav8765 Aug 8, 2025
e0b5365
chore: remove unused styles
yaroslav8765 Aug 9, 2025
e862007
chore: add styles for the button
yaroslav8765 Aug 11, 2025
ada932c
chore: add new tab for the af-demo
yaroslav8765 Aug 11, 2025
2c7fa49
feat: filter returned fields based on column showIn visibility
NoOne7135 Aug 11, 2025
f9de8c7
feat: add ITranslateFunction, IAdminUserExpressRequest and ITransla…
yaroslav8765 Aug 11, 2025
9a742be
docs: add ITranslateExpressRequest and IAdminUserExpressRequest types…
yaroslav8765 Aug 11, 2025
2526a03
refactor: rename resolveAllowed to resolveVisible and update page han…
NoOne7135 Aug 11, 2025
a921354
docs: improved examles comsistency
yaroslav8765 Aug 11, 2025
07ffa98
Merge pull request #302 from devforth/hide-columns-by-showIn
ivictbor Aug 11, 2025
e41b2fe
fix: fix hover styling fot three dots menu
yaroslav8765 Aug 11, 2025
b812e12
Merge branch 'next' into AdminForth/743
yaroslav8765 Aug 11, 2025
f9d8a03
fix: fix calendar date chage
yaroslav8765 Aug 11, 2025
0ac0ca1
Merge pull request #301 from devforth/AdminForth/743
yaroslav8765 Aug 11, 2025
926f318
feat: enhance data filtering by adding primary key check in visibilit…
NoOne7135 Aug 11, 2025
56775a8
Merge branch 'next' of https://github.com/devforth/adminforth into next
NoOne7135 Aug 11, 2025
81ddf7d
fix: fix login page prompt
yaroslav8765 Aug 11, 2025
8268e33
fix: fix duplicate atribute error in ShowTable
yaroslav8765 Aug 11, 2025
a7a1efd
fix: fix ShowTable open error
yaroslav8765 Aug 11, 2025
c7cb3be
Revert "refactor: rename resolveAllowed to resolveVisible and update …
NoOne7135 Aug 11, 2025
73d0185
Revert "feat: filter returned fields based on column showIn visibility"
NoOne7135 Aug 11, 2025
8c631c1
Revert "refactor: rename resolveAllowed to resolveVisible and update …
NoOne7135 Aug 11, 2025
c363c90
Revert "feat: filter returned fields based on column showIn visibility"
NoOne7135 Aug 11, 2025
c42ba35
Merge branch 'next' of https://github.com/devforth/adminforth into next
NoOne7135 Aug 11, 2025
533c5db
Merge branch 'next' of https://github.com/devforth/adminforth into hi…
NoOne7135 Aug 11, 2025
a7b6458
docs: update virtual columns and security documentation for backend-o…
ivictbor Aug 11, 2025
cbbddb4
fix: fix docs generation
yaroslav8765 Aug 11, 2025
1265db8
Merge pull request #303 from devforth/AdminForth/758
yaroslav8765 Aug 11, 2025
8b0858a
Update 12-security.md
ivictbor Aug 11, 2025
71d113f
fix: fix style on dev demo
yaroslav8765 Aug 11, 2025
5a13112
Merge branch 'next' of https://github.com/devforth/adminforth into next
yaroslav8765 Aug 11, 2025
ecebb3d
fix: fix tooltip for the "Remove selection" button
yaroslav8765 Aug 12, 2025
5b9f19c
fix: fix dark form border color
yaroslav8765 Aug 12, 2025
4c02ad2
Merge pull request #307 from devforth/fixDarkFormBorderColor
yaroslav8765 Aug 12, 2025
a74ae1a
feat: implement backend-only column visibility logic in REST API
NoOne7135 Aug 12, 2025
5636511
refactor: simplify backend-only column visibility checks in REST API
NoOne7135 Aug 12, 2025
b266531
Merge pull request #308 from devforth/hide-columns-by-showIn
NoOne7135 Aug 12, 2025
443cb6c
fix: fix flag size for the list view
yaroslav8765 Aug 12, 2025
754e3d1
Merge branch 'next' of https://github.com/devforth/adminforth into next
yaroslav8765 Aug 12, 2025
72f031e
feat: scale CheckOutline icon in checkbox using rem
yaroslav8765 Aug 12, 2025
7d8a990
fix: fix docs generation for IAdminUserExpressRequest, ITranslateExpr…
yaroslav8765 Aug 12, 2025
d28f6d7
Merge branch 'next' into AdminForth/757
yaroslav8765 Aug 12, 2025
66ba874
feat: remove CustomDatePicker and add DatePicker to the afcl
yaroslav8765 Aug 12, 2025
43ef8bf
fix: fix style for light theme checkbox
yaroslav8765 Aug 13, 2025
764ae68
Merge pull request #313 from devforth/AdminForth/766
yaroslav8765 Aug 13, 2025
10a8418
docs: add missed import in example
yaroslav8765 Aug 13, 2025
e25d74a
Merge pull request #314 from devforth/AdminForth/767
ivictbor Aug 13, 2025
65c5d30
Merge pull request #312 from devforth/AdminForth/761
ivictbor Aug 13, 2025
01452b5
Merge pull request #311 from devforth/AdminForth/764
ivictbor Aug 13, 2025
ec8dc50
Merge pull request #310 from devforth/AdminForth/762
ivictbor Aug 13, 2025
8257693
Merge pull request #306 from devforth/AdminForth/757
ivictbor Aug 13, 2025
85fc125
Update 12-security.md
ivictbor Aug 13, 2025
9270b5f
Update 12-security.md
ivictbor Aug 13, 2025
fc32967
Merge pull request #304 from devforth/add_docs_about_dyn_visibility
ivictbor Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions adminforth/commands/createApp/templates/index.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AdminForth from 'adminforth';
import usersResource from "./resources/adminuser.js";
import { fileURLToPath } from 'url';
import path from 'path';
import { Filters } from 'adminforth';

const ADMIN_BASE_URL = '';

Expand All @@ -15,6 +16,12 @@ export const admin = new AdminForth({
rememberMeDays: 30,
loginBackgroundImage: 'https://images.unsplash.com/photo-1534239697798-120952b76f2b?q=80&w=3389&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
loginBackgroundPosition: '1/2',
loginPromptHTML: async () => {
const adminforthUserExists = await admin.resource("adminuser").count(Filters.EQ('email', 'adminforth')) > 0;
if (adminforthUserExists) {
return "Please use <b>adminforth</b> as username and <b>adminforth</b> as password"
}
},
},
customization: {
brandName: "{{appName}}",
Expand Down
3 changes: 3 additions & 0 deletions adminforth/commands/createCustomComponent/configLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import fs from 'fs/promises';
import path from 'path';
import chalk from 'chalk';
import jiti from 'jiti';
import dotenv from "dotenv";

dotenv.config({ path: '.env.local', override: true });
dotenv.config({ path: '.env', override: true });

export async function loadAdminForthConfig() {
const configFileName = 'index.ts';
Expand Down
18 changes: 17 additions & 1 deletion adminforth/dataConnectors/baseConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,23 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
const fieldObj = resource.dataSourceColumns.find((col) => col.name == (filters as IAdminForthSingleFilter).field);
if (!fieldObj) {
const similar = suggestIfTypo(resource.dataSourceColumns.map((col) => col.name), (filters as IAdminForthSingleFilter).field);
throw new Error(`Field '${(filters as IAdminForthSingleFilter).field}' not found in resource '${resource.resourceId}'. ${similar ? `Did you mean '${similar}'?` : ''}`);

let isPolymorphicTarget = false;
if (global.adminforth?.config?.resources) {
isPolymorphicTarget = global.adminforth.config.resources.some(res =>
res.dataSourceColumns.some(col =>
col.foreignResource?.polymorphicResources?.some(pr =>
pr.resourceId === resource.resourceId
)
)
);
}
if (isPolymorphicTarget) {
process.env.HEAVY_DEBUG && console.log(`⚠️ Field '${(filters as IAdminForthSingleFilter).field}' not found in polymorphic target resource '${resource.resourceId}', allowing query to proceed.`);
return { ok: true, error: '' };
} else {
throw new Error(`Field '${(filters as IAdminForthSingleFilter).field}' not found in resource '${resource.resourceId}'. ${similar ? `Did you mean '${similar}'?` : ''}`);
}
}
// value normalization
if (filters.operator == AdminForthFilterOperators.IN || filters.operator == AdminForthFilterOperators.NIN) {
Expand Down
23 changes: 15 additions & 8 deletions adminforth/dataConnectors/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
return Number.isInteger(value) ? 'integer' : 'float';
}
if (value instanceof Date) return 'datetime';
if (value && typeof value === 'object' && ('$numberDecimal' in value || value._bsontype === 'Decimal128')) return 'decimal';
if (typeof value === 'object') return 'json';
return 'string';
}
Expand All @@ -89,13 +90,18 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
sampleValues.set(fullKey, value);
}

if (
value instanceof Buffer ||
(value && typeof value === 'object' && (value as any)._bsontype === 'Decimal128')
) {
if (value instanceof Buffer) {
addType(fullKey, 'json');
return;
}
if (
value &&
typeof value === 'object' &&
('$numberDecimal' in value || (value as any)._bsontype === 'Decimal128')
) {
addType(fullKey, 'decimal');
return;
}

if (
value &&
Expand All @@ -104,9 +110,10 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
!(value instanceof Date)
) {
addType(fullKey, 'json');
} else {
addType(fullKey, detectType(value));
return
}

addType(fullKey, detectType(value));
});
}

Expand All @@ -117,7 +124,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
return Array.from(fieldTypes.entries()).map(([name, types]) => {
const primaryKey = name === '_id';

const priority = ['datetime', 'date', 'integer', 'float', 'boolean', 'json', 'string'];
const priority = ['datetime', 'date', 'integer', 'float', 'boolean', 'json', 'decimal', 'string'];

const matched = priority.find(t => types.has(t)) || 'string';

Expand All @@ -129,8 +136,8 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
datetime: 'DATETIME',
date: 'DATE',
json: 'JSON',
decimal: 'DECIMAL',
};

return {
name,
type: typeMap[matched] ?? 'STRING',
Expand Down
2 changes: 1 addition & 1 deletion adminforth/documentation/blog/2024-10-01-ai-blog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ model ContentImage {
Create a migration:

```bash
npm run makemigration -- --name add-posts && npm run migrate:local
npm run makemigration -- --name add-posts ; npm run migrate:local
```


Expand Down
5 changes: 3 additions & 2 deletions adminforth/documentation/docs/tutorial/001-gettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This will create a migration file in `migrations` and apply it to the database.
In future, when you need to add new resources, you need to modify `schema.prisma` (add models, change fields, etc.). After doing any modification you need to create a new migration using next command:

```bash
npm run makemigration -- --name init && npm run migrate:local
npm run makemigration -- --name init ; npm run migrate:local
```

Other developers need to pull migration and run `npm run migrateLocal` to apply any unapplied migrations.
Expand Down Expand Up @@ -173,7 +173,7 @@ model apartments {
Run the following command to create a new migration:

```bash
npm run makemigration -- --name add-apartments && npm run migrate:local
npm run makemigration -- --name add-apartments ; npm run migrate:local
```

### Step3. Create the `apartments` resource
Expand Down Expand Up @@ -292,6 +292,7 @@ export default {
name: 'realtor_id',
foreignResource: {
resourceId: 'adminuser',
searchableFields: ["id", "email"], // fields available for search in filter
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion adminforth/documentation/docs/tutorial/01-helloWorld.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ model Post {
Create database using `prisma migrate`:

```bash
npm run makemigration --name init && npm run migrate:local
npm run makemigration --name init ; npm run migrate:local
```

## Setting up AdminForth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ const admin = new AdminForth({
Here is how it looks:
![AdminForth Themes](image-10.png)

## Single theme

If you want to enforce a consistent theme and disable the theme switcher, you can configure AdminForth to use only one theme variant.

```ts title='./index.ts'

const admin = new AdminForth({
...
customization: {
//diff-add
singleTheme: "light",
styles: {
...
}
}
},
...
});
```


## Square vs rounded buttons?

Expand Down Expand Up @@ -149,4 +169,52 @@ auth: {
`loginBackgroundPosition` accepts values:

- `over` - image will be over the whole login page with cover mode
- `1/2`(default), `3/4`, `2/5`, `3/5` etc. - image will be in the left side of the login page with cover mode
- `1/2`(default), `3/4`, `2/5`, `3/5` etc. - image will be in the left side of the login page with cover mode

### Disabling background blend mode

When using `loginBackgroundPosition: 'over'`, AdminForth applies a background blend mode by default to ensure text readability over the background image. If you want to disable this blend mode and display the background image without any overlay effects, you can add:

```ts title='./index.ts'
auth: {
...
loginBackgroundImage: '@@/photo-1516501312919-d0cb0b7b60b8.jpeg',
loginBackgroundPosition: 'over',
//diff-add
removeBackgroundBlendMode: true,
}

```

## Custom items in html head

If you want to add custom elements to the HTML head, you can define them in the configuration:

```ts title='./index.ts'
customization: {
customHeadItems: [
{
tagName: 'link',
attributes: {
rel: 'stylesheet',
href: 'https://example.com/custom.css'
}
},
{
tagName: 'script',
attributes: {
src: 'https://example.com/custom.js',
defer: true
}
},
{
tagName: 'meta',
attributes: {
name: 'theme-color',
content: ' #000000'
}
}
]
}

```
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const props = defineProps<{
meta: any;
resource: AdminForthResourceCommon;
adminUser: AdminUser;
readonly: boolean;
}>();

const emit = defineEmits(["update:value"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,4 @@ Hook still has access to the virtual field `updates.password`, and we use built-
After hook is executed, `updates.password` will be removed from the record since it is virtual, so password itself will not be saved to the database.


### Backend-only fields

Another important point is that `hashed_password` field should never be passed to frontend due to security reasons.

To do it we have 2 options:

1) Do not list `password_hash` in the `columns` array of the resource. If AdminForth knows nothing about field
it will never pass this field to frontend.
2) Define `password_hash` in columns way but set `backendOnly`. The scond option is more explicit and should be preferrred

```ts
{
name: 'password_hash',
type: AdminForthDataTypes.STRING,
showIn: { all: false },
backendOnly: true, // will never go to frontend
}
```

Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,14 @@ Open `index.ts` file and add the following code *BEFORE* `admin.express.serve(`

```ts title="/index.ts"

import type { IAdminUserExpressRequest } from 'adminforth';
import express from 'express';

....

app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
admin.express.authorize(
async (req:any, res:any) => {
async (req:IAdminUserExpressRequest, res: express.Response) => {
const days = req.body.days || 7;
const apartsByDays = admin.resource('aparts').dataConnector.client.prepare(
`SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ Now create file `ApartsPie.vue` in the `custom` folder of your project:
Also we have to add an Api to get percentages:

```ts title="./index.ts"
import type { IAdminUserExpressRequest } from 'adminforth';
import express from 'express';

....

app.get(`${ADMIN_BASE_URL}/api/aparts-by-room-percentages/`,
admin.express.authorize(
async (req, res) => {
async (req: IAdminUserExpressRequest, res: express.Response) => {
const roomPercentages = await admin.resource('aparts').dataConnector.client.prepare(
`SELECT
number_of_rooms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ To implement this limitation use `allowed`:
If you want to prohibit the use of bulk action for user, you can do it this way:

```ts title="./resources/apartments.ts"
import { admin } from '../index';

....

bulkActions: [
{
label: 'Mark as listed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,72 @@ server {
proxy_set_header X-Forwarded-For $remote_addr;
}
}
```
```



### Backend-only fields

Some fields should never be accessed on frontend. For example, `hashed_password` field which is always created using CLI initial app, should never be passed to frontend due to security reasons.
If any user of system can read `hashed_password` of another user, it can lead to account compromise.

To eliminate it we have 2 options:

1) Do not list `password_hash` in the `columns` array of the resource. If AdminForth knows nothing about field
it will never pass this field to frontend!
2) Define `password_hash` in columns way but set `backendOnly`.

The second option is more explicit and should be preferred. This option is used by default in CLI-bootstrapped projects:

```ts
{
name: 'password_hash',
type: AdminForthDataTypes.STRING,
showIn: { all: false },
backendOnly: true, // will never go to frontend
}
```

#### Dynamically hide fields depending on user ACL / role

You can use `column.showIn` to show or hide column for user depending on his role.

However even if `showIn` value (or value returned by showIn function) is `false`, record value will still go to frontend and will be
visible in the Network tab, so advanced user can still access field value. We did it in this way to provide AdminForth developers with ability to quickly use any record field in custom components.

However if you need securely hide only certain fields depending on role, you should use `column.backendOnly` and pass function there.

Let's consider example:

```ts
{
name: 'email',
type: AdminForthDataTypes.STRING,
showIn: {
//diff-add
all: false,
//diff-add
list: ({ adminUser }: { adminUser: AdminUser }) => adminUser.dbUser.role === 'superadmin',
},
}
```

So if you will configure the email column in user resource like this, only superadmin will be able to see emails, and only in the list view.
However, the email will still be present in the record and can be accessed by advanced users through the Network tab.

So to completely hide the email field from all users apart superadmins, you should use `column.backendOnly` and pass a function there.

```ts
{
name: 'email',
type: AdminForthDataTypes.STRING,
//diff-add
backendOnly: ({ adminUser }: { adminUser: AdminUser }) => adminUser.dbUser.role === 'superadmin',
showIn: {
all: false,
list: ({ adminUser }: { adminUser: AdminUser }) => adminUser.dbUser.role === 'superadmin',
},
}
```

So if you will configure the email column in user resource like this, only superadmin will be able to see emails, and only in the list view.
Loading