Email is now functional

This commit is contained in:
neviyn 2019-07-26 13:53:09 +01:00
parent 507cf9edd1
commit 2e63653e78
4 changed files with 17 additions and 7 deletions

View File

@ -32,6 +32,7 @@ class Email {
logger.debug("Constructing email") logger.debug("Constructing email")
val email = EmailBuilder.startingBlank() val email = EmailBuilder.startingBlank()
.to("Simulator Team", environment.getProperty("smtp.toaddress")) .to("Simulator Team", environment.getProperty("smtp.toaddress"))
.from("noreply@obsdb")
.withSubject("Observation Session Data") .withSubject("Observation Session Data")
.withPlainText("Attached observation data was generated: ${DateTime.now()}.") .withPlainText("Attached observation data was generated: ${DateTime.now()}.")
.withAttachment("observations.csv", observationsToCSV(observations).toByteArray(), "text/csv") .withAttachment("observations.csv", observationsToCSV(observations).toByteArray(), "text/csv")

View File

@ -9,7 +9,7 @@
"type": "java.lang.Boolean" "type": "java.lang.Boolean"
}, },
{ {
"name": "smtp.server", "name": "smtp.host",
"type": "java.lang.String" "type": "java.lang.String"
}, },
{ {

View File

@ -7,7 +7,7 @@ spring.cache.cache-names=observations,charts
spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s
management.endpoints.web.exposure.include=health,info,metrics management.endpoints.web.exposure.include=health,info,metrics
smtp.enabled=false smtp.enabled=false
smtp.server=x smtp.host=x
smtp.port=587 smtp.port=587
smtp.username=none smtp.username=none
smtp.password=none smtp.password=none

View File

@ -372,11 +372,20 @@ export default {
this.startDate = moment().subtract(amount, timeType); this.startDate = moment().subtract(amount, timeType);
}, },
sendEmail: function() { sendEmail: function() {
Vue.axios.post("/observations/email").catch(error => { Vue.axios
this.errorStatus = error.response.status; .post("/observations/email", {
this.errorMessage = error.response.data; site: this.$store.state.search.site,
this.$refs.errorModal.show(); tutor: this.$store.state.search.tutor,
}); startDate: moment(this.startDate).format("YYYY-MM-DD"),
endDate: moment(this.endDate).format("YYYY-MM-DD"),
whom: this.$store.state.search.whom,
person: this.$store.state.search.person
})
.catch(error => {
this.errorStatus = error.response.status;
this.errorMessage = error.response.data;
this.$refs.errorModal.show();
});
} }
} }
}; };