karamokoisrael / directus-extension-flow2pdf

Other
14 stars 3 forks source link

Save file inside directus #5

Open Bollznet opened 3 months ago

Bollznet commented 3 months ago

Hi, Is possibile edit extension to save file inside directus? thanks

karamokoisrael commented 3 months ago

Hi, it is possible. But you need an extension type that is ran on the backend. Like Endpoint and Hooks.

On Wed, Jun 26, 2024 at 10:18 PM Bollznet @.***> wrote:

Hi, Is possibile edit extension to save file inside directus? thanks

— Reply to this email directly, view it on GitHub https://github.com/karamokoisrael/directus-extension-flow2pdf/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARHNR45LVCXO3NBD4SW4LZLZJLEU7AVCNFSM6AAAAABJ6AEI2WVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3TKNBZHA2TIOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

karamokoisrael commented 3 months ago

We can collaborate to add this feature if you think it'll be useful.

Bollznet commented 3 months ago

We can collaborate to add this feature if you think it'll be useful.

Hi think it’ll be very useful. I can help you, but I'm not that great with development

karamokoisrael commented 3 months ago

No problem, you can just describe how want it to work and I'll handle the implementation.

Bollznet commented 3 months ago

Wow fantastic. I was thinking of making an extension that could be integrated into flows and that would save the file inside directus. So you could modify the payload and manipulate the data as you wanted. furthermore, it can be attached to an email or to another record etc... I hope it was clear and sorry for my English. I wrote to you on IG

karamokoisrael commented 3 months ago

Ok. The flow2pdf extension allows you to get data from flow and print to populate a pdf that you can download. Do you think saving the pdf locally in directus will solve the use case you are talking about ?

Bollznet commented 3 months ago

Yes! Is perfect! but it would be even better to be able to integrate the creation of the PDF into a flow.

karamokoisrael commented 3 months ago

Oh now I get it, like an operation available in flows to save a pdf from the data collected by the flow. But how will the user be notified ?

Bollznet commented 3 months ago

then I add to the flow to send an email to notify the user and inside I put the link to the file. what do you think about it?

karamokoisrael commented 3 months ago

Sounds good to me. We can also add in app notifications. Directus has a way to notify connected users.

On Thu, Jun 27, 2024 at 9:32 PM Bollznet @.***> wrote:

then I add to the flow to send an email to notify the user and inside I put the link to the file. what do you think about it?

— Reply to this email directly, view it on GitHub https://github.com/karamokoisrael/directus-extension-flow2pdf/issues/5#issuecomment-2194703745, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARHNR43GIHTPKTYJJXHX3I3ZJQH7RAVCNFSM6AAAAABJ6AEI2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUG4YDGNZUGU . You are receiving this because you commented.Message ID: @.*** com>

karamokoisrael commented 3 months ago

I'll try to implement and basic version during my free time and let you know.

On Thu, Jun 27, 2024 at 9:52 PM Israël karamoko @.***> wrote:

Sounds good to me. We can also add in app notifications. Directus has a way to notify connected users.

On Thu, Jun 27, 2024 at 9:32 PM Bollznet @.***> wrote:

then I add to the flow to send an email to notify the user and inside I put the link to the file. what do you think about it?

— Reply to this email directly, view it on GitHub https://github.com/karamokoisrael/directus-extension-flow2pdf/issues/5#issuecomment-2194703745, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARHNR43GIHTPKTYJJXHX3I3ZJQH7RAVCNFSM6AAAAABJ6AEI2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUG4YDGNZUGU . You are receiving this because you commented.Message ID: @.*** com>

Bollznet commented 3 months ago

Yes, in the flow you can make everything, so email or directus notification or update record or start a new flow.

Bollznet commented 3 months ago

Thanks.

Unfortunately I don't know how to develop in this advanced way and I can't help you.

I'll try to implement and basic version during my free time and let you know. On Thu, Jun 27, 2024 at 9:52 PM Israël karamoko @.> wrote: Sounds good to me. We can also add in app notifications. Directus has a way to notify connected users. On Thu, Jun 27, 2024 at 9:32 PM Bollznet @.> wrote: > then I add to the flow to send an email to notify the user and inside I > put the link to the file. what do you think about it? > > — > Reply to this email directly, view it on GitHub > <#5 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ARHNR43GIHTPKTYJJXHX3I3ZJQH7RAVCNFSM6AAAAABJ6AEI2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUG4YDGNZUGU > . > You are receiving this because you commented.Message ID: > @.*** > com> >

karamokoisrael commented 3 months ago

You're already doing a lot suggesting new features. You can also help by testing the extension and giving feedbacks.

Bollznet commented 3 months ago

Hi Israel, did you have some time to work on it? Can I help you in any way?

karamokoisrael commented 3 months ago

Hi @Bollznet, not yet. But I'm going to start next week.

Bollznet commented 3 months ago

Hi Israel! Thanks! When you need information, I'm here.

Bollznet commented 3 months ago

Hi @karamokoisrael do you have any news? Were you able to watch us if possible?

karamokoisrael commented 3 months ago

Hi @Bollznet , I've implemented most of the features we've talked about. But I was wondering, should we let the user select his own operation ( sending email or notification ) after the pdf is generated or or operation should handle it all ?

Bollznet commented 3 months ago

Wow fantastic @karamokoisrael! I think best thing is that user select his own operation. so it can be adapted to multiple solutions What do you think?

karamokoisrael commented 3 months ago

I also think it's a good idea to give the user the freedom to chose his own operation. Our operation will return the saved file data then the user can decide how he wants to use it.

karamokoisrael commented 3 months ago

Hi @Bollznet . I'm done, you can install it locally and give it a try.

Bollznet commented 3 months ago

Hi @karamokoisrael ! Today I’m out of office! As soon as I get back I'll try it straight away and give you some feedback! thanks

Bollznet commented 3 months ago

hi @karamokoisrael i'm try the extension but there is an error:

[09:39:17.519] WARN: Cannot find module 'html-pdf-node' directus-1 | Require stack: directus-1 | - /directus/extensions/directus-extension-flow2pdf-master/dist/api.cjs directus-1 | err: { directus-1 | "type": "Error", directus-1 | "message": "Cannot find module 'html-pdf-node'\nRequire stack:\n- /directus/extensions/directus-extension-flow2pdf-master/dist/api.cjs", directus-1 | "stack": directus-1 | Error: Cannot find module 'html-pdf-node' directus-1 | Require stack: directus-1 | - /directus/extensions/directus-extension-flow2pdf-master/dist/api.cjs directus-1 | at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15) directus-1 | at Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25) directus-1 | at require (node:internal/modules/helpers:177:18) directus-1 | at Object. (/directus/extensions/directus-extension-flow2pdf-master/dist/api.cjs:1:113328) directus-1 | at Module._compile (node:internal/modules/cjs/loader:1364:14) directus-1 | at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) directus-1 | at Module.load (node:internal/modules/cjs/loader:1203:32) directus-1 | at Module._load (node:internal/modules/cjs/loader:1019:12) directus-1 | at ModuleWrap. (node:internal/modules/esm/translators:203:29) directus-1 | at ModuleJob.run (node:internal/modules/esm/module_job:195:25) directus-1 | "code": "MODULE_NOT_FOUND", directus-1 | "requireStack": [ directus-1 | "/directus/extensions/directus-extension-flow2pdf-master/dist/api.cjs" directus-1 | ] directus-1 | }

Can you help? thanks

karamokoisrael commented 3 months ago

Have you installed it with a package manager like npm, yarn... or from the marketplace ?

karamokoisrael commented 3 months ago

If you install it with the package manager everything will work fine. But if you try with the marketplace the following package will be missing html-pdf-node. I'll try to ask for help in the community.

Bollznet commented 3 months ago

@karamokoisrael i try with package manager but doesn't go. I launch this command "npm i directus-extension-flow2pdf" in root directory.

Bollznet commented 3 months ago

@karamokoisrael i had install it. But in the flow i had this error { "name": "DirectusError", "extensions": { "collection": "directus_files" }, "code": "UNEXPECTED_ERROR", "status": 500 }

How did you set up your flow to save the file? Thanks Stefano

Bollznet commented 3 months ago

this in log Error: Failed to launch the browser process! spawn /directus/node_modules/.pnpm/puppeteer@10.4.0/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome ENOENT directus-1 | TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md directus-1 | at onClose (/directus/node_modules/.pnpm/puppeteer@10.4.0/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20) directus-1 | at ChildProcess. (/directus/node_modules/.pnpm/puppeteer@10.4.0/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:189:85) directus-1 | at ChildProcess.emit (node:events:517:28) directus-1 | at ChildProcess._handle.onexit (node:internal/child_process:290:12) directus-1 | at onErrorNT (node:internal/child_process:477:16) directus-1 | at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

karamokoisrael commented 3 months ago

You can try to reinstall the package and see if it works

Bollznet commented 3 months ago

nothing change @karamokoisrael the problem is install chrome inside docker. I'm are in localhost and this is my dockerfile

`FROM directus/directus:latest

USER root RUN corepack enable RUN apk update RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm RUN apk add google-chrome-stable_current_x86_64.rpm USER node

RUN pnpm install directus-extension-flow2pdf`

Do you use extension in localhost or in web server? thanks

karamokoisrael commented 3 months ago

It works in both environments

Bollznet commented 3 months ago

May I ask you how to install the extension. Because I installed chromium, but then I have to install all the rest of the dependencies. I can't get it to work, something is missing every time.

karamokoisrael commented 3 months ago

It should be easier with npm. However, if you install from the marketplace, the dependency used for printing the PDF will cause some issues. I've asked for help in the community, but the suggestions I've received haven't worked.

Bollznet commented 3 months ago

@karamokoisrael Thanks for your effort, I haven't been able to install it yet. I think there is some problem on where to read the nodo_modules. I've been trying to fix it for two days but without success. I'm also asking for help fixing the source.