node-red-contrib-mobius-flow-base 3.0.0-beta.12 → 3.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,3 +16,4 @@ export declare const updateObject: (apiClient: AxiosInstance, uri: string, confi
16
16
  export declare const filterObjectsByRIDValue: (apiClient: AxiosInstance, uri: string, pids: string[], rid: string, limit: number, func: (v: string | number | boolean) => boolean, callback: Function) => Promise<any>;
17
17
  export declare const getHubId: (apiClient: AxiosInstance, callback: Function) => Promise<void>;
18
18
  export declare const getNodeConfig: (apiClient: AxiosInstance, uri: string, callback: Function) => Promise<void>;
19
+ export declare const changeAdminPassword: (apiClient: AxiosInstance, password: string, callback: Function) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNodeConfig = exports.getHubId = exports.filterObjectsByRIDValue = exports.updateObject = exports.getServiceConfig = exports.sendDirectCommand = exports.sendBroadcastCommand = exports.readObject = exports.readResource = exports.clearResource = exports.writeMultiResource = exports.writeResource = exports.discover = void 0;
3
+ exports.changeAdminPassword = exports.getNodeConfig = exports.getHubId = exports.filterObjectsByRIDValue = exports.updateObject = exports.getServiceConfig = exports.sendDirectCommand = exports.sendBroadcastCommand = exports.readObject = exports.readResource = exports.clearResource = exports.writeMultiResource = exports.writeResource = exports.discover = void 0;
4
4
  const discover = async (apiClient, uri, callback) => {
5
5
  try {
6
6
  const response = await apiClient({
@@ -212,3 +212,24 @@ const getNodeConfig = async (apiClient, uri, callback) => {
212
212
  }
213
213
  };
214
214
  exports.getNodeConfig = getNodeConfig;
215
+ const changeAdminPassword = async (apiClient, password, callback) => {
216
+ try {
217
+ const response = await apiClient({
218
+ method: 'get',
219
+ url: `/auth/user/admin`,
220
+ });
221
+ const adminUserId = response.data;
222
+ await apiClient({
223
+ method: 'patch',
224
+ url: `/auth/user/password/${adminUserId}`,
225
+ data: {
226
+ password,
227
+ },
228
+ });
229
+ callback(null, 'Ok');
230
+ }
231
+ catch (err) {
232
+ callback(err);
233
+ }
234
+ };
235
+ exports.changeAdminPassword = changeAdminPassword;
@@ -3,5 +3,6 @@ export declare let tokens: null | {
3
3
  refreshToken: string;
4
4
  };
5
5
  export declare let loggedIn: boolean;
6
- export declare const getApiClient: (protocol: string, host: string, port: number, username: string, password: string) => import("axios").AxiosInstance;
6
+ export declare const getApiClient: (protocol: 'http' | 'https', host: string, port: number, username: string, password: string) => import("axios").AxiosInstance;
7
7
  export declare const setLoggedIn: (value: boolean) => void;
8
+ export declare const closeApiClient: () => void;
@@ -3,12 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setLoggedIn = exports.getApiClient = exports.loggedIn = exports.tokens = void 0;
6
+ exports.closeApiClient = exports.setLoggedIn = exports.getApiClient = exports.loggedIn = exports.tokens = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const engine_websocket_1 = require("./engine-websocket");
9
9
  exports.tokens = null;
10
10
  exports.loggedIn = false;
11
+ let reloginInterval = null;
11
12
  const getApiClient = (protocol, host, port, username, password) => {
13
+ (0, engine_websocket_1.setWebSocketConnectParams)(host, port, protocol);
12
14
  //const baseURL = `http://localhost:8443/api/v1`;
13
15
  const baseURL = `${protocol}://${host}:${port}/api/v1`;
14
16
  const client = axios_1.default.create({
@@ -17,6 +19,11 @@ const getApiClient = (protocol, host, port, username, password) => {
17
19
  'Content-Type': 'application/json',
18
20
  },
19
21
  });
22
+ reloginInterval = setInterval(() => {
23
+ if (!exports.loggedIn) {
24
+ login();
25
+ }
26
+ }, 30000);
20
27
  // Add auth headers to all axios calls
21
28
  client.interceptors.request.use((config) => {
22
29
  if (!config.url?.endsWith('/auth/login')) {
@@ -29,6 +36,7 @@ const getApiClient = (protocol, host, port, username, password) => {
29
36
  Promise.reject(error);
30
37
  });
31
38
  const login = async () => {
39
+ console.log('Attempting Mobius Engine API Login');
32
40
  try {
33
41
  const response = await client({
34
42
  method: 'post',
@@ -40,7 +48,7 @@ const getApiClient = (protocol, host, port, username, password) => {
40
48
  });
41
49
  exports.tokens = response.data;
42
50
  exports.loggedIn = true;
43
- console.log('Logged in');
51
+ console.log('Logged in to Mobius Engine API');
44
52
  (0, engine_websocket_1.connectToWebSocket)();
45
53
  }
46
54
  catch (e) {
@@ -75,7 +83,7 @@ const getApiClient = (protocol, host, port, username, password) => {
75
83
  if (!error.response) {
76
84
  // notify
77
85
  }
78
- if (error.response.status === 401 && !error.config.url?.endsWith('/auth/login')) {
86
+ if (!error.config.url?.endsWith('/auth/login')) {
79
87
  console.log(`Logged Out: ${JSON.stringify(error.response)}`);
80
88
  exports.loggedIn = false;
81
89
  exports.tokens = null;
@@ -90,3 +98,9 @@ const setLoggedIn = (value) => {
90
98
  exports.loggedIn = value;
91
99
  };
92
100
  exports.setLoggedIn = setLoggedIn;
101
+ const closeApiClient = () => {
102
+ if (reloginInterval) {
103
+ clearInterval(reloginInterval);
104
+ }
105
+ };
106
+ exports.closeApiClient = closeApiClient;
@@ -1,15 +1,17 @@
1
1
  type WebSocketTopics = 'authorize' | 'subscribe' | 'unsubscribe' | 'connected' | 'authorized' | 'object-cov' | 'resource-cov' | 'service-status' | 'broadcast-command' | 'error' | 'ping' | 'pong';
2
2
  type Events = 'connected' | 'disconnected';
3
+ export declare const setWebSocketConnectParams: (hostname: string, port: number, protocol: 'http' | 'https') => void;
3
4
  export declare const on: (eventName: Events, callback: Function) => void;
4
5
  export declare function registerCallback(topic: WebSocketTopics, callback: Function): void;
5
6
  export declare function clearAllCallbacks(): void;
7
+ export declare const killWebSocket: () => void;
6
8
  /**
7
9
  * Connect to the Mobius WebSocket API
8
10
  * This method will connect to the Mobius WebSocket API and authenticate with the API token
9
11
  */
10
12
  export declare const connectToWebSocket: () => void;
11
13
  /**
12
- * Disconnect from the Mobius WebSocket API
14
+ * Disconnect from the Mobius WebSocket API - Using this will not stop socket from attempting to reconnect
13
15
  * This method will close the connection to the Mobius WebSocket API
14
16
  */
15
17
  export declare const disconnectFromWebSocket: () => void;
@@ -3,15 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.unsubscribeToBCMD = exports.subscribeToBCMD = exports.unsubscribeToResourceCOV = exports.subscribeToResourceCOV = exports.unsubscribeToObjectCOV = exports.subscribeToObjectCOV = exports.disconnectFromWebSocket = exports.connectToWebSocket = exports.clearAllCallbacks = exports.registerCallback = exports.on = void 0;
6
+ exports.unsubscribeToBCMD = exports.subscribeToBCMD = exports.unsubscribeToResourceCOV = exports.subscribeToResourceCOV = exports.unsubscribeToObjectCOV = exports.subscribeToObjectCOV = exports.disconnectFromWebSocket = exports.connectToWebSocket = exports.killWebSocket = exports.clearAllCallbacks = exports.registerCallback = exports.on = exports.setWebSocketConnectParams = void 0;
7
7
  const ws_1 = __importDefault(require("ws"));
8
8
  const engine_api_client_1 = require("./engine-api-client");
9
9
  let webSocket = null;
10
- const pendingWebSocketMessages = [];
10
+ let pendingWebSocketMessages = [];
11
11
  let pendingWebSocketMessageInterval = null;
12
12
  let pingInterval = null;
13
13
  let registeredCallbacks = [];
14
- const eventListeners = [];
14
+ let eventListeners = [];
15
+ let reconnectInterval = null;
16
+ let attemptReconnect = false;
17
+ let connectParams = null;
18
+ const setWebSocketConnectParams = (hostname, port, protocol) => {
19
+ connectParams = { hostname, port, protocol };
20
+ };
21
+ exports.setWebSocketConnectParams = setWebSocketConnectParams;
15
22
  const on = (eventName, callback) => {
16
23
  eventListeners.push({ eventName, callback });
17
24
  };
@@ -49,7 +56,7 @@ function handleWebSocketMessage(message) {
49
56
  console.log(`Websocket Error: ${message.payload}`);
50
57
  }
51
58
  if (message.topic === 'authorized') {
52
- console.log('Websocket Auth Success');
59
+ console.log('Engine API Subscription WebSocket Auth Success');
53
60
  triggerEvent('connected');
54
61
  }
55
62
  const callbacks = registeredCallbacks
@@ -58,30 +65,49 @@ function handleWebSocketMessage(message) {
58
65
  callbacks.forEach((cb) => cb(message.payload));
59
66
  }
60
67
  const reconnect = () => {
61
- console.log('WebSocket Client reconnecting...');
68
+ console.log('Engine API Subscription WebSocket Client reconnecting...');
62
69
  (0, exports.connectToWebSocket)();
63
70
  };
64
- let reconnectInterval = null;
71
+ // To be used only when connection node is deleted, hence removal of all callbacks etc.
72
+ const killWebSocket = () => {
73
+ attemptReconnect = false;
74
+ if (reconnectInterval) {
75
+ clearInterval(reconnectInterval);
76
+ }
77
+ registeredCallbacks = [];
78
+ pendingWebSocketMessages = [];
79
+ eventListeners = [];
80
+ if (webSocket) {
81
+ webSocket.close();
82
+ }
83
+ console.log('Killing Engine API Subscription WebSocket Client');
84
+ };
85
+ exports.killWebSocket = killWebSocket;
65
86
  /**
66
87
  * Connect to the Mobius WebSocket API
67
88
  * This method will connect to the Mobius WebSocket API and authenticate with the API token
68
89
  */
69
90
  const connectToWebSocket = () => {
91
+ if (!connectParams) {
92
+ console.log('Unabled to connect to Engine API Subscription WebSocket as no connect params are set');
93
+ return;
94
+ }
70
95
  if (!engine_api_client_1.tokens) {
71
- console.log('Unabled to connect to websocket as no tokens are available');
96
+ console.log('Unabled to connect to Engine API Subscription WebSocket as no tokens are available');
72
97
  return;
73
98
  }
74
99
  if (webSocket) {
75
100
  webSocket.close();
76
101
  webSocket = null;
77
102
  }
78
- let webSocketProtocol = 'ws';
79
- // if (window.location.protocol === 'http:') {
80
- // webSocketProtocol = 'ws';
81
- // }
82
- webSocket = new ws_1.default(`ws://localhost:8443/api/v1/mobius/subscribe/connect`);
103
+ let webSocketProtocol = 'wss';
104
+ if (connectParams.protocol === 'http') {
105
+ webSocketProtocol = 'ws';
106
+ }
107
+ webSocket = new ws_1.default(`${webSocketProtocol}://${connectParams.hostname}:${connectParams.port}/api/v1/mobius/subscribe/connect`);
83
108
  webSocket.onopen = () => {
84
- console.log('WebSocket Client Connected');
109
+ attemptReconnect = true;
110
+ console.log('Engine API Subscription WebSocket Client Connected');
85
111
  pingInterval = setInterval(sendPingMessage, 30000);
86
112
  clearInterval(reconnectInterval);
87
113
  webSocket?.send(JSON.stringify({
@@ -96,15 +122,22 @@ const connectToWebSocket = () => {
96
122
  }, 1000);
97
123
  };
98
124
  webSocket.onclose = () => {
99
- console.log('WebSocket Client Closed');
125
+ console.log('Engine API Subscription WebSocket Client Closed');
100
126
  if (pingInterval) {
101
127
  clearInterval(pingInterval);
102
128
  }
129
+ webSocket = null;
130
+ clearInterval(reconnectInterval);
103
131
  if (pendingWebSocketMessageInterval) {
104
132
  clearInterval(pendingWebSocketMessageInterval);
105
- reconnectInterval = setInterval(reconnect, 5000);
106
133
  }
107
- webSocket = null;
134
+ if (attemptReconnect) {
135
+ reconnectInterval = setInterval(() => {
136
+ if (engine_api_client_1.loggedIn) {
137
+ reconnect();
138
+ }
139
+ }, 30000);
140
+ }
108
141
  triggerEvent('disconnected');
109
142
  };
110
143
  webSocket.onmessage = (message) => {
@@ -119,12 +152,17 @@ const connectToWebSocket = () => {
119
152
  }
120
153
  };
121
154
  webSocket.on('error', (e) => {
122
- console.error(e);
155
+ if (e.code === 'ECONNREFUSED') {
156
+ (0, engine_api_client_1.setLoggedIn)(false);
157
+ }
158
+ else {
159
+ console.error('Engine API Subscription WebSocket Client Error: ', e);
160
+ }
123
161
  });
124
162
  };
125
163
  exports.connectToWebSocket = connectToWebSocket;
126
164
  /**
127
- * Disconnect from the Mobius WebSocket API
165
+ * Disconnect from the Mobius WebSocket API - Using this will not stop socket from attempting to reconnect
128
166
  * This method will close the connection to the Mobius WebSocket API
129
167
  */
130
168
  const disconnectFromWebSocket = () => {
@@ -64,18 +64,28 @@ if (typeof selectionIndex === undefined) {
64
64
  * @param {number} rowIndex - The list row index
65
65
  * @param {object} opts - Mobsearch options object
66
66
  */
67
- function addMobsearchListButton(field, rowIndex, opts) {
68
- field.click(function () {
69
- selectionIndex = rowIndex;
70
- $(`#${opts.containerRowName}`).hide();
71
- $('#instance-search-sid').val('');
72
- $('#instance-search-pid').val('');
73
- $('#instance-search-ins').val('');
74
- $('#instance-search-rid').val('');
75
- $('#node-search-return').removeClass('disabled');
76
- $('#node-search-accept').removeClass('disabled');
77
- $('#instance-search-row').show();
78
- });
67
+ function addMobsearchListButton(mobiusSrvc, field, rowIndex, opts) {
68
+ if (mobiusSrvc !== '_ADD_') {
69
+ $.getJSON(`mgetconnected?mobius=${mobiusSrvc}`, function (response) {
70
+ if (!response) {
71
+ field.css('color', '#CCCCCC');
72
+ } else {
73
+ field.click(function () {
74
+ selectionIndex = rowIndex;
75
+ $(`#${opts.containerRowName}`).hide();
76
+ $('#instance-search-sid').val('');
77
+ $('#instance-search-pid').val('');
78
+ $('#instance-search-ins').val('');
79
+ $('#instance-search-rid').val('');
80
+ $('#node-search-return').removeClass('disabled');
81
+ $('#node-search-accept').removeClass('disabled');
82
+ $('#instance-search-row').show();
83
+ });
84
+ }
85
+ });
86
+ } else {
87
+ field.css('color', '#CCCCCC');
88
+ }
79
89
  }
80
90
 
81
91
  /**
@@ -116,6 +126,9 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
116
126
 
117
127
  //Inject new html
118
128
  document.getElementById(opts.htmlElementId).innerHTML += `
129
+ <div id="bad-connection-alert" style="color:#FF0000" align="center">
130
+ <p>Setup and deploy MOBiUS connection to allow search.</p>
131
+ </div>
119
132
  <div id="instance-search-row">
120
133
  <div class="form-row">
121
134
  <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
@@ -143,12 +156,23 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
143
156
 
144
157
  // * INIT SETUP * //
145
158
 
159
+ let mobConnected = false;
160
+ $.getJSON(`mgetconnected?mobius=${mobiusSrvc}`, function (response) {
161
+ mobConnected = response;
162
+ if (!mobConnected) {
163
+ $('#node-lookup-instance').css('color', '#CCCCCC');
164
+ $('#bad-connection-alert').show();
165
+ } else {
166
+ $('#bad-connection-alert').hide();
167
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
168
+ $('#instance-search-hid').val(response);
169
+ });
170
+ }
171
+ });
172
+
146
173
  $('#instance-search-row').hide();
147
174
  $('#wildcard-alert-row').hide();
148
175
  $('#node-search-return').addClass('disabled');
149
- $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
150
- $('#instance-search-hid').val(response);
151
- });
152
176
  let readyToAccept = false;
153
177
 
154
178
  let searchObject = {};
@@ -451,18 +475,20 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
451
475
  // * CLICK RESPONSE * //
452
476
 
453
477
  $('#node-lookup-instance').click(function () {
454
- //When search button is clicked
455
- $('#instance-search-sid').val('');
456
- $('#instance-search-pid').val('');
457
- $('#instance-search-ins').val('');
458
- if (useRid) {
459
- $('#instance-search-rid').val('');
478
+ if (mobConnected) {
479
+ //When search button is clicked
480
+ $('#instance-search-sid').val('');
481
+ $('#instance-search-pid').val('');
482
+ $('#instance-search-ins').val('');
483
+ if (useRid) {
484
+ $('#instance-search-rid').val('');
485
+ }
486
+ $('#node-lookup-instance').addClass('disabled');
487
+ $('#node-search-return').removeClass('disabled');
488
+ $('#node-search-accept').removeClass('disabled');
489
+ $('#instance-row').hide();
490
+ $('#instance-search-row').show();
460
491
  }
461
- $('#node-lookup-instance').addClass('disabled');
462
- $('#node-search-return').removeClass('disabled');
463
- $('#node-search-accept').removeClass('disabled');
464
- $('#instance-row').hide();
465
- $('#instance-search-row').show();
466
492
  });
467
493
 
468
494
  $('#instance-search-sid').click(function () {
@@ -0,0 +1,26 @@
1
+ /**
2
+ Copyright (C) 2016, IAConnects Technology Limited
3
+ All Rights Reserved
4
+
5
+ ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
6
+ THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
7
+ IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
8
+ HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
9
+ AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
10
+ DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
11
+ IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
12
+ FROM IACONNECTS TECHNOLOGY LIMITED.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
18
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ POSSIBILITY OF SUCH DAMAGE.
25
+ **/
26
+ export {};
@@ -0,0 +1,98 @@
1
+ <!--
2
+ Copyright (C) 2016, IAConnects Technology Limited
3
+ All Rights Reserved
4
+
5
+ ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
6
+ THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
7
+ IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
8
+ HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
9
+ AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
10
+ DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
11
+ IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
12
+ FROM IACONNECTS TECHNOLOGY LIMITED.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
18
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ POSSIBILITY OF SUCH DAMAGE.
25
+ -->
26
+
27
+ <script type="text/x-red" data-template-name="mobius change admin password">
28
+ <div class="form-row">
29
+ <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
30
+ <input type="text" id="node-input-connection">
31
+ </div>
32
+ <hr>
33
+
34
+ <div class="form-row" id="input-row">
35
+ <label for="node-input-password"><i class="fa fa-key"></i> Password</label>
36
+ <input type="text" id="node-input-password" placeholder="Password (Min 8 Chars)">
37
+ </div>
38
+
39
+ <hr>
40
+
41
+ <div class="form-row">
42
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
43
+ <input type="text" id="node-input-name" placeholder="Name">
44
+ </div>
45
+ </script>
46
+
47
+ <script type="text/javascript">
48
+ RED.nodes.registerType('mobius change admin password',{
49
+ category: 'mobius',
50
+ defaults: {
51
+ name: {value:""},
52
+ password: {value:"", validate:function(v) {
53
+ if (v.length < 8) {
54
+ return false;
55
+ } else {
56
+ return true;
57
+ }
58
+ }},
59
+ connection: {type:"mobius connection", required:true}
60
+ },
61
+ color:"#6a8cc8",
62
+ inputs:1,
63
+ outputs:0,
64
+ icon: "mobius.png",
65
+ align: "right",
66
+ paletteLabel: 'change admin password',
67
+ label: 'Change Admin Password',
68
+ labelStyle: function() {
69
+ return this.name ? "node_label_italic":"";
70
+ },
71
+ });
72
+ </script>
73
+
74
+ <script type="text/x-red" data-help-name="mobius change admin password">
75
+ <p>Set MOBiUS admin password.</p>
76
+
77
+ <h3>Configuration Page</h3>
78
+ <dl class="message-properties">
79
+ <dt>MOBiUS <span class="property-type">node</span></dt>
80
+ <dd>Shared MOBiUS connection for communication with the MOBiUS Hub.</dd>
81
+ <dt>Password <span class="property-type">string</span></dt>
82
+ <dd>The new admin passsord (must be at least 8 characters).</dd>
83
+ </dl>
84
+
85
+ <h3>Inputs</h3>
86
+ <ol class="node-ports">
87
+ <li>Input message to trigger changes of password
88
+ <dl class="message-properties">
89
+ <dt class="optional">payload.passsword <span class="property-type">string</span></dt>
90
+ <dd>An optional property that overwrites the new password set in the node configuration page.
91
+ If the property is not valid (less than 8 characters) no action is taken.</dd>
92
+ </dl>
93
+ </li>
94
+ </ol>
95
+
96
+ <br>
97
+ <p align="center" style="color:#000080">mobiusflow © 2023</p>
98
+ </script>
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /**
3
+ Copyright (C) 2016, IAConnects Technology Limited
4
+ All Rights Reserved
5
+
6
+ ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
7
+ THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
8
+ IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
9
+ HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
10
+ AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
11
+ DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
12
+ IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
13
+ FROM IACONNECTS TECHNOLOGY LIMITED.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
19
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ POSSIBILITY OF SUCH DAMAGE.
26
+ **/
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ module.exports = function (RED) {
29
+ RED.nodes.registerType('mobius change admin password', function (n) {
30
+ RED.nodes.createNode(this, n);
31
+ let node = (() => {
32
+ this['password'] = n.password;
33
+ this['serviceConn'] = RED.nodes.getNode(n.connection);
34
+ return this;
35
+ })();
36
+ if (node.serviceConn) {
37
+ node.status({
38
+ fill: 'red',
39
+ shape: 'ring',
40
+ text: 'Disconnected',
41
+ });
42
+ node.on('input', function (msg) {
43
+ let password = node.password;
44
+ if (msg.hasOwnProperty('payload')) {
45
+ if (msg.payload.hasOwnProperty('password')) {
46
+ password = msg.payload.password;
47
+ }
48
+ }
49
+ if (password.length < 8) {
50
+ node.error('Password provided must be at least 8 characters long');
51
+ return;
52
+ }
53
+ if (password) {
54
+ node.status({
55
+ fill: 'green',
56
+ shape: 'ring',
57
+ text: 'Busy',
58
+ });
59
+ node.serviceConn.changeAdminPassword(password, (err, response) => {
60
+ if (err) {
61
+ node.status({
62
+ fill: 'yellow',
63
+ shape: 'dot',
64
+ text: 'Error: ' + JSON.stringify(err.code),
65
+ });
66
+ node.error('Mobius error setting admin password ' + JSON.stringify(err));
67
+ }
68
+ else {
69
+ node.status({
70
+ fill: 'green',
71
+ shape: 'dot',
72
+ text: 'Admin password changed (use on next login)',
73
+ });
74
+ }
75
+ });
76
+ }
77
+ });
78
+ node.serviceConn.register(node);
79
+ node.on('close', function (done) {
80
+ node.serviceConn.deregister(node, done);
81
+ });
82
+ }
83
+ else {
84
+ node.error(RED._('Mobius service not defined'));
85
+ }
86
+ });
87
+ };
@@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
47
47
  <label>&nbsp;</label>
48
48
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
49
49
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
50
+ <input type="hidden" id="node-input-outputs"/>
50
51
  </div>
51
52
  <hr>
52
53
  <div class="form-row">
@@ -74,11 +75,12 @@ POSSIBILITY OF SUCH DAMAGE.
74
75
  return false;
75
76
  }},
76
77
  priority: {value:15, type: 'Number', validate:function(v) { return (v > 0 && v < 16) }},
77
- connection: {type:"mobius connection", required:true}
78
+ connection: {type:"mobius connection", required:true},
79
+ outputs: {value:2},
78
80
  },
79
81
  color:"#8abff5",
80
82
  inputs:1,
81
- outputs:2,
83
+ outputs: 2,
82
84
  outputLabels: function (index) {
83
85
  if(index === 0) return ("Resource's PV");
84
86
  if(index === 1) return ("Resource's PV and name");
@@ -99,6 +101,10 @@ POSSIBILITY OF SUCH DAMAGE.
99
101
  return this.name ? "node_label_italic":"";
100
102
  },
101
103
  oneditprepare: function () {
104
+ $("#node-input-outputs").val(this.detailedOutput ? 4 : 2);
105
+ $("#node-input-detailedOutput").change(function() {
106
+ $("#node-input-outputs").val(this.checked ? 4 : 2);
107
+ });
102
108
  var node = this;
103
109
  let mobiusSrvc = $("#node-input-connection").val();
104
110
 
@@ -109,13 +115,13 @@ POSSIBILITY OF SUCH DAMAGE.
109
115
  };
110
116
  initMobsearch.toRid(mobiusSrvc, opts);
111
117
  },
112
- oneditsave: function() {
113
- if($("#node-input-detailedOutput").prop('checked')) {
114
- this.outputs = 4;
115
- } else {
116
- this.outputs = 2;
117
- }
118
- }
118
+ // oneditsave: function() {
119
+ // if($("#node-input-detailedOutput").prop('checked')) {
120
+ // this.outputs = 4;
121
+ // } else {
122
+ // this.outputs = 2;
123
+ // }
124
+ // }
119
125
  });
120
126
  </script>
121
127
 
@@ -35,7 +35,6 @@ module.exports = function (RED) {
35
35
  this.priority = n.priority;
36
36
  this.serviceConn = RED.nodes.getNode(n.connection);
37
37
  var node = this;
38
-
39
38
  if (node.serviceConn) {
40
39
  node.status({
41
40
  fill: 'red',
@@ -0,0 +1,45 @@
1
+ export interface NodeInterface {
2
+ on(type: 'input', callback: (msg: any, done?: any) => void): any;
3
+ on(type: 'close', callback: (done?: any) => void): any;
4
+ send(msg: any): any;
5
+ status(status: any): void;
6
+ log(msg: string): any;
7
+ warn(msg: string): any;
8
+ error(msg: string): any;
9
+ }
10
+ export interface MobiusConnectionInterface {
11
+ host: string;
12
+ port: number;
13
+ username: string;
14
+ password: string;
15
+ secure: boolean;
16
+ connected: boolean;
17
+ register(node: any): void;
18
+ deregister(node: any, done: () => void): void;
19
+ discover(uri: string, callback: (err: any, response: any) => void): void;
20
+ writeResourceValue(uri: string, value: string, callback: (err: any, response: any) => void): void;
21
+ writeMultiResourceValue(uri: string, updates: {
22
+ r: string;
23
+ p: number;
24
+ v: string | number | boolean;
25
+ }[], callback: (err: any, response: any) => void): void;
26
+ clearResourcePriority(uri: string, priority: number, callback: (err: any, response: any) => void): void;
27
+ readResource(uri: string, callback: (err: any, response: any) => void): void;
28
+ readObject(uri: string, callback: (err: any, response: any) => void): void;
29
+ filterObjectsByRidValue(uri: string, pids: string[], linit: number, func: Function, callback: (err: any, response: any) => void): void;
30
+ changeAdminPassword(password: string, callback: (err: any, response: string) => void): void;
31
+ subscribeToCov(uri: string, ref: string, callback: (err: any, response: any) => void): void;
32
+ unsubscribeToCov(uri: string, ref: string, callback: (err: any, response: any) => void): void;
33
+ subscribeToObjectCOV(uri: string, ref: string, callback: (err: any, response: any) => void): void;
34
+ unsubscribeToObjectCOV(uri: string, ref: string, callback: (err: any, response: any) => void): void;
35
+ subscribeToBCMD(uri: string, ref: string, callback: (err: any, response: any) => void): void;
36
+ unsubscribeToBCMD(uri: string, ref: string, callback: (err: any, response: any) => void): void;
37
+ sendBroadcastCommand(cid: string, commandData: any): void;
38
+ sendDirectCommand(uri: string, cid: string, timeout: number, callback: (err: any, response: any) => void): void;
39
+ getServiceConfig(hid: string, sid: string, callback: (err: any, response: any) => void): void;
40
+ updateObjectInServiceConfig(hid: string, sid: string, pid: string, ins: string, config: any, callback: (err: any, response: any) => void): void;
41
+ getNodeConfig(uri: string, callback: (err: any, response: any) => void): void;
42
+ }
43
+ export interface ServiceConn {
44
+ serviceConn: MobiusConnectionInterface;
45
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -32,7 +32,7 @@ var uiFuncs = require('../node-red-ui-funcs');
32
32
  const webSocket = require('../engine-websocket');
33
33
  const apiCalls = require('../engine-api-calls');
34
34
  const webSocketCalls = require('../engine-websocket');
35
- const { getApiClient, setLoggedIn } = require('../engine-api-client');
35
+ const { getApiClient, setLoggedIn, closeApiClient } = require('../engine-api-client');
36
36
 
37
37
  module.exports = function (RED) {
38
38
  /**
@@ -232,6 +232,11 @@ module.exports = function (RED) {
232
232
  * @param {Function} done - A callback to be run by the node after it has been deregistered
233
233
  */
234
234
  node.deregister = function (mobiusNode, done) {
235
+ node.users[mobiusNode.id].status({
236
+ fill: 'red',
237
+ shape: 'ring',
238
+ text: 'Disconnected',
239
+ });
235
240
  delete node.users[mobiusNode.id];
236
241
  try {
237
242
  node.resourceSubscriptions.forEach((subs, key) => {
@@ -277,6 +282,19 @@ module.exports = function (RED) {
277
282
  * Register the close connection handler
278
283
  */
279
284
  node.on('close', (done) => {
285
+ webSocket.killWebSocket();
286
+ closeApiClient();
287
+ setLoggedIn(false);
288
+ this.log(`Connection to MOBiUS closed.`);
289
+ for (var id in node.users) {
290
+ if (node.users.hasOwnProperty(id)) {
291
+ node.users[id].status({
292
+ fill: 'red',
293
+ shape: 'ring',
294
+ text: 'Disconnected',
295
+ });
296
+ }
297
+ }
280
298
  if (node.connected) {
281
299
  // Wait for all nodes to unsubscribe before terminating the connection
282
300
  node.unsubscribeTimeout = 0;
@@ -288,15 +306,11 @@ module.exports = function (RED) {
288
306
  node.unsubscribeTimeout > 50
289
307
  ) {
290
308
  clearInterval(waitForCleanup);
291
- webSocket.disconnectFromWebSocket();
292
- setLoggedIn(false);
293
309
  done();
294
310
  }
295
311
  node.unsubscribeTimeout++;
296
312
  }, 100);
297
313
  } else {
298
- setLoggedIn(false);
299
- webSocket.disconnectFromWebSocket();
300
314
  done();
301
315
  }
302
316
  });
@@ -378,6 +392,15 @@ module.exports = function (RED) {
378
392
  apiCalls.filterObjectsByRIDValue(this.apiClient, uri, pids, rid, limit, func, callback);
379
393
  };
380
394
 
395
+ /**
396
+ * Change the password of the admin user
397
+ * @param {*} password - The new password
398
+ * @param {*} callback - Callback when complete, function(err, [object]) {}
399
+ */
400
+ node.changeAdminPassword = function(password, callback) {
401
+ apiCalls.changeAdminPassword(this.apiClient, password, callback);
402
+ }
403
+
381
404
  /**
382
405
  * Subscribe to a resource COV
383
406
  * @param {string} uri - The full URI of the resource
@@ -674,8 +697,7 @@ module.exports = function (RED) {
674
697
  RED.httpAdmin.get('/mgetconnected', RED.auth.needsPermission('serial.read'), function (req, res) {
675
698
  let conn = RED.nodes.getNode(req.query.mobius);
676
699
  if (conn === null) {
677
- RED.log.error('Get hid failed - could not to connect to MOBiUS hub.');
678
- throw new Error('Get hid failed - could not to connect to MOBiUS hub.');
700
+ res.json(false);
679
701
  } else {
680
702
  res.json(conn.connected);
681
703
  }
@@ -187,7 +187,7 @@ POSSIBILITY OF SUCH DAMAGE.
187
187
  node.subscriptions[i] = {uri: '', type: 'include'}
188
188
  }
189
189
 
190
- addMobsearchListButton(searchField, i, mobsearchOpts)
190
+ addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts)
191
191
  // *** END MOBSEARCH *** //
192
192
  },
193
193
  });
@@ -67,7 +67,6 @@ POSSIBILITY OF SUCH DAMAGE.
67
67
  category: 'mobius',
68
68
  color: '#8abff5',
69
69
  defaults: {
70
- outputs: { value: 1 },
71
70
  name: { value: '' },
72
71
  pids: { value: '[]' },
73
72
  func: { value: '' },
@@ -93,6 +92,7 @@ POSSIBILITY OF SUCH DAMAGE.
93
92
  },
94
93
  },
95
94
  connection: { type: 'mobius connection', required: true },
95
+ outputs: {value:1},
96
96
  },
97
97
  inputs: 1,
98
98
  outputs: 1,
@@ -114,6 +114,10 @@ POSSIBILITY OF SUCH DAMAGE.
114
114
  return this.name ? 'node_label_italic' : '';
115
115
  },
116
116
  oneditprepare: function () {
117
+ $("#node-input-outputs").val(this.detailedOutput ? 2 : 1);
118
+ $("#node-input-detailedOutput").change(function() {
119
+ $("#node-input-outputs").val(this.checked ? 2 : 1);
120
+ });
117
121
  $('#node-input-pids').typedInput({
118
122
  type: 'json',
119
123
  types: ['json'],
@@ -125,11 +129,11 @@ POSSIBILITY OF SUCH DAMAGE.
125
129
  });
126
130
  },
127
131
  oneditsave: function () {
128
- if ($('#node-input-detailedOutput').prop('checked')) {
129
- $('#node-input-outputs').val(2);
130
- } else {
131
- $('#node-input-outputs').val(1);
132
- }
132
+ // if ($('#node-input-detailedOutput').prop('checked')) {
133
+ // $('#node-input-outputs').val(2);
134
+ // } else {
135
+ // $('#node-input-outputs').val(1);
136
+ // }
133
137
  this.func = this.editor.getValue();
134
138
  this.editor.destroy();
135
139
  delete this.editor;
@@ -107,7 +107,7 @@ POSSIBILITY OF SUCH DAMAGE.
107
107
  node.subscriptions[i] = {uri: '', type: 'include'}
108
108
  }
109
109
 
110
- addMobsearchListButton(searchField, i, mobsearchOpts)
110
+ addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts)
111
111
  // *** END MOBSEARCH *** //
112
112
  }
113
113
  });
@@ -116,7 +116,7 @@ POSSIBILITY OF SUCH DAMAGE.
116
116
  node.mobjects[i] = {uri: '', comment: ''}
117
117
  }
118
118
 
119
- addMobsearchListButton(searchField, i, mobsearchOpts)
119
+ addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts)
120
120
  // *** END MOBSEARCH *** //
121
121
 
122
122
  },
@@ -108,6 +108,7 @@ POSSIBILITY OF SUCH DAMAGE.
108
108
 
109
109
  // *** MOBSEARCH *** //
110
110
  var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
111
+
111
112
  // *** END MOBSEARCH *** //
112
113
 
113
114
  row.append('&nbsp;&nbsp;-&nbsp;');
@@ -122,7 +123,7 @@ POSSIBILITY OF SUCH DAMAGE.
122
123
  if (!node.resources[i]) {
123
124
  node.resources[i] = {uri: '', comment: ''}
124
125
  }
125
- addMobsearchListButton(searchField, i, mobsearchOpts)
126
+ addMobsearchListButton(mobiusSrvc, searchField, i, mobsearchOpts)
126
127
  // *** END MOBSEARCH *** //
127
128
 
128
129
  },
@@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
53
53
  <label>&nbsp;</label>
54
54
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
55
55
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
56
+ <input type="hidden" id="node-input-outputs"/>
56
57
  </div>
57
58
  <hr>
58
59
  <div class="form-row">
@@ -81,7 +82,8 @@ POSSIBILITY OF SUCH DAMAGE.
81
82
  if(parts.length < 4 && parts[parts.length - 1] === '#') { return true; }
82
83
  return false;
83
84
  }},
84
- connection: {type: "mobius connection", required: true}
85
+ connection: {type: "mobius connection", required: true},
86
+ outputs: {value:1},
85
87
  },
86
88
  inputs:1,
87
89
  outputs:1,
@@ -104,6 +106,10 @@ POSSIBILITY OF SUCH DAMAGE.
104
106
  return this.name ? "node_label_italic":"";
105
107
  },
106
108
  oneditprepare: function () {
109
+ $("#node-input-outputs").val(this.detailedOutput ? 3 : 1);
110
+ $("#node-input-detailedOutput").change(function() {
111
+ $("#node-input-outputs").val(this.checked ? 3 : 1);
112
+ });
107
113
  var node = this;
108
114
  let mobiusSrvc = $("#node-input-connection").val();
109
115
 
@@ -114,13 +120,13 @@ POSSIBILITY OF SUCH DAMAGE.
114
120
  };
115
121
  initMobsearch.toIns(mobiusSrvc, opts);
116
122
  },
117
- oneditsave: function() {
118
- if($("#node-input-detailedOutput").prop('checked')) {
119
- this.outputs = 3;
120
- } else {
121
- this.outputs = 1;
122
- }
123
- }
123
+ // oneditsave: function() {
124
+ // if($("#node-input-detailedOutput").prop('checked')) {
125
+ // this.outputs = 3;
126
+ // } else {
127
+ // this.outputs = 1;
128
+ // }
129
+ // }
124
130
  });
125
131
  </script>
126
132
 
@@ -46,12 +46,14 @@ POSSIBILITY OF SUCH DAMAGE.
46
46
  <label>&nbsp;</label>
47
47
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
48
48
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
49
+ <input type="hidden" id="node-input-outputs"/>
49
50
  </div>
50
51
  <hr>
51
52
  <div class="form-row">
52
53
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
53
54
  <input type="text" id="node-input-name" placeholder="Name">
54
55
  </div>
56
+
55
57
  </script>
56
58
 
57
59
  <script src="common/mobsearch.js"></script>
@@ -73,10 +75,11 @@ POSSIBILITY OF SUCH DAMAGE.
73
75
  if(parts.length < 5 && parts[parts.length - 1] === '#') { return true; }
74
76
  return false;
75
77
  }},
76
- connection: {type:"mobius connection", required:true}
78
+ connection: {type:"mobius connection", required: true},
79
+ outputs: {value:2},
77
80
  },
78
81
  inputs:1,
79
- outputs:2,
82
+ outputs: 2,
80
83
  outputLabels: function (index) {
81
84
  if(index === 0) return ("Resource's PV");
82
85
  if(index === 1) return ("Resource's PV and name");
@@ -97,9 +100,12 @@ POSSIBILITY OF SUCH DAMAGE.
97
100
  return this.name ? "node_label_italic":"";
98
101
  },
99
102
  oneditprepare: function () {
103
+ $("#node-input-outputs").val(this.detailedOutput ? 4 : 2);
104
+ $("#node-input-detailedOutput").change(function() {
105
+ $("#node-input-outputs").val(this.checked ? 4 : 2);
106
+ });
100
107
  var node = this;
101
108
  let mobiusSrvc = $("#node-input-connection").val();
102
-
103
109
  opts = {
104
110
  htmlElementId: 'mobsearch',
105
111
  uriFieldName: 'node-input-resource',
@@ -108,13 +114,13 @@ POSSIBILITY OF SUCH DAMAGE.
108
114
  initMobsearch.toRid(mobiusSrvc, opts);
109
115
 
110
116
  },
111
- oneditsave: function() {
112
- if($("#node-input-detailedOutput").prop('checked')) {
113
- this.outputs = 4;
114
- } else {
115
- this.outputs = 2;
116
- }
117
- }
117
+ // oneditsave: function() {
118
+ // if($("#node-input-detailedOutput").prop('checked')) {
119
+ // this.outputs = 4;
120
+ // } else {
121
+ // this.outputs = 2;
122
+ // }
123
+ // }
118
124
  });
119
125
  </script>
120
126
 
@@ -61,6 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
61
61
  <label>&nbsp;</label>
62
62
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
63
63
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
64
+ <input type="hidden" id="node-input-outputs"/>
64
65
  </div>
65
66
  <hr>
66
67
  <div class="form-row">
@@ -89,7 +90,8 @@ POSSIBILITY OF SUCH DAMAGE.
89
90
  if(parts.length < 4 && parts[parts.length - 1] === '#') { return true; }
90
91
  return false;
91
92
  }},
92
- connection: {type:"mobius connection", required:true}
93
+ connection: {type:"mobius connection", required:true},
94
+ outputs: {value:1},
93
95
  },
94
96
  color:"#8abff5",
95
97
  inputs:0,
@@ -113,7 +115,10 @@ POSSIBILITY OF SUCH DAMAGE.
113
115
  return this.name ? "node_label_italic":"";
114
116
  },
115
117
  oneditprepare: function () {
116
-
118
+ $("#node-input-outputs").val(this.detailedOutput ? 3 : 1);
119
+ $("#node-input-detailedOutput").change(function() {
120
+ $("#node-input-outputs").val(this.checked ? 3 : 1);
121
+ });
117
122
  var node = this;
118
123
  let mobiusSrvc = $("#node-input-connection").val();
119
124
 
@@ -124,13 +129,13 @@ POSSIBILITY OF SUCH DAMAGE.
124
129
  };
125
130
  initMobsearch.toIns(mobiusSrvc, opts);
126
131
  },
127
- oneditsave: function() {
128
- if($("#node-input-detailedOutput").prop('checked')) {
129
- this.outputs = 3;
130
- } else {
131
- this.outputs = 1;
132
- }
133
- }
132
+ // oneditsave: function() {
133
+ // if($("#node-input-detailedOutput").prop('checked')) {
134
+ // this.outputs = 3;
135
+ // } else {
136
+ // this.outputs = 1;
137
+ // }
138
+ // }
134
139
  });
135
140
  </script>
136
141
 
@@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
44
44
  <label>&nbsp;</label>
45
45
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
46
46
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
47
+ <input type="hidden" id="node-input-outputs"/>
47
48
  </div>
48
49
  <hr>
49
50
  <div class="form-row">
@@ -69,7 +70,8 @@ POSSIBILITY OF SUCH DAMAGE.
69
70
  if(parts.length < 5 && parts[parts.length - 1] === '#') { return true; }
70
71
  return false;
71
72
  }},
72
- connection: {type:"mobius connection", required:true}
73
+ connection: {type:"mobius connection", required:true},
74
+ outputs: {value:2},
73
75
  },
74
76
  color:"#8abff5",
75
77
  inputs:0,
@@ -94,6 +96,10 @@ POSSIBILITY OF SUCH DAMAGE.
94
96
  return this.name ? "node_label_italic":"";
95
97
  },
96
98
  oneditprepare: function () {
99
+ $("#node-input-outputs").val(this.detailedOutput ? 4 : 2);
100
+ $("#node-input-detailedOutput").change(function() {
101
+ $("#node-input-outputs").val(this.checked ? 4 : 2);
102
+ });
97
103
  var node = this;
98
104
  let mobiusSrvc = $("#node-input-connection").val();
99
105
 
@@ -104,13 +110,13 @@ POSSIBILITY OF SUCH DAMAGE.
104
110
  };
105
111
  initMobsearch.toRid(mobiusSrvc, opts);
106
112
  },
107
- oneditsave: function() {
108
- if($("#node-input-detailedOutput").prop('checked')) {
109
- this.outputs = 4;
110
- } else {
111
- this.outputs = 2;
112
- }
113
- }
113
+ // oneditsave: function() {
114
+ // if($("#node-input-detailedOutput").prop('checked')) {
115
+ // this.outputs = 4;
116
+ // } else {
117
+ // this.outputs = 2;
118
+ // }
119
+ // }
114
120
  });
115
121
  </script>
116
122
 
@@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
45
45
  <label>&nbsp;</label>
46
46
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
47
47
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
48
+ <input type="hidden" id="node-input-outputs"/>
48
49
  </div>
49
50
  <hr>
50
51
  <div class="form-row">
@@ -70,11 +71,12 @@ POSSIBILITY OF SUCH DAMAGE.
70
71
  if(parts.length === 4) { return true; }
71
72
  return false;
72
73
  }},
73
- connection: {type:"mobius connection", required:true}
74
+ connection: {type:"mobius connection", required:true},
75
+ outputs: {value:2},
74
76
  },
75
77
  color:"#8abff5",
76
78
  inputs:1,
77
- outputs:1,
79
+ outputs:2,
78
80
  outputLabels: function (index) {
79
81
  if(index === 0) return ("MOBiUS object");
80
82
  if(index === 1) return ("Full MOBiUS response");
@@ -93,6 +95,10 @@ POSSIBILITY OF SUCH DAMAGE.
93
95
  return this.name ? "node_label_italic":"";
94
96
  },
95
97
  oneditprepare: function () {
98
+ $("#node-input-outputs").val(this.detailedOutput ? 4 : 2);
99
+ $("#node-input-detailedOutput").change(function() {
100
+ $("#node-input-outputs").val(this.checked ? 4 : 2);
101
+ });
96
102
  var node = this;
97
103
  let mobiusSrvc = $("#node-input-connection").val();
98
104
 
@@ -103,13 +109,13 @@ POSSIBILITY OF SUCH DAMAGE.
103
109
  };
104
110
  initMobsearch.toIns(mobiusSrvc, opts);
105
111
  },
106
- oneditsave: function() {
107
- if($("#node-input-detailedOutput").prop('checked')) {
108
- this.outputs = 2;
109
- } else {
110
- this.outputs = 1;
111
- }
112
- }
112
+ // oneditsave: function() {
113
+ // if($("#node-input-detailedOutput").prop('checked')) {
114
+ // this.outputs = 2;
115
+ // } else {
116
+ // this.outputs = 1;
117
+ // }
118
+ // }
113
119
  });
114
120
  </script>
115
121
 
@@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
49
49
  <label>&nbsp;</label>
50
50
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
51
51
  <label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
52
+ <input type="hidden" id="node-input-outputs"/>
52
53
  </div>
53
54
  <hr>
54
55
  <div class="form-row">
@@ -76,7 +77,8 @@ POSSIBILITY OF SUCH DAMAGE.
76
77
  return false;
77
78
  }},
78
79
  priority: {value:15, type: 'Number', validate:function(v) { return (v > 0 && v < 16) }},
79
- connection: {type:"mobius connection", required:true}
80
+ connection: {type:"mobius connection", required:true},
81
+ outputs: {value:2},
80
82
  },
81
83
  color:"#8abff5",
82
84
  inputs:1,
@@ -101,6 +103,10 @@ POSSIBILITY OF SUCH DAMAGE.
101
103
  return this.name ? "node_label_italic":"";
102
104
  },
103
105
  oneditprepare: function () {
106
+ $("#node-input-outputs").val(this.detailedOutput ? 4 : 2);
107
+ $("#node-input-detailedOutput").change(function() {
108
+ $("#node-input-outputs").val(this.checked ? 4 : 2);
109
+ });
104
110
  var node = this;
105
111
  let mobiusSrvc = $("#node-input-connection").val();
106
112
 
@@ -111,13 +117,13 @@ POSSIBILITY OF SUCH DAMAGE.
111
117
  };
112
118
  initMobsearch.toRid(mobiusSrvc, opts);
113
119
  },
114
- oneditsave: function() {
115
- if($("#node-input-detailedOutput").prop('checked')) {
116
- this.outputs = 4;
117
- } else {
118
- this.outputs = 2;
119
- }
120
- }
120
+ // oneditsave: function() {
121
+ // if($("#node-input-detailedOutput").prop('checked')) {
122
+ // this.outputs = 4;
123
+ // } else {
124
+ // this.outputs = 2;
125
+ // }
126
+ // }
121
127
  });
122
128
  </script>
123
129
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "3.0.0-beta.12",
3
+ "version": "3.0.0-beta.13",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "tsc && mkdir -p dist/nodes && cp src/nodes/*.js dist/nodes/ && cp src/nodes/*.html dist/nodes/ && cp -r src/nodes/icons dist/nodes/ && mkdir -p dist/nodes/common && cp src/mobsearch.js dist/nodes/common/ && cp src/node-red-ui-funcs.js dist/"
9
+ "build": "mkdir -p dist/nodes && tsc && cp src/nodes/*.js dist/nodes/ && cp src/nodes/*.html dist/nodes/ && cp -r src/nodes/icons dist/nodes/ && mkdir -p dist/nodes/common && cp src/mobsearch.js dist/nodes/common/ && cp src/node-red-ui-funcs.js dist/"
10
10
  },
11
11
  "repository": "bitbucket:interiorautomation/node-red-contrib-mobius-flow-base",
12
12
  "node-red": {
@@ -27,7 +27,8 @@
27
27
  "mobius resource cov": "dist/nodes/mobius-resource-cov.js",
28
28
  "mobius send bcmd": "dist/nodes/mobius-send-bcmd.js",
29
29
  "mobius sub bcmd": "dist/nodes/mobius-sub-bcmd.js",
30
- "mobius send dcmd": "dist/nodes/mobius-send-dcmd.js"
30
+ "mobius send dcmd": "dist/nodes/mobius-send-dcmd.js",
31
+ "mobius change admin password": "dist/nodes/mobius-change-admin-password.js"
31
32
  }
32
33
  },
33
34
  "keywords": [