node-red-contrib-mobius-flow-base 2.5.86-beta.6 → 2.5.86-beta.63

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.
@@ -41,12 +41,16 @@ POSSIBILITY OF SUCH DAMAGE.
41
41
  <option value="object">Object - Resource PVs, URIs and Names</option>
42
42
  </select>
43
43
  </div>
44
- <div class="form-row node-input-resources-container-row">
44
+ <div id="node-input-resources-container-row" class="form-row node-input-resources-container-row">
45
45
  <label for="node-input-resources-container"><i class="fa fa-bars"></i> Resources</label>
46
46
  <ol id="node-input-resources-container"></ol>
47
47
  </div>
48
+
49
+ <div id="mobsearch"></div>
48
50
  </script>
49
51
 
52
+ <script src="common/mobsearch.js"></script>
53
+
50
54
  <script type="text/javascript">
51
55
  RED.nodes.registerType('mobius get multi-resource', {
52
56
  category: 'mobius',
@@ -82,6 +86,8 @@ POSSIBILITY OF SUCH DAMAGE.
82
86
  resource.find(".node-input-resource-comment").width(newWidth - 270);
83
87
  }
84
88
 
89
+ let mobiusSrvc = $("#node-input-connection").val();
90
+
85
91
  /** Create the subs container and populate it */
86
92
  $('#node-input-resources-container').css('min-height', '300px').css('min-width', '450px').editableList ({
87
93
  addButton: "add",
@@ -99,14 +105,26 @@ POSSIBILITY OF SUCH DAMAGE.
99
105
  }
100
106
 
101
107
  var row = $('<div>URI</div>').appendTo(container);
102
- var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
108
+ var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width: 190px; margin-left: 5px; text-align: left;"}).appendTo(row);
109
+
110
+ // *** MOBSEARCH *** //
111
+ var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
112
+ // *** END MOBSEARCH *** //
113
+
103
114
  row.append('&nbsp;&nbsp;-&nbsp;');
104
- var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
115
+ var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "width: 110px; margin-left: 5px; text-align: left;"}).appendTo(row);
105
116
 
106
117
  // Populate the new stat
107
118
  uriField.val(resource.uri);
108
119
  commentField.val(resource.comment);
109
- resizeResource(container);
120
+ // resizeResource(container);
121
+
122
+ // *** MOBSEARCH *** //
123
+ if (!node.resources[i]) {
124
+ node.resources[i] = {uri: '', comment: ''}
125
+ }
126
+ addMobsearchListButton(searchField, i)
127
+ // *** END MOBSEARCH *** //
110
128
  },
111
129
  resizeItem: resizeResource
112
130
  });
@@ -115,19 +133,32 @@ POSSIBILITY OF SUCH DAMAGE.
115
133
  if (!node.resources) {
116
134
  node.resources = [resource = {uri: '', comment: ''}];
117
135
  }
118
- // Populate list with all saved filters
136
+
137
+ // *** MOBSEARCH *** //
138
+
139
+ opts = {
140
+ htmlElementId: 'mobsearch',
141
+ list: node.resources,
142
+ containerRowName: 'node-input-resources-container-row',
143
+ containerName: 'node-input-resources-container',
144
+ containerSecondFieldName: 'node-input-resources-comment',
145
+ };
146
+ initMobsearch.toRid_listed(mobiusSrvc, opts);
147
+
148
+ // *** END MOBSEARCH *** //
149
+
119
150
  for (let i = 0; i < node.resources.length; i++) {
120
151
  let resource = node.resources[i];
121
152
  $("#node-input-resources-container").editableList('addItem', resource);
122
153
  }
123
154
  },
124
155
  oneditresize(size) {
125
- var rows = $("#dialog-form>div:not(.node-input-resources-container-row)");
156
+ var rows = $("#dialog-form>div:not(.node-input-resources-container)");
126
157
  var height = size.height;
127
158
  for (var i=0; i<rows.size(); i++) {
128
159
  height -= $(rows[i]).outerHeight(true);
129
160
  }
130
- var editorRow = $("#dialog-form>div.node-input-resources-container-row");
161
+ var editorRow = $("#dialog-form>div.node-input-resources-container");
131
162
  height -= 4 * ((parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))));
132
163
 
133
164
  $("#node-input-resources-container").editableList('height',height);
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusFlowNode (n) {
31
+ function MobiusFlowNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.resources = n.resources;
34
34
  this.sendFormat = n.send;
@@ -39,7 +39,7 @@ module.exports = function (RED) {
39
39
  node.status({
40
40
  fill: 'red',
41
41
  shape: 'ring',
42
- text: 'Disconnected'
42
+ text: 'Disconnected',
43
43
  });
44
44
 
45
45
  node.serviceConn.register(node);
@@ -48,7 +48,7 @@ module.exports = function (RED) {
48
48
  node.status({
49
49
  fill: 'green',
50
50
  shape: 'ring',
51
- text: 'Busy'
51
+ text: 'Busy',
52
52
  });
53
53
 
54
54
  for (const resource of node.resources) {
@@ -56,7 +56,7 @@ module.exports = function (RED) {
56
56
  node.status({
57
57
  fill: 'yellow',
58
58
  shape: 'dot',
59
- text: 'URIs not Valid'
59
+ text: 'URIs not Valid',
60
60
  });
61
61
  if (done) {
62
62
  return done();
@@ -72,23 +72,23 @@ module.exports = function (RED) {
72
72
  node.status({
73
73
  fill: 'green',
74
74
  shape: 'dot',
75
- text: 'Done'
75
+ text: 'Done',
76
76
  });
77
77
  if (node.sendFormat === 'array') {
78
- node.send({topic: msg.topic, payload: values});
78
+ node.send({ topic: msg.topic, payload: values });
79
79
  } else {
80
80
  let payload = values.reduce((obj, item) => {
81
81
  obj[item.uri] = { pv: item.pv, name: item.name };
82
82
  return obj;
83
83
  }, {});
84
- node.send({topic: msg.topic, payload: payload});
84
+ node.send({ topic: msg.topic, payload: payload });
85
85
  }
86
86
  })
87
87
  .catch((err) => {
88
88
  node.status({
89
89
  fill: 'yellow',
90
90
  shape: 'dot',
91
- text: 'Error: ' + JSON.stringify(err.code)
91
+ text: 'Error: ' + JSON.stringify(err.code),
92
92
  });
93
93
  node.error('Mobius error reading resource ' + JSON.stringify(err));
94
94
  })
@@ -107,7 +107,7 @@ module.exports = function (RED) {
107
107
  }
108
108
  }
109
109
 
110
- function validateResourceURI (uri) {
110
+ function validateResourceURI(uri) {
111
111
  let parts = uri.split('/');
112
112
  for (let lp = 0; lp < parts.length; lp++) {
113
113
  if (parts[lp] === null || parts[lp] === '') {
@@ -120,7 +120,7 @@ module.exports = function (RED) {
120
120
  return false;
121
121
  }
122
122
 
123
- function readResource (node, uri) {
123
+ function readResource(node, uri) {
124
124
  return new Promise((resolve, reject) => {
125
125
  node.serviceConn.readResource(uri, (err, response) => {
126
126
  if (err) {
@@ -129,7 +129,7 @@ module.exports = function (RED) {
129
129
  if (node.sendFormat === 'array') {
130
130
  resolve(response.value.pv);
131
131
  } else {
132
- resolve({uri: uri, pv: response.value.pv, name: response.value.name});
132
+ resolve({ uri: uri, pv: response.value.pv, name: response.value.name });
133
133
  }
134
134
  }
135
135
  });
@@ -137,4 +137,12 @@ module.exports = function (RED) {
137
137
  }
138
138
 
139
139
  RED.nodes.registerType('mobius get multi-resource', MobiusFlowNode);
140
+
141
+ RED.httpAdmin.get('/common/*', function (req, res) {
142
+ var options = {
143
+ root: __dirname + '/common/',
144
+ dotfiles: 'deny',
145
+ };
146
+ res.sendFile(req.params[0], options);
147
+ });
140
148
  };
@@ -29,10 +29,17 @@ POSSIBILITY OF SUCH DAMAGE.
29
29
  <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
30
30
  <input type="text" id="node-input-connection">
31
31
  </div>
32
- <div class="form-row">
33
- <label for="node-input-mobject"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-mobject" placeholder="Object URI (hid/sid/pid/ins)">
32
+ <hr>
33
+
34
+ <div id="instance-row">
35
+ <div class="form-row" id="input-row">
36
+ <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
37
+ <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
38
+ </div>
35
39
  </div>
40
+
41
+ <div id="mobsearch"></div>
42
+
36
43
  <div class="form-row">
37
44
  <label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
38
45
  <select type="text" id="node-input-format" style="display: inline-block; width: auto; vertical-align: center;">
@@ -52,6 +59,8 @@ POSSIBILITY OF SUCH DAMAGE.
52
59
  </div>
53
60
  </script>
54
61
 
62
+ <script src="common/mobsearch.js"></script>
63
+
55
64
  <script type="text/javascript">
56
65
  RED.nodes.registerType('mobius get object',{
57
66
  category: 'mobius',
@@ -60,7 +69,7 @@ POSSIBILITY OF SUCH DAMAGE.
60
69
  name: {value: ""},
61
70
  detailedOutput: {value:false},
62
71
  format: {value: "name", required: true},
63
- mobject: {value: "", validate:function(v) {
72
+ instance: {value: "", validate:function(v) {
64
73
  if(v === '') { return true; }
65
74
  let parts = v.split('/');
66
75
  for(let lp = 0; lp < parts.length; lp++) {
@@ -86,12 +95,23 @@ POSSIBILITY OF SUCH DAMAGE.
86
95
  if(this.name) {
87
96
  return this.name;
88
97
  } else {
89
- return this.mobject ? `Get - ${this.mobject}` : "get object";
98
+ return this.instance ? `Get - ${this.instance}` : "get object";
90
99
  }
91
100
  },
92
101
  labelStyle: function() {
93
102
  return this.name ? "node_label_italic":"";
94
103
  },
104
+ oneditprepare: function () {
105
+
106
+ var node = this;
107
+ let mobiusSrvc = $("#node-input-connection").val();
108
+
109
+ opts = {
110
+ htmlElementId: 'mobsearch',
111
+ uriFieldName: 'node-input-instance '
112
+ };
113
+ initMobsearch.toIns(mobiusSrvc, opts);
114
+ },
95
115
  oneditsave: function() {
96
116
  if($("#node-input-detailedOutput").prop('checked')) {
97
117
  this.outputs = 3;
@@ -30,11 +30,11 @@
30
30
  const _ = require('lodash');
31
31
 
32
32
  module.exports = function (RED) {
33
- function MobiusGetObjectNode (n) {
33
+ function MobiusGetObjectNode(n) {
34
34
  RED.nodes.createNode(this, n);
35
35
  this.detailedOutput = n.detailedOutput;
36
36
  this.format = n.format;
37
- this.mobject = n.mobject;
37
+ this.instance = n.instance;
38
38
  this.serviceConn = RED.nodes.getNode(n.connection);
39
39
  var node = this;
40
40
 
@@ -42,11 +42,11 @@ module.exports = function (RED) {
42
42
  node.status({
43
43
  fill: 'red',
44
44
  shape: 'ring',
45
- text: 'Disconnected'
45
+ text: 'Disconnected',
46
46
  });
47
47
 
48
48
  node.on('input', function (msg) {
49
- let uri = node.mobject;
49
+ let uri = node.instance;
50
50
  if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 4)) {
51
51
  uri = msg.topic;
52
52
  }
@@ -54,32 +54,35 @@ module.exports = function (RED) {
54
54
  node.status({
55
55
  fill: 'green',
56
56
  shape: 'ring',
57
- text: 'Busy'
57
+ text: 'Busy',
58
58
  });
59
59
  node.serviceConn.readObject(uri, (err, response) => {
60
60
  if (err) {
61
61
  node.status({
62
62
  fill: 'yellow',
63
63
  shape: 'dot',
64
- text: 'Error: ' + JSON.stringify(err.code)
64
+ text: 'Error: ' + JSON.stringify(err.code),
65
65
  });
66
66
  node.error('Mobius error reading object ' + JSON.stringify(err));
67
67
  if (node.detailedOutput === true) {
68
- node.send([null, null, {topic: uri, payload: { error: true, response: err }}]);
68
+ node.send([null, null, { topic: uri, payload: { error: true, response: err } }]);
69
69
  }
70
70
  } else {
71
71
  node.status({
72
72
  fill: 'green',
73
73
  shape: 'dot',
74
- text: JSON.stringify(response.uri)
74
+ text: JSON.stringify(response.uri),
75
75
  });
76
76
 
77
- let allResources = _.keyBy(response.value.resources, node.format === 'name' ? 'name' : 'rid');
77
+ let allResources = _.keyBy(
78
+ response.value.resources,
79
+ node.format === 'name' ? 'name' : 'rid'
80
+ );
78
81
  if (node.detailedOutput === true) {
79
82
  node.send([
80
83
  { topic: uri, payload: allResources },
81
84
  { topic: uri, payload: response.value },
82
- { topic: uri, payload: { error: false, response: response } }
85
+ { topic: uri, payload: { error: false, response: response } },
83
86
  ]);
84
87
  } else {
85
88
  node.send({ topic: uri, payload: allResources });
@@ -99,4 +102,12 @@ module.exports = function (RED) {
99
102
  }
100
103
 
101
104
  RED.nodes.registerType('mobius get object', MobiusGetObjectNode);
105
+
106
+ RED.httpAdmin.get('/common/*', function (req, res) {
107
+ var options = {
108
+ root: __dirname + '/common/',
109
+ dotfiles: 'deny',
110
+ };
111
+ res.sendFile(req.params[0], options);
112
+ });
102
113
  };
@@ -29,10 +29,18 @@ POSSIBILITY OF SUCH DAMAGE.
29
29
  <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
30
30
  <input type="text" id="node-input-connection">
31
31
  </div>
32
- <div class="form-row">
33
- <label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-resource" placeholder="Resource URI (hid/sid/pid/ins/rid)">
32
+
33
+ <hr>
34
+
35
+ <div id="instance-row">
36
+ <div class="form-row" id="input-row">
37
+ <label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
38
+ <input type="text" id="node-input-resource" style="width:61%;" placeholder="HID/SID/PID/INS/RID">
39
+ </div>
35
40
  </div>
41
+
42
+ <div id="mobsearch"></div>
43
+
36
44
  <div class="form-row">
37
45
  <label>&nbsp;</label>
38
46
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
@@ -45,6 +53,8 @@ POSSIBILITY OF SUCH DAMAGE.
45
53
  </div>
46
54
  </script>
47
55
 
56
+ <script src="common/mobsearch.js"></script>
57
+
48
58
  <script type="text/javascript">
49
59
  RED.nodes.registerType('mobius get resource',{
50
60
  category: 'mobius',
@@ -85,6 +95,15 @@ POSSIBILITY OF SUCH DAMAGE.
85
95
  labelStyle: function() {
86
96
  return this.name ? "node_label_italic":"";
87
97
  },
98
+ oneditprepare: function () {
99
+ var node = this;
100
+ let mobiusSrvc = $("#node-input-connection").val();
101
+ opts = {
102
+ htmlElementId: 'mobsearch',
103
+ uriFieldName: 'node-input-resource'
104
+ };
105
+ initMobsearch.toRid(mobiusSrvc, opts);
106
+ },
88
107
  oneditsave: function() {
89
108
  if($("#node-input-detailedOutput").prop('checked')) {
90
109
  this.outputs = 4;
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusGetResourceNode (n) {
31
+ function MobiusGetResourceNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.detailedOutput = n.detailedOutput;
34
34
  this.resource = n.resource;
@@ -39,7 +39,7 @@ module.exports = function (RED) {
39
39
  node.status({
40
40
  fill: 'red',
41
41
  shape: 'ring',
42
- text: 'Disconnected'
42
+ text: 'Disconnected',
43
43
  });
44
44
 
45
45
  node.on('input', function (msg) {
@@ -51,36 +51,41 @@ module.exports = function (RED) {
51
51
  node.status({
52
52
  fill: 'green',
53
53
  shape: 'ring',
54
- text: 'Busy'
54
+ text: 'Busy',
55
55
  });
56
56
  node.serviceConn.readResource(uri, (err, response) => {
57
57
  if (err) {
58
58
  node.status({
59
59
  fill: 'yellow',
60
60
  shape: 'dot',
61
- text: 'Error: ' + JSON.stringify(err.code)
61
+ text: 'Error: ' + JSON.stringify(err.code),
62
62
  });
63
63
  node.error('Mobius error reading resource ' + JSON.stringify(err));
64
64
  if (node.detailedOutput === true) {
65
- node.send([null, null, null, {topic: uri, payload: {error: true, response: err}}]);
65
+ node.send([
66
+ null,
67
+ null,
68
+ null,
69
+ { topic: uri, payload: { error: true, response: err } },
70
+ ]);
66
71
  }
67
72
  } else {
68
73
  node.status({
69
74
  fill: 'green',
70
75
  shape: 'dot',
71
- text: JSON.stringify(response.value.pv)
76
+ text: JSON.stringify(response.value.pv),
72
77
  });
73
78
  if (node.detailedOutput === true) {
74
79
  node.send([
75
80
  { topic: uri, payload: response.value.pv },
76
81
  { topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
77
82
  { topic: uri, payload: response.value },
78
- { topic: uri, payload: { error: false, response: response } }
83
+ { topic: uri, payload: { error: false, response: response } },
79
84
  ]);
80
85
  } else {
81
86
  node.send([
82
87
  { topic: uri, payload: response.value.pv },
83
- { topic: uri, payload: { pv: response.value.pv, name: response.value.name } }
88
+ { topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
84
89
  ]);
85
90
  }
86
91
  }
@@ -98,4 +103,12 @@ module.exports = function (RED) {
98
103
  }
99
104
 
100
105
  RED.nodes.registerType('mobius get resource', MobiusGetResourceNode);
106
+
107
+ RED.httpAdmin.get('/common/*', function (req, res) {
108
+ var options = {
109
+ root: __dirname + '/common/',
110
+ dotfiles: 'deny',
111
+ };
112
+ res.sendFile(req.params[0], options);
113
+ });
101
114
  };