Skip to content
Merged

Next #116

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8d5cd7a
fix: add i18n for login page errors
Jan 30, 2025
031641a
docs: im prove showIn and explain allowMinMaxQuery
ivictbor Jan 30, 2025
675901d
refactor dialog component and add export from afcl
Jan 31, 2025
206aaf7
docs: add afcl dialog component documentation
Jan 31, 2025
e4870ab
Merge pull request #104 from devforth/implement-dialog-component
ivictbor Jan 31, 2025
be9abc8
change translation handling for login error
Jan 31, 2025
011eece
add datepicker translation
Jan 31, 2025
f4537f3
fix password input validity message
Jan 31, 2025
621ebd4
fix: fix dynamic showIn calls
Jan 31, 2025
d24fa00
Merge pull request #106 from devforth/fix-dynamic-showin
ivictbor Jan 31, 2025
b9d2981
Merge pull request #105 from devforth/add-login-translations
ivictbor Jan 31, 2025
42e61d3
fix(afcl): support input.focus() for AFCL <Input ref="input"
ivictbor Feb 1, 2025
6274ae9
fix: supply resource and adminUser props for custom components set i…
ivictbor Feb 1, 2025
45abeca
Merge branches 'next' and 'next' of github.com:devforth/adminforth in…
ivictbor Feb 1, 2025
84373d9
Merge branch 'main' of github.com:devforth/adminforth into next
ivictbor Feb 1, 2025
cf7fead
fix: support mysql in adminforth CLI
ivictbor Feb 1, 2025
bf0bf66
fix: change inputs for date and time to date selectors
Feb 3, 2025
fee1101
fix: upgrade ApexCharts to v4.4.0
SerVitasik Feb 3, 2025
786a2a3
Merge pull request #107 from devforth/add-date-and-time-inputs
ivictbor Feb 3, 2025
1781149
fix: change table routing to a new tab to include baseUrl
Feb 3, 2025
66273c0
perf(postgres): remove cast for UUID, significant improve of show speed
ivictbor Feb 3, 2025
6a478e9
perf: call listTableClickUrl only for list page, increase perf for sh…
ivictbor Feb 3, 2025
fa93aae
perf: call getTotals query only for list page
ivictbor Feb 3, 2025
67557e2
remove long dev string
ivictbor Feb 3, 2025
2da50bf
Merge branch 'next' of github.com:devforth/adminforth into next
ivictbor Feb 3, 2025
605fb9a
Merge pull request #108 from devforth/fix-table-row-ctrl-click
ivictbor Feb 3, 2025
99dd2ed
fix: don't stretch wide logos
ivictbor Feb 4, 2025
41af0f9
feat: add filterOptions field to columns
Feb 4, 2025
6a38590
Merge pull request #109 from devforth/add-column-filter-options
mamchurovskyy Feb 4, 2025
4b6f689
feat: add dotenvx support for CLI
mamchurovskyy Feb 4, 2025
ff4b1ae
Merge pull request #110 from devforth/dotenvx
ivictbor Feb 4, 2025
c961191
feat: add unsetLabel field to foreign resources
Feb 4, 2025
f6af373
docs: truncate posts and fix links
ivictbor Feb 4, 2025
fbcc903
docs: fix tags
ivictbor Feb 4, 2025
6a97e60
Merge pull request #111 from devforth/foreign-resource-unset-label
ivictbor Feb 4, 2025
f39dbce
fix(postgres): fix fuzzy search for UUIDs in filters
ivictbor Feb 4, 2025
84bd990
fix(CLI): call table admin users instead of users
ivictbor Feb 4, 2025
00ad2ca
Merge branch 'next' of github.com:devforth/adminforth into next
ivictbor Feb 4, 2025
6fde4a5
docs: add unset label section to foreign resources documentation
Feb 5, 2025
317ab9b
fix: remove separate i18n categories for editing notes
Feb 5, 2025
bd570cd
feat: add README template for CLI
mamchurovskyy Feb 5, 2025
baf835b
Merge pull request #113 from devforth/change-editing-note-i18n-category
ivictbor Feb 5, 2025
dcfd025
Merge pull request #112 from devforth/foreign-resource-unset-label
ivictbor Feb 5, 2025
58d9dc3
docs: suggestOnCreate
ivictbor Feb 6, 2025
b89e066
feat: add suggestOnCreate field to column
Feb 10, 2025
c138e02
Merge pull request #115 from devforth/implement-suggest-on-create
ivictbor Feb 10, 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
2 changes: 1 addition & 1 deletion adminforth/commands/createApp/templates/adminuser.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
dataSource: 'maindb',
table: 'adminuser',
resourceId: 'adminuser',
label: 'Users',
label: 'Admin Users',
recordLabel: (r) => `👤 ${r.email}`,
options: {
allowedActions: {
Expand Down
8 changes: 5 additions & 3 deletions adminforth/commands/createApp/templates/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"license": "ISC",
"description": "",
"scripts": {
"start": "tsx watch --env-file=.env index.ts",
"migrate": "npx prisma migrate deploy",
"makemigration": "npx --yes prisma migrate deploy; npx --yes prisma migrate dev",
"env": "dotenvx run -f .env.local -f .env --overload --",
"start": "npm run env -- tsx watch index.ts",
"migrateLocal": "npm run env -- npx prisma migrate deploy",
"makemigration": "npm run migrateLocal; npm run env -- npx --yes prisma migrate dev",
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.34.0",
"adminforth": "latest",
"express": "latest"
},
Expand Down
40 changes: 40 additions & 0 deletions adminforth/commands/createApp/templates/readme.md.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Starting the application

Install dependencies:

```bash
npm ci
```

Migrate the database:

```bash
npm run migrateLocal
```

Start the server:

```bash
npm start
```

{{#if prismaDbUrl}}
## Changing schema

Open `schema.prisma` and change schema as needed: add new tables, columns, etc (See [Prisma schema reference](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema)).

Run the following command to generate a new migration and apply it instantly in local database:

```bash
npm run makemigration -- --name <name_of_changes>
```

Your colleagues will need to pull the changes and run `npm run migrateLocal` to apply the migration in their local database.
{{/if}}

## Documentation

- [Customizing AdminForth Branding](https://adminforth.dev/docs/tutorial/Customization/branding/)
- [Custom Field Rendering](https://adminforth.dev/docs/tutorial/Customization/customFieldRendering/)
- [Hooks](https://adminforth.dev/docs/tutorial/Customization/hooks/)
- [Custom Pages](https://adminforth.dev/docs/tutorial/Customization/customPages/)
34 changes: 23 additions & 11 deletions adminforth/commands/createApp/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function checkNodeVersion(minRequiredVersion = 20) {
if (isNaN(major) || major < minRequiredVersion) {
throw new Error(
`Node.js v${minRequiredVersion}+ is required. You have ${process.versions.node}. ` +
`Please upgrade Node.js.`
`Please upgrade Node.js. We recommend using nvm for managing multiple Node.js versions.`
);
}
}
Expand All @@ -80,6 +80,8 @@ function detectDbProvider(protocol) {
return 'postgresql';
} else if (protocol.startsWith('mongodb')) {
return 'mongodb';
} else if (protocol.startsWith('mysql')) {
return 'mysql';
}

const message = `Unknown database provider for ${protocol}. Only SQLite, PostgreSQL, and MongoDB are supported now.`;
Expand Down Expand Up @@ -180,15 +182,21 @@ async function writeTemplateFiles(dirname, cwd, options) {
data: {},
},
{
src: '.env.sample.hbs',
dest: '.env.sample',
src: '.env.local.hbs',
dest: '.env.local',
data: { dbUrl, prismaDbUrl },
},
{
src: 'readme.md.hbs',
dest: 'README.md',
data: { dbUrl, prismaDbUrl },
},
{
// We'll write .env using the same content as .env.sample
src: '.env.sample.hbs',
src: '.env.local.hbs',
dest: '.env',
data: { dbUrl, prismaDbUrl },
data: {},
empty: true,
},
{
src: 'adminuser.ts.hbs',
Expand All @@ -211,12 +219,16 @@ async function writeTemplateFiles(dirname, cwd, options) {
// If a condition is specified and false, skip this file
if (task.condition === false) continue;

const templatePath = path.join(dirname, 'templates', task.src);
const compiled = renderHBSTemplate(templatePath, task.data);
const destPath = path.join(cwd, task.dest);
// Ensure parent directory exists
// fse.ensureDirSync(path.dirname(destPath));
fs.writeFileSync(destPath, compiled);

if (task.empty) {
fs.writeFileSync(destPath, '');
} else {
const templatePath = path.join(dirname, 'templates', task.src);
const compiled = renderHBSTemplate(templatePath, task.data);
fs.writeFileSync(destPath, compiled);
}
}
}

Expand All @@ -233,11 +245,11 @@ function generateFinalInstructions(skipPrismaSetup) {
let instruction = '⏭️ Run the following commands to get started:\n';
if (!skipPrismaSetup)
instruction += `
${chalk.dim('// runs "npx prisma migrate dev --name init" to generate and apply initial migration')};
${chalk.dim('// Generate and apply initial migration')}
${chalk.cyan('$ npm run makemigration -- --name init')}\n`;

instruction += `
${chalk.dim('// Starts dev server with tsx watch for hot-reloading')}
${chalk.dim('// Start dev server with tsx watch for hot-reloading')}
${chalk.cyan('$ npm start')}\n
`;

Expand Down
10 changes: 2 additions & 8 deletions adminforth/dataConnectors/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,9 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
}
return dayjs(value).toISOString();
} else if (field.type == AdminForthDataTypes.DATE) {
if (!value) {
return null;
}
return dayjs(value).toISOString().split('T')[0];
return value || null;
} else if (field.type == AdminForthDataTypes.TIME) {
if (!value) {
return null;
}
return dayjs(value).toISOString().split('T')[1];
return value || null;
} else if (field.type == AdminForthDataTypes.BOOLEAN) {
return !!value;
} else if (field.type == AdminForthDataTypes.JSON) {
Expand Down
9 changes: 5 additions & 4 deletions adminforth/dataConnectors/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
totalCounter += 1;
}


if (fieldData._underlineType == 'uuid') {
field = `cast("${field}" as text)`
if (fieldData._underlineType == 'uuid' &&
(f.operator == AdminForthFilterOperators.ILIKE || f.operator == AdminForthFilterOperators.LIKE)
) {
field = `cast("${field}" as text)`
} else {
field = `"${field}"`
field = `"${field}"`
}
return `${field} ${operator} ${placeholder}`;
}).join(' AND ')}` : '';
Expand Down
2 changes: 2 additions & 0 deletions adminforth/documentation/blog/2024-08-05-chatgpt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Here is how it looks in action:

![alt text](../../docs/tutorial/05-Plugins/demoChatGpt.gif)

<!-- truncate -->

## Simple controls

To control plugin we use our open-source [vue-suggestion-input](https://github.com/devforth/vue-suggestion-input).
Expand Down
2 changes: 2 additions & 0 deletions adminforth/documentation/blog/2024-10-01-ai-blog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ But what about writing plain text? For example blogs and micro-blogs: sometimes

![alt text](nuxtBlog.gif)

<!-- truncate -->


For AI plugins are backed by OpenAI API, but their architecture allows to be easily extended for other AI providers once OpenAI competitors will reach the same or better level of quality.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ tags: [aws, terraform]

Here is a row snippet to deploy AdminForth to Terraform.

<!-- truncate -->


Assume you have your AdminForth project in `myadmin`.

Create file `Dockerfile` in `myadmin`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Here Terraform state will be stored in the cloud, so you can run this deployment

We will use GitHub Actions as CI/CD, but you can use any other CI/CD, for example self-hosted free WoodpeckerCI.

<!-- truncate -->

Assume you have your AdminForth project in `myadmin`.


Expand Down
2 changes: 2 additions & 0 deletions adminforth/documentation/blog/2024-12-11-backup/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Every reliable system requires a backup strategy.

If you have no own backup infrastructure, here can suggest a small docker container that will help you to backup your database to AWS Glacier.

<!-- truncate -->

As a base guide we will use a previous blog post about [deploying adminforth infrastructure](/blog/compose-ec2-deployment-github-actions).


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ That is why we decided to move the idea of generating versions, and GitHub relea

In this post I will explain why we did a transition from manual releases to automatic, what profits we got from it, and also will show you simple example how to do it in your project!

<!-- truncate -->


## Prehistory and issues

Before 1.6.0 AdminForth was using manual CHANGELOG.md.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Recently, while moving plugins to separate repositories, I decided to try [Infis

Here’s what I did:

<!-- truncate -->

```yaml title=".woodpecker.yml"

Expand Down
17 changes: 16 additions & 1 deletion adminforth/documentation/blog/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,19 @@ nuxt:
github-actions:
label: GitHub Actions
permalink: /github-actions
description: GitHub Actions is a continuous integration and continuous deployment (CI/CD) service provided by GitHub that allows you to automate your software development workflows.
description: GitHub Actions is a continuous integration and continuous deployment (CI/CD) service provided by GitHub that allows you to automate your software development workflows.

git:
label: Git
permalink: /git
description: Git is a distributed version control system that allows multiple developers to collaborate on a project.

versioning:
label: Versioning
permalink: /versioning
description: Versioning is the process of assigning unique identifiers to different versions of a software application or project.

npm:
label: NPM
permalink: /npm
description: NPM is a package manager for the JavaScript programming language that allows developers to share and reuse code.
28 changes: 12 additions & 16 deletions adminforth/documentation/docs/tutorial/001-gettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started
# Getting Started

This page provides a step-by-step guide to quickly get started with AdminForth using the `adminforth` CLI.
This page provides a step-by-step guide to quickly get started with AdminForth using the `adminforth` CLI.
You will learn how to set up a new project using the `adminforth create-app` command and explore AdminForth’s fundamentals.

> 👆 For setup example without CLI check out [Hello World without CLI](./01-helloWorld.md)
Expand All @@ -17,7 +17,7 @@ nvm use 20

## Creating an AdminForth Project

The recommended way to get started with AdminForth is via the **`create-app`** CLI, which scaffolds a basic fully functional back-office application. Apart boilerplate it creates one resource for users management.
The recommended way to get started with AdminForth is via the **`create-app`** CLI, which scaffolds a basic fully functional back-office application. Apart boilerplate it creates one resource for users management.

First, create and enter a directory where you want your AdminForth project to live. For instance:

Expand Down Expand Up @@ -69,31 +69,31 @@ myadmin/
├── index.ts # Main entry point: configures AdminForth & starts the server
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
├── .env # Environment variables (e.g. database connection string)
├── .env.sample # Sample env file (for distribution to teammates)
└── .gitignore
├── .env # Env vars like tokens, secrets that should not be in version control
├── .env.local # General local environment variables
└── .gitignore

```

### Initial Migration & Future Migrations

> ☝️ CLI creates Prisma schema file for managing migrations in relational databases, however you are not forced to use it. Instead you are free to use your favourite or existing migration tool. In this case just ignore generated prisma file, and don't run migration command which will be suggested by CLI. However you have to ensure that your migration tool will generate required table `adminuser` with same fields and types for Users resource.
> ☝️ CLI creates Prisma schema file for managing migrations in relational databases, however you are not forced to use it. Instead you are free to use your favourite or existing migration tool. In this case just ignore generated prisma file, and don't run migration command which will be suggested by CLI. However you have to ensure that your migration tool will generate required table `adminuser` with same fields and types for Users resource.

CLI will suggest you a command to initialize the database with Prisma:

```bash
npm run makemigration -- --name init
```

This will create a migration file in `migrations` and apply it to the database.
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 <name_of_changes>
```

Other developers need to pull migration and run `npm run migrate` to apply any unapplied migrations.
Other developers need to pull migration and run `npm run migrateLocal` to apply any unapplied migrations.

## Run the Server

Expand All @@ -107,12 +107,11 @@ Open http://localhost:3500 in your browser and (default credentials are `adminfo

![alt text](localhost_3500_login.png)


## AdminForth Basic Philosophy

AdminForth connects to existing databases and provides a back-office for managing data including CRUD operations, filtering, sorting, and more.

Database can be already created by using any database management tool, ORM or migrator.
Database can be already created by using any database management tool, ORM or migrator.

AdminForth itself never modifies database schema, does not add columns or new tables. However for those who have no own migration managment AdminForth CLI suggests using Prisma. This allows to provide simple and reliable schema management for standalone projects which have no DB yet.

Expand All @@ -124,11 +123,9 @@ Also in AdminForth you can define in "Vue" way:
* create own pages e.g. Dashboard using AdminForth Components Library (AFCL) or any other Vue componetns.
* insert injections into standard pages (e.g. add diagram to list view)



## Adding an `apartments` Model

So far, our freshly generated AdminForth project includes a default `adminuser` model and a corresponding `adminuser` resource.
So far, our freshly generated AdminForth project includes a default `adminuser` model and a corresponding `adminuser` resource.

Let’s expand our app to suport managment of **`apartments`** model. Adding new resource will involve next steps:

Expand Down Expand Up @@ -373,7 +370,7 @@ export const admin = new AdminForth({

```

## Generating fake appartments
## Generating fake appartments

```ts title="./index.ts"
//diff-add
Expand Down Expand Up @@ -435,4 +432,3 @@ This will create records during first launch. Now you should see:
![alt text](localhost_3500_resource_aparts.png)

Feel free to play with the data, add more fields, and customize the UI to your liking.

Loading