64 lines
2.5 KiB
HTML
64 lines
2.5 KiB
HTML
|
|
<script type="text/javascript">
|
|||
|
|
RED.nodes.registerType("zammad-user", {
|
|||
|
|
category: "Zammad",
|
|||
|
|
color: "#3e8e41",
|
|||
|
|
defaults: {
|
|||
|
|
name: { value: "" },
|
|||
|
|
config: { type: "zammad-config", required: true },
|
|||
|
|
operation: { value: "list" }
|
|||
|
|
},
|
|||
|
|
inputs: 1,
|
|||
|
|
outputs: 1,
|
|||
|
|
icon: "font-awesome/fa-user",
|
|||
|
|
label: function () {
|
|||
|
|
return this.name || ("Zammad User " + this.operation);
|
|||
|
|
},
|
|||
|
|
labelStyle: function () {
|
|||
|
|
return this.name ? "node_label_italic" : "";
|
|||
|
|
},
|
|||
|
|
oneditprepare: function () {
|
|||
|
|
$("#node-input-config").val(this.config ? this.config.id : "");
|
|||
|
|
},
|
|||
|
|
oneditsave: function () {
|
|||
|
|
this.operation = $("#node-select-operation").val();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<script type="text/x-red" data-template-name="zammad-user">
|
|||
|
|
<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="Zammad User">
|
|||
|
|
</div>
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label for="node-input-config"><i class="fa fa-server"></i> Config</label>
|
|||
|
|
<input type="text" id="node-input-config">
|
|||
|
|
</div>
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label for="node-select-operation"><i class="fa fa-wrench"></i> Operation</label>
|
|||
|
|
<select id="node-select-operation">
|
|||
|
|
<option value="me">Get Current User (me)</option>
|
|||
|
|
<option value="list">List Users</option>
|
|||
|
|
<option value="search">Search Users</option>
|
|||
|
|
<option value="get">Get User by ID</option>
|
|||
|
|
<option value="create">Create User</option>
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-tips" style="color:#888; font-size:11px; margin-top:10px;">
|
|||
|
|
<b>Search</b>: msg.query – e.g. <code>email:foo@example.com</code><br>
|
|||
|
|
<b>Create</b>: msg.firstname, msg.lastname, msg.email, msg.phone, msg.customer (login), msg.group
|
|||
|
|
</div>
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<script type="text/x-red" data-help-name="zammad-user">
|
|||
|
|
<p>Zammad user operations: me, list, search, get, create.</p>
|
|||
|
|
<h3>Operations</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li><b>me</b> – Get currently authenticated user info</li>
|
|||
|
|
<li><b>list</b> – List all users (optional msg.limit, msg.page)</li>
|
|||
|
|
<li><b>search</b> – Search users by query string (msg.query)</li>
|
|||
|
|
<li><b>get</b> – Get user by msg.userId</li>
|
|||
|
|
<li><b>create</b> – Create user from individual properties or full JSON payload</li>
|
|||
|
|
</ul>
|
|||
|
|
</script>
|