@subiz/widget-v4 4.1.146 → 4.1.148
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/assets/less/form.less +13 -2
- package/assets/less/message.less +11 -0
- package/assets/less/message_input.less +19 -10
- package/assets/less/reboot.less +1 -1
- package/assets/less/widget.less +21 -17
- package/chat.html +10 -0
- package/chat.js +50 -0
- package/compiled_src/chatbox/Event.js +2 -1
- package/compiled_src/chatbox/FileAttachments.js +1 -0
- package/compiled_src/chatbox/Header.js +1 -0
- package/compiled_src/chatbox/ImageAttachments.js +2 -0
- package/compiled_src/chatbox/Widget.js +6 -2
- package/compiled_src/chatbox/block.js +15 -0
- package/compiled_src/lib.js +6 -1
- package/compiled_src/store/api.js +20 -24
- package/compiled_src/store/store.js +11 -2
- package/dist/{1970d063f3c.27.js → 1977d0fb90d.27.js} +1 -1
- package/dist/1977d0fb90d.278.js +1 -0
- package/dist/{1970d063f3c.339.js → 1977d0fb90d.339.js} +1 -1
- package/dist/{1970d063f3c.459.js → 1977d0fb90d.459.js} +1 -1
- package/dist/1977d0fb90d.app.js +1 -0
- package/dist/1977d0fb90d.chat.html +1 -0
- package/dist/1977d0fb90d.chat.js +1 -0
- package/dist/{1970d063f3c.form.html → 1977d0fb90d.form.html} +1 -1
- package/dist/{1970d063f3c.form.js → 1977d0fb90d.form.js} +1 -1
- package/dist/{1970d063f3c.index.html → 1977d0fb90d.index.html} +1 -1
- package/dist/{1970d063f3c.library.html → 1977d0fb90d.library.html} +1 -1
- package/dist/1977d0fb90d.library.js +1 -0
- package/dist/{1970d063f3c.preview.html → 1977d0fb90d.preview.html} +1 -1
- package/dist/1977d0fb90d.preview.js +1 -0
- package/dist/1977d0fb90d.webview.js +1 -0
- package/dist/27.js +1 -1
- package/dist/278.js +1 -1
- package/dist/459.js +1 -1
- package/dist/HASH +1 -0
- package/dist/screenshoot.js +26 -4
- package/package.json +5 -6
- package/src/chatbox/Event.js +7 -6
- package/src/chatbox/FileAttachments.js +7 -6
- package/src/chatbox/Header.js +1 -0
- package/src/chatbox/ImageAttachments.js +2 -0
- package/src/chatbox/Widget.js +6 -2
- package/src/chatbox/block.js +15 -0
- package/src/lib.js +5 -1
- package/src/store/api.js +30 -16
- package/src/store/store.js +14 -3
- package/webpack.dev.js +2 -0
- package/webpack.prod.js +7 -0
- package/dist/.HASH +0 -1
- package/dist/1970d063f3c.278.js +0 -1
- package/dist/1970d063f3c.app.js +0 -1
- package/dist/1970d063f3c.library.js +0 -1
- package/dist/1970d063f3c.preview.js +0 -1
- package/dist/1970d063f3c.webview.js +0 -1
- /package/dist/{1970d063f3c.127.js → 1977d0fb90d.127.js} +0 -0
- /package/dist/{1970d063f3c.132.js → 1977d0fb90d.132.js} +0 -0
- /package/dist/{1970d063f3c.185.js → 1977d0fb90d.185.js} +0 -0
- /package/dist/{1970d063f3c.490.js → 1977d0fb90d.490.js} +0 -0
- /package/dist/{1970d063f3c.74.js → 1977d0fb90d.74.js} +0 -0
- /package/dist/{1970d063f3c.997.js → 1977d0fb90d.997.js} +0 -0
package/assets/less/form.less
CHANGED
|
@@ -75,6 +75,17 @@ select.form-control {
|
|
|
75
75
|
select.form-control {
|
|
76
76
|
padding: 1px 8px;
|
|
77
77
|
}
|
|
78
|
+
input[type='date'].form-control {
|
|
79
|
+
height: 40px;
|
|
80
|
+
width: 100%;
|
|
81
|
+
background-color: #fff;
|
|
82
|
+
}
|
|
83
|
+
.form-wrapper-attachment input[type='date'].form-control {
|
|
84
|
+
height: 32px;
|
|
85
|
+
padding-top: 6px;
|
|
86
|
+
padding-bottom: 6px;
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
input[type='text'].form-control:focus,
|
|
79
90
|
input[type='number'].form-control:focus,
|
|
80
91
|
input[type='date'].form-control:focus,
|
|
@@ -548,11 +559,11 @@ select.form-control.form-control--empty {
|
|
|
548
559
|
height: 30px;
|
|
549
560
|
background-image: url('../img/stars_v2.png');
|
|
550
561
|
background-position: 0px 0px;
|
|
551
|
-
|
|
562
|
+
background-size: cover;
|
|
552
563
|
}
|
|
553
564
|
|
|
554
565
|
.form-wrapper-attachment .star-wrapper {
|
|
555
|
-
|
|
566
|
+
padding-right: 12px;
|
|
556
567
|
}
|
|
557
568
|
|
|
558
569
|
.star-wrapper {
|
package/assets/less/message.less
CHANGED
|
@@ -919,3 +919,14 @@ a.product_attachment__title {
|
|
|
919
919
|
font-weight: 500;
|
|
920
920
|
opacity: 0.4;
|
|
921
921
|
}
|
|
922
|
+
|
|
923
|
+
.message-text-inline-image-wrapper {
|
|
924
|
+
display: block;
|
|
925
|
+
margin-top: 8px;
|
|
926
|
+
margin-bottom: 8px;
|
|
927
|
+
max-width: 100%;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
.message-text-inline-image {
|
|
931
|
+
width: 100%;
|
|
932
|
+
}
|
|
@@ -7,17 +7,19 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.message-input--disabled {
|
|
10
|
-
background: #
|
|
10
|
+
background: #f0f0f0;
|
|
11
11
|
opacity: 0.6;
|
|
12
12
|
filter: grayscale(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
textarea[disabled=disabled] {
|
|
16
|
-
&::-webkit-input-placeholder {
|
|
15
|
+
textarea[disabled='disabled'] {
|
|
16
|
+
&::-webkit-input-placeholder {
|
|
17
|
+
// Edge
|
|
17
18
|
.color(#a4a4a4);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
&:-ms-input-placeholder {
|
|
21
|
+
&:-ms-input-placeholder {
|
|
22
|
+
// Internet Explorer 10-11
|
|
21
23
|
.color(#a4a4a4);
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -36,15 +38,16 @@ textarea[disabled=disabled] {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
.message-input--input::placeholder {
|
|
39
|
-
|
|
41
|
+
opacity: 0.5; /* Firefox */
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
.message-input--input::-ms-input-placeholder {
|
|
43
|
-
|
|
44
|
+
.message-input--input::-ms-input-placeholder {
|
|
45
|
+
/* Edge 12 -18 */
|
|
46
|
+
opacity: 0.5; /* Firefox */
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
.message-input--emoji-button {
|
|
47
|
-
background-image: url(
|
|
50
|
+
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXNtaWxlIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCI+PC9jaXJjbGU+PHBhdGggZD0iTTggMTRzMS41IDIgNCAyIDQtMiA0LTIiPjwvcGF0aD48bGluZSB4MT0iOSIgeTE9IjkiIHgyPSI5LjAxIiB5Mj0iOSI+PC9saW5lPjxsaW5lIHgxPSIxNSIgeTE9IjkiIHgyPSIxNS4wMSIgeTI9IjkiPjwvbGluZT48L3N2Zz4K');
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
.message-input--button {
|
|
@@ -72,7 +75,7 @@ textarea[disabled=disabled] {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
.message-input--attachment-button {
|
|
75
|
-
background-image: url(
|
|
78
|
+
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImdyYXkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXBhcGVyY2xpcCI+PHBhdGggZD0iTTIxLjQ0IDExLjA1bC05LjE5IDkuMTlhNiA2IDAgMCAxLTguNDktOC40OWw5LjE5LTkuMTlhNCA0IDAgMCAxIDUuNjYgNS42NmwtOS4yIDkuMTlhMiAyIDAgMCAxLTIuODMtMi44M2w4LjQ5LTguNDgiPjwvcGF0aD48L3N2Zz4K');
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
.message-input--send-button {
|
|
@@ -94,7 +97,13 @@ textarea[disabled=disabled] {
|
|
|
94
97
|
.color(@white);
|
|
95
98
|
font-size: 14px;
|
|
96
99
|
line-height: 20px;
|
|
97
|
-
text-align: center
|
|
100
|
+
text-align: center;
|
|
98
101
|
background: @primary-color;
|
|
99
102
|
width: 60%;
|
|
100
103
|
}
|
|
104
|
+
|
|
105
|
+
.widget-body.embed-chat .message-input {
|
|
106
|
+
border: 1px solid #e3e3e3;
|
|
107
|
+
border-radius: 8px;
|
|
108
|
+
margin-bottom: 20px;
|
|
109
|
+
}
|
package/assets/less/reboot.less
CHANGED
|
@@ -51,6 +51,7 @@ a {
|
|
|
51
51
|
color: @blue;
|
|
52
52
|
text-decoration: none;
|
|
53
53
|
background-color: transparent; // Remove the gray background on active links in IE 10.
|
|
54
|
+
font-weight: 600;
|
|
54
55
|
|
|
55
56
|
&:hover {
|
|
56
57
|
cursor: pointer;
|
|
@@ -204,7 +205,6 @@ textarea {
|
|
|
204
205
|
// 2. Change font properties to `inherit` in Safari.
|
|
205
206
|
//
|
|
206
207
|
|
|
207
|
-
|
|
208
208
|
// Always hide an element with the `hidden` HTML attribute (from PureCSS).
|
|
209
209
|
// Needed for proper display in IE 10-.
|
|
210
210
|
[hidden] {
|
package/assets/less/widget.less
CHANGED
|
@@ -291,6 +291,10 @@
|
|
|
291
291
|
position: relative;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
.widget-body.embed-chat {
|
|
295
|
+
max-width: 600px;
|
|
296
|
+
}
|
|
297
|
+
|
|
294
298
|
.widget-body--content {
|
|
295
299
|
overflow-y: auto;
|
|
296
300
|
overflow-x: hidden;
|
|
@@ -543,21 +547,21 @@
|
|
|
543
547
|
}
|
|
544
548
|
|
|
545
549
|
.widget-internet-status {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
550
|
+
position: absolute;
|
|
551
|
+
bottom: 0;
|
|
552
|
+
left: 0;
|
|
553
|
+
width: 100%;
|
|
554
|
+
font-size: 14px;
|
|
555
|
+
z-index: 10;
|
|
556
|
+
text-align: center;
|
|
557
|
+
padding: 6px 5px;
|
|
558
|
+
|
|
559
|
+
&.negative {
|
|
560
|
+
background-color: #212325;
|
|
561
|
+
color: #fff;
|
|
562
|
+
}
|
|
563
|
+
&.positive {
|
|
564
|
+
background-color: #19b600;
|
|
565
|
+
color: #fff;
|
|
566
|
+
}
|
|
563
567
|
}
|
package/chat.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
4
|
+
</head>
|
|
5
|
+
<body style="margin: 0">
|
|
6
|
+
<div style="overflow: hidden; width: 100%; height: 100%" class="container">
|
|
7
|
+
<div id="result_text" style="color: #f00; padding-top: 120px; text-align: center; font-size: 24px"></div>
|
|
8
|
+
</div>
|
|
9
|
+
</body>
|
|
10
|
+
</html>
|
package/chat.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// TODO: lam bo test template
|
|
2
|
+
// chu ngan, chu dai, anh ngan, anh dai voi tung template
|
|
3
|
+
import ApiV4 from './src/lib.js'
|
|
4
|
+
const config = require('./config.js')
|
|
5
|
+
|
|
6
|
+
function getUrlParameter(name) {
|
|
7
|
+
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
|
|
8
|
+
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)')
|
|
9
|
+
var results = regex.exec(location.search)
|
|
10
|
+
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function runChatbox(subiz) {
|
|
14
|
+
let popup = {
|
|
15
|
+
type: 'chatbox',
|
|
16
|
+
enabled: true,
|
|
17
|
+
chatbox: {
|
|
18
|
+
window_mode: 'full',
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
subiz._overridePlugin([popup])
|
|
22
|
+
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
subiz.showWidget()
|
|
25
|
+
}, 1)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function run() {
|
|
29
|
+
let accid = getUrlParameter('id') || getUrlParameter('acc_id') || getUrlParameter('account_id')
|
|
30
|
+
|
|
31
|
+
let subiz = new ApiV4(config.ApiURL, config.FileURL, config.RealtimeURL, true, false)
|
|
32
|
+
window.subiz = subiz
|
|
33
|
+
subiz._overrideDeviceType('mobile')
|
|
34
|
+
if (window.innerWidth > 760) {
|
|
35
|
+
// table or wider screen
|
|
36
|
+
subiz.setEmbebedChatMode()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//runChatbox(subiz)
|
|
40
|
+
let res = await subiz.setAccount(accid, document.querySelector('.container'))
|
|
41
|
+
if (res.error) {
|
|
42
|
+
document.querySelector('#result_text').textContent = `ERROR: ${res.error} with account id "${accid}"`
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
subiz.showWidget()
|
|
47
|
+
}, 1)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
run()
|
|
@@ -494,10 +494,11 @@ class Event extends _common.Com {
|
|
|
494
494
|
}
|
|
495
495
|
getSenderName(ev) {
|
|
496
496
|
let bytype = _index.default.get(ev, 'by.type');
|
|
497
|
-
let byid = _index.default.get(ev, 'by.display_id', _index.default.get(ev, 'by.id'));
|
|
497
|
+
let byid = _index.default.get(ev, 'by.display_id', _index.default.get(ev, 'by.id')) || '';
|
|
498
498
|
if (bytype === 'user') return _index.default.getUserDisplayName(this.props.store.matchUser());
|
|
499
499
|
let acc = this.props.store.matchAccount();
|
|
500
500
|
if (bytype === 'agent') return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
501
|
+
if (byid.startsWith('at')) return _index.default.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
501
502
|
if (bytype === 'bot') {
|
|
502
503
|
let bot = this.props.store.matchBot()[byid];
|
|
503
504
|
if (!bot) return 'Bot';
|
|
@@ -11,6 +11,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
11
11
|
class FileAttachments extends _common.Com {
|
|
12
12
|
render() {
|
|
13
13
|
var byType = _index.default.get(this.props.ev, 'by.type', 'agent');
|
|
14
|
+
if (byType !== 'user') byType = 'agent';
|
|
14
15
|
var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
|
|
15
16
|
var files = [];
|
|
16
17
|
_index.default.each(attachments, att => {
|
|
@@ -211,6 +211,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
211
211
|
renderCloseButton() {
|
|
212
212
|
let accSetting = this.props.plugin.chatbox || {};
|
|
213
213
|
if (accSetting.hide_close_button) return null;
|
|
214
|
+
if (this.props.store.isEmbededChatMode()) return;
|
|
214
215
|
return (0, _preact.h)("div", {
|
|
215
216
|
class: "widget-header--button-close",
|
|
216
217
|
"data-tooltip": this.props.t('close'),
|
|
@@ -70,6 +70,7 @@ class ImageAttachment extends _common.Com {
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
73
|
+
if (byType !== 'user') byType = 'agent';
|
|
73
74
|
if (!image.width || !image.height) {
|
|
74
75
|
return (0, _preact.h)("div", {
|
|
75
76
|
class: `image-attachment image-attachment--${byType}`
|
|
@@ -116,6 +117,7 @@ class ImageAttachment extends _common.Com {
|
|
|
116
117
|
var attachments = _index.default.get(this.props.ev, 'data.message.attachments', []);
|
|
117
118
|
var images = [];
|
|
118
119
|
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
120
|
+
if (byType !== 'user') byType = 'agent';
|
|
119
121
|
_index.default.each(attachments, (att, i) => {
|
|
120
122
|
if (!att) return;
|
|
121
123
|
if (!_index.default.includes(att.mimetype, 'image')) return;
|
|
@@ -654,8 +654,10 @@ class Widget extends _common.Com {
|
|
|
654
654
|
let hasError = _index.default.find(this.state.formData, field => !!field.error);
|
|
655
655
|
let newData = this.validateForm(this.state.formData);
|
|
656
656
|
let hasEmptyError = _index.default.find(newData, field => !!field.is_empty_error);
|
|
657
|
+
let bodycls = 'widget-body';
|
|
658
|
+
if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat';
|
|
657
659
|
return (0, _preact.h)("div", {
|
|
658
|
-
class:
|
|
660
|
+
class: bodycls
|
|
659
661
|
}, (0, _preact.h)(FormMounter, {
|
|
660
662
|
key: form._updated,
|
|
661
663
|
form: form,
|
|
@@ -816,8 +818,10 @@ class Widget extends _common.Com {
|
|
|
816
818
|
onClick: e => this.onStartConvoClick(e)
|
|
817
819
|
}, this.props.t('offline_preform_btn')));
|
|
818
820
|
}
|
|
821
|
+
let bodycls = 'widget-body';
|
|
822
|
+
if (this.props.store.isEmbededChatMode()) bodycls += ' embed-chat';
|
|
819
823
|
return (0, _preact.h)("div", {
|
|
820
|
-
class:
|
|
824
|
+
class: bodycls
|
|
821
825
|
}, (0, _preact.h)("div", {
|
|
822
826
|
class: "widget-body--content",
|
|
823
827
|
onClick: e => this.onContainerClick(e)
|
|
@@ -99,6 +99,11 @@ class Block extends _common.Com {
|
|
|
99
99
|
if (block.type == 'table') {
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
+
if (block.type === 'image') {
|
|
103
|
+
ele.tag = 'img';
|
|
104
|
+
ele.attrs['src'] = _index.default.get(block, 'image.url');
|
|
105
|
+
ele.attrs['alt'] = block.alt_text;
|
|
106
|
+
}
|
|
102
107
|
let $body = null;
|
|
103
108
|
if (_index.default.size(block.content)) {
|
|
104
109
|
$body = _index.default.map(block.content, block => this.renderBlock(block));
|
|
@@ -128,6 +133,16 @@ class Block extends _common.Com {
|
|
|
128
133
|
$body = ele.text;
|
|
129
134
|
}
|
|
130
135
|
switch (ele.tag) {
|
|
136
|
+
case 'img':
|
|
137
|
+
return (0, _preact.h)("a", {
|
|
138
|
+
class: "message-text-inline-image-wrapper",
|
|
139
|
+
href: _index.default.get(ele, 'attrs.src'),
|
|
140
|
+
target: "_blank"
|
|
141
|
+
}, (0, _preact.h)("img", {
|
|
142
|
+
class: "message-text-inline-image",
|
|
143
|
+
src: _index.default.get(ele, 'attrs.src'),
|
|
144
|
+
alt: _index.default.get(ele, 'attrs.alt') || ''
|
|
145
|
+
}));
|
|
131
146
|
case 'div':
|
|
132
147
|
return (0, _preact.h)("div", null, $body);
|
|
133
148
|
case 'h1':
|
package/compiled_src/lib.js
CHANGED
|
@@ -44,6 +44,9 @@ class Widget {
|
|
|
44
44
|
setAIDevMode(mode) {
|
|
45
45
|
this.store.setAIDevMode(mode);
|
|
46
46
|
}
|
|
47
|
+
setEmbebedChatMode() {
|
|
48
|
+
this.store.setEmbebedChatMode();
|
|
49
|
+
}
|
|
47
50
|
setTrackPageView(val) {
|
|
48
51
|
this.store.setTrackPageview(val);
|
|
49
52
|
}
|
|
@@ -105,7 +108,9 @@ class Widget {
|
|
|
105
108
|
return outmask;
|
|
106
109
|
}
|
|
107
110
|
async setAccount(id, $container, mask, cb) {
|
|
108
|
-
if (!id) return
|
|
111
|
+
if (!id) return {
|
|
112
|
+
error: 'empty_account_id'
|
|
113
|
+
};
|
|
109
114
|
let outmask = await this.store.init(id, mask);
|
|
110
115
|
_index.default.setTimeout(() => window.postMessage({
|
|
111
116
|
type: 'widget_loaded',
|
|
@@ -60,40 +60,36 @@ class _default {
|
|
|
60
60
|
_defineProperty(this, "sendTyping", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));
|
|
61
61
|
_defineProperty(this, "sendLostFocus", () => this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`));
|
|
62
62
|
_defineProperty(this, "uploadToS3", async file => {
|
|
63
|
-
|
|
64
|
-
body
|
|
63
|
+
var {
|
|
64
|
+
body,
|
|
65
65
|
error
|
|
66
|
-
} = await
|
|
67
|
-
|
|
66
|
+
} = await ajax.setBaseUrl('https://api5.subiz.com.vn/4.1').withCredentials(true).setQuery({
|
|
67
|
+
'account-id': accid,
|
|
68
68
|
description: 'upload\n user-client: web-widget',
|
|
69
69
|
name: file.name.replace(/\s+/g, '_'),
|
|
70
70
|
size: file.size,
|
|
71
71
|
type: file.type
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
error
|
|
88
|
-
} = await this.apireq.post(`/accounts/${this.accid}/files/${signed.id}`, {
|
|
89
|
-
account_id: this.accid
|
|
90
|
-
}));
|
|
72
|
+
}).setParser('json').beforeHook((param, done) => {
|
|
73
|
+
if (this.token_generator) {
|
|
74
|
+
let user_id = this.profile_id;
|
|
75
|
+
this.token_generator().then(token => {
|
|
76
|
+
if (user_id != this.profile_id) return done(true);
|
|
77
|
+
if (!token) return done(false);
|
|
78
|
+
if (token == 'error') return done(false);
|
|
79
|
+
param.request = param.request.addQuery('x-access-token', token);
|
|
80
|
+
return done(true);
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.ref) param.request = param.request.addQuery('x-user-ref', this.ref);else if (this.mask) param.request = param.request.addQuery('x-user-mask', this.mask);
|
|
85
|
+
return done(true);
|
|
86
|
+
}).post('/files', file);
|
|
91
87
|
if (error) return {
|
|
92
88
|
body,
|
|
93
89
|
error
|
|
94
90
|
};
|
|
95
91
|
return {
|
|
96
|
-
url: body.url
|
|
92
|
+
url: _index.default.get(body, 'file.url')
|
|
97
93
|
};
|
|
98
94
|
});
|
|
99
95
|
_defineProperty(this, "time", _ => ajax.setBaseUrl(this.ApiURL).withCredentials(true).setParser('json').get('/time'));
|
|
@@ -362,9 +362,15 @@ class Store {
|
|
|
362
362
|
setAIDevMode(mode) {
|
|
363
363
|
this.ai_dev_mode = mode;
|
|
364
364
|
}
|
|
365
|
+
setEmbebedChatMode() {
|
|
366
|
+
this.is_embed_chat_mode = true;
|
|
367
|
+
}
|
|
365
368
|
isAIDevMode() {
|
|
366
369
|
return this.ai_dev_mode;
|
|
367
370
|
}
|
|
371
|
+
isEmbededChatMode() {
|
|
372
|
+
return this.is_embed_chat_mode;
|
|
373
|
+
}
|
|
368
374
|
overrideDeviceType(type) {
|
|
369
375
|
this.forceDevice = type;
|
|
370
376
|
this.pubsub.publish('account');
|
|
@@ -449,7 +455,10 @@ class Store {
|
|
|
449
455
|
mask: mask,
|
|
450
456
|
ref: userRef
|
|
451
457
|
});
|
|
452
|
-
if (user.error)
|
|
458
|
+
if (user.error) {
|
|
459
|
+
console.error(user);
|
|
460
|
+
return user;
|
|
461
|
+
}
|
|
453
462
|
if (this.realtime) this.realtime.stop();
|
|
454
463
|
if (this.fake) this.realtime = new _realtime_fake.default();else this.realtime = new Realtime(this.RealtimeURL, {
|
|
455
464
|
account_id: accid,
|
|
@@ -1058,7 +1067,7 @@ class Store {
|
|
|
1058
1067
|
src = src.replace('http://file.subiz.com/', this.FileURL);
|
|
1059
1068
|
src = src.replace('https://file.mysubiz.com/', this.FileURL);
|
|
1060
1069
|
src = src.replace('http://file.mysubiz.com/', this.FileURL);
|
|
1061
|
-
return src;
|
|
1070
|
+
return src.replace('vcdn.subiz-cdn.com', 'cdn.subiz.net');
|
|
1062
1071
|
}
|
|
1063
1072
|
clearBrowserData() {
|
|
1064
1073
|
_index.default.each(this.cookie.all(), (v, k) => {
|