@ntlab/sipd-tu-bridge-ui 1.3.0 → 1.4.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/package.json +1 -1
- package/public/css/app.css +13 -3
- package/views/ui/error.ejs +79 -42
- package/views/ui/queue.ejs +2 -2
- package/views/ui/util.ejs +5 -5
package/package.json
CHANGED
package/public/css/app.css
CHANGED
|
@@ -22,8 +22,11 @@ img.logo {
|
|
|
22
22
|
.ui.container.queue-result {
|
|
23
23
|
max-width: 22.5em;
|
|
24
24
|
}
|
|
25
|
+
.ui.container.err-message {
|
|
26
|
+
max-width: 20em;
|
|
27
|
+
}
|
|
25
28
|
.ui.container.err-data {
|
|
26
|
-
max-width:
|
|
29
|
+
max-width: 25em;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -34,8 +37,11 @@ img.logo {
|
|
|
34
37
|
.ui.container.queue-result {
|
|
35
38
|
max-width: 17.5em;
|
|
36
39
|
}
|
|
40
|
+
.ui.container.err-message {
|
|
41
|
+
max-width: 15em;
|
|
42
|
+
}
|
|
37
43
|
.ui.container.err-data {
|
|
38
|
-
max-width:
|
|
44
|
+
max-width: 20em;
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
|
|
@@ -46,14 +52,18 @@ img.logo {
|
|
|
46
52
|
.ui.container.queue-result {
|
|
47
53
|
max-width: 12.5em;
|
|
48
54
|
}
|
|
55
|
+
.ui.container.err-message {
|
|
56
|
+
max-width: 12.5em;
|
|
57
|
+
}
|
|
49
58
|
.ui.container.err-data {
|
|
50
|
-
max-width:
|
|
59
|
+
max-width: 15em;
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
@media only screen and (max-width: 767.98px) {
|
|
55
64
|
.ui.container.queue-name,
|
|
56
65
|
.ui.container.queue-result,
|
|
66
|
+
.ui.container.err-message,
|
|
57
67
|
.ui.container.err-data {
|
|
58
68
|
max-width: 75vw;
|
|
59
69
|
margin-left: 0 !important;
|
package/views/ui/error.ejs
CHANGED
|
@@ -30,42 +30,7 @@ $.error = $.loader($('div[data-tab="error"] table'), {
|
|
|
30
30
|
}
|
|
31
31
|
$('a.err-clicker').on('click', function(e) {
|
|
32
32
|
e.preventDefault();
|
|
33
|
-
|
|
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
|
-
}
|
|
47
|
-
}
|
|
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
|
-
}
|
|
33
|
+
self.handle($(this));
|
|
69
34
|
});
|
|
70
35
|
if (self.loading) {
|
|
71
36
|
self.loading = false;
|
|
@@ -73,11 +38,11 @@ $.error = $.loader($('div[data-tab="error"] table'), {
|
|
|
73
38
|
}
|
|
74
39
|
});
|
|
75
40
|
$.error.toRow = function(data) {
|
|
76
|
-
return $(
|
|
77
|
-
|
|
41
|
+
return $(\`
|
|
42
|
+
<tr><td>\${data.nr}</td>
|
|
78
43
|
<td>\${this.toImg($.toStr(data.image), data.filename)}</td>
|
|
79
|
-
<td>\${
|
|
80
|
-
<td
|
|
44
|
+
<td>\${this.toPayload(data.error, '${_('Error Message')}')}</td>
|
|
45
|
+
<td>\${this.toPayload(data.data, '${_('Error Data')}')}</td>
|
|
81
46
|
<td>
|
|
82
47
|
<a href="#" class="err-clicker" data-op="delete" data-filename="\${data.filename}" role="button"><i class="trash alternate outline red icon"></i></a>
|
|
83
48
|
</td>
|
|
@@ -85,11 +50,83 @@ $.error.toRow = function(data) {
|
|
|
85
50
|
}
|
|
86
51
|
$.error.toImg = function(data, alt) {
|
|
87
52
|
if (data) {
|
|
88
|
-
return
|
|
89
|
-
<
|
|
53
|
+
return \`
|
|
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}">
|
|
56
|
+
</a>\`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
$.error.toPayload = function(data, title) {
|
|
60
|
+
if (data) {
|
|
61
|
+
if (typeof data === 'string' && data.startsWith('{')) {
|
|
62
|
+
try {
|
|
63
|
+
data = JSON.parse(data);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const payload = $.toStr(data);
|
|
69
|
+
let excerpt = payload;
|
|
70
|
+
if (excerpt.length > 100) {
|
|
71
|
+
excerpt = excerpt.substr(0, 100);
|
|
72
|
+
if (excerpt.includes('\\n')) {
|
|
73
|
+
excerpt = excerpt.substr(0, excerpt.lastIndexOf('\\n'));
|
|
74
|
+
} else if (excerpt.includes(' ')) {
|
|
75
|
+
excerpt = excerpt.substr(0, excerpt.lastIndexOf(' '));
|
|
76
|
+
} else if (excerpt.includes('-')) {
|
|
77
|
+
excerpt = excerpt.substr(0, excerpt.lastIndexOf('-'));
|
|
78
|
+
}
|
|
79
|
+
excerpt += '…';
|
|
80
|
+
}
|
|
81
|
+
return \`
|
|
82
|
+
<a href="#" class="err-clicker" data-op="view" data-title="\${title}">
|
|
83
|
+
<span>\${excerpt}</span>
|
|
84
|
+
<pre style="display: none;">\${payload}</pre>
|
|
90
85
|
</a>\`;
|
|
91
86
|
}
|
|
92
87
|
}
|
|
88
|
+
$.error.handle = function(el) {
|
|
89
|
+
switch (el.data('op')) {
|
|
90
|
+
case 'view':
|
|
91
|
+
let content, size = 'large';
|
|
92
|
+
const img = el.find('img'), pre = el.find('pre');
|
|
93
|
+
if (img.length) {
|
|
94
|
+
content = \`<img class="ui fluid image" src="\${img.attr('src')}" style="max-height: 70vh;">\`;
|
|
95
|
+
size = 'fullscreen';
|
|
96
|
+
}
|
|
97
|
+
if (pre.length) {
|
|
98
|
+
content = \`<div class="ui fluid scrolling container"><pre>\${pre.text()}</pre></div>\`;
|
|
99
|
+
}
|
|
100
|
+
const dlg = $.ntdlg.create('err-view-dlg', el.data('title'), content, {
|
|
101
|
+
size,
|
|
102
|
+
buttons: {
|
|
103
|
+
okay: {
|
|
104
|
+
type: 'green approve',
|
|
105
|
+
caption: '<i class="check icon"></i>${_('Ok')}',
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
$.ntdlg.show(dlg);
|
|
110
|
+
break;
|
|
111
|
+
case 'delete':
|
|
112
|
+
$.ntdlg.confirm(
|
|
113
|
+
'err-delete-confirm-dlg',
|
|
114
|
+
'${_('Confirm')}',
|
|
115
|
+
'${_('Are you sure want to remove error <code>%ERR%</code>?')}'.replace(/%ERR%/g, el.data('filename')),
|
|
116
|
+
$.ntdlg.ICON_QUESTION,
|
|
117
|
+
function() {
|
|
118
|
+
$.post('${route('Ui', {name: 'task', op: 'remove'})}', {error: el.data('filename')})
|
|
119
|
+
.done(function(json) {
|
|
120
|
+
$.tasks.notify(json);
|
|
121
|
+
if (json.success) {
|
|
122
|
+
self.reload();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
93
130
|
$.error.reload = function() {
|
|
94
131
|
const self = this;
|
|
95
132
|
if (!self.loading) {
|
package/views/ui/queue.ejs
CHANGED
|
@@ -36,8 +36,8 @@ $.queue = $.loader($('div[data-tab="queue"] table'), {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
$.queue.toRow = function(data) {
|
|
39
|
-
return $(
|
|
40
|
-
|
|
39
|
+
return $(\`
|
|
40
|
+
<tr><td>\${data.nr}</td>
|
|
41
41
|
<td>\${$.toStr(data.id)}</td>
|
|
42
42
|
<td>\${$.toStr(data.type)}</td>
|
|
43
43
|
<td><div class="ui scrolling container queue-name">\${$.hidePayload($.toStr(data.name))}</div></td>
|
package/views/ui/util.ejs
CHANGED
|
@@ -47,12 +47,12 @@ $.hidePayload = function(message) {
|
|
|
47
47
|
}
|
|
48
48
|
return message;
|
|
49
49
|
}
|
|
50
|
+
$.isPayload = function(data) {
|
|
51
|
+
return Array.isArray(data) || typeof data === 'object' && data.constructor.name === 'Object';
|
|
52
|
+
}
|
|
50
53
|
$.toStr = function(o) {
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
typeof o === 'object' && o.constructor.name === 'Object'
|
|
54
|
-
) {
|
|
55
|
-
return JSON.stringify(o);
|
|
54
|
+
if ($.isPayload(o)) {
|
|
55
|
+
return JSON.stringify(o, null, ' ');
|
|
56
56
|
} else if (o !== undefined && o !== null) {
|
|
57
57
|
return o.toString();
|
|
58
58
|
}
|