Skip to content

Commit

Permalink
more email updates
Browse files Browse the repository at this point in the history
  • Loading branch information
GroG committed Jan 8, 2025
1 parent 3d9bd40 commit f4b2fca
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/myrobotlab/service/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public Email(String n, String id) {

Properties props = new Properties();


public Object addProperty(String name, String value) {
return props.setProperty(name, value);
}

public Object removeProperty(String name) {
return props.remove(name);
}

public Properties setGmailProps(String user, String password) {

Expand Down
59 changes: 59 additions & 0 deletions src/main/resources/resource/WebGui/app/service/js/EmailGui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,65 @@ angular.module("mrlapp.service.EmailGui", []).controller("EmailGuiCtrl", [
var _self = this
var msg = this.msg

// Toggle edit mode for a specific property
$scope.toggleEdit = function (key) {
$scope.editMode[key] = !$scope.editMode[key]
}

// Remove a property from the service
$scope.removeProp = function (key) {
msg.send("removeProperty", key)
msg.send("broadcastState")
}

// New property template
$scope.newProp = { name: "", value: "" }

// Add a new property to the service
$scope.addProp = function () {
if ($scope.newProp.name && $scope.newProp.value) {
msg.send("addProperty", $scope.newProp.name, $scope.newProp.value)
msg.send("broadcastState")
$scope.newProp.name = ""
$scope.newProp.value = ""
}
}

// Email data
$scope.emailRecipient = ""
$scope.emailMessage = ""
$scope.attachment = null

// Handle file selection
$scope.handleFileChange = function (event) {
$scope.$apply(() => {
$scope.attachment = event.target.files[0]
})
}

// Send email function (placeholder)
$scope.sendEmail = function () {
if (!$scope.emailRecipient.trim()) {
alert("Please enter a recipient email.")
return
}

if (!$scope.emailMessage.trim()) {
alert("Please enter an email message.")
return
}

console.log("Sending email...")
console.log("To:", $scope.emailRecipient)
console.log("Message:", $scope.emailMessage)
console.log("SMTP Config:", $scope.service.props)
if ($scope.attachment) {
console.log("Attachment:", $scope.attachment.name)
}

alert("Email Sent Successfully! (This is a placeholder function)")
}

// GOOD TEMPLATE TO FOLLOW
this.updateState = function (service) {
$scope.service = service
Expand Down

0 comments on commit f4b2fca

Please sign in to comment.