@danimart1991/node-red-radarr-api
Version:
A set of Node-RED nodes to use with Radarr API.
206 lines (200 loc) • 9.45 kB
HTML
<script type="text/html" data-template-name="radarr-api-history-get">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-input-server" />
</div>
<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="Name" />
</div>
<hr align="middle" />
<div class="form-row">
<label for="node-input-include_movie"><i class="fa fa-plus"></i> Movie Data</label>
<input type="text" id="node-input-include_movie" />
<input type="hidden" id="node-input-include_movie_type" />
</div>
<hr align="middle" />
<div class="form-row">
<label for="node-input-movie_id"><i class="fa fa-hashtag"></i> Movie Id</label>
<input type="text" id="node-input-movie_id" placeholder="Optional" />
<input type="hidden" id="node-input-movie_id_type" />
</div>
<div class="form-row">
<label for="node-input-event_type"><i class="fa fa-history"></i> Events Type</label>
<input type="text" id="node-input-event_type" />
</div>
<div id="node-input-order_row">
<hr align="middle" />
<div class="form-row">
<label for="node-input-sort_key"><i class="fa fa-sort-alpha-asc"></i> Sort By</label>
<input type="text" id="node-input-sort_key" />
</div>
<div class="form-row">
<label for="node-input-sort_dir"><i class="fa fa-sort"></i> Direction</label>
<input type="text" id="node-input-sort_dir" />
</div>
<div class="form-row">
<label for="node-input-page"><i class="fa fa-files-o"></i> Page</label>
<input type="text" id="node-input-page" placeholder="Default: 1" />
<input type="hidden" id="node-input-page_type" />
</div>
<div class="form-row">
<label for="node-input-page_size"><i class="fa fa-file-text-o"></i> Page Size</label>
<input type="text" id="node-input-page_size" placeholder="Default: 10" />
<input type="hidden" id="node-input-page_size_type" />
</div>
</div>
</script>
<script type="text/html" data-help-name="radarr-api-history-get">
<p>
Get an <i>Array</i> with histories stored in the <i>Radarr</i> database. The <b>Id</b> of a movie can be included as an additional parameter to obtain
only the data of that movie. Indeed, there are other filters and options (see below).
</p>
<p>In addition, the second output provides a <b>Log</b> with information on how the execution has worked.</p>
<h3>Parameters</h3>
<dl class="message-properties">
<dt>server <span class="property-type">radarr-api-server</span></dt>
<dd>a <b>Radarr Server</b> previously configured.</dd>
<dt>include_movie <span class="property-type">bool</span></dt>
<dd>adds Movie data to the response.</dd>
<dt class="optional">movie_id <span class="property-type">number</span></dt>
<dd>return only histories of a <b>Movie</b>.</dd>
<dt class="optional">event_type <span class="property-type">select</span></dt>
<dd>filter histories by <b>Event Type</b>.</dd>
<dt class="optional">sort_key <span class="property-type">select</span></dt>
<dd>sort histories by <b>Date</b> or <b>Title</b>.</dd>
<dt class="optional">sort_dir <span class="property-type">select</span></dt>
<dd>sort histories <b>Descending</b> or <b>Ascending</b>.</dd>
<dt class="optional">page <span class="property-type">number</span></dt>
<dd>return this <b>page</b> number.</dd>
<dt class="optional">page_size <span class="property-type">number</span></dt>
<dd>split result in pages with this <b>size</b>.</dd>
</dl>
<h3>Output 1 (Result)</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>an <i>Array</i> with one or more history <i>objects</i>.</dd>
</dl>
<h3>Output 2 (Log)</h3>
<dl class="message-properties">
<dt>payload.level <span class="property-type">string</span></dt>
<dd>the log <b>Level</b>: <i>Debug</i>, <i>Info</i>, <i>Warn</i>, <i>Error</i>, <i>Critical</i> or <i>Other</i>.</dd>
<dt>payload.message <span class="property-type">string</span></dt>
<dd>the log <b>Message</b>.</dd>
<dt>payload.source.id <span class="property-type">string</span></dt>
<dd>the <b>Id</b> of the node that threw the log.</dd>
<dt>payload.source.type <span class="property-type">string</span></dt>
<dd>the <b>Type</b> of the node that threw the log.</dd>
<dt>payload.source.name <span class="property-type">string</span></dt>
<dd>the <b>Name</b>, if set, of the node that threw the log.</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType('radarr-api-history-get', {
category: 'radarr',
color: '#ffc230',
defaults: {
name: { value: '' },
server: { value: '', type: 'radarr-api-server', required: true },
include_movie: { value: '' },
include_movie_type: { value: 'bool' },
movie_id: { value: '' },
movie_id_type: { value: 'num' },
event_type: { value: '' },
sort_key: { value: '' },
sort_dir: { value: '' },
page: { value: '' },
page_type: { value: 'num' },
page_size: { value: '' },
page_size_type: { value: 'num' },
},
inputs: 1,
outputs: 2,
icon: 'font-awesome/fa-play',
label: function () {
return this.name || 'get histories';
},
paletteLabel: function () {
return 'get histories';
},
outputLabels: ['histories', 'log'],
oneditprepare: function () {
$('#node-input-include_movie').typedInput({
default: 'bool',
typeField: $('#node-input-include_movie_type'),
types: ['bool'],
});
$('#node-input-movie_id').on('change', function (element) {
if (element.currentTarget.value) {
$('#node-input-order_row').hide();
} else {
$('#node-input-order_row').show();
}
});
$('#node-input-movie_id').typedInput({
default: 'num',
typeField: $('#node-input-movie_id_type'),
types: ['num', 'msg', 'flow', 'global', 'jsonata'],
});
$('#node-input-event_type').typedInput({
types: [
{
value: 'event_type',
options: [
{ value: '', label: 'All' },
{ value: '0', label: 'Unknown' },
{ value: '1', label: 'Grabbed' },
{ value: '3', label: 'Download Folder Imported' },
{ value: '4', label: 'Download Failed' },
{ value: '6', label: 'Movie File Deleted' },
{ value: '7', label: 'Movie Folder Imported' },
{ value: '8', label: 'Movie File Renamed' },
{ value: '9', label: 'Download Ignored' },
],
},
],
});
$('#node-input-sort_key').typedInput({
types: [
{
value: 'sort_key',
options: [
{ value: 'date', label: 'Date' },
{ value: 'title', label: 'Movie Title' },
],
},
],
});
$('#node-input-sort_dir').typedInput({
types: [
{
value: 'sort_dir',
options: [
{ value: 'descending', label: 'Descending' },
{ value: 'ascending', label: 'Ascending' },
],
},
],
});
$('#node-input-page').typedInput({
default: 'num',
typeField: $('#node-input-page_type'),
types: ['num', 'msg', 'flow', 'global', 'jsonata'],
});
$('#node-input-page_size').typedInput({
default: 'num',
typeField: $('#node-input-page_size_type'),
types: ['num', 'msg', 'flow', 'global', 'jsonata'],
});
},
oneditsave: function () {
let movie_id = $('#node-input-movie_id').val();
if (movie_id) {
$('#node-input-sort_key').val('');
$('#node-input-sort_dir').val('');
$('#node-input-page').val('');
$('#node-input-page_size').val('');
}
},
});
</script>