Skip to content

Commit 4f27ea8

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 58a58b0 + f48a6ca commit 4f27ea8

File tree

7 files changed

+198
-5
lines changed

7 files changed

+198
-5
lines changed

adminforth/documentation/docs/tutorial/08-Plugins/04-RichEditor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ To get completion suggestions for the text in the editor, you can use the `compl
145145

146146
![alt text](gptDemo.gif)
147147

148-
### Imges in Rich editor
148+
### Images in Rich editor
149149

150150
First, you need to create resource for images:
151151
```prisma title="schema.prisma"

adminforth/documentation/docs/tutorial/08-Plugins/14-markdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Here is how it looks in show view:
3737
![alt text](markdown-show1.png)
3838
![alt text](markdown-show2.png)
3939

40-
### Imges in Markdown
40+
### Images in Markdown
4141

4242
First, you need to create resource for images:
4343
```prisma title="schema.prisma"

adminforth/modules/restApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
13991399
}
14001400

14011401
const { error } = await this.adminforth.updateResourceRecord({
1402-
resource, record, adminUser, oldRecord, recordId, response,
1402+
resource, updates: record, adminUser, oldRecord, recordId, response,
14031403
extra: { body, query, headers, cookies, requestUrl, response }
14041404
});
14051405
if (error) {

adminforth/spa/src/afcl/Dialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<p class="mb-6 text-lightDialogBodyText dark:text-darkDialogBodyText">{{ props.closeConfirmationText }}</p>
6363
<div class="flex justify-end">
6464
<Button
65-
class="me-3"
65+
class="me-3 !bg-gray-50 dark:!bg-gray-700 !text-lightDialogBodyText dark:!text-darkDialogBodyText hover:!bg-gray-100 dark:hover:!bg-gray-600 !border-gray-200 dark:!border-gray-600"
6666
@click="showConfirmationOnClose = false"
6767
>
6868
Cancel

adminforth/spa/src/components/MenuLink.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
class="min-w-5 min-h-5 text-lightSidebarIcons dark:text-darkSidebarIcons group-hover:text-lightSidebarIconsHover dark:group-hover:text-darkSidebarIconsHover transition-all duration-200 ease-in-out"
1717
>
1818
</component>
19+
<IconFileImageOutline v-else
20+
class="min-w-5 min-h-5 text-lightSidebarIcons dark:text-darkSidebarIcons group-hover:text-lightSidebarIconsHover dark:group-hover:text-darkSidebarIconsHover transition-all duration-200 ease-in-out"
21+
/>
1922
<div
2023
class="overflow-hidden block ms-3 pr-4 text-left rtl:text-right transition-all duration-200 ease-in-out"
2124
:class="{
@@ -57,6 +60,7 @@ import { getIcon } from '@/utils';
5760
import { Tooltip } from '@/afcl';
5861
import { ref, watch, computed } from 'vue';
5962
import { useCoreStore } from '@/stores/core';
63+
import { IconFileImageOutline } from '@iconify-prerendered/vue-flowbite';
6064
6165
const props = defineProps(['item', 'isChild', 'isSidebarIconOnly', 'isSidebarHovering']);
6266

adminforth/types/Back.ts

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,45 +737,143 @@ export type DeleteResourceRecordResult = {
737737
* Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
738738
*/
739739
export type BeforeDeleteSaveFunction = (params: {
740+
/**
741+
* Resource info.
742+
*/
740743
resource: AdminForthResource,
744+
/**
745+
* Primary key value of the record to delete.
746+
*/
741747
recordId: any,
742-
adminUser: AdminUser,
748+
/**
749+
* Admin user performing the action.
750+
*/
751+
adminUser: AdminUser,
752+
/**
753+
* Record data before deletion.
754+
*/
743755
record: any,
756+
/**
757+
* Adminforth instance.
758+
*/
744759
adminforth: IAdminForth,
760+
/**
761+
* HTTP response object.
762+
*
763+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
764+
*/
745765
response?: IAdminForthHttpResponse,
766+
/**
767+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
768+
*/
746769
extra?: HttpExtra,
747770
}) => Promise<{ok: boolean, error?: string}>;
748771

749772

750773
export type BeforeEditSaveFunction = (params: {
774+
/**
775+
* Resource info.
776+
*/
751777
resource: AdminForthResource,
778+
/**
779+
* Primary key value of the record to delete.
780+
*/
752781
recordId: any,
782+
/**
783+
* Admin user performing the action.
784+
*/
753785
adminUser: AdminUser,
786+
/*
787+
* Fields to update in record.
788+
*/
754789
updates: any,
790+
/**
791+
* Record with updates
792+
*
793+
* @deprecated. Will be removed in 2.0.0. Use updates instead.
794+
*/
755795
record: any, // legacy, 'updates' should be used instead
796+
/**
797+
* Record data before update.
798+
*/
756799
oldRecord: any,
800+
/**
801+
* Adminforth instance.
802+
*/
757803
adminforth: IAdminForth,
804+
/**
805+
* HTTP response object.
806+
*
807+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
808+
*/
758809
response: IAdminForthHttpResponse,
810+
/**
811+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
812+
*/
759813
extra?: HttpExtra,
760814
}) => Promise<{ok: boolean, error?: string | null}>;
761815

762816
export type BeforeCreateSaveFunction = (params: {
817+
/**
818+
* Resource info.
819+
*/
763820
resource: AdminForthResource,
821+
/**
822+
* Admin user performing the action.
823+
*/
764824
adminUser: AdminUser,
825+
/**
826+
* Record data to create.
827+
*/
765828
record: any,
829+
/**
830+
* Adminforth instance.
831+
*/
766832
adminforth: IAdminForth,
833+
/**
834+
* HTTP response object.
835+
*
836+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
837+
*/
767838
response: IAdminForthHttpResponse,
839+
768840
extra?: HttpExtra,
769841
}) => Promise<{ok: boolean, error?: string | null, newRecordId?: string}>;
770842

771843
export type AfterCreateSaveFunction = (params: {
844+
/**
845+
* Resource info.
846+
*/
772847
resource: AdminForthResource,
848+
/**
849+
* Primary key value of the record to delete.
850+
*/
773851
recordId: any,
852+
/**
853+
* Admin user performing the action.
854+
*/
774855
adminUser: AdminUser,
856+
/**
857+
* Record data after creation.
858+
*/
775859
record: any,
860+
/**
861+
* Adminforth instance.
862+
*/
776863
adminforth: IAdminForth,
864+
/**
865+
* Record with virtual columns after creation.
866+
*/
777867
recordWithVirtualColumns?: any,
868+
/**
869+
* HTTP response object.
870+
*
871+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
872+
*/
778873
response: IAdminForthHttpResponse,
874+
/**
875+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
876+
*/
779877
extra?: HttpExtra,
780878
}) => Promise<{ok: boolean, error?: string}>;
781879

@@ -784,36 +882,107 @@ export type AfterCreateSaveFunction = (params: {
784882
* Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
785883
*/
786884
export type AfterDeleteSaveFunction = (params: {
885+
/**
886+
* Resource info.
887+
*/
787888
resource: AdminForthResource,
889+
/**
890+
* Primary key value of the record to delete.
891+
*/
788892
recordId: any,
893+
/**
894+
* Admin user performing the action.
895+
*/
789896
adminUser: AdminUser,
897+
/**
898+
* Record data, that was deleted.
899+
*/
790900
record: any,
901+
/**
902+
* Adminforth instance.
903+
*/
791904
adminforth: IAdminForth,
905+
/**
906+
* HTTP response object.
907+
*
908+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
909+
*/
792910
response: IAdminForthHttpResponse,
911+
/**
912+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
913+
*/
793914
extra?: HttpExtra,
794915
}) => Promise<{ok: boolean, error?: string}>;
795916

796917

797918
export type AfterEditSaveFunction = (params: {
919+
/**
920+
* Resource info.
921+
*/
798922
resource: AdminForthResource,
923+
/**
924+
* Primary key value of the record to delete.
925+
*/
799926
recordId: any,
927+
/**
928+
* Admin user performing the action.
929+
*/
800930
adminUser: AdminUser,
931+
/**
932+
* Record updates.
933+
*/
801934
updates: any,
935+
/**
936+
* Record after update.
937+
*
938+
* @deprecated. Will be removed in 2.0.0. Use updates instead.
939+
*/
802940
record: any, // legacy, 'updates' should be used instead
941+
/**
942+
* Record data before update.
943+
*/
803944
oldRecord: any,
945+
/**
946+
* Adminforth instance.
947+
*/
804948
adminforth: IAdminForth,
949+
/**
950+
* HTTP response object.
951+
*
952+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
953+
*/
805954
response: IAdminForthHttpResponse,
955+
/**
956+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
957+
*/
806958
extra?: HttpExtra,
807959
}) => Promise<{ok: boolean, error?: string}>;
808960

809961
/**
810962
* Allow to get user data before login confirmation, will triger when user try to login.
811963
*/
812964
export type BeforeLoginConfirmationFunction = (params?: {
965+
/**
966+
* Admin user performing the action.
967+
*/
813968
adminUser: AdminUser,
969+
/**
970+
* HTTP response object.
971+
*
972+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
973+
*/
814974
response: IAdminForthHttpResponse,
975+
/**
976+
* Adminforth instance.
977+
*/
815978
adminforth: IAdminForth,
979+
/**
980+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
981+
*/
816982
extra?: HttpExtra,
983+
/**
984+
* Duration of session in format "1s", "1m", "1h", or "1d" (e.g., "30d" for 30 days)
985+
*/
817986
sessionDuration?: string,
818987
}) => Promise<{
819988
error?: string,
@@ -827,9 +996,23 @@ export type BeforeLoginConfirmationFunction = (params?: {
827996
* Allow to make extra authorization
828997
*/
829998
export type AdminUserAuthorizeFunction = ((params?: {
999+
/**
1000+
* Admin user performing the action.
1001+
*/
8301002
adminUser: AdminUser,
1003+
/**
1004+
* HTTP response object.
1005+
*
1006+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
1007+
*/
8311008
response: IAdminForthHttpResponse,
1009+
/**
1010+
* Adminforth instance.
1011+
*/
8321012
adminforth: IAdminForth,
1013+
/**
1014+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
1015+
*/
8331016
extra?: HttpExtra,
8341017
}) => Promise<{
8351018
error?: string,

dev-demo/resources/carsResourseTemplate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,19 @@ export default function carsResourseTemplate(resourceId: string, dataSource: str
247247
`${dataSource}/car_images/cars_promo_images_generated/${originalFilename}_${Date.now()}.${originalExtension}`,
248248
preview: {
249249
maxShowWidth: "300px",
250+
previewUrl({ filePath }) {
251+
return `https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${filePath}`;
252+
},
250253
},
251254
generation: {
252255
countToGenerate: 2,
253256
adapter: new ImageGenerationAdapterOpenAI({
254257
openAiApiKey: process.env.OPENAI_API_KEY as string,
255258
model: 'gpt-image-1',
256259
}),
260+
attachFiles: async ({ record }) => {
261+
return [`https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${record.promo_picture}`];
262+
},
257263
generationPrompt: "Generate a high-quality promotional image for a car with model {{model}} and color {{color}}. The car is a {{body_type}} type. The image should be vibrant and eye-catching, suitable for advertising purposes.",
258264
outputSize: '1536x1024'
259265
}

0 commit comments

Comments
 (0)