odant-work 1.0.80 → 1.0.82
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/#system/package-manifest.json +40 -38
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +38 -8
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +91 -9
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/video.html +8 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +95 -8
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/system.js +33 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/database.js +22 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/messengers.js +7 -7
- package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +8 -6
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +14 -2
- package/$server/$folder/handlers/pages/form/$handler/form.js +47 -6
- package/$server/$folder/lib/calendar-form/calendar-form.js +7 -5
- package/$server/$folder/lib/class-picker/class-picker.js +5 -2
- package/$server/$folder/lib/dialogs/confirm/confirm.js +6 -2
- package/$server/$folder/lib/dialogs/input/input.js +15 -9
- package/$server/$folder/lib/editor-form/editor-form.js +8 -5
- package/$server/$folder/lib/explorer/explorer.js +76 -13
- package/$server/$folder/lib/local-models-transfer/local-models-transfer.js +3 -2
- package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
- package/$server/$folder/lib/support/support.js +1373 -0
- package/oda/components/containers/containers.js +2 -2
- package/oda/components/containers/popover/popover.js +83 -18
- package/oda/components/inputs/link/link.js +7 -5
- package/oda/components/layouts/app-layout/app-layout.js +33 -10
- package/oda/components/menus/menu/menu.js +2 -2
- package/oda/oda.js +13 -2
- package/oda/tools/styles/styles.js +68 -0
- package/package.json +1 -1
- package/sources/client/folder.js +1 -0
- package/sources/index.html +7 -4
- package/sources/manifest.json +12 -6
- package/sources/modules/support/index.js +414 -0
- package/sources/modules/user-profile/user-profile.js +27 -5
- package/sources/page.html +7 -4
- package/sources/server/access/gateway.js +3 -0
- package/sources/server/class.js +11 -0
- package/sources/tester.html +4 -4
|
@@ -0,0 +1,1373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Клиентский модуль службы поддержки и встроенного Remote Desktop (ODA):
|
|
3
|
+
* - <work-support-panel>: создание обращения (скриншот с разметкой / видео до 60 сек / техданные) + переписка по тикетам;
|
|
4
|
+
* - <work-support-remote-bar>: плавающая плашка активного Remote Desktop с переключателем «Только просмотр / Управление WORK»,
|
|
5
|
+
* WebRTC + резервной передачей кадров, лазерной указкой и безопасным управлением интерфейсом WORK (включая iframe форм).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_VIDEO_SEC = 60;
|
|
9
|
+
const REMOTE_POLL_MS = 650;
|
|
10
|
+
|
|
11
|
+
export function installSupportErrorCollector() {
|
|
12
|
+
if (typeof window === 'undefined') return;
|
|
13
|
+
const host = globalThis.WORK || window;
|
|
14
|
+
if (host.__supportErrInstalled) return;
|
|
15
|
+
host.__supportErrInstalled = true;
|
|
16
|
+
host.__supportErrors = host.__supportErrors || [];
|
|
17
|
+
const pushErr = (kind, msg) => {
|
|
18
|
+
const list = host.__supportErrors;
|
|
19
|
+
list.push({ time: new Date().toISOString(), kind, message: String(msg || '').slice(0, 300) });
|
|
20
|
+
if (list.length > 15) list.shift();
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener('error', (e) => pushErr('error', e?.message || e?.error?.message || 'Script error'));
|
|
23
|
+
window.addEventListener('unhandledrejection', (e) => pushErr('rejection', e?.reason?.message || e?.reason || 'Unhandled rejection'));
|
|
24
|
+
}
|
|
25
|
+
installSupportErrorCollector();
|
|
26
|
+
|
|
27
|
+
function deepElementFromPoint(x, y) {
|
|
28
|
+
let doc = document;
|
|
29
|
+
let cx = x;
|
|
30
|
+
let cy = y;
|
|
31
|
+
for (let hop = 0; hop < 8; hop++) {
|
|
32
|
+
let el = doc.elementFromPoint(cx, cy);
|
|
33
|
+
if (!el) return null;
|
|
34
|
+
while (el && el.shadowRoot) {
|
|
35
|
+
const inner = el.shadowRoot.elementFromPoint(cx, cy);
|
|
36
|
+
if (!inner || inner === el) break;
|
|
37
|
+
el = inner;
|
|
38
|
+
}
|
|
39
|
+
if (el && el.tagName === 'IFRAME') {
|
|
40
|
+
try {
|
|
41
|
+
const subDoc = el.contentDocument;
|
|
42
|
+
if (subDoc) {
|
|
43
|
+
const r = el.getBoundingClientRect();
|
|
44
|
+
cx = cx - r.left;
|
|
45
|
+
cy = cy - r.top;
|
|
46
|
+
doc = subDoc;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return el;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return el;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isSensitiveOrProtectedTarget(el) {
|
|
60
|
+
if (!el) return true;
|
|
61
|
+
let cur = el;
|
|
62
|
+
for (let i = 0; i < 12 && cur; i++) {
|
|
63
|
+
const tag = String(cur.tagName || '').toLowerCase();
|
|
64
|
+
if (tag === 'work-support-remote-bar' || tag === 'work-support-panel')
|
|
65
|
+
return true;
|
|
66
|
+
if (tag === 'input' && String(cur.type || '').toLowerCase() === 'password')
|
|
67
|
+
return true;
|
|
68
|
+
if (cur.dataset?.secret !== undefined || cur.classList?.contains('secret'))
|
|
69
|
+
return true;
|
|
70
|
+
cur = cur.parentElement || cur.getRootNode?.()?.host || null;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const href = String(el.ownerDocument?.location?.href || '');
|
|
74
|
+
if (href.includes('#secret') || href.includes('read_secret'))
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch { /* ignore */ }
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function applyRemoteControlEvent(ev) {
|
|
82
|
+
if (!ev || typeof ev !== 'object') return;
|
|
83
|
+
const x = Math.max(0, Math.min(window.innerWidth - 1, Math.round((Number(ev.x) || 0) * window.innerWidth)));
|
|
84
|
+
const y = Math.max(0, Math.min(window.innerHeight - 1, Math.round((Number(ev.y) || 0) * window.innerHeight)));
|
|
85
|
+
const target = deepElementFromPoint(x, y);
|
|
86
|
+
if (!target || isSensitiveOrProtectedTarget(target))
|
|
87
|
+
return;
|
|
88
|
+
|
|
89
|
+
const win = target.ownerDocument?.defaultView || window;
|
|
90
|
+
if (ev.type === 'click' || ev.type === 'dblclick') {
|
|
91
|
+
target.focus?.();
|
|
92
|
+
const opts = { bubbles: true, cancelable: true, composed: true, clientX: x, clientY: y, view: win };
|
|
93
|
+
target.dispatchEvent(new MouseEvent('mousedown', opts));
|
|
94
|
+
target.dispatchEvent(new MouseEvent('mouseup', opts));
|
|
95
|
+
target.dispatchEvent(new MouseEvent('click', opts));
|
|
96
|
+
if (ev.type === 'dblclick')
|
|
97
|
+
target.dispatchEvent(new MouseEvent('dblclick', opts));
|
|
98
|
+
}
|
|
99
|
+
else if (ev.type === 'scroll') {
|
|
100
|
+
let sc = target;
|
|
101
|
+
while (sc && sc !== sc.ownerDocument?.documentElement) {
|
|
102
|
+
if (sc.scrollHeight > sc.clientHeight) {
|
|
103
|
+
sc.scrollTop += Number(ev.deltaY) || 0;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
sc = sc.parentElement || sc.getRootNode?.()?.host || null;
|
|
107
|
+
}
|
|
108
|
+
win.scrollBy(0, Number(ev.deltaY) || 0);
|
|
109
|
+
}
|
|
110
|
+
else if (ev.type === 'input' && typeof ev.text === 'string') {
|
|
111
|
+
const active = target.ownerDocument?.activeElement || target;
|
|
112
|
+
const el = (active && !isSensitiveOrProtectedTarget(active)) ? active : target;
|
|
113
|
+
if ('value' in el && !el.readOnly && !el.disabled) {
|
|
114
|
+
el.value = String(el.value || '') + ev.text;
|
|
115
|
+
el.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
116
|
+
el.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (ev.type === 'keydown' && typeof ev.key === 'string') {
|
|
120
|
+
const active = target.ownerDocument?.activeElement || target;
|
|
121
|
+
const el = (active && !isSensitiveOrProtectedTarget(active)) ? active : target;
|
|
122
|
+
if (ev.key === 'Backspace' && 'value' in el && !el.readOnly && !el.disabled) {
|
|
123
|
+
el.value = String(el.value || '').slice(0, -1);
|
|
124
|
+
el.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
el.dispatchEvent(new KeyboardEvent('keydown', { key: ev.key, bubbles: true, cancelable: true, composed: true }));
|
|
128
|
+
el.dispatchEvent(new KeyboardEvent('keyup', { key: ev.key, bubbles: true, cancelable: true, composed: true }));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
ODA({
|
|
133
|
+
is: 'work-support-remote-bar',
|
|
134
|
+
imports: 'oda//icon',
|
|
135
|
+
template: /*html*/`
|
|
136
|
+
<style>
|
|
137
|
+
:host {
|
|
138
|
+
position: fixed;
|
|
139
|
+
inset: 0;
|
|
140
|
+
pointer-events: none;
|
|
141
|
+
z-index: 2147483000;
|
|
142
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
143
|
+
}
|
|
144
|
+
.pill {
|
|
145
|
+
position: fixed;
|
|
146
|
+
top: max(10px, var(--safe-top, 0px));
|
|
147
|
+
left: 50%;
|
|
148
|
+
transform: translateX(-50%);
|
|
149
|
+
pointer-events: auto;
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
flex-wrap: wrap;
|
|
154
|
+
row-gap: 6px;
|
|
155
|
+
column-gap: 8px;
|
|
156
|
+
max-width: calc(100vw - 16px - var(--safe-left, 0px) - var(--safe-right, 0px));
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
padding: 7px 14px;
|
|
159
|
+
border-radius: 20px;
|
|
160
|
+
background: #0f172a;
|
|
161
|
+
color: #f8fafc;
|
|
162
|
+
border: 1px solid rgba(56, 189, 248, 0.45);
|
|
163
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
|
|
164
|
+
font-size: 12.5px;
|
|
165
|
+
text-align: center;
|
|
166
|
+
}
|
|
167
|
+
.pill-title {
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
gap: 7px;
|
|
171
|
+
min-width: 0;
|
|
172
|
+
}
|
|
173
|
+
.pill-actions {
|
|
174
|
+
display: inline-flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
flex-wrap: wrap;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
gap: 6px;
|
|
179
|
+
}
|
|
180
|
+
.dot {
|
|
181
|
+
width: 9px;
|
|
182
|
+
height: 9px;
|
|
183
|
+
border-radius: 50%;
|
|
184
|
+
background: #ef4444;
|
|
185
|
+
box-shadow: 0 0 8px #ef4444;
|
|
186
|
+
flex-shrink: 0;
|
|
187
|
+
}
|
|
188
|
+
.mode-btn {
|
|
189
|
+
border: 1px solid rgba(255, 255, 255, 0.22);
|
|
190
|
+
background: rgba(255, 255, 255, 0.1);
|
|
191
|
+
color: #fff;
|
|
192
|
+
border-radius: 999px;
|
|
193
|
+
padding: 4px 10px;
|
|
194
|
+
font: inherit;
|
|
195
|
+
font-size: 12px;
|
|
196
|
+
font-weight: 600;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
}
|
|
199
|
+
.mode-btn.control {
|
|
200
|
+
background: #16a34a;
|
|
201
|
+
border-color: #4ade80;
|
|
202
|
+
}
|
|
203
|
+
.stop-btn {
|
|
204
|
+
border: none;
|
|
205
|
+
background: #dc2626;
|
|
206
|
+
color: #fff;
|
|
207
|
+
border-radius: 999px;
|
|
208
|
+
padding: 4px 11px;
|
|
209
|
+
font: inherit;
|
|
210
|
+
font-size: 12px;
|
|
211
|
+
font-weight: 600;
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
}
|
|
214
|
+
.cursor {
|
|
215
|
+
position: fixed;
|
|
216
|
+
pointer-events: none;
|
|
217
|
+
transform: translate(-4px, -4px);
|
|
218
|
+
display: flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
gap: 4px;
|
|
221
|
+
transition: left 60ms linear, top 60ms linear;
|
|
222
|
+
}
|
|
223
|
+
.cursor-dot {
|
|
224
|
+
width: 14px;
|
|
225
|
+
height: 14px;
|
|
226
|
+
border-radius: 50%;
|
|
227
|
+
background: rgba(239, 68, 68, 0.9);
|
|
228
|
+
border: 2px solid #fff;
|
|
229
|
+
box-shadow: 0 0 10px rgba(239, 68, 68, 0.85);
|
|
230
|
+
}
|
|
231
|
+
.cursor-tag {
|
|
232
|
+
padding: 2px 7px;
|
|
233
|
+
border-radius: 6px;
|
|
234
|
+
background: #ef4444;
|
|
235
|
+
color: #fff;
|
|
236
|
+
font-size: 11px;
|
|
237
|
+
font-weight: 600;
|
|
238
|
+
box-shadow: 0 2px 8px rgba(0,0,0,.3);
|
|
239
|
+
}
|
|
240
|
+
</style>
|
|
241
|
+
<div class="pill">
|
|
242
|
+
<span class="pill-title">
|
|
243
|
+
<span class="dot"></span>
|
|
244
|
+
<span>Поддержка видит экран · <b>{{ticketId}}</b></span>
|
|
245
|
+
</span>
|
|
246
|
+
<span class="pill-actions">
|
|
247
|
+
<button type="button" class="mode-btn" :class="{ control: mode === 'control' }" @tap="toggleMode()">
|
|
248
|
+
{{mode === 'control' ? 'Управление WORK (вкл)' : 'Только просмотр'}}
|
|
249
|
+
</button>
|
|
250
|
+
<button type="button" class="stop-btn" @tap="stopSession()">Прервать</button>
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
<div class="cursor" ~if="cursorVisible" :style="'left:' + cursorX + 'px;top:' + cursorY + 'px'">
|
|
254
|
+
<div class="cursor-dot"></div>
|
|
255
|
+
<div class="cursor-tag">{{engineerName || 'Поддержка'}}</div>
|
|
256
|
+
</div>
|
|
257
|
+
`,
|
|
258
|
+
ticketId: '',
|
|
259
|
+
mode: 'view',
|
|
260
|
+
engineerName: 'Поддержка',
|
|
261
|
+
cursorVisible: false,
|
|
262
|
+
cursorX: 0,
|
|
263
|
+
cursorY: 0,
|
|
264
|
+
_stream: null,
|
|
265
|
+
_pc: null,
|
|
266
|
+
_pollTimer: null,
|
|
267
|
+
_frameTimer: null,
|
|
268
|
+
_lastOfferSeq: 0,
|
|
269
|
+
_iceConnected: false,
|
|
270
|
+
async start(ticketId, { mode = 'view', engineerName = 'Поддержка' } = {}) {
|
|
271
|
+
this.ticketId = ticketId;
|
|
272
|
+
this.mode = mode === 'control' ? 'control' : 'view';
|
|
273
|
+
this.engineerName = engineerName || 'Поддержка';
|
|
274
|
+
try {
|
|
275
|
+
this._stream = await navigator.mediaDevices.getDisplayMedia({
|
|
276
|
+
video: { frameRate: 12 },
|
|
277
|
+
preferCurrentTab: true,
|
|
278
|
+
audio: false,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
catch (err) {
|
|
282
|
+
throw new Error('Не удалось получить доступ к экрану: ' + (err?.message || err));
|
|
283
|
+
}
|
|
284
|
+
const track = this._stream.getVideoTracks()[0];
|
|
285
|
+
track?.addEventListener('ended', () => this.stopSession(true));
|
|
286
|
+
|
|
287
|
+
await WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
288
|
+
ticketId: this.ticketId,
|
|
289
|
+
action: 'start',
|
|
290
|
+
mode: this.mode,
|
|
291
|
+
}));
|
|
292
|
+
|
|
293
|
+
this._setupPeer();
|
|
294
|
+
this._startPolling();
|
|
295
|
+
this._startFallbackFrames();
|
|
296
|
+
},
|
|
297
|
+
_setupPeer() {
|
|
298
|
+
try {
|
|
299
|
+
const pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] });
|
|
300
|
+
this._pc = pc;
|
|
301
|
+
for (const t of this._stream.getTracks())
|
|
302
|
+
pc.addTrack(t, this._stream);
|
|
303
|
+
pc.oniceconnectionstatechange = () => {
|
|
304
|
+
this._iceConnected = pc.iceConnectionState === 'connected' || pc.iceConnectionState === 'completed';
|
|
305
|
+
};
|
|
306
|
+
pc.onicecandidate = (e) => {
|
|
307
|
+
if (e.candidate && this.ticketId) {
|
|
308
|
+
WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
309
|
+
ticketId: this.ticketId,
|
|
310
|
+
action: 'ice',
|
|
311
|
+
candidate: e.candidate.toJSON ? e.candidate.toJSON() : e.candidate,
|
|
312
|
+
})).catch(() => {});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
catch { /* fallback frames will handle it */ }
|
|
317
|
+
},
|
|
318
|
+
_startPolling() {
|
|
319
|
+
if (this._pollTimer) clearInterval(this._pollTimer);
|
|
320
|
+
this._pollTimer = setInterval(async () => {
|
|
321
|
+
if (!this.ticketId) return;
|
|
322
|
+
try {
|
|
323
|
+
const res = await WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
324
|
+
ticketId: this.ticketId,
|
|
325
|
+
action: 'poll',
|
|
326
|
+
}));
|
|
327
|
+
const r = res?.remote;
|
|
328
|
+
if (!r) return;
|
|
329
|
+
if (r.state === 'ended') {
|
|
330
|
+
this.stopSession(false);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (r.offer && r.offer.seq !== this._lastOfferSeq && this._pc) {
|
|
334
|
+
this._lastOfferSeq = r.offer.seq;
|
|
335
|
+
try {
|
|
336
|
+
await this._pc.setRemoteDescription(new RTCSessionDescription({ type: r.offer.type, sdp: r.offer.sdp }));
|
|
337
|
+
const ans = await this._pc.createAnswer();
|
|
338
|
+
await this._pc.setLocalDescription(ans);
|
|
339
|
+
await WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
340
|
+
ticketId: this.ticketId,
|
|
341
|
+
action: 'answer',
|
|
342
|
+
answer: { type: ans.type, sdp: ans.sdp },
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
catch { /* ignore */ }
|
|
346
|
+
}
|
|
347
|
+
if (Array.isArray(r.ice) && this._pc) {
|
|
348
|
+
for (const c of r.ice) {
|
|
349
|
+
try { await this._pc.addIceCandidate(new RTCIceCandidate(c)); } catch { /* ignore */ }
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (Array.isArray(r.controlEvents)) {
|
|
353
|
+
for (const ev of r.controlEvents) {
|
|
354
|
+
if (ev.type === 'pointer') {
|
|
355
|
+
this.cursorVisible = true;
|
|
356
|
+
this.cursorX = Math.round((Number(ev.x) || 0) * window.innerWidth);
|
|
357
|
+
this.cursorY = Math.round((Number(ev.y) || 0) * window.innerHeight);
|
|
358
|
+
}
|
|
359
|
+
else if (this.mode === 'control') {
|
|
360
|
+
applyRemoteControlEvent(ev);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
catch { /* ignore */ }
|
|
366
|
+
}, REMOTE_POLL_MS);
|
|
367
|
+
},
|
|
368
|
+
_startFallbackFrames() {
|
|
369
|
+
if (this._frameTimer) clearInterval(this._frameTimer);
|
|
370
|
+
const video = document.createElement('video');
|
|
371
|
+
video.muted = true;
|
|
372
|
+
video.playsInline = true;
|
|
373
|
+
video.srcObject = this._stream;
|
|
374
|
+
video.play().catch(() => {});
|
|
375
|
+
const canvas = document.createElement('canvas');
|
|
376
|
+
this._frameTimer = setInterval(async () => {
|
|
377
|
+
if (this._iceConnected || !this._stream || !video.videoWidth) return;
|
|
378
|
+
const scale = Math.min(1, 1280 / video.videoWidth);
|
|
379
|
+
canvas.width = Math.max(1, Math.round(video.videoWidth * scale));
|
|
380
|
+
canvas.height = Math.max(1, Math.round(video.videoHeight * scale));
|
|
381
|
+
const ctx = canvas.getContext('2d');
|
|
382
|
+
if (!ctx) return;
|
|
383
|
+
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
384
|
+
const dataUrl = canvas.toDataURL('image/jpeg', 0.65);
|
|
385
|
+
WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
386
|
+
ticketId: this.ticketId,
|
|
387
|
+
action: 'frame',
|
|
388
|
+
dataUrl,
|
|
389
|
+
width: canvas.width,
|
|
390
|
+
height: canvas.height,
|
|
391
|
+
})).catch(() => {});
|
|
392
|
+
}, 1000);
|
|
393
|
+
},
|
|
394
|
+
async toggleMode() {
|
|
395
|
+
this.mode = this.mode === 'control' ? 'view' : 'control';
|
|
396
|
+
if (this.ticketId) {
|
|
397
|
+
await WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
398
|
+
ticketId: this.ticketId,
|
|
399
|
+
action: 'mode',
|
|
400
|
+
mode: this.mode,
|
|
401
|
+
})).catch(() => {});
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
async stopSession(notifyServer = true) {
|
|
405
|
+
const tid = this.ticketId;
|
|
406
|
+
this.ticketId = '';
|
|
407
|
+
if (this._pollTimer) clearInterval(this._pollTimer);
|
|
408
|
+
if (this._frameTimer) clearInterval(this._frameTimer);
|
|
409
|
+
this._pollTimer = null;
|
|
410
|
+
this._frameTimer = null;
|
|
411
|
+
try { this._pc?.close(); } catch { /* ignore */ }
|
|
412
|
+
this._pc = null;
|
|
413
|
+
try { this._stream?.getTracks?.().forEach(t => t.stop()); } catch { /* ignore */ }
|
|
414
|
+
this._stream = null;
|
|
415
|
+
if (notifyServer && tid) {
|
|
416
|
+
await WORK.fetch('/', 'support_remote', {}, JSON.stringify({
|
|
417
|
+
ticketId: tid,
|
|
418
|
+
action: 'end',
|
|
419
|
+
})).catch(() => {});
|
|
420
|
+
}
|
|
421
|
+
this.dispatchEvent(new CustomEvent('remote-ended', { bubbles: true, composed: true }));
|
|
422
|
+
this.remove();
|
|
423
|
+
},
|
|
424
|
+
detached() {
|
|
425
|
+
if (this._pollTimer) clearInterval(this._pollTimer);
|
|
426
|
+
if (this._frameTimer) clearInterval(this._frameTimer);
|
|
427
|
+
try { this._pc?.close(); } catch { /* ignore */ }
|
|
428
|
+
try { this._stream?.getTracks?.().forEach(t => t.stop()); } catch { /* ignore */ }
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
ODA({
|
|
433
|
+
is: 'work-support-panel',
|
|
434
|
+
imports: 'oda//icon, oda//button',
|
|
435
|
+
template: /*html*/`
|
|
436
|
+
<style>
|
|
437
|
+
:host {
|
|
438
|
+
position: fixed;
|
|
439
|
+
inset: 0;
|
|
440
|
+
z-index: 2147482000;
|
|
441
|
+
display: flex;
|
|
442
|
+
align-items: center;
|
|
443
|
+
justify-content: center;
|
|
444
|
+
padding: max(12px, var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) max(12px, var(--safe-bottom, 0px)) max(12px, var(--safe-left, 0px));
|
|
445
|
+
box-sizing: border-box;
|
|
446
|
+
background: rgba(15, 23, 42, 0.45);
|
|
447
|
+
backdrop-filter: blur(3px);
|
|
448
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
449
|
+
color: var(--content-color, #0f172a);
|
|
450
|
+
}
|
|
451
|
+
:host([minimized]) {
|
|
452
|
+
background: transparent;
|
|
453
|
+
backdrop-filter: none;
|
|
454
|
+
pointer-events: none;
|
|
455
|
+
align-items: flex-end;
|
|
456
|
+
justify-content: flex-end;
|
|
457
|
+
padding: max(12px, var(--safe-top, 0px)) max(16px, var(--safe-right, 0px)) max(16px, var(--safe-bottom, 0px)) max(12px, var(--safe-left, 0px));
|
|
458
|
+
}
|
|
459
|
+
.rec-bar {
|
|
460
|
+
pointer-events: auto;
|
|
461
|
+
display: flex;
|
|
462
|
+
align-items: center;
|
|
463
|
+
flex-wrap: wrap;
|
|
464
|
+
justify-content: center;
|
|
465
|
+
gap: 10px;
|
|
466
|
+
max-width: 100%;
|
|
467
|
+
box-sizing: border-box;
|
|
468
|
+
padding: 10px 16px;
|
|
469
|
+
border-radius: 20px;
|
|
470
|
+
background: #0f172a;
|
|
471
|
+
color: #fff;
|
|
472
|
+
box-shadow: 0 12px 32px rgba(0,0,0,.35);
|
|
473
|
+
font-size: 13px;
|
|
474
|
+
}
|
|
475
|
+
.rec-dot {
|
|
476
|
+
width: 10px;
|
|
477
|
+
height: 10px;
|
|
478
|
+
border-radius: 50%;
|
|
479
|
+
background: #ef4444;
|
|
480
|
+
animation: pulse 1s infinite;
|
|
481
|
+
flex-shrink: 0;
|
|
482
|
+
}
|
|
483
|
+
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
|
|
484
|
+
.card {
|
|
485
|
+
@apply --dialog-card;
|
|
486
|
+
width: min(820px, 100%);
|
|
487
|
+
max-width: 100%;
|
|
488
|
+
max-height: 100%;
|
|
489
|
+
border-radius: 14px;
|
|
490
|
+
}
|
|
491
|
+
.card.tab-list {
|
|
492
|
+
height: min(640px, 100%);
|
|
493
|
+
}
|
|
494
|
+
.head {
|
|
495
|
+
@apply --dialog-head;
|
|
496
|
+
padding: 10px 14px;
|
|
497
|
+
background: var(--subtle-background, #f8fafc);
|
|
498
|
+
border-bottom: 1px solid var(--subtle-border, #e2e8f0);
|
|
499
|
+
}
|
|
500
|
+
.head-brand {
|
|
501
|
+
display: flex;
|
|
502
|
+
align-items: center;
|
|
503
|
+
gap: 8px;
|
|
504
|
+
min-width: 0;
|
|
505
|
+
flex: 0 1 auto;
|
|
506
|
+
}
|
|
507
|
+
.head-title {
|
|
508
|
+
font-weight: 700;
|
|
509
|
+
font-size: 15px;
|
|
510
|
+
white-space: nowrap;
|
|
511
|
+
overflow: hidden;
|
|
512
|
+
text-overflow: ellipsis;
|
|
513
|
+
}
|
|
514
|
+
.tabs {
|
|
515
|
+
display: flex;
|
|
516
|
+
flex-wrap: wrap;
|
|
517
|
+
gap: 6px;
|
|
518
|
+
min-width: 0;
|
|
519
|
+
}
|
|
520
|
+
.tab-btn {
|
|
521
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
522
|
+
background: var(--content-background, #fff);
|
|
523
|
+
color: inherit;
|
|
524
|
+
border-radius: 8px;
|
|
525
|
+
padding: 6px 12px;
|
|
526
|
+
font: inherit;
|
|
527
|
+
font-size: 12.5px;
|
|
528
|
+
font-weight: 600;
|
|
529
|
+
cursor: pointer;
|
|
530
|
+
min-height: 32px;
|
|
531
|
+
box-sizing: border-box;
|
|
532
|
+
}
|
|
533
|
+
.tab-btn.active {
|
|
534
|
+
background: var(--accent-color, #4f46e5);
|
|
535
|
+
color: #fff;
|
|
536
|
+
border-color: var(--accent-color, #4f46e5);
|
|
537
|
+
}
|
|
538
|
+
.close-x {
|
|
539
|
+
margin-left: auto;
|
|
540
|
+
border: none;
|
|
541
|
+
background: transparent;
|
|
542
|
+
color: var(--muted-color, #64748b);
|
|
543
|
+
font-size: 20px;
|
|
544
|
+
line-height: 1;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
min-width: 34px;
|
|
547
|
+
min-height: 34px;
|
|
548
|
+
display: inline-flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
justify-content: center;
|
|
551
|
+
border-radius: 8px;
|
|
552
|
+
flex-shrink: 0;
|
|
553
|
+
}
|
|
554
|
+
.close-x:hover {
|
|
555
|
+
background: var(--subtle-background, #e2e8f0);
|
|
556
|
+
color: var(--content-color, #0f172a);
|
|
557
|
+
}
|
|
558
|
+
.body {
|
|
559
|
+
@apply --dialog-body;
|
|
560
|
+
padding: 14px 16px;
|
|
561
|
+
display: flex;
|
|
562
|
+
flex-direction: column;
|
|
563
|
+
gap: 12px;
|
|
564
|
+
}
|
|
565
|
+
.body.list-body {
|
|
566
|
+
overflow: hidden;
|
|
567
|
+
}
|
|
568
|
+
.footer {
|
|
569
|
+
@apply --dialog-footer;
|
|
570
|
+
padding: 10px 16px;
|
|
571
|
+
background: var(--subtle-background, #f8fafc);
|
|
572
|
+
border-top: 1px solid var(--subtle-border, #e2e8f0);
|
|
573
|
+
}
|
|
574
|
+
.capture-row {
|
|
575
|
+
display: flex;
|
|
576
|
+
gap: 8px;
|
|
577
|
+
flex-wrap: wrap;
|
|
578
|
+
align-items: center;
|
|
579
|
+
min-width: 0;
|
|
580
|
+
}
|
|
581
|
+
.btn {
|
|
582
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
583
|
+
background: var(--subtle-background, #f1f5f9);
|
|
584
|
+
color: inherit;
|
|
585
|
+
border-radius: 8px;
|
|
586
|
+
padding: 7px 12px;
|
|
587
|
+
min-height: 34px;
|
|
588
|
+
box-sizing: border-box;
|
|
589
|
+
font: inherit;
|
|
590
|
+
font-size: 13px;
|
|
591
|
+
font-weight: 600;
|
|
592
|
+
cursor: pointer;
|
|
593
|
+
display: inline-flex;
|
|
594
|
+
align-items: center;
|
|
595
|
+
justify-content: center;
|
|
596
|
+
gap: 6px;
|
|
597
|
+
max-width: 100%;
|
|
598
|
+
}
|
|
599
|
+
.btn:hover { filter: brightness(0.96); }
|
|
600
|
+
.btn.primary {
|
|
601
|
+
background: var(--accent-color, #4f46e5);
|
|
602
|
+
border-color: var(--accent-color, #4f46e5);
|
|
603
|
+
color: #fff;
|
|
604
|
+
}
|
|
605
|
+
.btn.ok {
|
|
606
|
+
background: #16a34a;
|
|
607
|
+
border-color: #16a34a;
|
|
608
|
+
color: #fff;
|
|
609
|
+
}
|
|
610
|
+
.btn.danger {
|
|
611
|
+
background: #dc2626;
|
|
612
|
+
border-color: #dc2626;
|
|
613
|
+
color: #fff;
|
|
614
|
+
}
|
|
615
|
+
textarea, input[type="text"] {
|
|
616
|
+
width: 100%;
|
|
617
|
+
max-width: 100%;
|
|
618
|
+
box-sizing: border-box;
|
|
619
|
+
padding: 9px 12px;
|
|
620
|
+
border-radius: 8px;
|
|
621
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
622
|
+
background: var(--content-background, #fff);
|
|
623
|
+
color: inherit;
|
|
624
|
+
font: inherit;
|
|
625
|
+
font-size: 13px;
|
|
626
|
+
resize: vertical;
|
|
627
|
+
}
|
|
628
|
+
.preview-box {
|
|
629
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
630
|
+
border-radius: 10px;
|
|
631
|
+
padding: 10px;
|
|
632
|
+
background: var(--subtle-background, #f8fafc);
|
|
633
|
+
display: flex;
|
|
634
|
+
flex-direction: column;
|
|
635
|
+
gap: 8px;
|
|
636
|
+
min-width: 0;
|
|
637
|
+
}
|
|
638
|
+
.shot-canvas {
|
|
639
|
+
max-width: 100%;
|
|
640
|
+
max-height: min(260px, 34dvh);
|
|
641
|
+
width: auto;
|
|
642
|
+
height: auto;
|
|
643
|
+
border-radius: 6px;
|
|
644
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
645
|
+
cursor: crosshair;
|
|
646
|
+
align-self: center;
|
|
647
|
+
background: #0f172a;
|
|
648
|
+
}
|
|
649
|
+
.tickets-split {
|
|
650
|
+
display: flex;
|
|
651
|
+
flex: 1 1 auto;
|
|
652
|
+
min-height: 0;
|
|
653
|
+
min-width: 0;
|
|
654
|
+
gap: 12px;
|
|
655
|
+
}
|
|
656
|
+
.t-list {
|
|
657
|
+
width: 255px;
|
|
658
|
+
flex-shrink: 0;
|
|
659
|
+
border: 1px solid var(--subtle-border, #e2e8f0);
|
|
660
|
+
border-radius: 10px;
|
|
661
|
+
overflow-y: auto;
|
|
662
|
+
min-height: 0;
|
|
663
|
+
display: flex;
|
|
664
|
+
flex-direction: column;
|
|
665
|
+
}
|
|
666
|
+
.t-item {
|
|
667
|
+
padding: 10px 12px;
|
|
668
|
+
border-bottom: 1px solid var(--subtle-border, #e2e8f0);
|
|
669
|
+
cursor: pointer;
|
|
670
|
+
display: flex;
|
|
671
|
+
flex-direction: column;
|
|
672
|
+
gap: 4px;
|
|
673
|
+
min-width: 0;
|
|
674
|
+
}
|
|
675
|
+
.t-item:hover { background: var(--subtle-background, #f8fafc); }
|
|
676
|
+
.t-item.active {
|
|
677
|
+
background: color-mix(in srgb, var(--accent-color, #4f46e5) 10%, var(--content-background, #fff));
|
|
678
|
+
border-left: 3px solid var(--accent-color, #4f46e5);
|
|
679
|
+
}
|
|
680
|
+
.t-thread {
|
|
681
|
+
flex: 1 1 auto;
|
|
682
|
+
min-width: 0;
|
|
683
|
+
min-height: 0;
|
|
684
|
+
border: 1px solid var(--subtle-border, #e2e8f0);
|
|
685
|
+
border-radius: 10px;
|
|
686
|
+
padding: 12px;
|
|
687
|
+
display: flex;
|
|
688
|
+
flex-direction: column;
|
|
689
|
+
gap: 10px;
|
|
690
|
+
}
|
|
691
|
+
.t-back {
|
|
692
|
+
display: none;
|
|
693
|
+
}
|
|
694
|
+
.msgs {
|
|
695
|
+
flex: 1 1 auto;
|
|
696
|
+
min-height: 0;
|
|
697
|
+
overflow-y: auto;
|
|
698
|
+
display: flex;
|
|
699
|
+
flex-direction: column;
|
|
700
|
+
gap: 8px;
|
|
701
|
+
overscroll-behavior: contain;
|
|
702
|
+
}
|
|
703
|
+
.msg {
|
|
704
|
+
padding: 8px 11px;
|
|
705
|
+
border-radius: 10px;
|
|
706
|
+
background: var(--subtle-background, #f1f5f9);
|
|
707
|
+
font-size: 13px;
|
|
708
|
+
max-width: 92%;
|
|
709
|
+
word-break: break-word;
|
|
710
|
+
}
|
|
711
|
+
.msg.support {
|
|
712
|
+
align-self: flex-start;
|
|
713
|
+
background: color-mix(in srgb, #2563eb 11%, var(--content-background, #fff));
|
|
714
|
+
border: 1px solid color-mix(in srgb, #2563eb 25%, transparent);
|
|
715
|
+
}
|
|
716
|
+
.msg.client {
|
|
717
|
+
align-self: flex-end;
|
|
718
|
+
background: color-mix(in srgb, var(--accent-color, #4f46e5) 10%, var(--content-background, #fff));
|
|
719
|
+
}
|
|
720
|
+
.reply-bar {
|
|
721
|
+
display: flex;
|
|
722
|
+
gap: 8px;
|
|
723
|
+
align-items: center;
|
|
724
|
+
flex-shrink: 0;
|
|
725
|
+
min-width: 0;
|
|
726
|
+
}
|
|
727
|
+
.reply-bar input {
|
|
728
|
+
flex: 1 1 auto;
|
|
729
|
+
min-width: 0;
|
|
730
|
+
}
|
|
731
|
+
.tag {
|
|
732
|
+
display: inline-flex;
|
|
733
|
+
align-items: center;
|
|
734
|
+
padding: 2px 7px;
|
|
735
|
+
border-radius: 999px;
|
|
736
|
+
font-size: 11px;
|
|
737
|
+
font-weight: 600;
|
|
738
|
+
background: var(--subtle-background, #e2e8f0);
|
|
739
|
+
}
|
|
740
|
+
.tag.ok { background: #dcfce7; color: #15803d; }
|
|
741
|
+
.tag.warn { background: #fef3c7; color: #b45309; }
|
|
742
|
+
.tag.info { background: #e0f2fe; color: #0369a1; }
|
|
743
|
+
.remote-banner {
|
|
744
|
+
padding: 10px 12px;
|
|
745
|
+
border-radius: 10px;
|
|
746
|
+
border: 1px solid #38bdf8;
|
|
747
|
+
background: color-mix(in srgb, #0284c7 10%, var(--content-background, #fff));
|
|
748
|
+
display: flex;
|
|
749
|
+
flex-direction: column;
|
|
750
|
+
gap: 8px;
|
|
751
|
+
font-size: 13px;
|
|
752
|
+
flex-shrink: 0;
|
|
753
|
+
}
|
|
754
|
+
.err { color: #dc2626; font-size: 12.5px; }
|
|
755
|
+
.muted { color: var(--muted-color, #64748b); font-size: 12px; }
|
|
756
|
+
@media (max-width: 680px) {
|
|
757
|
+
.tickets-split {
|
|
758
|
+
flex-direction: column;
|
|
759
|
+
}
|
|
760
|
+
.t-list {
|
|
761
|
+
width: 100%;
|
|
762
|
+
flex: 1 1 auto;
|
|
763
|
+
}
|
|
764
|
+
.tickets-split.mobile-thread .t-list {
|
|
765
|
+
display: none;
|
|
766
|
+
}
|
|
767
|
+
.tickets-split:not(.mobile-thread) .t-thread {
|
|
768
|
+
display: none;
|
|
769
|
+
}
|
|
770
|
+
.t-back {
|
|
771
|
+
display: inline-flex;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
@media (max-width: 640px) {
|
|
775
|
+
:host(:not([minimized])) {
|
|
776
|
+
padding: 0;
|
|
777
|
+
}
|
|
778
|
+
.card {
|
|
779
|
+
width: 100%;
|
|
780
|
+
height: 100%;
|
|
781
|
+
max-width: 100%;
|
|
782
|
+
max-height: 100%;
|
|
783
|
+
border-radius: 0;
|
|
784
|
+
border: none;
|
|
785
|
+
}
|
|
786
|
+
.head {
|
|
787
|
+
padding: max(10px, var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) 10px max(12px, var(--safe-left, 0px));
|
|
788
|
+
}
|
|
789
|
+
.tabs {
|
|
790
|
+
order: 3;
|
|
791
|
+
width: 100%;
|
|
792
|
+
}
|
|
793
|
+
.tabs .tab-btn {
|
|
794
|
+
flex: 1 1 auto;
|
|
795
|
+
text-align: center;
|
|
796
|
+
}
|
|
797
|
+
.body {
|
|
798
|
+
padding: 12px max(12px, var(--safe-right, 0px)) 12px max(12px, var(--safe-left, 0px));
|
|
799
|
+
}
|
|
800
|
+
.footer {
|
|
801
|
+
padding: 10px max(12px, var(--safe-right, 0px)) max(10px, var(--safe-bottom, 0px)) max(12px, var(--safe-left, 0px));
|
|
802
|
+
}
|
|
803
|
+
.footer .btn {
|
|
804
|
+
flex: 1 1 auto;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
</style>
|
|
808
|
+
|
|
809
|
+
<div ~if="recording" class="rec-bar">
|
|
810
|
+
<span class="rec-dot"></span>
|
|
811
|
+
<span>Запись экрана: {{recordSecLabel}} / 01:00</span>
|
|
812
|
+
<button type="button" class="btn danger" style="padding:4px 10px;font-size:12px" @tap="stopVideoCapture()">⏹ Остановить</button>
|
|
813
|
+
</div>
|
|
814
|
+
|
|
815
|
+
<div ~if="!minimized" class="card" :class="{ 'tab-list': activeTab === 'list' && tickets.length > 0 }">
|
|
816
|
+
<div class="head">
|
|
817
|
+
<div class="head-brand">
|
|
818
|
+
<oda-icon icon="icons:help" icon-size="20" style="flex-shrink:0"></oda-icon>
|
|
819
|
+
<span class="head-title">Служба поддержки ODANT-WORK</span>
|
|
820
|
+
</div>
|
|
821
|
+
<div class="tabs">
|
|
822
|
+
<button type="button" class="tab-btn" :class="{ active: activeTab === 'new' }" @tap="activeTab = 'new'">Новое обращение</button>
|
|
823
|
+
<button type="button" class="tab-btn" :class="{ active: activeTab === 'list' }" @tap="openListTab()">
|
|
824
|
+
Обращения ({{tickets.length}})<span ~if="unreadTotal > 0"> · +{{unreadTotal}}</span>
|
|
825
|
+
</button>
|
|
826
|
+
</div>
|
|
827
|
+
<button type="button" class="close-x" title="Закрыть" @tap="closePanel()">×</button>
|
|
828
|
+
</div>
|
|
829
|
+
|
|
830
|
+
<!-- Вкладка: Новое обращение -->
|
|
831
|
+
<div class="body" ~if="activeTab === 'new'">
|
|
832
|
+
<div class="capture-row">
|
|
833
|
+
<button type="button" class="btn" @tap="captureScreenshot()">📸 Скриншот экрана</button>
|
|
834
|
+
<button type="button" class="btn" @tap="startVideoCapture()">🎥 Записать видео (до 60 с)</button>
|
|
835
|
+
<label class="btn" style="cursor:pointer">
|
|
836
|
+
📎 Прикрепить файл
|
|
837
|
+
<input type="file" accept="image/*,video/*" style="display:none" @change="onFilePicked($event)">
|
|
838
|
+
</label>
|
|
839
|
+
<span class="muted">Скриншот и видео снимаются прямо с рабочего экрана WORK</span>
|
|
840
|
+
</div>
|
|
841
|
+
|
|
842
|
+
<!-- Редактор разметки скриншота -->
|
|
843
|
+
<div class="preview-box" ~if="hasScreenshot">
|
|
844
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap">
|
|
845
|
+
<span class="muted">Можно обвести проблемное место прямо мышью по скриншоту:</span>
|
|
846
|
+
<div style="display:flex;gap:6px;flex-wrap:wrap">
|
|
847
|
+
<button type="button" class="btn" style="padding:4px 9px;font-size:12px" @tap="clearScreenshotMarkup()">Сбросить пометки</button>
|
|
848
|
+
<button type="button" class="btn" style="padding:4px 9px;font-size:12px;color:#dc2626" @tap="removeScreenshot()">Удалить скриншот</button>
|
|
849
|
+
</div>
|
|
850
|
+
</div>
|
|
851
|
+
<canvas id="shotCanvas" class="shot-canvas"
|
|
852
|
+
@mousedown="onShotDrawStart($event)"
|
|
853
|
+
@mousemove="onShotDrawMove($event)"
|
|
854
|
+
@mouseup="onShotDrawEnd()"
|
|
855
|
+
@mouseleave="onShotDrawEnd()"></canvas>
|
|
856
|
+
</div>
|
|
857
|
+
|
|
858
|
+
<!-- Предпросмотр видео -->
|
|
859
|
+
<div class="preview-box" ~if="videoDataUrl">
|
|
860
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap">
|
|
861
|
+
<span class="muted">Записанное видео ({{videoName}})</span>
|
|
862
|
+
<button type="button" class="btn" style="padding:4px 9px;font-size:12px;color:#dc2626" @tap="removeVideo()">Удалить видео</button>
|
|
863
|
+
</div>
|
|
864
|
+
<video controls :src="videoDataUrl" style="max-width:100%;max-height:min(240px,32dvh);border-radius:6px;background:#000"></video>
|
|
865
|
+
</div>
|
|
866
|
+
|
|
867
|
+
<div>
|
|
868
|
+
<textarea rows="4" placeholder="Опишите проблему: что делали, что ожидали и что пошло не так…" ::value="problemText"></textarea>
|
|
869
|
+
</div>
|
|
870
|
+
|
|
871
|
+
<label style="display:flex;align-items:flex-start;gap:8px;font-size:12.5px;cursor:pointer;user-select:none">
|
|
872
|
+
<input type="checkbox" style="margin-top:2px;flex-shrink:0" ::checked="includeTech">
|
|
873
|
+
<span>Приложить технические данные (версия WORK, путь текущей формы и ошибки)</span>
|
|
874
|
+
</label>
|
|
875
|
+
|
|
876
|
+
<div ~if="error" class="err">{{error}}</div>
|
|
877
|
+
</div>
|
|
878
|
+
|
|
879
|
+
<div class="footer" ~if="activeTab === 'new'">
|
|
880
|
+
<button type="button" class="btn" @tap="closePanel()">Отмена</button>
|
|
881
|
+
<button type="button" class="btn primary" :disabled="sending" @tap="submitTicket()">
|
|
882
|
+
{{sending ? 'Отправка…' : 'Отправить в поддержку'}}
|
|
883
|
+
</button>
|
|
884
|
+
</div>
|
|
885
|
+
|
|
886
|
+
<!-- Вкладка: Список обращений и переписка -->
|
|
887
|
+
<div class="body list-body" ~if="activeTab === 'list'">
|
|
888
|
+
<div ~if="error" class="err">{{error}}</div>
|
|
889
|
+
<div ~if="!tickets.length && !loading" class="muted" style="padding:24px;text-align:center">
|
|
890
|
+
Обращений пока нет. Нажмите «Новое обращение», чтобы написать в службу поддержки.
|
|
891
|
+
</div>
|
|
892
|
+
<div class="tickets-split" :class="{ 'mobile-thread': mobileTicketOpen }" ~if="tickets.length">
|
|
893
|
+
<div class="t-list">
|
|
894
|
+
<div class="t-item" ~for="tickets" :class="{ active: selectedTicketId === $for.item.ticketId }" @tap="selectTicket($for.item.ticketId, true)">
|
|
895
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:6px;min-width:0">
|
|
896
|
+
<b style="font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{$for.item.ticketId}}</b>
|
|
897
|
+
<span class="tag" :class="$for.item.status === 'answered' ? 'ok' : ($for.item.status === 'in_progress' ? 'info' : 'warn')">
|
|
898
|
+
{{statusLabel($for.item.status)}}
|
|
899
|
+
</span>
|
|
900
|
+
</div>
|
|
901
|
+
<div class="muted" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis">
|
|
902
|
+
{{($for.item.messages?.[0]?.text) || 'Без описания'}}
|
|
903
|
+
</div>
|
|
904
|
+
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap">
|
|
905
|
+
<span class="muted">{{formatTime($for.item.createdAt)}}</span>
|
|
906
|
+
<span ~if="$for.item.unreadCount > 0" class="tag ok">+{{$for.item.unreadCount}}</span>
|
|
907
|
+
<span ~if="$for.item.remote?.state === 'requested'" class="tag info">🖥 Запрос экрана</span>
|
|
908
|
+
</div>
|
|
909
|
+
</div>
|
|
910
|
+
</div>
|
|
911
|
+
|
|
912
|
+
<div class="t-thread" ~if="selectedTicket">
|
|
913
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;border-bottom:1px solid var(--subtle-border,#e2e8f0);padding-bottom:8px;flex-shrink:0">
|
|
914
|
+
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0">
|
|
915
|
+
<button type="button" class="btn t-back" style="padding:4px 8px;font-size:12px" @tap="mobileTicketOpen = false">← Список</button>
|
|
916
|
+
<b>{{selectedTicket.ticketId}}</b>
|
|
917
|
+
<span class="tag">{{selectedTicket.tierName || 'Поддержка'}}</span>
|
|
918
|
+
<span ~if="selectedTicket.assignedSupportName" class="muted">Инженер: {{selectedTicket.assignedSupportName}}</span>
|
|
919
|
+
</div>
|
|
920
|
+
<button ~if="selectedTicket.status !== 'closed'" type="button" class="btn" style="padding:4px 9px;font-size:12px" @tap="startRemoteDesktop(selectedTicket.ticketId, 'view')">
|
|
921
|
+
🖥 Поделиться экраном
|
|
922
|
+
</button>
|
|
923
|
+
</div>
|
|
924
|
+
|
|
925
|
+
<!-- Запрос оператора на удалённый экран -->
|
|
926
|
+
<div class="remote-banner" ~if="selectedTicket.remote?.state === 'requested'">
|
|
927
|
+
<div><b>{{selectedTicket.remote?.requestedBy?.engineerName || 'Инженер поддержки'}}</b> запрашивает доступ к вашему экрану WORK.</div>
|
|
928
|
+
<div style="display:flex;gap:6px;flex-wrap:wrap">
|
|
929
|
+
<button type="button" class="btn ok" style="padding:5px 10px;font-size:12px" @tap="startRemoteDesktop(selectedTicket.ticketId, 'view')">Поделиться (Только просмотр)</button>
|
|
930
|
+
<button type="button" class="btn primary" style="padding:5px 10px;font-size:12px" @tap="startRemoteDesktop(selectedTicket.ticketId, 'control')">Поделиться с управлением</button>
|
|
931
|
+
<button type="button" class="btn" style="padding:5px 10px;font-size:12px" @tap="rejectRemoteDesktop(selectedTicket.ticketId)">Отклонить</button>
|
|
932
|
+
</div>
|
|
933
|
+
</div>
|
|
934
|
+
|
|
935
|
+
<div class="msgs">
|
|
936
|
+
<div class="msg" ~for="selectedTicket.messages" :class="$for.item.from === 'support' ? 'support' : 'client'">
|
|
937
|
+
<div class="muted" style="margin-bottom:2px"><b>{{$for.item.author}}</b> · {{formatTime($for.item.time)}}</div>
|
|
938
|
+
<div style="white-space:pre-wrap">{{$for.item.text}}</div>
|
|
939
|
+
<div ~if="$for.item.attachments?.length" style="display:flex;gap:6px;flex-wrap:wrap;margin-top:6px">
|
|
940
|
+
<div ~for="$for.item.attachments">
|
|
941
|
+
<img ~if="$for.$for.item.kind !== 'video'" :src="mediaUrl($for.$for.item)" style="max-width:min(220px,100%);max-height:140px;border-radius:6px;border:1px solid var(--subtle-border);cursor:pointer" @tap="loadMediaInto($event, selectedTicket.ticketId, $for.$for.item)">
|
|
942
|
+
<video ~if="$for.$for.item.kind === 'video'" controls preload="metadata" :src="mediaUrl($for.$for.item)" style="max-width:min(260px,100%);max-height:160px;border-radius:6px;background:#000"></video>
|
|
943
|
+
</div>
|
|
944
|
+
</div>
|
|
945
|
+
</div>
|
|
946
|
+
</div>
|
|
947
|
+
|
|
948
|
+
<div ~if="selectedTicket.status !== 'closed'" class="reply-bar">
|
|
949
|
+
<input type="text" placeholder="Написать сообщение инженеру…" ::value="replyText" @keydown.enter="sendReply()">
|
|
950
|
+
<button type="button" class="btn primary" style="flex-shrink:0" :disabled="sending" @tap="sendReply()">Отправить</button>
|
|
951
|
+
</div>
|
|
952
|
+
</div>
|
|
953
|
+
</div>
|
|
954
|
+
</div>
|
|
955
|
+
</div>
|
|
956
|
+
`,
|
|
957
|
+
activeTab: 'new',
|
|
958
|
+
problemText: '',
|
|
959
|
+
includeTech: true,
|
|
960
|
+
hasScreenshot: false,
|
|
961
|
+
_rawShotCanvas: null,
|
|
962
|
+
_drawing: false,
|
|
963
|
+
_lastPt: null,
|
|
964
|
+
videoDataUrl: '',
|
|
965
|
+
videoMime: '',
|
|
966
|
+
videoName: '',
|
|
967
|
+
recording: false,
|
|
968
|
+
recordSec: 0,
|
|
969
|
+
_recTimer: null,
|
|
970
|
+
_mediaRecorder: null,
|
|
971
|
+
_recStream: null,
|
|
972
|
+
minimized: {
|
|
973
|
+
$def: false,
|
|
974
|
+
$attr: true,
|
|
975
|
+
},
|
|
976
|
+
sending: false,
|
|
977
|
+
loading: false,
|
|
978
|
+
error: '',
|
|
979
|
+
tickets: [],
|
|
980
|
+
unreadTotal: 0,
|
|
981
|
+
selectedTicketId: '',
|
|
982
|
+
mobileTicketOpen: false,
|
|
983
|
+
replyText: '',
|
|
984
|
+
_mediaCache: {},
|
|
985
|
+
_pollTimer: null,
|
|
986
|
+
get recordSecLabel() {
|
|
987
|
+
const s = Math.max(0, Number(this.recordSec) || 0);
|
|
988
|
+
return `00:${String(s).padStart(2, '0')}`;
|
|
989
|
+
},
|
|
990
|
+
get selectedTicket() {
|
|
991
|
+
return (this.tickets || []).find(t => t.ticketId === this.selectedTicketId) || this.tickets?.[0] || null;
|
|
992
|
+
},
|
|
993
|
+
attached() {
|
|
994
|
+
this.refreshTickets();
|
|
995
|
+
this._pollTimer = setInterval(() => {
|
|
996
|
+
if (this.activeTab === 'list')
|
|
997
|
+
this.refreshTickets();
|
|
998
|
+
}, 8000);
|
|
999
|
+
},
|
|
1000
|
+
detached() {
|
|
1001
|
+
if (this._pollTimer) clearInterval(this._pollTimer);
|
|
1002
|
+
if (this._recTimer) clearInterval(this._recTimer);
|
|
1003
|
+
try { this._recStream?.getTracks?.().forEach(t => t.stop()); } catch { /* ignore */ }
|
|
1004
|
+
},
|
|
1005
|
+
statusLabel(st) {
|
|
1006
|
+
return { open: 'Открыт', in_progress: 'На контроле', answered: 'Отвечен', closed: 'Закрыт' }[st] || st || 'Открыт';
|
|
1007
|
+
},
|
|
1008
|
+
formatTime(ms) {
|
|
1009
|
+
if (!ms) return '';
|
|
1010
|
+
try { return new Date(ms).toLocaleString('ru-RU', { dateStyle: 'short', timeStyle: 'short' }); }
|
|
1011
|
+
catch { return ''; }
|
|
1012
|
+
},
|
|
1013
|
+
closePanel() {
|
|
1014
|
+
this.dispatchEvent(new CustomEvent('support-closed', { detail: { unreadTotal: this.unreadTotal }, bubbles: true, composed: true }));
|
|
1015
|
+
this.remove();
|
|
1016
|
+
},
|
|
1017
|
+
async openListTab() {
|
|
1018
|
+
this.activeTab = 'list';
|
|
1019
|
+
this.mobileTicketOpen = false;
|
|
1020
|
+
await this.refreshTickets();
|
|
1021
|
+
if (this.selectedTicket)
|
|
1022
|
+
await this.selectTicket(this.selectedTicket.ticketId, false);
|
|
1023
|
+
},
|
|
1024
|
+
async refreshTickets() {
|
|
1025
|
+
this.loading = true;
|
|
1026
|
+
try {
|
|
1027
|
+
const res = await WORK.fetch('/', 'support_list');
|
|
1028
|
+
this.tickets = Array.isArray(res?.tickets) ? res.tickets : [];
|
|
1029
|
+
this.unreadTotal = Number(res?.unreadTotal || 0);
|
|
1030
|
+
if (!this.selectedTicketId && this.tickets.length)
|
|
1031
|
+
this.selectedTicketId = this.tickets[0].ticketId;
|
|
1032
|
+
// Предзагрузка медиафайлов выбранного тикета через локальный WORK
|
|
1033
|
+
if (this.selectedTicket)
|
|
1034
|
+
this._preloadTicketMedia(this.selectedTicket);
|
|
1035
|
+
}
|
|
1036
|
+
catch (err) {
|
|
1037
|
+
this.error = String(err?.message || err);
|
|
1038
|
+
}
|
|
1039
|
+
finally {
|
|
1040
|
+
this.loading = false;
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
async selectTicket(ticketId, openOnMobile = false) {
|
|
1044
|
+
this.selectedTicketId = ticketId;
|
|
1045
|
+
if (openOnMobile)
|
|
1046
|
+
this.mobileTicketOpen = true;
|
|
1047
|
+
const t = (this.tickets || []).find(x => x.ticketId === ticketId);
|
|
1048
|
+
if (t && t.unreadCount > 0) {
|
|
1049
|
+
await WORK.fetch('/', 'support_mark_read', {}, JSON.stringify({ ticketId })).catch(() => {});
|
|
1050
|
+
t.unreadCount = 0;
|
|
1051
|
+
this.tickets = [...this.tickets];
|
|
1052
|
+
this.unreadTotal = this.tickets.reduce((s, x) => s + Number(x.unreadCount || 0), 0);
|
|
1053
|
+
}
|
|
1054
|
+
if (t)
|
|
1055
|
+
this._preloadTicketMedia(t);
|
|
1056
|
+
},
|
|
1057
|
+
mediaUrl(att) {
|
|
1058
|
+
if (!att?.id) return '';
|
|
1059
|
+
return this._mediaCache?.[att.id] || '';
|
|
1060
|
+
},
|
|
1061
|
+
async _preloadTicketMedia(ticket) {
|
|
1062
|
+
const atts = [];
|
|
1063
|
+
for (const m of ticket?.messages || []) {
|
|
1064
|
+
for (const a of m?.attachments || [])
|
|
1065
|
+
atts.push(a);
|
|
1066
|
+
}
|
|
1067
|
+
for (const a of atts) {
|
|
1068
|
+
if (!a?.id || this._mediaCache[a.id]) continue;
|
|
1069
|
+
try {
|
|
1070
|
+
const res = await WORK.fetch('/', 'support_media', { ticketId: ticket.ticketId, file: a.id });
|
|
1071
|
+
if (res?.dataUrl) {
|
|
1072
|
+
this._mediaCache = { ...this._mediaCache, [a.id]: res.dataUrl };
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
catch { /* ignore */ }
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
async captureScreenshot() {
|
|
1079
|
+
this.error = '';
|
|
1080
|
+
if (!navigator.mediaDevices?.getDisplayMedia) {
|
|
1081
|
+
this.error = 'Захват экрана не поддерживается в этом браузере — прикрепите файл кнопкой «Прикрепить файл».';
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
this.minimized = true;
|
|
1085
|
+
await new Promise(r => setTimeout(r, 220));
|
|
1086
|
+
let stream = null;
|
|
1087
|
+
try {
|
|
1088
|
+
stream = await navigator.mediaDevices.getDisplayMedia({
|
|
1089
|
+
video: { displaySurface: 'browser' },
|
|
1090
|
+
preferCurrentTab: true,
|
|
1091
|
+
audio: false,
|
|
1092
|
+
});
|
|
1093
|
+
const video = document.createElement('video');
|
|
1094
|
+
video.muted = true;
|
|
1095
|
+
video.srcObject = stream;
|
|
1096
|
+
await video.play();
|
|
1097
|
+
await new Promise(r => setTimeout(r, 120));
|
|
1098
|
+
const canvas = document.createElement('canvas');
|
|
1099
|
+
canvas.width = video.videoWidth || 1280;
|
|
1100
|
+
canvas.height = video.videoHeight || 720;
|
|
1101
|
+
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
1102
|
+
this._rawShotCanvas = canvas;
|
|
1103
|
+
this.hasScreenshot = true;
|
|
1104
|
+
this.minimized = false;
|
|
1105
|
+
await new Promise(r => setTimeout(r, 60));
|
|
1106
|
+
this._renderRawShotToUi();
|
|
1107
|
+
}
|
|
1108
|
+
catch (err) {
|
|
1109
|
+
this.minimized = false;
|
|
1110
|
+
if (err?.name !== 'AbortError' && err?.name !== 'NotAllowedError')
|
|
1111
|
+
this.error = 'Не удалось снять скриншот: ' + (err?.message || err);
|
|
1112
|
+
}
|
|
1113
|
+
finally {
|
|
1114
|
+
try { stream?.getTracks?.().forEach(t => t.stop()); } catch { /* ignore */ }
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
_renderRawShotToUi() {
|
|
1118
|
+
const uiCanvas = this.$('#shotCanvas');
|
|
1119
|
+
const src = this._rawShotCanvas;
|
|
1120
|
+
if (!uiCanvas || !src) return;
|
|
1121
|
+
uiCanvas.width = src.width;
|
|
1122
|
+
uiCanvas.height = src.height;
|
|
1123
|
+
uiCanvas.getContext('2d').drawImage(src, 0, 0);
|
|
1124
|
+
},
|
|
1125
|
+
clearScreenshotMarkup() {
|
|
1126
|
+
this._renderRawShotToUi();
|
|
1127
|
+
},
|
|
1128
|
+
removeScreenshot() {
|
|
1129
|
+
this.hasScreenshot = false;
|
|
1130
|
+
this._rawShotCanvas = null;
|
|
1131
|
+
},
|
|
1132
|
+
_canvasCoords(e) {
|
|
1133
|
+
const c = this.$('#shotCanvas');
|
|
1134
|
+
if (!c) return null;
|
|
1135
|
+
const r = c.getBoundingClientRect();
|
|
1136
|
+
return {
|
|
1137
|
+
x: ((e.clientX - r.left) / r.width) * c.width,
|
|
1138
|
+
y: ((e.clientY - r.top) / r.height) * c.height,
|
|
1139
|
+
};
|
|
1140
|
+
},
|
|
1141
|
+
onShotDrawStart(e) {
|
|
1142
|
+
this._drawing = true;
|
|
1143
|
+
this._lastPt = this._canvasCoords(e);
|
|
1144
|
+
},
|
|
1145
|
+
onShotDrawMove(e) {
|
|
1146
|
+
if (!this._drawing) return;
|
|
1147
|
+
const c = this.$('#shotCanvas');
|
|
1148
|
+
const pt = this._canvasCoords(e);
|
|
1149
|
+
if (!c || !pt || !this._lastPt) return;
|
|
1150
|
+
const ctx = c.getContext('2d');
|
|
1151
|
+
ctx.strokeStyle = '#ef4444';
|
|
1152
|
+
ctx.lineWidth = Math.max(3, Math.round(c.width / 320));
|
|
1153
|
+
ctx.lineCap = 'round';
|
|
1154
|
+
ctx.beginPath();
|
|
1155
|
+
ctx.moveTo(this._lastPt.x, this._lastPt.y);
|
|
1156
|
+
ctx.lineTo(pt.x, pt.y);
|
|
1157
|
+
ctx.stroke();
|
|
1158
|
+
this._lastPt = pt;
|
|
1159
|
+
},
|
|
1160
|
+
onShotDrawEnd() {
|
|
1161
|
+
this._drawing = false;
|
|
1162
|
+
this._lastPt = null;
|
|
1163
|
+
},
|
|
1164
|
+
async startVideoCapture() {
|
|
1165
|
+
this.error = '';
|
|
1166
|
+
if (!navigator.mediaDevices?.getDisplayMedia || typeof MediaRecorder === 'undefined') {
|
|
1167
|
+
this.error = 'Запись видео с экрана не поддерживается в этом браузере.';
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
this.minimized = true;
|
|
1171
|
+
try {
|
|
1172
|
+
const stream = await navigator.mediaDevices.getDisplayMedia({
|
|
1173
|
+
video: { frameRate: 15 },
|
|
1174
|
+
preferCurrentTab: true,
|
|
1175
|
+
audio: false,
|
|
1176
|
+
});
|
|
1177
|
+
this._recStream = stream;
|
|
1178
|
+
const chunks = [];
|
|
1179
|
+
const mime = MediaRecorder.isTypeSupported('video/webm;codecs=vp8')
|
|
1180
|
+
? 'video/webm;codecs=vp8'
|
|
1181
|
+
: 'video/webm';
|
|
1182
|
+
const mr = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 900_000 });
|
|
1183
|
+
this._mediaRecorder = mr;
|
|
1184
|
+
this.recording = true;
|
|
1185
|
+
this.recordSec = 0;
|
|
1186
|
+
|
|
1187
|
+
mr.ondataavailable = (e) => { if (e.data?.size) chunks.push(e.data); };
|
|
1188
|
+
mr.onstop = () => {
|
|
1189
|
+
this.recording = false;
|
|
1190
|
+
this.minimized = false;
|
|
1191
|
+
if (this._recTimer) { clearInterval(this._recTimer); this._recTimer = null; }
|
|
1192
|
+
try { stream.getTracks().forEach(t => t.stop()); } catch { /* ignore */ }
|
|
1193
|
+
this._recStream = null;
|
|
1194
|
+
if (chunks.length) {
|
|
1195
|
+
const blob = new Blob(chunks, { type: 'video/webm' });
|
|
1196
|
+
const reader = new FileReader();
|
|
1197
|
+
reader.onload = () => {
|
|
1198
|
+
this.videoDataUrl = String(reader.result || '');
|
|
1199
|
+
this.videoMime = 'video/webm';
|
|
1200
|
+
this.videoName = `screen-${this.recordSec || 1}s.webm`;
|
|
1201
|
+
};
|
|
1202
|
+
reader.readAsDataURL(blob);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
stream.getVideoTracks()[0]?.addEventListener('ended', () => this.stopVideoCapture());
|
|
1206
|
+
mr.start(500);
|
|
1207
|
+
this._recTimer = setInterval(() => {
|
|
1208
|
+
this.recordSec++;
|
|
1209
|
+
if (this.recordSec >= MAX_VIDEO_SEC)
|
|
1210
|
+
this.stopVideoCapture();
|
|
1211
|
+
}, 1000);
|
|
1212
|
+
}
|
|
1213
|
+
catch (err) {
|
|
1214
|
+
this.recording = false;
|
|
1215
|
+
this.minimized = false;
|
|
1216
|
+
if (err?.name !== 'AbortError' && err?.name !== 'NotAllowedError')
|
|
1217
|
+
this.error = 'Не удалось начать запись: ' + (err?.message || err);
|
|
1218
|
+
}
|
|
1219
|
+
},
|
|
1220
|
+
stopVideoCapture() {
|
|
1221
|
+
try {
|
|
1222
|
+
if (this._mediaRecorder && this._mediaRecorder.state !== 'inactive')
|
|
1223
|
+
this._mediaRecorder.stop();
|
|
1224
|
+
}
|
|
1225
|
+
catch { /* ignore */ }
|
|
1226
|
+
},
|
|
1227
|
+
removeVideo() {
|
|
1228
|
+
this.videoDataUrl = '';
|
|
1229
|
+
this.videoMime = '';
|
|
1230
|
+
this.videoName = '';
|
|
1231
|
+
},
|
|
1232
|
+
onFilePicked(e) {
|
|
1233
|
+
const file = e?.target?.files?.[0];
|
|
1234
|
+
if (!file) return;
|
|
1235
|
+
const reader = new FileReader();
|
|
1236
|
+
reader.onload = () => {
|
|
1237
|
+
const url = String(reader.result || '');
|
|
1238
|
+
if (file.type.startsWith('video/')) {
|
|
1239
|
+
this.videoDataUrl = url;
|
|
1240
|
+
this.videoMime = file.type;
|
|
1241
|
+
this.videoName = file.name;
|
|
1242
|
+
}
|
|
1243
|
+
else if (file.type.startsWith('image/')) {
|
|
1244
|
+
const img = new Image();
|
|
1245
|
+
img.onload = async () => {
|
|
1246
|
+
const c = document.createElement('canvas');
|
|
1247
|
+
c.width = img.naturalWidth || 1280;
|
|
1248
|
+
c.height = img.naturalHeight || 720;
|
|
1249
|
+
c.getContext('2d').drawImage(img, 0, 0);
|
|
1250
|
+
this._rawShotCanvas = c;
|
|
1251
|
+
this.hasScreenshot = true;
|
|
1252
|
+
await new Promise(r => setTimeout(r, 50));
|
|
1253
|
+
this._renderRawShotToUi();
|
|
1254
|
+
};
|
|
1255
|
+
img.src = url;
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
reader.readAsDataURL(file);
|
|
1259
|
+
e.target.value = '';
|
|
1260
|
+
},
|
|
1261
|
+
_collectTechContext() {
|
|
1262
|
+
const host = globalThis.WORK || window;
|
|
1263
|
+
let focusedPath = '';
|
|
1264
|
+
try {
|
|
1265
|
+
const exp = document.querySelector('item-explorer') || window.top?.document?.querySelector('item-explorer');
|
|
1266
|
+
focusedPath = exp?.focusedPage || exp?.$item?.path || '';
|
|
1267
|
+
}
|
|
1268
|
+
catch { /* ignore */ }
|
|
1269
|
+
return {
|
|
1270
|
+
url: window.location.href,
|
|
1271
|
+
focusedPath,
|
|
1272
|
+
userAgent: navigator.userAgent,
|
|
1273
|
+
viewport: `${window.innerWidth}x${window.innerHeight}`,
|
|
1274
|
+
recentErrors: Array.isArray(host.__supportErrors) ? [...host.__supportErrors] : [],
|
|
1275
|
+
};
|
|
1276
|
+
},
|
|
1277
|
+
async submitTicket() {
|
|
1278
|
+
this.error = '';
|
|
1279
|
+
const text = String(this.problemText || '').trim();
|
|
1280
|
+
const attachments = [];
|
|
1281
|
+
const shotCanvas = this.$('#shotCanvas');
|
|
1282
|
+
if (this.hasScreenshot && shotCanvas) {
|
|
1283
|
+
attachments.push({
|
|
1284
|
+
name: 'screenshot.png',
|
|
1285
|
+
mime: 'image/png',
|
|
1286
|
+
dataBase64: shotCanvas.toDataURL('image/png'),
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
if (this.videoDataUrl) {
|
|
1290
|
+
attachments.push({
|
|
1291
|
+
name: this.videoName || 'recording.webm',
|
|
1292
|
+
mime: this.videoMime || 'video/webm',
|
|
1293
|
+
dataBase64: this.videoDataUrl,
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
if (!text && !attachments.length) {
|
|
1297
|
+
this.error = 'Опишите проблему или приложите скриншот / видео.';
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
this.sending = true;
|
|
1301
|
+
try {
|
|
1302
|
+
const res = await WORK.fetch('/', 'support_create', {}, JSON.stringify({
|
|
1303
|
+
text,
|
|
1304
|
+
includeTech: Boolean(this.includeTech),
|
|
1305
|
+
techContext: this.includeTech ? this._collectTechContext() : null,
|
|
1306
|
+
attachments,
|
|
1307
|
+
}));
|
|
1308
|
+
this.problemText = '';
|
|
1309
|
+
this.removeScreenshot();
|
|
1310
|
+
this.removeVideo();
|
|
1311
|
+
await this.refreshTickets();
|
|
1312
|
+
if (res?.ticket?.ticketId)
|
|
1313
|
+
this.selectedTicketId = res.ticket.ticketId;
|
|
1314
|
+
this.activeTab = 'list';
|
|
1315
|
+
}
|
|
1316
|
+
catch (err) {
|
|
1317
|
+
this.error = String(err?.message || err);
|
|
1318
|
+
}
|
|
1319
|
+
finally {
|
|
1320
|
+
this.sending = false;
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
async sendReply() {
|
|
1324
|
+
const text = String(this.replyText || '').trim();
|
|
1325
|
+
if (!text || !this.selectedTicket) return;
|
|
1326
|
+
this.sending = true;
|
|
1327
|
+
this.error = '';
|
|
1328
|
+
try {
|
|
1329
|
+
await WORK.fetch('/', 'support_reply', {}, JSON.stringify({
|
|
1330
|
+
ticketId: this.selectedTicket.ticketId,
|
|
1331
|
+
text,
|
|
1332
|
+
}));
|
|
1333
|
+
this.replyText = '';
|
|
1334
|
+
await this.refreshTickets();
|
|
1335
|
+
}
|
|
1336
|
+
catch (err) {
|
|
1337
|
+
this.error = String(err?.message || err);
|
|
1338
|
+
}
|
|
1339
|
+
finally {
|
|
1340
|
+
this.sending = false;
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
async rejectRemoteDesktop(ticketId) {
|
|
1344
|
+
try {
|
|
1345
|
+
await WORK.fetch('/', 'support_remote', {}, JSON.stringify({ ticketId, action: 'reject' }));
|
|
1346
|
+
await this.refreshTickets();
|
|
1347
|
+
}
|
|
1348
|
+
catch (err) {
|
|
1349
|
+
this.error = String(err?.message || err);
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
async startRemoteDesktop(ticketId, mode = 'view') {
|
|
1353
|
+
this.error = '';
|
|
1354
|
+
if (document.querySelector('work-support-remote-bar')) {
|
|
1355
|
+
this.error = 'Сессия удалённого экрана уже активна.';
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const t = (this.tickets || []).find(x => x.ticketId === ticketId);
|
|
1359
|
+
const bar = document.createElement('work-support-remote-bar');
|
|
1360
|
+
document.body.appendChild(bar);
|
|
1361
|
+
try {
|
|
1362
|
+
await bar.start(ticketId, {
|
|
1363
|
+
mode,
|
|
1364
|
+
engineerName: t?.remote?.requestedBy?.engineerName || t?.assignedSupportName || 'Поддержка',
|
|
1365
|
+
});
|
|
1366
|
+
this.closePanel();
|
|
1367
|
+
}
|
|
1368
|
+
catch (err) {
|
|
1369
|
+
bar.remove();
|
|
1370
|
+
this.error = String(err?.message || err);
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
});
|