Files
nextcloud-nodered-ocs-api/nodes/nextcloud-ocs/mail.html
T

67 lines
5.8 KiB
HTML

<script type="text/javascript">
RED.nodes.registerType('mail', {
category: 'nextcloud',
color: '#CC9900',
defaults: {
name: { value: "" }, nextcloud: { type: "nextcloud-config", required: true },
operation: { value: "account:list" },
messageId: { value: "" }, attachmentId: { value: "" }, mailboxId: { value: "" },
bodyAccountId: { value: "" }, bodyFromEmail: { value: "" }, bodySubject: { value: "" },
bodyBody: { value: "" }, bodyIsHtml: { value: "" }, bodyTo: { value: "" },
bodyCc: { value: "" }, bodyBcc: { value: "" }, bodyReferences: { value: "" },
bodyCursor: { value: "" }, bodyFilter: { value: "" }, bodyLimit: { value: "" }, bodyView: { value: "" }
},
inputs: 1, outputs: 1, icon: "mail.svg",
label: function() { return this.name || "Mail"; },
oneditprepare: function() {
var opMeta = {
'account:list': { method:'GET', params:false, send:false, mailbox:false },
'message:get': { method:'GET', params:false, send:false, mailbox:false },
'message:getRaw': { method:'GET', params:false, send:false, mailbox:false },
'message:attachment':{ method:'GET', params:false, send:false, mailbox:false },
'mailbox:list': { method:'GET', params:false, send:false, mailbox:false },
'mailbox:messages': { method:'GET', params:true, send:false, mailbox:true },
'message:send': { method:'POST',params:false, send:true, mailbox:false }
};
function update() {
var m = opMeta[$('#node-input-operation').val()] || {};
$('#mail-params').toggle(m.params); $('#mail-send').toggle(m.send);
$('#mail-mailbox').toggle(m.mailbox); $('#op-method-mail').text(m.method || 'GET');
}
$('#node-input-operation').change(update); setTimeout(update, 100);
}
});
</script>
<script type="text/html" data-template-name="mail">
<div class="form-row"><label for="node-input-name"><i class="fa fa-tag"></i> Name</label><input type="text" id="node-input-name" placeholder="Mail"></div>
<div class="form-row"><label for="node-input-nextcloud"><i class="fa fa-cloud"></i> Nextcloud Config</label><input type="text" id="node-input-nextcloud" placeholder="Select config node"></div>
<div class="form-row"><label for="node-input-operation"><i class="fa fa-cog"></i> Operation</label>
<select id="node-input-operation" style="width:100%;">
<optgroup label="Accounts"><option value="account:list">List Accounts</option></optgroup>
<optgroup label="Messages"><option value="message:get">Get Message</option><option value="message:getRaw">Get Raw Message</option><option value="message:attachment">Get Attachment</option><option value="message:send">Send Email</option></optgroup>
<optgroup label="Mailboxes"><option value="mailbox:list">List Mailboxes</option><option value="mailbox:messages">List Messages</option></optgroup>
</select><span id="op-method-mail" style="margin-left:8px;color:#888;font-size:0.85em;">GET</span>
</div>
<hr><div style="font-weight:bold;margin-bottom:6px;">Path Parameters</div>
<div class="form-row"><label>Message ID</label><input type="text" id="node-input-messageId" placeholder="msg.messageId"></div>
<div class="form-row"><label>Attachment ID</label><input type="text" id="node-input-attachmentId" placeholder="msg.attachmentId"></div>
<div class="form-row" id="mail-mailbox"><label>Mailbox ID</label><input type="text" id="node-input-mailboxId" placeholder="msg.mailboxId"></div>
<div id="mail-params" style="display:none;"><hr><div style="font-weight:bold;margin-bottom:6px;">Query Params</div>
<div class="form-row"><label>Cursor</label><input type="text" id="node-input-bodyCursor" placeholder="msg.cursor"></div>
<div class="form-row"><label>Filter</label><input type="text" id="node-input-bodyFilter" placeholder="msg.filter"></div>
<div class="form-row"><label>Limit</label><input type="text" id="node-input-bodyLimit" placeholder="msg.limit"></div>
<div class="form-row"><label>View</label><input type="text" id="node-input-bodyView" placeholder="msg.view"></div>
</div>
<div id="mail-send" style="display:none;"><hr><div style="font-weight:bold;margin-bottom:6px;">Send Email</div>
<div class="form-row"><label>Account ID</label><input type="text" id="node-input-bodyAccountId" placeholder="msg.accountId"></div>
<div class="form-row"><label>From Email</label><input type="text" id="node-input-bodyFromEmail" placeholder="msg.fromEmail"></div>
<div class="form-row"><label>Subject</label><input type="text" id="node-input-bodySubject" placeholder="msg.subject"></div>
<div class="form-row"><label>Body</label><textarea id="node-input-bodyBody" rows="3" placeholder="msg.body"></textarea></div>
<div class="form-row"><label>Is HTML</label><input type="text" id="node-input-bodyIsHtml" placeholder="true/false (msg.isHtml)"></div>
<div class="form-row"><label>To (JSON)</label><input type="text" id="node-input-bodyTo" placeholder='[{"email":"a@b.com"}]'></div>
<div class="form-row"><label>CC (JSON)</label><input type="text" id="node-input-bodyCc" placeholder='[{"email":"a@b.com"}]'></div>
<div class="form-row"><label>BCC (JSON)</label><input type="text" id="node-input-bodyBcc" placeholder='[{"email":"a@b.com"}]'></div>
<div class="form-row"><label>References</label><input type="text" id="node-input-bodyReferences" placeholder="msg.references"></div>
</div>
<div class="form-tips"><p>All fields overridable via <code>msg.*</code>. To/CC/BCC: pass arrays in msg.to/msg.cc/msg.bcc.</p></div>
</script>