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,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Серверный модуль службы поддержки и встроенного Remote Desktop в WORK (sources/modules/support/index.js).
|
|
3
|
+
*
|
|
4
|
+
* Связывает локальный сервер WORK с work.odant.org через приватные методы сервера:
|
|
5
|
+
* - подписывает обращения из #system/owner-token.json и #system/license.json (не раскрывая их браузеру);
|
|
6
|
+
* - работает как для лицензированных серверов (SLA), так и для гостевых/пробных установок;
|
|
7
|
+
* - изолирует тикеты по автору (USER видит только свои, BOSS корня — все по серверу);
|
|
8
|
+
* - проксирует медиавложения и сигналинг/кадры Remote Desktop, исключая проблемы CORS в ЛВС.
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { DEV_MODE } from '../../host/config.js';
|
|
13
|
+
import { getVersionStatus } from '../../host/auto-updater.js';
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_LICENSE_HUB_URL,
|
|
16
|
+
loadOwnerTokenBinding,
|
|
17
|
+
loadLocalLicense,
|
|
18
|
+
getHardwareIdentity,
|
|
19
|
+
} from '../license/index.js';
|
|
20
|
+
|
|
21
|
+
const SYSTEM_DIR = './#system';
|
|
22
|
+
const SUPPORT_STORE_FILE = 'support-tickets.json';
|
|
23
|
+
|
|
24
|
+
function parseBody(params = {}) {
|
|
25
|
+
if (params.post && typeof params.post === 'string') {
|
|
26
|
+
try { return JSON.parse(params.post); }
|
|
27
|
+
catch { return {}; }
|
|
28
|
+
}
|
|
29
|
+
if (params.post && typeof params.post === 'object')
|
|
30
|
+
return params.post;
|
|
31
|
+
return params;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolveSystemDir(storage) {
|
|
35
|
+
const rootDir = path.resolve(storage?.dir || process.cwd());
|
|
36
|
+
return path.join(rootDir, '#system');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readLocalTicketsStore(systemDir = SYSTEM_DIR) {
|
|
40
|
+
const file = path.join(systemDir, SUPPORT_STORE_FILE);
|
|
41
|
+
try {
|
|
42
|
+
if (fs.existsSync(file)) {
|
|
43
|
+
const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
44
|
+
if (raw && Array.isArray(raw.tickets))
|
|
45
|
+
return raw;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch { /* ignore */ }
|
|
49
|
+
return { tickets: [] };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function writeLocalTicketsStore(systemDir = SYSTEM_DIR, storeObj = { tickets: [] }) {
|
|
53
|
+
fs.mkdirSync(systemDir, { recursive: true });
|
|
54
|
+
const file = path.join(systemDir, SUPPORT_STORE_FILE);
|
|
55
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
56
|
+
fs.writeFileSync(tmp, JSON.stringify(storeObj, null, 2), 'utf8');
|
|
57
|
+
fs.renameSync(tmp, file);
|
|
58
|
+
return storeObj;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resolveHubUrl(systemDir = SYSTEM_DIR, override = '') {
|
|
62
|
+
if (override)
|
|
63
|
+
return String(override).replace(/\/+$/, '');
|
|
64
|
+
if (process.env.WORK_SUPPORT_HUB_URL)
|
|
65
|
+
return String(process.env.WORK_SUPPORT_HUB_URL).replace(/\/+$/, '');
|
|
66
|
+
const binding = loadOwnerTokenBinding(systemDir);
|
|
67
|
+
if (binding?.hubUrl)
|
|
68
|
+
return String(binding.hubUrl).replace(/\/+$/, '');
|
|
69
|
+
const lic = loadLocalLicense(undefined, { systemDir });
|
|
70
|
+
if (lic?.hubUrl)
|
|
71
|
+
return String(lic.hubUrl).replace(/\/+$/, '');
|
|
72
|
+
return String(DEFAULT_LICENSE_HUB_URL).replace(/\/+$/, '');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function resolveUserContext(storage, params = {}) {
|
|
76
|
+
const uid = storage?.constructor?.resolveUid?.(params) || '';
|
|
77
|
+
if (!uid)
|
|
78
|
+
throw new Error('Требуется вход в систему WORK');
|
|
79
|
+
const roles = typeof storage?.roles === 'function'
|
|
80
|
+
? await storage.roles(params).catch(() => [])
|
|
81
|
+
: [];
|
|
82
|
+
const isBoss = Boolean(DEV_MODE || roles.includes('BOSS'));
|
|
83
|
+
|
|
84
|
+
let userName = uid;
|
|
85
|
+
let userEmail = '';
|
|
86
|
+
try {
|
|
87
|
+
const uItem = await globalThis.WORK?.get_item?.(`/USERS/${uid}`).catch(() => null);
|
|
88
|
+
if (uItem) {
|
|
89
|
+
await uItem.init?.catch?.(() => {});
|
|
90
|
+
userName = uItem.DATA?.label || uItem.label || uid;
|
|
91
|
+
userEmail = uItem.DATA?.email || '';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch { /* ignore */ }
|
|
95
|
+
return { uid, isBoss, userName: String(userName || uid), userEmail: String(userEmail || '') };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function createSupportTicketFromWork(storage, params = {}, { fetchImpl = globalThis.fetch } = {}) {
|
|
99
|
+
const { uid, userName, userEmail } = await resolveUserContext(storage, params);
|
|
100
|
+
const body = parseBody(params);
|
|
101
|
+
const text = String(body.text || '').trim();
|
|
102
|
+
const attachments = Array.isArray(body.attachments) ? body.attachments : [];
|
|
103
|
+
if (!text && !attachments.length)
|
|
104
|
+
throw new Error('Опишите проблему или приложите скриншот / видео');
|
|
105
|
+
|
|
106
|
+
const rootDir = path.resolve(storage?.dir || process.cwd());
|
|
107
|
+
const systemDir = path.join(rootDir, '#system');
|
|
108
|
+
const hubUrl = resolveHubUrl(systemDir, body.hubUrl);
|
|
109
|
+
const binding = loadOwnerTokenBinding(systemDir);
|
|
110
|
+
const lic = loadLocalLicense(undefined, { systemDir });
|
|
111
|
+
const hw = getHardwareIdentity();
|
|
112
|
+
const ver = getVersionStatus({ rootDir });
|
|
113
|
+
|
|
114
|
+
const techContext = body.includeTech !== false
|
|
115
|
+
? {
|
|
116
|
+
...(body.techContext && typeof body.techContext === 'object' ? body.techContext : {}),
|
|
117
|
+
version: ver.runningVersion,
|
|
118
|
+
diskVersion: ver.diskVersion,
|
|
119
|
+
serverId: hw.serverId,
|
|
120
|
+
hwid: hw.hwid,
|
|
121
|
+
}
|
|
122
|
+
: null;
|
|
123
|
+
|
|
124
|
+
const payload = {
|
|
125
|
+
ownerToken: binding?.token || '',
|
|
126
|
+
licenseId: lic?.unlicensed ? '' : (lic?.licenseId || ''),
|
|
127
|
+
serverId: hw.serverId,
|
|
128
|
+
serverName: storage?.DATA?.label || storage?.label || 'WORK',
|
|
129
|
+
customerName: lic?.customer?.name || binding?.email || storage?.DATA?.label || 'Сервер WORK',
|
|
130
|
+
userId: uid,
|
|
131
|
+
userName: body.userName || userName,
|
|
132
|
+
userEmail: body.userEmail || userEmail || binding?.email || '',
|
|
133
|
+
text: text || 'Скриншот / запись проблемы без текстового описания',
|
|
134
|
+
techContext,
|
|
135
|
+
attachments,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const res = await fetchImpl(`${hubUrl}/api/support/tickets`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
headers: { 'Content-Type': 'application/json' },
|
|
141
|
+
body: JSON.stringify(payload),
|
|
142
|
+
});
|
|
143
|
+
const data = await res.json().catch(() => ({}));
|
|
144
|
+
if (!res.ok || !data.ticket)
|
|
145
|
+
throw new Error(data.error || `Сервер поддержки ответил HTTP ${res.status}`);
|
|
146
|
+
|
|
147
|
+
const ticket = data.ticket;
|
|
148
|
+
const accessKey = String(ticket.ticketAccessKey || '');
|
|
149
|
+
const sanitized = { ...ticket };
|
|
150
|
+
delete sanitized.ticketAccessKey;
|
|
151
|
+
|
|
152
|
+
const store = readLocalTicketsStore(systemDir);
|
|
153
|
+
const now = Date.now();
|
|
154
|
+
store.tickets.unshift({
|
|
155
|
+
ticketId: sanitized.ticketId,
|
|
156
|
+
ticketAccessKey: accessKey,
|
|
157
|
+
hubUrl,
|
|
158
|
+
createdByUid: uid,
|
|
159
|
+
createdByName: payload.userName,
|
|
160
|
+
createdAt: sanitized.createdAt || now,
|
|
161
|
+
lastReadByUid: { [uid]: now },
|
|
162
|
+
cached: sanitized,
|
|
163
|
+
});
|
|
164
|
+
writeLocalTicketsStore(systemDir, store);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
ok: true,
|
|
168
|
+
ticket: { ...sanitized, unreadCount: 0, own: true },
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function listSupportTicketsForWork(storage, params = {}, { fetchImpl = globalThis.fetch } = {}) {
|
|
173
|
+
const { uid, isBoss } = await resolveUserContext(storage, params);
|
|
174
|
+
const rootDir = path.resolve(storage?.dir || process.cwd());
|
|
175
|
+
const systemDir = path.join(rootDir, '#system');
|
|
176
|
+
const defaultHubUrl = resolveHubUrl(systemDir);
|
|
177
|
+
const store = readLocalTicketsStore(systemDir);
|
|
178
|
+
|
|
179
|
+
const visibleRecs = store.tickets.filter(rec => rec && (isBoss || rec.createdByUid === uid));
|
|
180
|
+
if (!visibleRecs.length) {
|
|
181
|
+
return { ok: true, tickets: [], unreadTotal: 0, remoteRequests: 0, isBoss, hubUrl: defaultHubUrl };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Группируем по hubUrl и синхронизируем свежие статусы/сообщения с work.odant.org
|
|
185
|
+
const byHub = new Map();
|
|
186
|
+
for (const rec of visibleRecs) {
|
|
187
|
+
const u = String(rec.hubUrl || defaultHubUrl).replace(/\/+$/, '');
|
|
188
|
+
if (!byHub.has(u)) byHub.set(u, []);
|
|
189
|
+
byHub.get(u).push(rec);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let syncError = '';
|
|
193
|
+
const syncedById = new Map();
|
|
194
|
+
for (const [hubUrl, recs] of byHub.entries()) {
|
|
195
|
+
try {
|
|
196
|
+
const res = await fetchImpl(`${hubUrl}/api/support/tickets/sync`, {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: { 'Content-Type': 'application/json' },
|
|
199
|
+
body: JSON.stringify({
|
|
200
|
+
tickets: recs.map(r => ({ ticketId: r.ticketId, ticketAccessKey: r.ticketAccessKey })),
|
|
201
|
+
}),
|
|
202
|
+
signal: AbortSignal.timeout(8000),
|
|
203
|
+
});
|
|
204
|
+
const data = await res.json().catch(() => ({}));
|
|
205
|
+
if (res.ok && Array.isArray(data.tickets)) {
|
|
206
|
+
for (const t of data.tickets) {
|
|
207
|
+
if (t?.ticketId) syncedById.set(t.ticketId, t);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else if (!res.ok) {
|
|
211
|
+
syncError = data.error || `HTTP ${res.status}`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
syncError = String(err?.message || err);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let changed = false;
|
|
220
|
+
let unreadTotal = 0;
|
|
221
|
+
let remoteRequests = 0;
|
|
222
|
+
const tickets = [];
|
|
223
|
+
|
|
224
|
+
for (const rec of visibleRecs) {
|
|
225
|
+
const fresh = syncedById.get(rec.ticketId);
|
|
226
|
+
if (fresh) {
|
|
227
|
+
rec.cached = fresh;
|
|
228
|
+
changed = true;
|
|
229
|
+
}
|
|
230
|
+
const t = fresh || rec.cached || { ticketId: rec.ticketId, status: 'open', messages: [] };
|
|
231
|
+
const lastRead = Number(rec.lastReadByUid?.[uid] || 0);
|
|
232
|
+
const unreadCount = (t.messages || []).filter(m =>
|
|
233
|
+
(m.from === 'support' || m.role === 'engineer') && Number(m.time || 0) > lastRead
|
|
234
|
+
).length;
|
|
235
|
+
unreadTotal += unreadCount;
|
|
236
|
+
if (t.remote?.state === 'requested')
|
|
237
|
+
remoteRequests++;
|
|
238
|
+
tickets.push({
|
|
239
|
+
...t,
|
|
240
|
+
unreadCount,
|
|
241
|
+
own: rec.createdByUid === uid,
|
|
242
|
+
createdByUid: rec.createdByUid,
|
|
243
|
+
createdByName: rec.createdByName || t.userName || rec.createdByUid,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (changed)
|
|
248
|
+
writeLocalTicketsStore(systemDir, store);
|
|
249
|
+
|
|
250
|
+
tickets.sort((a, b) => Number(b.createdAt || 0) - Number(a.createdAt || 0));
|
|
251
|
+
return {
|
|
252
|
+
ok: true,
|
|
253
|
+
tickets,
|
|
254
|
+
unreadTotal,
|
|
255
|
+
remoteRequests,
|
|
256
|
+
isBoss,
|
|
257
|
+
hubUrl: defaultHubUrl,
|
|
258
|
+
...(syncError ? { syncError } : {}),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function findAuthorizedRecord(systemDir, ticketId, uid, isBoss) {
|
|
263
|
+
const store = readLocalTicketsStore(systemDir);
|
|
264
|
+
const rec = store.tickets.find(r => r?.ticketId === ticketId);
|
|
265
|
+
if (!rec)
|
|
266
|
+
throw new Error('Обращение не найдено на этом сервере');
|
|
267
|
+
if (!isBoss && rec.createdByUid !== uid)
|
|
268
|
+
throw new Error('Нет доступа к чужому обращению');
|
|
269
|
+
return { store, rec };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export async function replySupportTicketFromWork(storage, params = {}, { fetchImpl = globalThis.fetch } = {}) {
|
|
273
|
+
const { uid, isBoss, userName } = await resolveUserContext(storage, params);
|
|
274
|
+
const body = parseBody(params);
|
|
275
|
+
const ticketId = String(body.ticketId || params.ticketId || '').trim();
|
|
276
|
+
const text = String(body.text || '').trim();
|
|
277
|
+
const attachments = Array.isArray(body.attachments) ? body.attachments : [];
|
|
278
|
+
if (!ticketId)
|
|
279
|
+
throw new Error('Не указан номер обращения');
|
|
280
|
+
if (!text && !attachments.length)
|
|
281
|
+
throw new Error('Введите сообщение или приложите файл');
|
|
282
|
+
|
|
283
|
+
const systemDir = resolveSystemDir(storage);
|
|
284
|
+
const { store, rec } = findAuthorizedRecord(systemDir, ticketId, uid, isBoss);
|
|
285
|
+
const hubUrl = resolveHubUrl(systemDir, rec.hubUrl);
|
|
286
|
+
|
|
287
|
+
const res = await fetchImpl(`${hubUrl}/api/support/tickets/${encodeURIComponent(ticketId)}/message`, {
|
|
288
|
+
method: 'POST',
|
|
289
|
+
headers: { 'Content-Type': 'application/json' },
|
|
290
|
+
body: JSON.stringify({
|
|
291
|
+
ticketAccessKey: rec.ticketAccessKey,
|
|
292
|
+
author: userName,
|
|
293
|
+
userId: uid,
|
|
294
|
+
text,
|
|
295
|
+
attachments,
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
const data = await res.json().catch(() => ({}));
|
|
299
|
+
if (!res.ok || !data.ticket)
|
|
300
|
+
throw new Error(data.error || `Ошибка отправки сообщения (HTTP ${res.status})`);
|
|
301
|
+
|
|
302
|
+
rec.cached = data.ticket;
|
|
303
|
+
rec.lastReadByUid ??= {};
|
|
304
|
+
rec.lastReadByUid[uid] = Date.now();
|
|
305
|
+
writeLocalTicketsStore(systemDir, store);
|
|
306
|
+
return { ok: true, ticket: { ...data.ticket, unreadCount: 0, own: rec.createdByUid === uid } };
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export async function markSupportTicketRead(storage, params = {}) {
|
|
310
|
+
const { uid, isBoss } = await resolveUserContext(storage, params);
|
|
311
|
+
const body = parseBody(params);
|
|
312
|
+
const ticketId = String(body.ticketId || params.ticketId || '').trim();
|
|
313
|
+
const systemDir = resolveSystemDir(storage);
|
|
314
|
+
const store = readLocalTicketsStore(systemDir);
|
|
315
|
+
const now = Date.now();
|
|
316
|
+
let changed = false;
|
|
317
|
+
for (const rec of store.tickets) {
|
|
318
|
+
if (!rec) continue;
|
|
319
|
+
if (!isBoss && rec.createdByUid !== uid) continue;
|
|
320
|
+
if (!ticketId || rec.ticketId === ticketId) {
|
|
321
|
+
rec.lastReadByUid ??= {};
|
|
322
|
+
rec.lastReadByUid[uid] = now;
|
|
323
|
+
changed = true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (changed)
|
|
327
|
+
writeLocalTicketsStore(systemDir, store);
|
|
328
|
+
return { ok: true };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export async function fetchSupportMediaFromWork(storage, params = {}, { fetchImpl = globalThis.fetch } = {}) {
|
|
332
|
+
const { uid, isBoss } = await resolveUserContext(storage, params);
|
|
333
|
+
const ticketId = String(params.ticketId || '').trim();
|
|
334
|
+
const file = path.basename(String(params.file || '').trim());
|
|
335
|
+
if (!ticketId || !file)
|
|
336
|
+
throw new Error('Не указаны параметры медиафайла');
|
|
337
|
+
const systemDir = resolveSystemDir(storage);
|
|
338
|
+
const { rec } = findAuthorizedRecord(systemDir, ticketId, uid, isBoss);
|
|
339
|
+
const hubUrl = resolveHubUrl(systemDir, rec.hubUrl);
|
|
340
|
+
const url = `${hubUrl}/api/support/media/${encodeURIComponent(ticketId)}/${encodeURIComponent(file)}?key=${encodeURIComponent(rec.ticketAccessKey)}`;
|
|
341
|
+
const res = await fetchImpl(url);
|
|
342
|
+
if (!res.ok)
|
|
343
|
+
throw new Error(`Не удалось загрузить вложение (HTTP ${res.status})`);
|
|
344
|
+
const mime = res.headers.get('content-type') || 'application/octet-stream';
|
|
345
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
346
|
+
return {
|
|
347
|
+
ok: true,
|
|
348
|
+
mime,
|
|
349
|
+
dataUrl: `data:${mime};base64,${buf.toString('base64')}`,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export async function relaySupportRemoteFromWork(storage, params = {}, { fetchImpl = globalThis.fetch } = {}) {
|
|
354
|
+
const { uid, isBoss } = await resolveUserContext(storage, params);
|
|
355
|
+
const body = parseBody(params);
|
|
356
|
+
const ticketId = String(body.ticketId || params.ticketId || '').trim();
|
|
357
|
+
if (!ticketId)
|
|
358
|
+
throw new Error('Не указан номер обращения');
|
|
359
|
+
const systemDir = resolveSystemDir(storage);
|
|
360
|
+
const { rec } = findAuthorizedRecord(systemDir, ticketId, uid, isBoss);
|
|
361
|
+
const hubUrl = resolveHubUrl(systemDir, rec.hubUrl);
|
|
362
|
+
|
|
363
|
+
const payload = { ...body, ticketAccessKey: rec.ticketAccessKey };
|
|
364
|
+
delete payload.ticketId;
|
|
365
|
+
|
|
366
|
+
const res = await fetchImpl(`${hubUrl}/api/support/remote/${encodeURIComponent(ticketId)}/client`, {
|
|
367
|
+
method: 'POST',
|
|
368
|
+
headers: { 'Content-Type': 'application/json' },
|
|
369
|
+
body: JSON.stringify(payload),
|
|
370
|
+
});
|
|
371
|
+
const data = await res.json().catch(() => ({}));
|
|
372
|
+
if (!res.ok)
|
|
373
|
+
throw new Error(data.error || `Ошибка сигналинга Remote Desktop (HTTP ${res.status})`);
|
|
374
|
+
return data;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const SUPPORT_METHODS = Object.freeze({
|
|
378
|
+
support_list: {
|
|
379
|
+
level: 'user',
|
|
380
|
+
fn: async function (p = {}) {
|
|
381
|
+
return listSupportTicketsForWork(this, p);
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
support_create: {
|
|
385
|
+
level: 'user',
|
|
386
|
+
fn: async function (p = {}) {
|
|
387
|
+
return createSupportTicketFromWork(this, p);
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
support_reply: {
|
|
391
|
+
level: 'user',
|
|
392
|
+
fn: async function (p = {}) {
|
|
393
|
+
return replySupportTicketFromWork(this, p);
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
support_mark_read: {
|
|
397
|
+
level: 'user',
|
|
398
|
+
fn: async function (p = {}) {
|
|
399
|
+
return markSupportTicketRead(this, p);
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
support_media: {
|
|
403
|
+
level: 'user',
|
|
404
|
+
fn: async function (p = {}) {
|
|
405
|
+
return fetchSupportMediaFromWork(this, p);
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
support_remote: {
|
|
409
|
+
level: 'user',
|
|
410
|
+
fn: async function (p = {}) {
|
|
411
|
+
return relaySupportRemoteFromWork(this, p);
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
});
|
|
@@ -7,28 +7,50 @@ ODA({ is: 'user-profile', imports: 'oda//otp.js',
|
|
|
7
7
|
@apply --light;
|
|
8
8
|
@apply --vertical;
|
|
9
9
|
@apply --flex;
|
|
10
|
-
padding: 8px;
|
|
10
|
+
padding: max(8px, var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) max(16px, var(--safe-bottom, 0px)) max(12px, var(--safe-left, 0px));
|
|
11
|
+
box-sizing: border-box;
|
|
11
12
|
}
|
|
12
13
|
input {
|
|
13
14
|
border: 1px solid gray;
|
|
14
15
|
padding: 8px;
|
|
15
16
|
border-radius: 8px;
|
|
16
17
|
font-size: large;
|
|
18
|
+
width: 100%;
|
|
19
|
+
box-sizing: border-box;
|
|
17
20
|
}
|
|
18
21
|
button {
|
|
19
|
-
height:
|
|
22
|
+
min-height: 44px;
|
|
23
|
+
padding: 8px 14px;
|
|
20
24
|
border-radius: 8px;
|
|
21
|
-
font-size:
|
|
25
|
+
font-size: medium;
|
|
22
26
|
cursor: pointer;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
box-sizing: border-box;
|
|
23
29
|
}
|
|
24
30
|
legend {
|
|
25
|
-
font-size:
|
|
31
|
+
font-size: large;
|
|
26
32
|
}
|
|
27
33
|
.photo {
|
|
28
34
|
background-color: {{photoColor}};
|
|
29
35
|
}
|
|
36
|
+
.profile-wrap {
|
|
37
|
+
gap: 14px;
|
|
38
|
+
width: min(360px, 100%);
|
|
39
|
+
align-self: center;
|
|
40
|
+
margin: 0 auto auto auto;
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
}
|
|
43
|
+
.token-row {
|
|
44
|
+
gap: 8px;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
flex-wrap: wrap;
|
|
48
|
+
border: 1px solid gray;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
padding: 6px 8px;
|
|
51
|
+
}
|
|
30
52
|
</style>
|
|
31
|
-
<div no-flex vertical
|
|
53
|
+
<div no-flex vertical class="profile-wrap">
|
|
32
54
|
<div ~if="pendingInvite?.valid" style="padding:10px 12px;border-radius:8px;border:1px solid #10b981;background:rgba(16,185,129,0.1);font-size:small;line-height:1.4;text-align:center;">
|
|
33
55
|
<b>Приглашение:</b> {{pendingInvite.pointLabel}} → <b>{{pendingInvite.placeLabel}}</b>
|
|
34
56
|
</div>
|
package/sources/page.html
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="theme-color" content="#4b0082">
|
|
6
6
|
<meta name="color-scheme" id="color-scheme" content="light dark">
|
|
7
|
-
<meta name="viewport" content="initial-scale=1, maximum-scale=3,
|
|
8
|
-
<meta name="
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, viewport-fit=cover">
|
|
8
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
9
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
10
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
11
|
+
<meta name="description" content="ODANT-WORK">
|
|
9
12
|
<link rel="manifest" href="{item_path}?manifest" crossorigin="use-credentials">
|
|
10
13
|
<link rel="icon" type="image/svg+xml" href="{item_icon_path}" crossorigin="use-credentials">
|
|
11
14
|
<title>{title}</title>
|
|
@@ -115,8 +118,8 @@
|
|
|
115
118
|
@apply --center;
|
|
116
119
|
flex-wrap: wrap;
|
|
117
120
|
width: 100%;
|
|
118
|
-
padding: 4px 12px;
|
|
119
|
-
gap:
|
|
121
|
+
padding: max(4px, var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) 4px max(12px, var(--safe-left, 0px));
|
|
122
|
+
gap: 8px;
|
|
120
123
|
box-sizing: border-box;
|
|
121
124
|
|
|
122
125
|
div{
|
|
@@ -18,6 +18,7 @@ import { audit } from './audit.js';
|
|
|
18
18
|
import { DATA_METHODS } from '../../data/api.js';
|
|
19
19
|
import { TRAINER_METHODS } from '../../modules/trainer/index.js';
|
|
20
20
|
import { LICENSE_METHODS } from '../../modules/license/index.js';
|
|
21
|
+
import { SUPPORT_METHODS } from '../../modules/support/index.js';
|
|
21
22
|
import { NOTIFY_METHODS } from '../../modules/notify/index.js';
|
|
22
23
|
import { INVITE_METHODS } from './invites.js';
|
|
23
24
|
import { KLADR_METHODS } from '../../modules/kladr/index.js';
|
|
@@ -77,6 +78,8 @@ export const MEMBERS = Object.freeze({
|
|
|
77
78
|
...Object.fromEntries(Object.entries(TRAINER_METHODS).map(([name, m]) => [name, m.level])),
|
|
78
79
|
// лицензирование ПАК WORK (sources/modules/license/index.js)
|
|
79
80
|
...Object.fromEntries(Object.entries(LICENSE_METHODS).map(([name, m]) => [name, m.level])),
|
|
81
|
+
// служба поддержки и Remote Desktop (sources/modules/support/index.js)
|
|
82
|
+
...Object.fromEntries(Object.entries(SUPPORT_METHODS).map(([name, m]) => [name, m.level])),
|
|
80
83
|
// каналы уведомлений Telegram / MAX (sources/modules/notify/index.js)
|
|
81
84
|
...Object.fromEntries(Object.entries(NOTIFY_METHODS).map(([name, m]) => [name, m.level])),
|
|
82
85
|
// одноразовые приглашения пользователей на рабочие места (sources/server/access/invites.js)
|
package/sources/server/class.js
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
findProviderPreset,
|
|
31
31
|
} from '../modules/trainer/index.js';
|
|
32
32
|
import { LICENSE_METHODS } from '../modules/license/index.js';
|
|
33
|
+
import { SUPPORT_METHODS } from '../modules/support/index.js';
|
|
33
34
|
import { NOTIFY_METHODS, resolveBotForPoint, sanitizeBotForUi } from '../modules/notify/index.js';
|
|
34
35
|
import { INVITE_METHODS } from './access/invites.js';
|
|
35
36
|
import { KLADR_METHODS } from '../modules/kladr/index.js';
|
|
@@ -899,6 +900,16 @@ for (const [name, m] of Object.entries(LICENSE_METHODS)) {
|
|
|
899
900
|
configurable: true,
|
|
900
901
|
});
|
|
901
902
|
}
|
|
903
|
+
// методы службы поддержки и Remote Desktop (support_*)
|
|
904
|
+
for (const [name, m] of Object.entries(SUPPORT_METHODS)) {
|
|
905
|
+
Object.defineProperty($class.prototype, name, {
|
|
906
|
+
value: function (params = {}) {
|
|
907
|
+
return m.fn.call(this, params);
|
|
908
|
+
},
|
|
909
|
+
writable: true,
|
|
910
|
+
configurable: true,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
902
913
|
// методы мессенджеров и уведомлений точки (messenger_*)
|
|
903
914
|
for (const [name, m] of Object.entries(NOTIFY_METHODS)) {
|
|
904
915
|
Object.defineProperty($class.prototype, name, {
|
package/sources/tester.html
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html lang="
|
|
2
|
+
<html lang="ru">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
|
-
<meta name="theme-color" content="
|
|
5
|
+
<meta name="theme-color" content="#4b0082">
|
|
6
6
|
<meta name="color-scheme" id="color-scheme" content="light dark">
|
|
7
|
-
<meta name="viewport" content="initial-scale=1, maximum-scale=3">
|
|
8
|
-
<meta name="description" content="
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, viewport-fit=cover">
|
|
8
|
+
<meta name="description" content="ODANT-WORK Tester">
|
|
9
9
|
<link rel="shortcut icon" type="image/x-icon" href="@icon" crossorigin="use-credentials">
|
|
10
10
|
<title>{title}</title>
|
|
11
11
|
<style>
|