mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Migrate email node to credentials system
This commit is contained in:
@@ -53,26 +53,25 @@
|
||||
<input type="text" id="node-input-port" placeholder="465">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-userid"><i class="icon-user"></i> Userid</label>
|
||||
<input type="text" id="node-config-input-userid">
|
||||
<label for="node-input-userid"><i class="icon-user"></i> Userid</label>
|
||||
<input type="text" id="node-input-userid">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-password"><i class="icon-lock"></i> Password</label>
|
||||
<input type="password" id="node-config-input-password">
|
||||
<label for="node-input-password"><i class="icon-lock"></i> Password</label>
|
||||
<input type="password" id="node-input-password">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-row">
|
||||
<label for="node-input-dname"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-dname" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Using credentials from global emailkeys.js file.</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Copied credentials from global emailkeys.js file.</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="e-mail">
|
||||
<p>Sends the <b>msg.payload</b> as an email, with a subject of <b>msg.topic</b>.</p>
|
||||
<p>It sends the message to the configured recipient <i>only</i>.</p>
|
||||
<p><b>msg.topic</b> is used to set the subject of the email, and <b>msg.payload</b> is the body text.</p>
|
||||
<p>Uses the nodemailer module.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -86,6 +85,12 @@
|
||||
name: {value:"",required:true},
|
||||
dname: {value:""}
|
||||
},
|
||||
credentials: {
|
||||
userid: {type:"text"},
|
||||
password: {type: "password"},
|
||||
global: { type:"boolean"}
|
||||
},
|
||||
|
||||
inputs:1,
|
||||
outputs:0,
|
||||
icon: "envelope.png",
|
||||
@@ -97,40 +102,11 @@
|
||||
return (this.dname||!this.topic)?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$.getJSON('email/'+this.id,function(data) {
|
||||
if (data.userid) {
|
||||
$('#node-config-input-userid').val(data.userid);
|
||||
}
|
||||
if (data.hasPassword) {
|
||||
$('#node-config-input-password').val('__PWRD__');
|
||||
} else {
|
||||
$('#node-config-input-password').val('');
|
||||
}
|
||||
if (data.global) $('#node-tip').show();
|
||||
else $('#node-tip').hide();
|
||||
});
|
||||
},
|
||||
oneditsave: function() {
|
||||
var credentials = {};
|
||||
var newUser = $('#node-config-input-userid').val();
|
||||
var newPass = $('#node-config-input-password').val();
|
||||
credentials.userid = newUser;
|
||||
if (newPass != '__PWRD__') {
|
||||
credentials.password = newPass;
|
||||
}
|
||||
$.ajax({
|
||||
url: 'email/'+this.id,
|
||||
type: 'POST',
|
||||
data: credentials,
|
||||
success: function(result){}
|
||||
});
|
||||
},
|
||||
ondelete: function() {
|
||||
$.ajax({
|
||||
url: 'email/'+this.id,
|
||||
type: 'DELETE',
|
||||
success: function(result) {}
|
||||
});
|
||||
if (this.credentials.global) {
|
||||
$('#node-tip').show();
|
||||
} else {
|
||||
$('#node-tip').hide();
|
||||
};
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -151,19 +127,19 @@
|
||||
<input type="text" id="node-input-port" placeholder="993">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-userid"><i class="icon-user"></i> Userid</label>
|
||||
<input type="text" id="node-config-input-userid">
|
||||
<label for="node-input-userid"><i class="icon-user"></i> Userid</label>
|
||||
<input type="text" id="node-input-userid">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-password"><i class="icon-lock"></i> Password</label>
|
||||
<input type="password" id="node-config-input-password">
|
||||
<input type="password" id="node-input-password">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Using credentials from global emailkeys.js file.</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Copied credentials from global emailkeys.js file.</div>
|
||||
<div id="node-input-tip" class="form-tips">Tip: <b>ONLY</b> retrieves the single most recent email.</div>
|
||||
</script>
|
||||
|
||||
@@ -186,6 +162,11 @@
|
||||
port: {value:"993",required:true},
|
||||
name: {value:""}
|
||||
},
|
||||
credentials: {
|
||||
userid: {type:"text"},
|
||||
password: {type: "password"},
|
||||
global: { type:"boolean"}
|
||||
},
|
||||
inputs:0,
|
||||
outputs:1,
|
||||
icon: "envelope.png",
|
||||
@@ -196,40 +177,11 @@
|
||||
return (this.name||!this.topic)?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$.getJSON('email/'+this.id,function(data) {
|
||||
if (data.userid) {
|
||||
$('#node-config-input-userid').val(data.userid);
|
||||
}
|
||||
if (data.hasPassword) {
|
||||
$('#node-config-input-password').val('__PWRD__');
|
||||
} else {
|
||||
$('#node-config-input-password').val('');
|
||||
}
|
||||
if (data.global) $('#node-tip').show();
|
||||
else $('#node-tip').hide();
|
||||
});
|
||||
},
|
||||
oneditsave: function() {
|
||||
var credentials = {};
|
||||
var newUser = $('#node-config-input-userid').val();
|
||||
var newPass = $('#node-config-input-password').val();
|
||||
credentials.userid = newUser;
|
||||
if (newPass != '__PWRD__') {
|
||||
credentials.password = newPass;
|
||||
}
|
||||
$.ajax({
|
||||
url: 'email/'+this.id,
|
||||
type: 'POST',
|
||||
data: credentials,
|
||||
success: function(result){}
|
||||
});
|
||||
},
|
||||
ondelete: function() {
|
||||
$.ajax({
|
||||
url: 'email/'+this.id,
|
||||
type: 'DELETE',
|
||||
success: function(result) {}
|
||||
});
|
||||
if (this.credentials.global) {
|
||||
$('#node-tip').show();
|
||||
} else {
|
||||
$('#node-tip').hide();
|
||||
};
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
Reference in New Issue
Block a user