@ntlab/sipd-tu-bridge-ui 1.6.0 → 1.7.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 +11 -0
- package/index.js +13 -1
- package/package.json +4 -4
- package/views/ui/error.ejs +3 -3
- package/views/ui/util.ejs +10 -1
package/controller/ui.js
CHANGED
|
@@ -115,6 +115,17 @@ class UiController extends Controller {
|
|
|
115
115
|
result.pages = req.app.locals.pager(result.count, result.size, result.page);
|
|
116
116
|
res.json(result);
|
|
117
117
|
});
|
|
118
|
+
this.addRoute('capture', 'get', '/capture/:filename', async (req, res, next) => {
|
|
119
|
+
/** @type {import('..').SipdApi} */
|
|
120
|
+
const api = req.app.api;
|
|
121
|
+
const result = await api.getCapture(req.params.filename);
|
|
122
|
+
if (result.data) {
|
|
123
|
+
res.type('png');
|
|
124
|
+
res.send(result.data);
|
|
125
|
+
} else {
|
|
126
|
+
res.sendStatus(404);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
118
129
|
this.addRoute('task', 'post', '/task/:op', async (req, res, next) => {
|
|
119
130
|
const result = {
|
|
120
131
|
success: false
|
package/index.js
CHANGED
|
@@ -35,7 +35,10 @@ const { Assets, CDN } = require('@ntlab/ntjs-assets');
|
|
|
35
35
|
// register script repository
|
|
36
36
|
require('@ntlab/ntjs-repo')();
|
|
37
37
|
|
|
38
|
-
/* --- BEGIN API
|
|
38
|
+
/* --- BEGIN API V2 --- */
|
|
39
|
+
|
|
40
|
+
/* V1: 2026-03-05 */
|
|
41
|
+
/* V2: 2026-06-23 */
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* SIPD Penatausahaan Bridge main application.
|
|
@@ -52,6 +55,7 @@ require('@ntlab/ntjs-repo')();
|
|
|
52
55
|
* @property {ActivityFunction} getActivity Get activity logs
|
|
53
56
|
* @property {ObjectFunction} getCount Get activity count
|
|
54
57
|
* @property {PagedObjectsFunction} getErrors Get captured errors
|
|
58
|
+
* @property {CaptureFileFunction} getCapture Get captured PNG file
|
|
55
59
|
* @property {QueryFunction} query Perform API query
|
|
56
60
|
*/
|
|
57
61
|
|
|
@@ -127,6 +131,14 @@ require('@ntlab/ntjs-repo')();
|
|
|
127
131
|
* @returns {Promise<[{name: string, seq: string, time: number}]>}
|
|
128
132
|
*/
|
|
129
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Get captured PNG file.
|
|
136
|
+
*
|
|
137
|
+
* @callback CaptureFileFunction
|
|
138
|
+
* @param {string} filename Filename
|
|
139
|
+
* @returns {Promise<{data: Buffer}>}
|
|
140
|
+
*/
|
|
141
|
+
|
|
130
142
|
/* --- END API --- */
|
|
131
143
|
|
|
132
144
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntlab/sipd-tu-bridge-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "SIPD Penatausahaan Bridge Web Interface",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"@ntlab/express-controller": "^1.3.0",
|
|
35
35
|
"@ntlab/express-middleware": "^2.6.0",
|
|
36
36
|
"@ntlab/ntjs": "^3.1.0",
|
|
37
|
-
"@ntlab/ntjs-assets": "^
|
|
37
|
+
"@ntlab/ntjs-assets": "^3.28.0",
|
|
38
38
|
"@ntlab/ntjs-repo": "^3.1.0",
|
|
39
39
|
"@ntlab/ntlib": "^2.9.1",
|
|
40
40
|
"ejs": "^3.1.10",
|
|
41
41
|
"express": "^5.2.1",
|
|
42
42
|
"express-session": "^1.19.0",
|
|
43
43
|
"http-errors": "^2.0.1",
|
|
44
|
-
"morgan": "^1.
|
|
44
|
+
"morgan": "^1.11.0",
|
|
45
45
|
"session-file-store": "^1.5.0",
|
|
46
|
-
"terser": "^5.
|
|
46
|
+
"terser": "^5.48.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/views/ui/error.ejs
CHANGED
|
@@ -40,7 +40,7 @@ $.error = $.loader($('div[data-tab="error"] table'), {
|
|
|
40
40
|
$.error.toRow = function(data) {
|
|
41
41
|
return $(\`
|
|
42
42
|
<tr><td>\${data.nr}</td>
|
|
43
|
-
<td>\${this.toImg($.toStr(data.
|
|
43
|
+
<td>\${this.toImg($.toStr(data.filename), data.filename)}</td>
|
|
44
44
|
<td>\${this.toPayload(data.error, '${_('Error Message')}')}</td>
|
|
45
45
|
<td>\${this.toPayload(data.data, '${_('Error Data')}')}</td>
|
|
46
46
|
<td>
|
|
@@ -52,7 +52,7 @@ $.error.toImg = function(data, alt) {
|
|
|
52
52
|
if (data) {
|
|
53
53
|
return \`
|
|
54
54
|
<a href="#" class="err-clicker" data-op="view" data-title="\${alt}" data-tooltip="\${alt}" data-position="right center">
|
|
55
|
-
<img class="ui medium rounded bordered image" src="\${data}" alt="\${alt}">
|
|
55
|
+
<img class="ui medium rounded bordered image" src="\${'${route('Ui', {name: 'capture', filename: 'FILENAME'})}'.replace(/FILENAME/, data)}" alt="\${alt}">
|
|
56
56
|
</a>\`;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -96,7 +96,7 @@ $.error.handle = function(el) {
|
|
|
96
96
|
size = 'fullscreen';
|
|
97
97
|
}
|
|
98
98
|
if (pre.length) {
|
|
99
|
-
content = \`<div class="ui fluid scrolling container"><pre>\${pre.text()}</pre></div>\`;
|
|
99
|
+
content = \`<div class="ui fluid scrolling container"><pre>\${$.safeStr(pre.text())}</pre></div>\`;
|
|
100
100
|
}
|
|
101
101
|
const dlg = $.ntdlg.create('err-view-dlg', el.data('title'), content, {
|
|
102
102
|
size,
|
package/views/ui/util.ejs
CHANGED
|
@@ -74,11 +74,20 @@ $.hidePayload = function(message) {
|
|
|
74
74
|
$.isPayload = function(data) {
|
|
75
75
|
return Array.isArray(data) || typeof data === 'object' && data.constructor.name === 'Object';
|
|
76
76
|
}
|
|
77
|
+
$.safeStr = function(s) {
|
|
78
|
+
if (s !== '') {
|
|
79
|
+
const tn = document.createTextNode(s);
|
|
80
|
+
const pn = document.createElement('p');
|
|
81
|
+
pn.appendChild(tn);
|
|
82
|
+
s = pn.innerHTML;
|
|
83
|
+
}
|
|
84
|
+
return s;
|
|
85
|
+
}
|
|
77
86
|
$.toStr = function(o) {
|
|
78
87
|
if ($.isPayload(o)) {
|
|
79
88
|
return JSON.stringify(o, null, ' ');
|
|
80
89
|
} else if (o !== undefined && o !== null) {
|
|
81
|
-
return o.toString();
|
|
90
|
+
return $.safeStr(o.toString());
|
|
82
91
|
}
|
|
83
92
|
return '';
|
|
84
93
|
}
|