From 91dd8bd02809cbae4d5416a06826acb9ea4a4494 Mon Sep 17 00:00:00 2001 From: marysuon Date: Fri, 11 Aug 2023 20:09:51 +0200 Subject: [PATCH] feat(save-dialog): add plugin (#4618) * smtp-client * fix plugin ref * cloud settings * + save-dialog --------- Co-authored-by: Daniel Sogl --- docs/SUMMARY.md | 1 + docs/plugins/save-dialog.md | 18 ++++++++ docs/plugins/save-dialog/README.md | 20 +++++++++ docs/plugins/smtp-client/README.md | 5 +-- .../plugins/save-dialog/index.ts | 42 +++++++++++++++++++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 docs/plugins/save-dialog.md create mode 100644 docs/plugins/save-dialog/README.md create mode 100644 src/@awesome-cordova-plugins/plugins/save-dialog/index.ts diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 08169bcc85..2c8170a1d0 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -219,6 +219,7 @@ * [GCDWebServer](plugins/gcdwebserver.md) * [Smtp Client](plugins/smtp-client.md) * [Cashfree PG](plugins/cashfree-pg/README.md) + * [Save Dialog](plugins/save-dialog/README.md) * [Installation](installation.md) * [FAQ](faq.md) diff --git a/docs/plugins/save-dialog.md b/docs/plugins/save-dialog.md new file mode 100644 index 0000000000..d667a7657f --- /dev/null +++ b/docs/plugins/save-dialog.md @@ -0,0 +1,18 @@ +# Save Dialog + +```text +$ ionic cordova plugin add cordova-plugin-save-dialog +$ npm install @awesome-cordova-plugins/save-dialog +``` + +## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/save-dialog/) + +Plugin Repo: [https://github.com/Amphiluke/cordova-plugin-save-dialog](https://github.com/Amphiluke/cordova-plugin-save-dialog) + +This Cordova plugin displays the native Save dialog which allows users to store a file in the selected location. + +## Supported platforms + +* Android +* iOS + diff --git a/docs/plugins/save-dialog/README.md b/docs/plugins/save-dialog/README.md new file mode 100644 index 0000000000..d19e9a0553 --- /dev/null +++ b/docs/plugins/save-dialog/README.md @@ -0,0 +1,20 @@ +# Save Dialog + +```text +$ ionic cordova plugin add cordova-plugin-save-dialog +$ npm install @awesome-cordova-plugins/save-dialog +``` + +## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/save-dialog/) + +Plugin Repo: [https://github.com/Amphiluke/cordova-plugin-save-dialog](https://github.com/Amphiluke/cordova-plugin-save-dialog) + +This Cordova plugin displays the native Save dialog which allows users to store a file in the selected location. + +## Supported platforms + +* Android +* iOS + + + diff --git a/docs/plugins/smtp-client/README.md b/docs/plugins/smtp-client/README.md index 7f57fb7a05..564b8ebc4f 100644 --- a/docs/plugins/smtp-client/README.md +++ b/docs/plugins/smtp-client/README.md @@ -14,7 +14,4 @@ Plugin Repo: [https://github.com/CWBudde/cordova-plugin-smtp-client](https://git ## Supported platforms - Android - - iOS - - - +- iOS diff --git a/src/@awesome-cordova-plugins/plugins/save-dialog/index.ts b/src/@awesome-cordova-plugins/plugins/save-dialog/index.ts new file mode 100644 index 0000000000..e857039d56 --- /dev/null +++ b/src/@awesome-cordova-plugins/plugins/save-dialog/index.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; + +/** + * @name SaveDialog + * @description + * Plugin displays the native Save dialog which allows users to store a file in the selected location. + * @usage + * ```typescript + * import { SaveDialog } from '@awesome-cordova-plugins/save-dialog'; + * + * constructor(private saveDialog: SaveDialog) { } + * + * ... + * + * this.saveDialog.saveFile(blob, fileName); + * + * ``` + */ +@Plugin({ + pluginName: 'SaveDialog', + plugin: 'cordova-plugin-save-dialog', + pluginRef: 'SaveDialog', + repo: 'https://github.com/Amphiluke/cordova-plugin-save-dialog', + platforms: ['Android', 'iOS'], +}) +@Injectable({ + providedIn: 'root', +}) +export class SaveDialog extends AwesomeCordovaNativePlugin { + /** + * Creates a PDF using a URL, it download the document into an in memory Webkit object, and renders it into a PDF. + * + * @param url {string} URL to create a PDF from + * @param options {PDFGeneratorOptions} options for PDF generation + * @returns {Promise} + */ + @Cordova({ otherPromise: true }) + saveFile(blob: Blob, fileName?: string): Promise { + return; + } +}