diff --git a/src/main/java/org/myrobotlab/service/Email.java b/src/main/java/org/myrobotlab/service/Email.java index c84e7702c5..ba17eb2e83 100644 --- a/src/main/java/org/myrobotlab/service/Email.java +++ b/src/main/java/org/myrobotlab/service/Email.java @@ -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) { diff --git a/src/main/resources/resource/WebGui/app/service/js/EmailGui.js b/src/main/resources/resource/WebGui/app/service/js/EmailGui.js index ae3eab0fd9..824e770e53 100644 --- a/src/main/resources/resource/WebGui/app/service/js/EmailGui.js +++ b/src/main/resources/resource/WebGui/app/service/js/EmailGui.js @@ -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