-
Notifications
You must be signed in to change notification settings - Fork 4
/
actions.html
133 lines (129 loc) · 5.89 KB
/
actions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<script type="text/javascript">
RED.nodes.registerType('mailactions',{
category: 'social',
color: '#c7e9c0',
defaults: {
name: {value:""},
protocol: {value: "IMAP", required:true}, // Which protocol to use to connect to the mail server ("IMAP" or "POP3")
server: {value:"imap.gmail.com",required:true},
useSSL: {value: true},
port: {value:"993",required:true},
box: {value:"INBOX"}, // For IMAP, The mailbox to process
outbox: {value:"Processed"}, // For IMAP, The mailbox to process
tag: {value:"nodered"}, // For IMAP, The mailbox to process
},
credentials: {
userid: {type:"text"},
password: {type: "password"},
global: { type:"boolean"}
},
inputs:1,
outputs:1,
icon: "envelope.png",
paletteLabel: function() {
return "mail-actions";
},
label: function() {
return this.name||"mail-actions";
},
labelStyle: function() {
return (this.name)?"node_label_italic":"";
},
oneditprepare: function() {
if (this.credentials.global) {
$('#node-tip').show();
} else {
$('#node-tip').hide();
}
if (typeof this.box === 'undefined') {
$("#node-input-box").val("INBOX");
this.box = "INBOX";
}
}
});
</script>
<script type="text/x-red" data-template-name="mailactions">
<div class="form-row">
<label for="node-input-protocol"><i class="fa fa-envelope"></i> <span>Protocol</span></label>
<select type="text" id="node-input-protocol">
<option value="IMAP">IMAP</option>
<option value="POP3">POP3</option>
</select>
</div>
<div class="form-row">
<label for="node-input-useSSL"><i class="fa fa-lock"></i> <span>Use SSL?</span></label>
<input type="checkbox" id="node-input-useSSL" style="width: auto;">
</div>
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> <span>Server</span></label>
<input type="text" id="node-input-server" placeholder="imap.gmail.com">
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-random"></i> <span>Port</span></label>
<input type="text" id="node-input-port" placeholder="993">
</div>
<div class="form-row">
<label for="node-input-userid"><i class="fa fa-user"></i> <span>Userid</span></label>
<input type="text" id="node-input-userid">
</div>
<div class="form-row">
<label for="node-input-password"><i class="fa fa-lock"></i> <span>Password</span></label>
<input type="password" id="node-input-password">
</div>
<br/>
<div class="form-row node-input-box">
<label for="node-input-box"><i class="fa fa-inbox"></i> <span>Original Folder</span></label>
<input type="text" id="node-input-box">
</div>
<div class="form-row node-input-box">
<label for="node-input-outbox"><i class="fa fa-inbox"></i> <span>Target Folder</span></label>
<input type="text" id="node-input-outbox">
</div>
<br/>
<div class="form-row node-input-box">
<label for="node-input-tag"><i class="fa fa-tag"></i> <span>Tag</span></label>
<input type="text" id="node-input-tag">
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<script>
var checkPorts = function() {
var currentPort = $("#node-input-port").val();
if (currentPort === "143" || currentPort === "993" || currentPort === "110" || currentPort == "995") {
if ($("#node-input-useSSL").prop("checked") === true) {
$("#node-input-port").val($("#node-input-protocol").val() === "IMAP"?"993":"995");
} else {
$("#node-input-port").val($("#node-input-protocol").val() === "IMAP"?"143":"110");
}
}
};
$("#node-input-useSSL").change(function(x, y) {
console.log("useSSL: x="+ JSON.stringify(x) + ", y=" + y);
console.log("Value: " + $("#node-input-useSSL").prop("checked"));
checkPorts();
});
$("#node-input-protocol").change(function() {
var protocol = $("#node-input-protocol").val();
if (protocol === "IMAP") {
$(".node-input-box").show();
$(".node-input-disposition").show();
} else {
$(".node-input-box").hide();
$(".node-input-disposition").hide();
}
checkPorts();
});
</script>
</script>
<script type="text/x-red" data-help-name="mailactions">
<p>A node to compliment the existing email-IN node provided as standard within Node-RED.</p>
<h3>Inputs</h3>
<p>The message sent to this node is expected to contain the output of an email-in node. Specifically the <code>headers</code> object is used to locate the individual message related to this message. Once the email has been identified, the node attempts to add the <code>label</code> to the email, and move it to a specified <code>folder</code></p>
<p>The new label can be sent via <code>msg.email.label</code> or set in the node properties.</p>
<p>The new target folder can be sent via <code>msg.email.folder</code> or set in the node properties.</p>
<h3>Outputs</h3>
<p>The original message will remain unchanged as a result of this node however there will be an additional <code>msg._email</code> property which contains information about the specific email from the IMAP server.</p>
</script>