@ntlab/sipd-tu-bridge-ui 1.2.0 → 1.3.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.
package/controller/ui.js CHANGED
@@ -132,6 +132,11 @@ class UiController extends Controller {
132
132
  /** @type {import('..').SipdApi} */
133
133
  const api = req.app.api;
134
134
  switch (req.params.op) {
135
+ case 'remove':
136
+ if (req.body.error) {
137
+ Object.assign(result, await api.query({cmd: 'clean-err', error: req.body.error}));
138
+ }
139
+ break;
135
140
  case 'restart':
136
141
  Object.assign(result, await api.query({cmd: 'restart'}));
137
142
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntlab/sipd-tu-bridge-ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "SIPD Penatausahaan Bridge Web Interface",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,11 +6,12 @@
6
6
  <th><%= _('Screen') %></th>
7
7
  <th><%= _('Error') %></th>
8
8
  <th><%= _('Data') %></th>
9
+ <th><%= _('Action') %></th>
9
10
  </tr>
10
11
  </thead>
11
12
  </table>
12
13
  <%_ script.create('JQuery')
13
- .useDependencies(['SemanticUI/Loader', 'SemanticUI/Dialog'])
14
+ .useDependencies(['SemanticUI/Loader', 'SemanticUI/Dialog/Confirm'])
14
15
  .add(`
15
16
  $.error = $.loader($('div[data-tab="error"] table'), {
16
17
  url: '${route('Ui', {name: 'error', page: 'PAGE'})}',
@@ -27,23 +28,44 @@ $.error = $.loader($('div[data-tab="error"] table'), {
27
28
  counter.addClass('hidden');
28
29
  }
29
30
  }
30
- $('a.err-img-view').on('click', function(e) {
31
+ $('a.err-clicker').on('click', function(e) {
31
32
  e.preventDefault();
32
33
  const a = $(this);
33
- const dlg = $.ntdlg.create(
34
- 'err-img-view-dlg',
35
- a.data('tooltip'),
36
- \`<img class="ui fluid image" src="\${a.find('img').attr('src')}" style="max-height: 70vh;">\`, {
37
- size: 'fullscreen',
38
- buttons: {
39
- okay: {
40
- type: 'green approve',
41
- caption: '<i class="check icon"></i>${_('Ok')}',
34
+ switch (a.data('op')) {
35
+ case 'view':
36
+ const dlg = $.ntdlg.create(
37
+ 'err-img-view-dlg',
38
+ a.data('tooltip'),
39
+ \`<img class="ui fluid image" src="\${a.find('img').attr('src')}" style="max-height: 70vh;">\`, {
40
+ size: 'fullscreen',
41
+ buttons: {
42
+ okay: {
43
+ type: 'green approve',
44
+ caption: '<i class="check icon"></i>${_('Ok')}',
45
+ }
46
+ }
42
47
  }
43
- }
44
- }
45
- );
46
- $.ntdlg.show(dlg);
48
+ );
49
+ $.ntdlg.show(dlg);
50
+ break;
51
+ case 'delete':
52
+ $.ntdlg.confirm(
53
+ 'err-delete-confirm-dlg',
54
+ '${_('Confirm')}',
55
+ '${_('Are you sure want to remove error <code>%ERR%</code>?')}'.replace(/%ERR%/g, a.data('filename')),
56
+ $.ntdlg.ICON_QUESTION,
57
+ function() {
58
+ $.post('${route('Ui', {name: 'task', op: 'remove'})}', {error: a.data('filename')})
59
+ .done(function(json) {
60
+ $.tasks.notify(json);
61
+ if (json.success) {
62
+ self.reload();
63
+ }
64
+ });
65
+ }
66
+ );
67
+ break;
68
+ }
47
69
  });
48
70
  if (self.loading) {
49
71
  self.loading = false;
@@ -53,14 +75,17 @@ $.error = $.loader($('div[data-tab="error"] table'), {
53
75
  $.error.toRow = function(data) {
54
76
  return $(
55
77
  \`<tr><td>\${data.nr}</td>
56
- <td>\${this.toImg($.toStr(data.image), data.filename)}</td>
57
- <td>\${$.toStr(data.error)}</td>
58
- <td><div class="ui scrolling container err-data">\${$.hidePayload($.toStr(data.data))}</div></td>
78
+ <td>\${this.toImg($.toStr(data.image), data.filename)}</td>
79
+ <td>\${$.toStr(data.error)}</td>
80
+ <td><div class="ui scrolling container err-data">\${$.hidePayload($.toStr(data.data))}</div></td>
81
+ <td>
82
+ <a href="#" class="err-clicker" data-op="delete" data-filename="\${data.filename}" role="button"><i class="trash alternate outline red icon"></i></a>
83
+ </td>
59
84
  </tr>\`);
60
85
  }
61
86
  $.error.toImg = function(data, alt) {
62
87
  if (data) {
63
- return \`<a href="#" class="err-img-view" data-tooltip="\${alt}" data-position="right center">
88
+ return \`<a href="#" class="err-clicker" data-op="view" data-tooltip="\${alt}" data-position="right center">
64
89
  <img class="ui medium rounded bordered image" src="\${data}" alt="\${alt}">
65
90
  </a>\`;
66
91
  }
@@ -38,18 +38,18 @@ $.queue = $.loader($('div[data-tab="queue"] table'), {
38
38
  $.queue.toRow = function(data) {
39
39
  return $(
40
40
  \`<tr><td>\${data.nr}</td>
41
- <td>\${$.toStr(data.id)}</td>
42
- <td>\${$.toStr(data.type)}</td>
43
- <td><div class="ui scrolling container queue-name">\${$.hidePayload($.toStr(data.name))}</div></td>
44
- <td>\${this.toStatus(data.status)}</td>
45
- <td><div class="ui scrolling container queue-result">\${$.hidePayload($.toStr(data.result))}</div></td>
46
- <td>\${$.toStr(data.time)}</td>
41
+ <td>\${$.toStr(data.id)}</td>
42
+ <td>\${$.toStr(data.type)}</td>
43
+ <td><div class="ui scrolling container queue-name">\${$.hidePayload($.toStr(data.name))}</div></td>
44
+ <td>\${this.toStatus(data.status)}</td>
45
+ <td><div class="ui scrolling container queue-result">\${$.hidePayload($.toStr(data.result))}</div></td>
46
+ <td>\${$.toStr(data.time)}</td>
47
47
  </tr>\`);
48
48
  }
49
49
  $.queue.toStatus = function(data) {
50
50
  const icon = {
51
51
  new: 'pause circle outline',
52
- processing: 'spinner',
52
+ processing: 'loading spinner',
53
53
  done: 'green check',
54
54
  error: 'red times',
55
55
  timeout: 'clock outline',