Skip to content
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

Integrate email template in cli #11

Merged
merged 7 commits into from
Jan 31, 2023

Conversation

rupal-bq
Copy link
Member

Description

  • Integrated email template (for email body image, created a temporary png image for all format and deleted it before cli exists)

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Rupal Mahajan <maharup@amazon.com>
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
@rupal-bq rupal-bq requested a review from a team as a code owner January 24, 2023 17:48
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions

src/arguments.js Outdated
.default(DEFAULT_EMAIL_SUBJECT)
.env(ENV_VAR.EMAIL_SUBJECT))
.addOption(new Option('--note <subject>', 'email note')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does email note mean email body?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, It's the note section in email body
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would users know what it means? i've not heard email note before

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does email body or message makes more sense? any other suggestion?

src/constants.js Outdated
@@ -11,6 +11,7 @@ export const DEFAULT_WIDTH = '1680';
export const DEFAULT_MIN_HEIGHT = '600';
export const DEFAULT_FILENAME = 'opensearch-report';
export const DEFAULT_EMAIL_SUBJECT = 'This is an email containing your opensearch dashboard report';
export const DEFAULT_EMAIL_NOTE = 'Hi,<br>Here is the latest report!';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will users know to use <br> instead of new line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure. should we add template is html somewhere in the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if new line is provided? if doesn't work as expected maybe programmatically convert text to html?

just a thought but does this need to support reading from files for easier multi-line editing? e.g. --email-body-file ./email-body.txt. or users are likely to use one-line notes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, if new line is provided it just gets ignored
e.g. 'Hi,\nHere is the latest report!' will look like
image

We can surely add text to html logic and/or read from file. Not sure what is preferred though. will check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added logic to convert text to html and note will accept string or path to a text file which can contain verbose message.

src/download-helpers.js Show resolved Hide resolved
@rupal-bq
Copy link
Member Author

Screen.Recording.2023-01-24.at.10.51.34.AM.mov

Copy link
Collaborator

@mengweieric mengweieric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left minor comments

src/download-helpers.js Outdated Show resolved Hide resolved
@@ -22,11 +22,12 @@ try {
// Do not set AWS_SDK_LOAD_CONFIG if aws config file is missing.
}

export async function sendEmail(filename, format, sender, recipient, transport, smtphost, smtpport, smtpsecure, smtpusername, smtppassword, subject) {
export async function sendEmail(filename, url, sender, recipient, transport, smtphost, smtpport, smtpsecure, smtpusername, smtppassword, subject, note) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I feel the param list is a little bit long, we may consider to refactor it a little bit later.

Copy link
Member Author

@rupal-bq rupal-bq Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created issue #12 to track this. will address this in separate PR.

@rupal-bq rupal-bq mentioned this pull request Jan 24, 2023
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
Signed-off-by: Rupal Mahajan <maharup@amazon.com>
.replace(/>/g, "&gt;")
.replace(/\t/g, " ")
.replace(/ /g, "&#8203;&nbsp;&#8203;")
.replace(/\r\n|\r|\n/g, "<br />");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need " and '? (&quot; and &apos;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not needed. tested with text file note
image

@rupal-bq rupal-bq merged commit ae120f6 into opensearch-project:main Jan 31, 2023
@rupal-bq rupal-bq deleted the email-template branch January 31, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants