forked from Third-Culture-Software/bhima
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reports): implement report emailing
This commit implements the email dropdown on reports as a first step towards automatic email reporting. The automatic email reports will depend on a scheduler proposed in Third-Culture-Software#2308. The email functionality depends on having a mailgun account. You should put your mailgun API key and domain in the .env.development file. Some defaults for this project have been filled out. Partially addresses Third-Culture-Software#1688 and Third-Culture-Software#1766.
- Loading branch information
Showing
16 changed files
with
539 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,10 @@ DEBUG=app | |
|
||
UPLOAD_DIR='client/upload' | ||
|
||
# Mailgun Creds | ||
MAILGUN_API_KEY="key-xyz" | ||
MAILGUN_DOMAIN="bhi.ma" | ||
MAILGUN_SERVER_ADDRESS="[email protected]" | ||
|
||
# control Redis Pub/Sub | ||
ENABLE_EVENTS=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<form name="EmailForm" bh-submit="EmailCtrl.submit(EmailForm)" novalidate> | ||
<div class="modal-header"> | ||
<ol class="headercrumb"> | ||
<li class="static"> | ||
<span translate>TREE.REPORTS</span> | ||
</li> | ||
<li class="title">{{ EmailCtrl.reportName }}</li> | ||
</ol> | ||
</div> | ||
|
||
<div class="modal-body" style="max-height:600px;"> | ||
<div class="form-group" ng-class="{ 'has-error' : EmailForm.$submitted && EmailForm.email.$invalid }"> | ||
<label class="control-label" translate>FORM.LABELS.EMAIL</label> | ||
<input name="email" type="email" ng-model="EmailCtrl.params.email" class="form-control" required> | ||
|
||
<div class="help-block" ng-messages="EmailForm.email.$error" ng-show="EmailForm.$submitted"> | ||
<div ng-messages-include="modules/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
|
||
<p class="text-primary"> | ||
<i class="fa fa-info-circle"></i> | ||
<span translate>REPORT.UTIL.EMAIL_HELP_TXT</span> | ||
</p> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" data-method="cancel" class="btn btn-default" ng-click="EmailCtrl.dismiss()"> | ||
<span translate>FORM.BUTTONS.CANCEL</span> | ||
</button> | ||
|
||
<bh-loading-button loading-state="EmailForm.$loading"> | ||
<span translate>FORM.BUTTONS.SUBMIT</span> | ||
</bh-loading-button> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
angular.module('bhima.controllers') | ||
.controller('EmailReportController', EmailReportController); | ||
|
||
EmailReportController.$inject = [ | ||
'$uibModalInstance', 'NotifyService', 'BaseReportService', 'options', | ||
'SessionService', | ||
]; | ||
|
||
function EmailReportController(ModalInstance, Notify, SavedReports, options, Session) { | ||
var vm = this; | ||
|
||
vm.reportName = options.reportName; | ||
|
||
vm.params = { | ||
email : Session.user.email, | ||
}; | ||
|
||
vm.submit = function submit(EmailForm) { | ||
if (EmailForm.$invalid) { return 1; } | ||
|
||
return SavedReports.emailReport(options.uuid, vm.params.email) | ||
.then(function () { | ||
ModalInstance.close({ sent : true }); | ||
}) | ||
.catch(Notify.handleError); | ||
}; | ||
|
||
vm.dismiss = function dismiss() { | ||
ModalInstance.close({ sent : false }); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.