@bitpoolos/edge-bacnet 1.5.2 → 1.6.0

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.
@@ -106,6 +106,16 @@
106
106
  body: JSON.stringify({ d: device }),
107
107
  }).then((res) => res.json());
108
108
  }
109
+ updatePoint(device, pointKey) {
110
+ return fetch(RED.settings.httpNodeRoot + "bitpool-bacnet-data/updatePoint", {
111
+ method: "POST",
112
+ headers: {
113
+ Accept: "application/json",
114
+ "Content-Type": "application/json",
115
+ },
116
+ body: JSON.stringify({ d: device, k: pointKey }),
117
+ }).then((res) => res.json());
118
+ }
109
119
  setDeviceDisplayName(device, displayName) {
110
120
  return fetch(RED.settings.httpNodeRoot + "bitpool-bacnet-data/setDeviceDisplayName", {
111
121
  method: "POST",
@@ -143,6 +153,7 @@
143
153
  defaults: {
144
154
  name: { value: "" },
145
155
  local_device_address: { value: "", required: true },
156
+ local_interface_name: { value: "", required: false },
146
157
  apduTimeout: { value: 6000 },
147
158
  roundDecimal: { value: 2 },
148
159
  local_device_port: { value: 47808, required: true },
@@ -203,6 +214,11 @@
203
214
  label: "Server",
204
215
  });
205
216
 
217
+ tabs.addTab({
218
+ id: "read-backup-tab",
219
+ label: "Backup & Restore",
220
+ });
221
+
206
222
  if (node.networkInterfaces && node.networkInterfaces.length > 0) {
207
223
  let nicSelector = document.getElementById("node-input-local_device_address");
208
224
  node.networkInterfaces.forEach(function (option) {
@@ -236,6 +252,13 @@
236
252
  });
237
253
  }
238
254
 
255
+ //sets name of network adapter
256
+ document.getElementById("node-input-local_device_address").addEventListener("change", function () {
257
+ let selectedText = this.options[this.selectedIndex].innerText;
258
+ let nicName = selectedText.split(":")[0];
259
+ node.local_interface_name = nicName;
260
+ });
261
+
239
262
  queryAdapters();
240
263
 
241
264
  window.confirmDialogExists = window.confirmDialogExists || false;
@@ -333,6 +356,7 @@
333
356
  vueapp.use(primevue.confirmationservice);
334
357
  node.vm1 = vueapp.mount("#serverParent");
335
358
 
359
+ // Import Device List
336
360
  $("#file-upload").on("change", function (event) {
337
361
  const input = event.target.files[0];
338
362
  const reader = new FileReader();
@@ -349,13 +373,14 @@
349
373
  contentType: "application/json",
350
374
  data: JSON.stringify(jsonPayload),
351
375
  success: function (result) { },
352
- timeout: 15000,
376
+ timeout: 0,
353
377
  });
354
378
  };
355
379
 
356
380
  reader.readAsText(input);
357
381
  });
358
382
 
383
+ //Export Device List
359
384
  $("#file-export").click(function (params) {
360
385
  $.ajax({
361
386
  url: RED.settings.httpNodeRoot + "bitpool-bacnet-data/getDeviceList",
@@ -366,7 +391,46 @@
366
391
  aEle.setAttribute("download", "bitpool-bacnet-devices.json");
367
392
  aEle.click();
368
393
  },
369
- timeout: 10000,
394
+ timeout: 0,
395
+ });
396
+ });
397
+
398
+ //Import complete Data model
399
+ $("#file-upload-database").on("change", function (event) {
400
+ const input = event.target.files[0];
401
+ const reader = new FileReader();
402
+
403
+ reader.onload = function (e) {
404
+ const text = e.target.result;
405
+
406
+ let jsonPayload = JSON.parse(text);
407
+
408
+ $.ajax({
409
+ type: "POST",
410
+ url: RED.settings.httpNodeRoot + "bitpool-bacnet-data/updateDataModel",
411
+ dataType: "json",
412
+ contentType: "application/json",
413
+ data: JSON.stringify(jsonPayload),
414
+ success: function (result) { },
415
+ timeout: 0,
416
+ });
417
+ };
418
+
419
+ reader.readAsText(input);
420
+ });
421
+
422
+ // Export complete Data model
423
+ $("#file-export-database").click(function (params) {
424
+ $.ajax({
425
+ url: RED.settings.httpNodeRoot + "bitpool-bacnet-data/getDataModel",
426
+ success: function (deviceList) {
427
+ let data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(deviceList));
428
+ let aEle = document.getElementById("exportJSON");
429
+ aEle.setAttribute("href", "data:" + data);
430
+ aEle.setAttribute("download", "edge-bacnet-datastore.json");
431
+ aEle.click();
432
+ },
433
+ timeout: 0,
370
434
  });
371
435
  });
372
436
 
@@ -739,6 +803,20 @@
739
803
  .point_name {
740
804
  font-weight: bold;
741
805
  }
806
+ .database-backup {
807
+ border-top: 1px solid grey;
808
+ padding-top: 25px;
809
+ margin-top: 5px !important;
810
+ }
811
+ .database-file-label {
812
+ color: black;
813
+ font-weight: bold;
814
+ font-size: 16px;
815
+ width: auto !important;
816
+ }
817
+ .database-file-label-div {
818
+ padding-top: 15px;
819
+ }
742
820
  </style>
743
821
 
744
822
  <div class="form-row node-input-read-tabs-row">
@@ -967,6 +1045,26 @@
967
1045
  </div>
968
1046
  </div>
969
1047
  </div>
1048
+ <div id="read-backup-tab" style="display:none">
1049
+ <div class="database-file-label-div">
1050
+ <span class="database-file-label">Database File</span>
1051
+ </div>
1052
+
1053
+ <div class="form-row bp-import-buttons database-backup" id="importDeviceList">
1054
+ <!-- <label> Device List: </label> -->
1055
+ <label for="file-upload-database" class="custom-file-upload">
1056
+ <i class="fa fa-arrow-circle-up" id="fileLabel"></i>
1057
+ <a id="fileLabelText" style="padding-left: 10px;">Import database</a>
1058
+ </label>
1059
+ <input type="file" id="file-upload-database" accept="application/JSON" class="inputStyle" style="width: 258px;" />
1060
+ <label for="file-export-database" class="custom-file-upload" style="margin-left: 5px;">
1061
+ <i class="fa fa-arrow-circle-down" id="fileLabel"></i>
1062
+ <a id="fileLabelText" style="padding-left: 10px;">Export database</a>
1063
+ </label>
1064
+ <input id="file-export-database" class="inputStyle" style="width: 258px; display: none;" />
1065
+ <a id="exportJSON" style="display: none"></a>
1066
+ </div>
1067
+ </div>
970
1068
  </div>
971
1069
  </script>
972
1070
  <script type="text/html" data-help-name="Bacnet-Gateway">