@ntlab/sipd-tu-bridge-ui 1.7.0 → 1.7.2
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 +7 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/views/ui/error.ejs +43 -17
package/controller/ui.js
CHANGED
|
@@ -120,7 +120,13 @@ class UiController extends Controller {
|
|
|
120
120
|
const api = req.app.api;
|
|
121
121
|
const result = await api.getCapture(req.params.filename);
|
|
122
122
|
if (result.data) {
|
|
123
|
-
|
|
123
|
+
const ext = req.params.filename.substr(req.params.filename.lastIndexOf('.') + 1).toLowerCase();
|
|
124
|
+
switch (ext) {
|
|
125
|
+
case 'png':
|
|
126
|
+
case 'json':
|
|
127
|
+
res.type(ext);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
124
130
|
res.send(result.data);
|
|
125
131
|
} else {
|
|
126
132
|
res.sendStatus(404);
|
package/index.js
CHANGED
|
@@ -55,7 +55,7 @@ require('@ntlab/ntjs-repo')();
|
|
|
55
55
|
* @property {ActivityFunction} getActivity Get activity logs
|
|
56
56
|
* @property {ObjectFunction} getCount Get activity count
|
|
57
57
|
* @property {PagedObjectsFunction} getErrors Get captured errors
|
|
58
|
-
* @property {CaptureFileFunction} getCapture Get captured
|
|
58
|
+
* @property {CaptureFileFunction} getCapture Get captured error file
|
|
59
59
|
* @property {QueryFunction} query Perform API query
|
|
60
60
|
*/
|
|
61
61
|
|
|
@@ -132,7 +132,7 @@ require('@ntlab/ntjs-repo')();
|
|
|
132
132
|
*/
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Get captured
|
|
135
|
+
* Get captured error file.
|
|
136
136
|
*
|
|
137
137
|
* @callback CaptureFileFunction
|
|
138
138
|
* @param {string} filename Filename
|
package/package.json
CHANGED
package/views/ui/error.ejs
CHANGED
|
@@ -42,7 +42,7 @@ $.error.toRow = function(data) {
|
|
|
42
42
|
<tr><td>\${data.nr}</td>
|
|
43
43
|
<td>\${this.toImg($.toStr(data.filename), data.filename)}</td>
|
|
44
44
|
<td>\${this.toPayload(data.error, '${_('Error Message')}')}</td>
|
|
45
|
-
<td>\${this.toPayload(
|
|
45
|
+
<td>\${this.toPayload(null, '${_('Error Data')}', data.datafilename)}</td>
|
|
46
46
|
<td>
|
|
47
47
|
<a href="#" class="err-clicker" data-op="delete" data-filename="\${data.filename}" role="button"><i class="trash alternate outline red icon"></i></a>
|
|
48
48
|
</td>
|
|
@@ -56,17 +56,18 @@ $.error.toImg = function(data, alt) {
|
|
|
56
56
|
</a>\`;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
$.error.toPayload = function(data, title) {
|
|
60
|
-
if (data) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
data = JSON.parse(data);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
}
|
|
59
|
+
$.error.toPayload = function(data, title, filename) {
|
|
60
|
+
if (typeof data === 'string' && data.startsWith('{')) {
|
|
61
|
+
try {
|
|
62
|
+
data = JSON.parse(data);
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
catch (err) {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let excerpt, payload;
|
|
68
|
+
if (data) {
|
|
69
|
+
payload = $.toStr(data);
|
|
70
|
+
excerpt = payload;
|
|
70
71
|
if (excerpt.length > 100) {
|
|
71
72
|
excerpt = excerpt.substr(0, 100);
|
|
72
73
|
if (excerpt.includes('\\n')) {
|
|
@@ -78,12 +79,16 @@ $.error.toPayload = function(data, title) {
|
|
|
78
79
|
}
|
|
79
80
|
excerpt += '…';
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<pre style="display: none;">\${payload}</pre>
|
|
85
|
-
</a>\`;
|
|
82
|
+
} else {
|
|
83
|
+
excerpt = '…';
|
|
84
|
+
payload = '';
|
|
86
85
|
}
|
|
86
|
+
const url = filename ? '${route('Ui', {name: 'capture', filename: 'FILENAME'})}'.replace(/FILENAME/, filename) : '#';
|
|
87
|
+
return \`
|
|
88
|
+
<a href="\${url}" class="err-clicker" data-op="view" data-title="\${title}">
|
|
89
|
+
<span>\${excerpt}</span>
|
|
90
|
+
<pre style="display: none;">\${payload}</pre>
|
|
91
|
+
</a>\`;
|
|
87
92
|
}
|
|
88
93
|
$.error.handle = function(el) {
|
|
89
94
|
const self = this;
|
|
@@ -96,7 +101,19 @@ $.error.handle = function(el) {
|
|
|
96
101
|
size = 'fullscreen';
|
|
97
102
|
}
|
|
98
103
|
if (pre.length) {
|
|
99
|
-
|
|
104
|
+
if (el.attr('href') !== '#') {
|
|
105
|
+
content = \`
|
|
106
|
+
<div class="ui placeholder">
|
|
107
|
+
<div class="line"></div>
|
|
108
|
+
<div class="line"></div>
|
|
109
|
+
<div class="line"></div>
|
|
110
|
+
<div class="line"></div>
|
|
111
|
+
<div class="line"></div>
|
|
112
|
+
</div>\`;
|
|
113
|
+
} else {
|
|
114
|
+
content = \`<pre>\${$.safeStr(pre.text())}</pre>\`;
|
|
115
|
+
}
|
|
116
|
+
content = \`<div class="ui fluid scrolling container">\${content}</div>\`;
|
|
100
117
|
}
|
|
101
118
|
const dlg = $.ntdlg.create('err-view-dlg', el.data('title'), content, {
|
|
102
119
|
size,
|
|
@@ -105,6 +122,15 @@ $.error.handle = function(el) {
|
|
|
105
122
|
type: 'green approve',
|
|
106
123
|
caption: '<i class="check icon"></i>${_('Ok')}',
|
|
107
124
|
}
|
|
125
|
+
},
|
|
126
|
+
show() {
|
|
127
|
+
if (el.attr('href') !== '#') {
|
|
128
|
+
$.get(el.attr('href'))
|
|
129
|
+
.done(function(data) {
|
|
130
|
+
const content = typeof data === 'object' ? JSON.stringify(data, null, 2) : $.safeStr(data);
|
|
131
|
+
$('#err-view-dlg .container').html(\`<pre>\${content}</pre>\`);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
108
134
|
}
|
|
109
135
|
});
|
|
110
136
|
$.ntdlg.show(dlg);
|