UNPKG

node-red-contrib-snap4city-milestone

Version:

Node-Red integration to communicate with Milestone XProtect VMS

152 lines (133 loc) 5.01 kB
<!--/* NODE-RED-CONTRIB-SNAP4CITY-MILESTONE Copyright (C) 2023 DISIT Lab http://www.disit.org - University of Florence This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */--> <script type="text/javascript"> RED.nodes.registerType('x-login', { category: 'S4CMilestone', color: '#fde910', inputs: 0, outputs: 1, icon: 'icons/logocam.png', label: 'Login to Milestone', defaults: { address: { type: 'text', value: '', validate: function (v) { let url; try { url = new URL(v); } catch (_) { return false; } return url.protocol === "http:" || url.protocol === "https:"; } }, user: { type: 'text' }, password: { type: 'password' } } }); </script> <script type="text/html" data-template-name="x-login"> <!-- Address --> <div class="form-row"> <label for="node-input-address"><i class="fa fa-tag"></i> Address</label> <input id="node-input-address" type="text" placeholder="http://"> </div> <div id="node-row-basic-auth"> <!-- User --> <div class="form-row"> <label for="node-input-user"><i class="fa fa-tag"></i> User</label> <input type="text" id="node-input-user" placeholder="User"> </div> <!-- Password --> <div class="form-row"> <label for="node-input-password"><i class="fa fa-tag"></i> Password</label> <input type="password" id="node-input-password" placeholder="Password"> </div> </div> </script> <script type="text/x-red" data-help-name="x-login"> <p>It allows to Login to Milestone VMS with a basic user account with administrator role. Allows you to receive both the token for the REST and for the SOAP api with the same credentials.</p> <h3>Inputs</h3> <p>There aren't inputs. The credentials required for login are entered in the node properties and they are as follows:</p> <dl class="message-properties"> <dt>Address <span class="property-type">string</span> </dt> <dd>The hostname where the Milestone VMS runs on. Only http or https are allowed <b>(mandatory)</b></dd> <dt>Username <span class="property-type">string</span> </dt> <dd>The username present in the Milestone VMS, registered as basic user <b>(mandatory)</b></dd> <dt>Password <span class="property-type">string</span> </dt> <dd>A valid password for the username above <b>(mandatory)</b></dd> </dl> <h3>Outputs</h3> <p>JSON object with these properties:</p> <dl class="message-properties"> <dt>tokenRest <span class="property-type">string</span> </dt> <dd>The access Token for the rest APIs if the login was successful, null otherwise</dd> <dt>tokenSOAP <span class="property-type">string</span> </dt> <dd>The access Token for the SOAP calls if the login was successful, null otherwise</dd> <dt>expireRest <span class="property-type">number</span> </dt> <dd>The expire time of access Token for the rest APIs if the login was successful, null otherwisee</dd> <dt>expireSOAP <span class="property-type">number</span> </dt> <dd>The expire time of access Token for the SOAP calls if the login was successful, null otherwise</dd> <dt>error <span class="property-type">string</span> </dt> <dd>The error generated by an incorrect login, null otherwise</dd> </dl> <h3>Example of JSON output if login works:</h3> <dl class="exampleJson"> <dd> <pre> { tokenREST: "eyJhbOciODSUzI1NiIsImtpZCI6Ij", tokenSOAP: "TOKEN#85c18f10-e479-44c0- 9af7", expireREST: 3600, expireSOAP: 14400, error: null } </pre> </dd> </dl> <h3>Example of JSON output of incorrect login:</h3> <dl class="exampleJson"> <dd> <pre> { tokenREST: null, tokenSOAP: null, expireREST: null, expireSOAP: null, error: "invalid_password" } </pre> </dd> </dl> <h3>Details</h3> <p>The node can receive the parameters described above in the node properties. If they are not present or are wrong, an error is generated for the necessary parameters or the reason why are not correct.</p> </script>