@ntlab/sipd-tu-bridge-ui 1.7.2 → 1.7.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntlab/sipd-tu-bridge-ui",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "SIPD Penatausahaan Bridge Web Interface",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -127,6 +127,7 @@ $.error.handle = function(el) {
127
127
  if (el.attr('href') !== '#') {
128
128
  $.get(el.attr('href'))
129
129
  .done(function(data) {
130
+ $.fixBuffer(data);
130
131
  const content = typeof data === 'object' ? JSON.stringify(data, null, 2) : $.safeStr(data);
131
132
  $('#err-view-dlg .container').html(\`<pre>\${content}</pre>\`);
132
133
  });
@@ -63,7 +63,7 @@ $.uiCon = {
63
63
  }
64
64
  })
65
65
  .on('queue', function() {
66
- $.queue.reload();
66
+ $.theQueue.reload();
67
67
  $.uiRefresh();
68
68
  })
69
69
  .on('error', function() {
@@ -16,7 +16,7 @@
16
16
  <%_ script.create('JQuery')
17
17
  .useDependencies(['SemanticUI/Loader', 'SemanticUI/Dialog/Confirm'])
18
18
  .add(`
19
- $.queue = $.loader($('div[data-tab="queue"] table'), {
19
+ $.theQueue = $.loader($('div[data-tab="queue"] table'), {
20
20
  url: '${route('Ui', {name: 'queue', page: 'PAGE'})}',
21
21
  formatRow(item) {
22
22
  return this.toRow(item);
@@ -41,7 +41,7 @@ $.queue = $.loader($('div[data-tab="queue"] table'), {
41
41
  }
42
42
  }
43
43
  });
44
- $.queue.toRow = function(data) {
44
+ $.theQueue.toRow = function(data) {
45
45
  return $(\`
46
46
  <tr data-status="\${data.status}"><td>\${data.nr}</td>
47
47
  <td>\${$.toStr(data.id)}</td>
@@ -55,7 +55,7 @@ $.queue.toRow = function(data) {
55
55
  </td>
56
56
  </tr>\`);
57
57
  }
58
- $.queue.toStatus = function(data) {
58
+ $.theQueue.toStatus = function(data) {
59
59
  const icon = {
60
60
  new: 'pause circle outline',
61
61
  processing: 'loading spinner',
@@ -67,7 +67,7 @@ $.queue.toStatus = function(data) {
67
67
  return icon ? \`<div data-tooltip="\${data}" data-position="right center"><i class="\${icon} icon"></i></div>\` :
68
68
  $.toStr(data);
69
69
  }
70
- $.queue.handle = function(el) {
70
+ $.theQueue.handle = function(el) {
71
71
  const self = this;
72
72
  switch (el.data('op')) {
73
73
  case 'delete':
@@ -89,7 +89,7 @@ $.queue.handle = function(el) {
89
89
  break;
90
90
  }
91
91
  }
92
- $.queue.reload = function() {
92
+ $.theQueue.reload = function() {
93
93
  const self = this;
94
94
  if (!self.loading) {
95
95
  self.loading = true;
@@ -98,5 +98,5 @@ $.queue.reload = function() {
98
98
  }
99
99
  `)
100
100
  .addInitializer(`
101
- $.queue.load();
101
+ $.theQueue.load();
102
102
  `) -%>
package/views/ui/util.ejs CHANGED
@@ -72,7 +72,7 @@ $.hidePayload = function(message) {
72
72
  return message;
73
73
  }
74
74
  $.isPayload = function(data) {
75
- return Array.isArray(data) || typeof data === 'object' && data.constructor.name === 'Object';
75
+ return Array.isArray(data) || $.isPlainObject(data);
76
76
  }
77
77
  $.safeStr = function(s) {
78
78
  if (s !== '') {
@@ -91,4 +91,17 @@ $.toStr = function(o) {
91
91
  }
92
92
  return '';
93
93
  }
94
+ $.fixBuffer = function(data) {
95
+ if ($.isPlainObject(data)) {
96
+ for (const key of Object.keys(data)) {
97
+ if (data[key]) {
98
+ if (data[key].type === 'Buffer' && Array.isArray(data[key].data)) {
99
+ data[key] = data[key].data;
100
+ } else {
101
+ $.fixBuffer(data[key]);
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
94
107
  `) -%>