Skip to content

Commit 4bf209c

Browse files
author
GroG
committed
email and change log
1 parent 2ba5e79 commit 4bf209c

File tree

5 files changed

+138
-40
lines changed

5 files changed

+138
-40
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ jobs:
8585
name: myrobotlab
8686
path: target/
8787

88+
- name: Generate Change Log
89+
run: |
90+
echo "## Changelog" > changelog.md
91+
echo "" >> changelog.md
92+
git log --pretty=format:"- %s" -n 10 >> changelog.md
93+
echo "" >> changelog.md
94+
cat changelog.md
95+
8896
- name: Create GitHub Release
8997
uses: softprops/action-gh-release@v2
9098
with:
@@ -106,6 +114,8 @@ jobs:
106114
You will need **Java 11 or newer**. If you are only running MyRobotLab, you need the JRE (Java Runtime Environment).
107115
If you are building from source, you will need the JDK (Java Development Kit). Oracle or OpenJDK will work.
108116
117+
$(cat changelog.md)
118+
109119
files: target/myrobotlab-${{ needs.build.outputs.version }}.zip
110120
draft: false
111121
prerelease: false

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ public class Email extends Service<EmailConfig> {
4444
public Email(String n, String id) {
4545
super(n, id);
4646
}
47+
48+
Properties props = new Properties();
49+
4750

48-
public Map<String, String> setGmailProps(String user, String password) {
49-
Map<String, String> props = ((EmailConfig) this.config).properties;
51+
public Properties setGmailProps(String user, String password) {
52+
5053
props.put("mail.smtp.user", user);
5154
props.put("mail.smtp.pass", password);
5255
props.put("mail.smtp.host", "smtp.gmail.com");
@@ -88,11 +91,7 @@ public void sendImage(String to, String imageFile) {
8891
*/
8992

9093
public void sendMail(String to, String subject, String body, String imageFile) {
91-
EmailConfig config = (EmailConfig) this.config;
92-
93-
Properties props = new Properties();
94-
props.putAll(config.properties);
95-
sendTextMail(config.properties.get("mail.smtp.user"), to, subject, body, config.format, null);
94+
sendTextMail((String)props.get("mail.smtp.user"), to, subject, body, config.format, null);
9695
}
9796

9897
public void sendHtmlMail(String from, String to, String subject, String body, String imageFileName) {
@@ -108,9 +107,6 @@ public void sendHtmlMail(String from, String to, String subject, String body, St
108107
to = config.to;
109108
}
110109

111-
Properties props = new Properties();
112-
props.putAll(config.properties);
113-
114110
Session session = Session.getDefaultInstance(props);
115111

116112
// Create a default MimeMessage object.
@@ -191,10 +187,6 @@ public void sendHtmlMail(String from, String to, String subject, String body, St
191187

192188
public void sendTextMail(String from, String to, String subject, String body, String format, List<Object> attachments) {
193189
try {
194-
EmailConfig config = (EmailConfig) this.config;
195-
196-
Properties props = new Properties();
197-
props.putAll(config.properties);
198190

199191
Session session = Session.getDefaultInstance(props);
200192

@@ -252,11 +244,11 @@ public static void main(String[] args) {
252244
try {
253245

254246
LoggingFactory.init(Level.INFO);
255-
247+
Runtime.start("webgui","WebGui");
248+
Runtime.start("python","Python");
256249
Email email = (Email) Runtime.start("email", "Email");
257-
258-
email.setGmailProps("[email protected]", "xxxxxxxxx");
259-
email.sendImage("[email protected]", "data/OpenCV/cv-00573.png");
250+
email.setGmailProps("[email protected]", "XXXXXXXXXX");
251+
email.sendImage("[email protected]", "data/OpenCV/i01.opencv-00136.png");
260252

261253
} catch (Exception e) {
262254
log.error("main threw", e);
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
package org.myrobotlab.service.config;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
3+
/**
4+
* Email config gets turned into javax email props
5+
*/
66
public class EmailConfig extends ServiceConfig {
77

8-
@Deprecated /* is supposed to be userfriendly not like a single properties */
9-
public Map<String,String> properties = new HashMap<>();
10-
11-
public String to; // if set sends auto
12-
8+
public String to; // if set sends auto
139
public String format = "text/html"; // text/html or text/plain
14-
15-
// elements in the map
16-
public String user = null;
17-
public String host = null;
18-
public int port = 25; /* 465, 587 */
19-
public String from = null;
20-
boolean auth = true;
21-
boolean starttls = true;
22-
boolean debug = true;
23-
boolean starttlsRequired = true;
24-
String protocols = "TLSv1.2";
25-
String socketFactory = "javax.net.ssl.SSLSocketFactory";
26-
27-
public String pass = null;
10+
public String user = null;
11+
public String host = null;
12+
public int port = 25; /* 465, 587 */
13+
public String from = null;
14+
boolean auth = true;
15+
boolean starttls = true;
16+
boolean debug = true;
17+
boolean starttlsRequired = true;
18+
String protocols = "TLSv1.2";
19+
String socketFactory = "javax.net.ssl.SSLSocketFactory";
20+
21+
public String pass = null;
2822

2923
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
angular.module("mrlapp.service.EmailGui", []).controller("EmailGuiCtrl", [
2+
"$scope",
3+
"mrl",
4+
function ($scope, mrl) {
5+
console.info("EmailGuiCtrl")
6+
var _self = this
7+
var msg = this.msg
8+
9+
// GOOD TEMPLATE TO FOLLOW
10+
this.updateState = function (service) {
11+
$scope.service = service
12+
}
13+
14+
// init scope variables
15+
$scope.onTime = null
16+
$scope.onEpoch = null
17+
18+
this.onMsg = function (inMsg) {
19+
let data = inMsg.data[0]
20+
switch (inMsg.method) {
21+
case "onState":
22+
_self.updateState(data)
23+
$scope.$apply()
24+
break
25+
case "onTime":
26+
const date = new Date(data)
27+
$scope.onTime = date.toLocaleString()
28+
$scope.$apply()
29+
break
30+
case "onEpoch":
31+
$scope.onEpoch = data
32+
$scope.$apply()
33+
break
34+
default:
35+
console.error("ERROR - unhandled method " + $scope.name + " " + inMsg.method)
36+
break
37+
}
38+
}
39+
40+
msg.subscribe("publishTime")
41+
msg.subscribe("publishEpoch")
42+
msg.subscribe(this)
43+
},
44+
])
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<br/><br/><br/>
2+
&nbsp;<div class="row">
3+
<table class="padded-table">
4+
<thead>
5+
<tr>
6+
<th>Name</th>
7+
<th>Value</th>
8+
<th>Actions</th>
9+
</tr>
10+
</thead>
11+
<tbody>
12+
<tr ng-repeat="(key, value) in service.props">
13+
<td>{{ key }}</td>
14+
<td>
15+
<span ng-if="!editMode[key]">{{ value }}</span>
16+
<input ng-if="editMode[key]" type="text" ng-model="service.props[key]" />
17+
</td>
18+
<td>
19+
<button ng-click="toggleEdit(key)">
20+
<span ng-if="!editMode[key]">✏️</span>
21+
<span ng-if="editMode[key]">✔️</span>
22+
</button>
23+
<button ng-click="removeProp(key)"></button>
24+
</td>
25+
</tr>
26+
<tr>
27+
<td><input type="text" ng-model="newProp.name" placeholder="New Name" /></td>
28+
<td><input type="text" ng-model="newProp.value" placeholder="New Value" /></td>
29+
<td><button ng-click="addProp()"></button></td>
30+
</tr>
31+
</tbody>
32+
</table>
33+
</div>
34+
35+
<!-- Email Section -->
36+
<div class="row" style="margin-top: 20px;">
37+
<!-- Recipient Input -->
38+
<label>To:</label>
39+
<input type="email" ng-model="emailRecipient" style="width: 100%;" placeholder="Recipient Email" />
40+
41+
<!-- Email Message Input -->
42+
<label style="margin-top: 10px;">Email Message:</label>
43+
<textarea ng-model="emailMessage" rows="5" style="width: 100%;" placeholder="Type your message here..."></textarea>
44+
45+
<!-- Buttons Row -->
46+
<div style="margin-top: 10px;">
47+
<input type="file" ng-model="attachment" style="margin-right: 10px;" />
48+
<button ng-click="sendEmail()">📧 Send Email</button>
49+
</div>
50+
</div>
51+
52+
<!-- Minimal Padding for Table -->
53+
<style>
54+
.padded-table th, .padded-table td {
55+
padding: 5px;
56+
}
57+
</style>
58+

0 commit comments

Comments
 (0)