Skip to content

Commit f4b2fca

Browse files
author
GroG
committed
more email updates
1 parent 3d9bd40 commit f4b2fca

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/main/java/org/myrobotlab/service/Email.java

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public Email(String n, String id) {
4747

4848
Properties props = new Properties();
4949

50+
51+
public Object addProperty(String name, String value) {
52+
return props.setProperty(name, value);
53+
}
54+
55+
public Object removeProperty(String name) {
56+
return props.remove(name);
57+
}
5058

5159
public Properties setGmailProps(String user, String password) {
5260

src/main/resources/resource/WebGui/app/service/js/EmailGui.js

+59
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,65 @@ angular.module("mrlapp.service.EmailGui", []).controller("EmailGuiCtrl", [
66
var _self = this
77
var msg = this.msg
88

9+
// Toggle edit mode for a specific property
10+
$scope.toggleEdit = function (key) {
11+
$scope.editMode[key] = !$scope.editMode[key]
12+
}
13+
14+
// Remove a property from the service
15+
$scope.removeProp = function (key) {
16+
msg.send("removeProperty", key)
17+
msg.send("broadcastState")
18+
}
19+
20+
// New property template
21+
$scope.newProp = { name: "", value: "" }
22+
23+
// Add a new property to the service
24+
$scope.addProp = function () {
25+
if ($scope.newProp.name && $scope.newProp.value) {
26+
msg.send("addProperty", $scope.newProp.name, $scope.newProp.value)
27+
msg.send("broadcastState")
28+
$scope.newProp.name = ""
29+
$scope.newProp.value = ""
30+
}
31+
}
32+
33+
// Email data
34+
$scope.emailRecipient = ""
35+
$scope.emailMessage = ""
36+
$scope.attachment = null
37+
38+
// Handle file selection
39+
$scope.handleFileChange = function (event) {
40+
$scope.$apply(() => {
41+
$scope.attachment = event.target.files[0]
42+
})
43+
}
44+
45+
// Send email function (placeholder)
46+
$scope.sendEmail = function () {
47+
if (!$scope.emailRecipient.trim()) {
48+
alert("Please enter a recipient email.")
49+
return
50+
}
51+
52+
if (!$scope.emailMessage.trim()) {
53+
alert("Please enter an email message.")
54+
return
55+
}
56+
57+
console.log("Sending email...")
58+
console.log("To:", $scope.emailRecipient)
59+
console.log("Message:", $scope.emailMessage)
60+
console.log("SMTP Config:", $scope.service.props)
61+
if ($scope.attachment) {
62+
console.log("Attachment:", $scope.attachment.name)
63+
}
64+
65+
alert("Email Sent Successfully! (This is a placeholder function)")
66+
}
67+
968
// GOOD TEMPLATE TO FOLLOW
1069
this.updateState = function (service) {
1170
$scope.service = service

0 commit comments

Comments
 (0)