odant-work 1.0.108 → 1.0.110
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/$server/$folder/$class/$structure/$server/handlers/pages/form/system/sms/$handler/class.js +293 -0
- package/$server/$folder/$class/$structure/handlers/methods/invite/$handler/class.js +31 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +5 -2
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +25 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +48 -6
- package/$server/$folder/handlers/pages/form/$handler/class.js +79 -37
- package/$server/$folder/lib/consultant/consultant.js +58 -6
- package/$server/$folder/lib/explorer/explorer.js +49 -3
- package/$server/$folder/lib/invite/invite.js +370 -0
- package/$server/$folder/lib/node-explorer/node-explorer.js +0 -3
- package/package.json +1 -1
- package/sources/client.js +37 -4
- package/sources/host/auth-methods.js +398 -27
- package/sources/host/sms.js +351 -0
- package/sources/modules/license/index.js +9 -4
- package/sources/modules/user-profile/user-profile.js +337 -23
- package/sources/server/access/gateway.js +4 -1
- package/sources/server/access/invites.js +149 -8
- package/sources/server/server.js +31 -0
|
@@ -834,6 +834,8 @@ ODA({
|
|
|
834
834
|
this._watchPresence();
|
|
835
835
|
},
|
|
836
836
|
detached() {
|
|
837
|
+
clearInterval(this._runPollTimer);
|
|
838
|
+
this._runPollTimer = null;
|
|
837
839
|
this._unwatchPresence();
|
|
838
840
|
this._unbindTask();
|
|
839
841
|
this._voice?.disable();
|
|
@@ -1270,25 +1272,37 @@ ODA({
|
|
|
1270
1272
|
this._unbindTask();
|
|
1271
1273
|
this.taskItem = task || null;
|
|
1272
1274
|
this._hasActiveRun = false;
|
|
1273
|
-
if (!task)
|
|
1275
|
+
if (!task) {
|
|
1276
|
+
clearInterval(this._runPollTimer);
|
|
1277
|
+
this._runPollTimer = null;
|
|
1274
1278
|
return;
|
|
1279
|
+
}
|
|
1280
|
+
globalThis.WORK?._subscribeWsPath?.(task.short || task.path);
|
|
1275
1281
|
this._taskHandlers = {
|
|
1276
|
-
'changed': () => this._reloadTask(),
|
|
1282
|
+
'changed': () => { this._lastWsEvent = Date.now(); this._reloadTask(); },
|
|
1277
1283
|
'task.delta': e => {
|
|
1284
|
+
this._lastWsEvent = Date.now();
|
|
1278
1285
|
this._hasActiveRun = true;
|
|
1279
1286
|
this._onDelta(e.detail?.value);
|
|
1280
1287
|
},
|
|
1281
1288
|
'chat.start': () => {
|
|
1289
|
+
this._lastWsEvent = Date.now();
|
|
1282
1290
|
this._hasActiveRun = true;
|
|
1291
|
+
if (this.status !== 'running')
|
|
1292
|
+
this.status = 'running';
|
|
1293
|
+
this._ensureRunPoll();
|
|
1283
1294
|
},
|
|
1284
1295
|
'task.state': e => {
|
|
1296
|
+
this._lastWsEvent = Date.now();
|
|
1285
1297
|
const s = e.detail?.value?.status;
|
|
1286
1298
|
if (s) {
|
|
1287
1299
|
const prev = this.status;
|
|
1288
1300
|
this.status = s;
|
|
1289
1301
|
this._lastDelta = Date.now();
|
|
1290
|
-
if (s === 'running')
|
|
1302
|
+
if (s === 'running') {
|
|
1291
1303
|
this._hasActiveRun = true;
|
|
1304
|
+
this._ensureRunPoll();
|
|
1305
|
+
}
|
|
1292
1306
|
else if (s === 'waiting' && (this._hasActiveRun || prev === 'running') && this._isOnScreen()) {
|
|
1293
1307
|
this._hasActiveRun = false;
|
|
1294
1308
|
_playTaskCompletionClick?.();
|
|
@@ -1296,6 +1310,7 @@ ODA({
|
|
|
1296
1310
|
}
|
|
1297
1311
|
},
|
|
1298
1312
|
'chat.done': () => {
|
|
1313
|
+
this._lastWsEvent = Date.now();
|
|
1299
1314
|
if (this._hasActiveRun && this._isOnScreen())
|
|
1300
1315
|
_playTaskCompletionClick?.();
|
|
1301
1316
|
this._hasActiveRun = false;
|
|
@@ -1305,10 +1320,34 @@ ODA({
|
|
|
1305
1320
|
for (const [k, fn] of Object.entries(this._taskHandlers))
|
|
1306
1321
|
task.listen?.(k, fn);
|
|
1307
1322
|
this._reloadTask();
|
|
1323
|
+
this._ensureRunPoll();
|
|
1308
1324
|
this._notifyPresence();
|
|
1309
1325
|
},
|
|
1310
1326
|
|
|
1327
|
+
_ensureRunPoll() {
|
|
1328
|
+
if (this._runPollTimer)
|
|
1329
|
+
return;
|
|
1330
|
+
this._runPollTimer = setInterval(() => {
|
|
1331
|
+
if (!this.taskItem) {
|
|
1332
|
+
clearInterval(this._runPollTimer);
|
|
1333
|
+
this._runPollTimer = null;
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const active = this.status === 'running' || Boolean(this.optimistic) || this.starting;
|
|
1337
|
+
if (!active) {
|
|
1338
|
+
clearInterval(this._runPollTimer);
|
|
1339
|
+
this._runPollTimer = null;
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
const sinceWs = Date.now() - (this._lastWsEvent || 0);
|
|
1343
|
+
if (sinceWs >= 1500)
|
|
1344
|
+
this._reloadTask();
|
|
1345
|
+
}, 1800);
|
|
1346
|
+
},
|
|
1347
|
+
|
|
1311
1348
|
_unbindTask() {
|
|
1349
|
+
clearInterval(this._runPollTimer);
|
|
1350
|
+
this._runPollTimer = null;
|
|
1312
1351
|
const t = this.taskItem;
|
|
1313
1352
|
if (t && this._taskHandlers) {
|
|
1314
1353
|
for (const [k, fn] of Object.entries(this._taskHandlers))
|
|
@@ -1359,8 +1398,11 @@ ODA({
|
|
|
1359
1398
|
do {
|
|
1360
1399
|
this._again = false;
|
|
1361
1400
|
try {
|
|
1362
|
-
const
|
|
1401
|
+
const stateRes = await this.taskItem?.fetch?.('state').catch(() => null);
|
|
1402
|
+
const isLiveObj = Boolean(stateRes && typeof stateRes === 'object' && 'body' in stateRes);
|
|
1403
|
+
const raw = isLiveObj ? stateRes.body : await this.taskItem?.load();
|
|
1363
1404
|
const data = typeof raw === 'string' ? JSON.parse(raw || '{}') : (raw || {});
|
|
1405
|
+
const isRunning = isLiveObj ? Boolean(stateRes.running) : (data.status === 'running');
|
|
1364
1406
|
const done = new Set((data.items || []).filter(i => i.type === 'assistant' && (i.durationMs || i.stopped || i.interrupted)).map(i => i.id));
|
|
1365
1407
|
if (Object.keys(this.streams).some(id => done.has(id))) {
|
|
1366
1408
|
const s = {};
|
|
@@ -1371,10 +1413,20 @@ ODA({
|
|
|
1371
1413
|
this.streams = s;
|
|
1372
1414
|
}
|
|
1373
1415
|
this.data = data;
|
|
1416
|
+
const hasAssistant = (data.items || []).some(i => i.type === 'assistant');
|
|
1374
1417
|
if (this.items.length)
|
|
1375
1418
|
this.optimistic = null;
|
|
1376
|
-
// Пока
|
|
1377
|
-
|
|
1419
|
+
// Пока задача активна на сервере или только что создана (нет ответа и < 15с), не сбрасываем в idle
|
|
1420
|
+
const recentStart = Boolean(data.created && (Date.now() - (+data.created || 0) < 15000) && !hasAssistant);
|
|
1421
|
+
this.status = isRunning
|
|
1422
|
+
? (data.status === 'waiting' ? 'waiting' : 'running')
|
|
1423
|
+
: (data.status && data.status !== 'idle'
|
|
1424
|
+
? data.status
|
|
1425
|
+
: ((this.optimistic || (recentStart && data.status !== 'error' && data.status !== 'stopped')) ? 'running' : (data.status || 'idle')));
|
|
1426
|
+
if (this.status === 'running') {
|
|
1427
|
+
this._hasActiveRun = true;
|
|
1428
|
+
this._ensureRunPoll();
|
|
1429
|
+
}
|
|
1378
1430
|
this._lastDelta = Date.now();
|
|
1379
1431
|
this._stick();
|
|
1380
1432
|
this._voice?.onData({ ...data, status: this.status });
|
|
@@ -438,9 +438,8 @@ export default {
|
|
|
438
438
|
this.bookmarks = validItems;
|
|
439
439
|
const activeUrl = parsed.activeUrl || validItems.at(-1)?.url || '';
|
|
440
440
|
setTimeout(() => {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}, 1200);
|
|
441
|
+
this._verifyBookmarksAlive();
|
|
442
|
+
}, 600);
|
|
444
443
|
return {
|
|
445
444
|
activeUrl,
|
|
446
445
|
items: validItems,
|
|
@@ -450,6 +449,47 @@ export default {
|
|
|
450
449
|
return null;
|
|
451
450
|
}
|
|
452
451
|
},
|
|
452
|
+
async _verifyBookmarksAlive() {
|
|
453
|
+
if (!WORK?.uid && !WORK?.DEV_MODE)
|
|
454
|
+
return;
|
|
455
|
+
const list = Array.isArray(this.bookmarks) ? [...this.bookmarks] : [];
|
|
456
|
+
if (!list.length)
|
|
457
|
+
return;
|
|
458
|
+
const deadUrls = new Set();
|
|
459
|
+
await Promise.all(list.map(async (entry) => {
|
|
460
|
+
const short = entry?.short;
|
|
461
|
+
if (!short || short === '/')
|
|
462
|
+
return;
|
|
463
|
+
try {
|
|
464
|
+
const url = location.origin + (short.startsWith('/') ? short : '/' + short);
|
|
465
|
+
await WORK.fetch(url, 'info', {});
|
|
466
|
+
await this._hydrateBookmarkMeta(entry, { cachedOnly: true });
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
const msg = String(err?.message || err || '');
|
|
470
|
+
const isServerMissing = err?.name === 'WORK_ServerError'
|
|
471
|
+
|| /not found|enoent|не найден|отсутств|удален|удалён|доступ запрещ|нет доступа|404/i.test(msg);
|
|
472
|
+
if (isServerMissing && entry?.url)
|
|
473
|
+
deadUrls.add(entry.url);
|
|
474
|
+
}
|
|
475
|
+
}));
|
|
476
|
+
if (!deadUrls.size)
|
|
477
|
+
return;
|
|
478
|
+
for (const u of deadUrls)
|
|
479
|
+
this.pages.remove(u);
|
|
480
|
+
const nextList = (this.bookmarks || []).filter(b => b && !deadUrls.has(b.url));
|
|
481
|
+
this.bookmarks = nextList;
|
|
482
|
+
this._saveBookmarksState();
|
|
483
|
+
if (deadUrls.has(this.focusedPage)) {
|
|
484
|
+
const next = nextList.at(-1);
|
|
485
|
+
if (next)
|
|
486
|
+
this.activateBookmark(next);
|
|
487
|
+
else {
|
|
488
|
+
this.focusedPage = '';
|
|
489
|
+
this.render?.();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
},
|
|
453
493
|
async _hydrateBookmarkMeta(entry, { cachedOnly = false } = {}) {
|
|
454
494
|
if (!entry?.short)
|
|
455
495
|
return;
|
|
@@ -849,6 +889,12 @@ export default {
|
|
|
849
889
|
this._refreshSupportBadge();
|
|
850
890
|
this._syncExplorerTreeScope();
|
|
851
891
|
this.$('#consultant')?._refreshUserScope?.();
|
|
892
|
+
if (WORK.uid || WORK.DEV_MODE) {
|
|
893
|
+
if (!this.bookmarks?.length)
|
|
894
|
+
this._restoreBookmarksState();
|
|
895
|
+
else
|
|
896
|
+
this._verifyBookmarksAlive();
|
|
897
|
+
}
|
|
852
898
|
this.render?.();
|
|
853
899
|
});
|
|
854
900
|
if (!this._onNodeDeleted && WORK.chatEvents) {
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Диалог приглашения пользователя на рабочее место активной структуры ($structure) для BOSS.
|
|
3
|
+
* Используется как из метод-хендлера тулбара/контекстного меню ($structure/handlers/methods/invite),
|
|
4
|
+
* так и из вкладки «Система → Пользователи».
|
|
5
|
+
*/
|
|
6
|
+
function flattenRoles(roles = [], prefix = '', depth = 0, out = []) {
|
|
7
|
+
for (const r of (Array.isArray(roles) ? roles : [])) {
|
|
8
|
+
if (!r || !r.id)
|
|
9
|
+
continue;
|
|
10
|
+
const trail = prefix ? `${prefix}/${r.id}` : r.id;
|
|
11
|
+
out.push({
|
|
12
|
+
trail,
|
|
13
|
+
label: `${' '.repeat(depth)}${r.label || r.id}${r.external ? ' (клиент)' : ''}`,
|
|
14
|
+
});
|
|
15
|
+
if (Array.isArray(r.ROLES) && r.ROLES.length)
|
|
16
|
+
flattenRoles(r.ROLES, trail, depth + 1, out);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof ODA === 'function' && !customElements.get('work-invite-dialog')) {
|
|
22
|
+
ODA({
|
|
23
|
+
is: 'work-invite-dialog',
|
|
24
|
+
imports: 'oda//button, oda//icon',
|
|
25
|
+
template: /* html */`
|
|
26
|
+
<style>
|
|
27
|
+
:host {
|
|
28
|
+
@apply --vertical;
|
|
29
|
+
width: min(500px, 94vw);
|
|
30
|
+
max-height: min(640px, 84vh);
|
|
31
|
+
padding: 16px 18px;
|
|
32
|
+
gap: 12px;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
background: var(--content-background, #ffffff);
|
|
36
|
+
color: var(--content-color, #0f172a);
|
|
37
|
+
font-size: 13.5px;
|
|
38
|
+
}
|
|
39
|
+
.field {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 4px;
|
|
43
|
+
}
|
|
44
|
+
.field label {
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
color: var(--muted-color, #64748b);
|
|
48
|
+
}
|
|
49
|
+
.field input, .field select, .field textarea {
|
|
50
|
+
padding: 8px 10px;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
53
|
+
background: var(--content-background, #fff);
|
|
54
|
+
color: var(--content-color, #0f172a);
|
|
55
|
+
font: inherit;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
.tabs {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
gap: 6px;
|
|
63
|
+
}
|
|
64
|
+
.tab-btn {
|
|
65
|
+
padding: 6px 10px;
|
|
66
|
+
border-radius: 8px;
|
|
67
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
68
|
+
background: var(--subtle-background, #f8fafc);
|
|
69
|
+
color: inherit;
|
|
70
|
+
font: inherit;
|
|
71
|
+
font-size: 12.5px;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
}
|
|
75
|
+
.tab-btn.active {
|
|
76
|
+
background: var(--accent-color, #2563eb);
|
|
77
|
+
color: #ffffff;
|
|
78
|
+
border-color: transparent;
|
|
79
|
+
}
|
|
80
|
+
.existing-box {
|
|
81
|
+
padding: 10px 12px;
|
|
82
|
+
border-radius: 10px;
|
|
83
|
+
border: 1px solid rgba(16, 185, 129, 0.4);
|
|
84
|
+
background: rgba(16, 185, 129, 0.08);
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 8px;
|
|
88
|
+
}
|
|
89
|
+
.result-box {
|
|
90
|
+
padding: 10px 12px;
|
|
91
|
+
border-radius: 10px;
|
|
92
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
93
|
+
background: var(--subtle-background, #f8fafc);
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
}
|
|
98
|
+
.url-line {
|
|
99
|
+
word-break: break-all;
|
|
100
|
+
font-family: monospace;
|
|
101
|
+
font-size: 12px;
|
|
102
|
+
padding: 6px 8px;
|
|
103
|
+
border-radius: 6px;
|
|
104
|
+
background: var(--content-background, #fff);
|
|
105
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
106
|
+
}
|
|
107
|
+
.row-btns {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
}
|
|
113
|
+
.inv-list {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: 6px;
|
|
117
|
+
border-top: 1px solid var(--subtle-border, #e2e8f0);
|
|
118
|
+
padding-top: 10px;
|
|
119
|
+
}
|
|
120
|
+
.inv-item {
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 8px;
|
|
124
|
+
padding: 6px 8px;
|
|
125
|
+
border-radius: 8px;
|
|
126
|
+
border: 1px solid var(--subtle-border, #e2e8f0);
|
|
127
|
+
font-size: 12.5px;
|
|
128
|
+
}
|
|
129
|
+
.warn {
|
|
130
|
+
color: #b45309;
|
|
131
|
+
font-size: 12.5px;
|
|
132
|
+
}
|
|
133
|
+
.err {
|
|
134
|
+
color: #dc2626;
|
|
135
|
+
font-size: 12.5px;
|
|
136
|
+
}
|
|
137
|
+
.ok {
|
|
138
|
+
color: #059669;
|
|
139
|
+
font-size: 12.5px;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
143
|
+
|
|
144
|
+
<div class="field">
|
|
145
|
+
<label>Рабочее место в «{{$item?.DATA?.label || $item?.label || $item?.id}}»</label>
|
|
146
|
+
<select ::value="trail">
|
|
147
|
+
<option ~for="placeOptions" :value="$for.item.trail">{{$for.item.label}}</option>
|
|
148
|
+
</select>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div class="field">
|
|
152
|
+
<label>Способ приглашения</label>
|
|
153
|
+
<div class="tabs">
|
|
154
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'email' }" @tap="setChannel('email')">Email</button>
|
|
155
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'phone' }" @tap="setChannel('phone')">Телефон</button>
|
|
156
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'link' }" @tap="setChannel('link')">Ссылка</button>
|
|
157
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'telegram' }" @tap="setChannel('telegram')">Telegram</button>
|
|
158
|
+
<button type="button" class="tab-btn" ~class="{ active: channel === 'max' }" @tap="setChannel('max')">MAX</button>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<div class="field" ~if="channel !== 'link'">
|
|
163
|
+
<label>{{recipientLabel}}</label>
|
|
164
|
+
<input :type="channel === 'email' ? 'email' : (channel === 'phone' ? 'tel' : 'text')"
|
|
165
|
+
:placeholder="recipientPlaceholder"
|
|
166
|
+
::value="recipient"
|
|
167
|
+
@input="onRecipientInput">
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div ~if="existingUser" class="existing-box">
|
|
171
|
+
<div>
|
|
172
|
+
Пользователь уже зарегистрирован на сервере: <b>{{existingUser.label}}</b>
|
|
173
|
+
<span ~if="existingUser.enabled === false" style="color:#dc2626;"> (отключён)</span>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="row-btns" ~if="existingUser.enabled !== false">
|
|
176
|
+
<oda-button primary icon="icons:check" label="Назначить сразу" @tap="assignExisting" :disabled="busy || !trail"></oda-button>
|
|
177
|
+
<oda-button icon="icons:send" label="Отправить приглашение" @tap="createInvite" :disabled="busy || !trail"></oda-button>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div class="field">
|
|
182
|
+
<label>Комментарий (необязательно)</label>
|
|
183
|
+
<input type="text" placeholder="Например: добро пожаловать в команду" ::value="note">
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div class="row-btns" ~if="!existingUser">
|
|
187
|
+
<oda-button primary icon="icons:person-add" label="Создать и отправить приглашение" @tap="createInvite" :disabled="busy || !trail || (channel !== 'link' && !recipient.trim())"></oda-button>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div ~if="statusOk" class="ok">{{statusOk}}</div>
|
|
191
|
+
<div ~if="errorMsg" class="err">{{errorMsg}}</div>
|
|
192
|
+
|
|
193
|
+
<div ~if="createdResult" class="result-box">
|
|
194
|
+
<div class="ok" ~if="createdResult.sent">Приглашение отправлено ({{createdResult.sentVia}}).</div>
|
|
195
|
+
<div class="warn" ~if="createdResult.warning">{{createdResult.warning}}</div>
|
|
196
|
+
<div class="url-line">{{createdResult.url}}</div>
|
|
197
|
+
<div class="row-btns">
|
|
198
|
+
<oda-button icon="icons:content-copy" label="Копировать ссылку" @tap="copyUrl(createdResult.url)"></oda-button>
|
|
199
|
+
<oda-button ~if="createdResult.shareUrl" icon="icons:share" label="Поделиться в Telegram" @tap="openShare(createdResult.shareUrl)"></oda-button>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div class="inv-list" ~if="activeInvites.length">
|
|
204
|
+
<label style="font-size:12px;font-weight:600;color:var(--muted-color,#64748b);">Активные приглашения ({{activeInvites.length}})</label>
|
|
205
|
+
<div class="inv-item" ~for="activeInvites">
|
|
206
|
+
<div style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">
|
|
207
|
+
<b>{{$for.item.placeLabel}}</b> · {{$for.item.channel}}{{$for.item.recipient ? ': ' + $for.item.recipient : ''}}
|
|
208
|
+
</div>
|
|
209
|
+
<oda-button icon="icons:close" title="Отозвать приглашение" @tap="revokeInvite($for.item)" style="min-height:24px;"></oda-button>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
$item: {
|
|
214
|
+
$def: null,
|
|
215
|
+
set(n) {
|
|
216
|
+
if (n) this.load();
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
placeOptions: [],
|
|
220
|
+
trail: '',
|
|
221
|
+
channel: 'email',
|
|
222
|
+
recipient: '',
|
|
223
|
+
note: '',
|
|
224
|
+
existingUser: null,
|
|
225
|
+
createdResult: null,
|
|
226
|
+
activeInvites: [],
|
|
227
|
+
busy: false,
|
|
228
|
+
statusOk: '',
|
|
229
|
+
errorMsg: '',
|
|
230
|
+
get recipientLabel() {
|
|
231
|
+
if (this.channel === 'email') return 'Email получателя';
|
|
232
|
+
if (this.channel === 'phone') return 'Номер телефона (+79991234567)';
|
|
233
|
+
if (this.channel === 'telegram') return 'Telegram Chat ID (или @username для ссылки)';
|
|
234
|
+
if (this.channel === 'max') return 'MAX Chat ID';
|
|
235
|
+
return 'Получатель';
|
|
236
|
+
},
|
|
237
|
+
get recipientPlaceholder() {
|
|
238
|
+
if (this.channel === 'email') return 'user@company.ru';
|
|
239
|
+
if (this.channel === 'phone') return '+79991234567';
|
|
240
|
+
if (this.channel === 'telegram') return '123456789';
|
|
241
|
+
if (this.channel === 'max') return 'chat_id';
|
|
242
|
+
return '';
|
|
243
|
+
},
|
|
244
|
+
attached() {
|
|
245
|
+
if (this.$item) this.load();
|
|
246
|
+
},
|
|
247
|
+
setChannel(ch) {
|
|
248
|
+
this.channel = ch;
|
|
249
|
+
this.existingUser = null;
|
|
250
|
+
this.createdResult = null;
|
|
251
|
+
this.errorMsg = '';
|
|
252
|
+
this.statusOk = '';
|
|
253
|
+
},
|
|
254
|
+
onRecipientInput() {
|
|
255
|
+
this.existingUser = null;
|
|
256
|
+
this.statusOk = '';
|
|
257
|
+
this.errorMsg = '';
|
|
258
|
+
clearTimeout(this._lookupTimer);
|
|
259
|
+
if (this.channel !== 'email' && this.channel !== 'phone')
|
|
260
|
+
return;
|
|
261
|
+
const val = String(this.recipient || '').trim();
|
|
262
|
+
if (!val)
|
|
263
|
+
return;
|
|
264
|
+
this._lookupTimer = setTimeout(() => this.lookupExisting(val), 350);
|
|
265
|
+
},
|
|
266
|
+
async lookupExisting(val) {
|
|
267
|
+
if (!this.$item || (this.channel !== 'email' && this.channel !== 'phone'))
|
|
268
|
+
return;
|
|
269
|
+
try {
|
|
270
|
+
const payload = this.channel === 'email' ? { email: val } : { phone: val };
|
|
271
|
+
const res = await this.$item.fetch('invite_lookup_user', {}, payload);
|
|
272
|
+
if (String(this.recipient || '').trim() !== val)
|
|
273
|
+
return;
|
|
274
|
+
this.existingUser = res?.exists ? res : null;
|
|
275
|
+
} catch { /* ignore */ }
|
|
276
|
+
},
|
|
277
|
+
async load() {
|
|
278
|
+
if (!this.$item) return;
|
|
279
|
+
try {
|
|
280
|
+
await this.$item.init?.catch?.(() => {});
|
|
281
|
+
const sec = this.$item.DATA?.['#security'] || {};
|
|
282
|
+
const opts = [];
|
|
283
|
+
if (this.$item.DATA?.allowRoles !== false) {
|
|
284
|
+
flattenRoles(sec.ROLES || [], '', 0, opts);
|
|
285
|
+
}
|
|
286
|
+
opts.push({ trail: 'BOSS', label: 'Руководитель (BOSS)' });
|
|
287
|
+
this.placeOptions = opts;
|
|
288
|
+
if (!this.trail || !opts.some(o => o.trail === this.trail))
|
|
289
|
+
this.trail = opts[0]?.trail || 'BOSS';
|
|
290
|
+
await this.reloadInvites();
|
|
291
|
+
} catch (err) {
|
|
292
|
+
this.errorMsg = err?.message || String(err);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
async reloadInvites() {
|
|
296
|
+
if (!this.$item) return;
|
|
297
|
+
try {
|
|
298
|
+
const list = await this.$item.fetch('invite_list');
|
|
299
|
+
this.activeInvites = (Array.isArray(list) ? list : []).filter(i => i?.status === 'active');
|
|
300
|
+
} catch {
|
|
301
|
+
this.activeInvites = [];
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
async assignExisting() {
|
|
305
|
+
if (!this.$item || !this.existingUser?.uid || !this.trail || this.busy)
|
|
306
|
+
return;
|
|
307
|
+
this.busy = true;
|
|
308
|
+
this.errorMsg = '';
|
|
309
|
+
this.statusOk = '';
|
|
310
|
+
try {
|
|
311
|
+
const res = await this.$item.fetch('invite_assign_existing', {}, {
|
|
312
|
+
uid: this.existingUser.uid,
|
|
313
|
+
trail: this.trail,
|
|
314
|
+
});
|
|
315
|
+
this.statusOk = `Пользователь «${this.existingUser.label}» назначен на «${res?.placeLabel || this.trail}».`;
|
|
316
|
+
this.$item.reset?.();
|
|
317
|
+
this.fire('assigned', res);
|
|
318
|
+
} catch (err) {
|
|
319
|
+
this.errorMsg = err?.message || String(err);
|
|
320
|
+
} finally {
|
|
321
|
+
this.busy = false;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async createInvite() {
|
|
325
|
+
if (!this.$item || !this.trail || this.busy)
|
|
326
|
+
return;
|
|
327
|
+
this.busy = true;
|
|
328
|
+
this.errorMsg = '';
|
|
329
|
+
this.statusOk = '';
|
|
330
|
+
this.createdResult = null;
|
|
331
|
+
try {
|
|
332
|
+
const res = await this.$item.fetch('invite_create', {}, {
|
|
333
|
+
trail: this.trail,
|
|
334
|
+
channel: this.channel,
|
|
335
|
+
recipient: this.channel === 'link' ? '' : String(this.recipient || '').trim(),
|
|
336
|
+
note: String(this.note || '').trim(),
|
|
337
|
+
origin: location.origin,
|
|
338
|
+
});
|
|
339
|
+
this.createdResult = res;
|
|
340
|
+
await this.reloadInvites();
|
|
341
|
+
} catch (err) {
|
|
342
|
+
this.errorMsg = err?.message || String(err);
|
|
343
|
+
} finally {
|
|
344
|
+
this.busy = false;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
async revokeInvite(inv) {
|
|
348
|
+
if (!this.$item || !inv?.id)
|
|
349
|
+
return;
|
|
350
|
+
try {
|
|
351
|
+
await this.$item.fetch('invite_revoke', {}, { id: inv.id });
|
|
352
|
+
await this.reloadInvites();
|
|
353
|
+
} catch (err) {
|
|
354
|
+
this.errorMsg = err?.message || String(err);
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
async copyUrl(url) {
|
|
358
|
+
if (!url) return;
|
|
359
|
+
try {
|
|
360
|
+
await navigator.clipboard.writeText(url);
|
|
361
|
+
this.statusOk = 'Ссылка скопирована в буфер обмена.';
|
|
362
|
+
} catch {
|
|
363
|
+
this.statusOk = 'Скопируйте ссылку из поля выше.';
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
openShare(url) {
|
|
367
|
+
if (url) window.open(url, '_blank', 'noopener');
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
@@ -6,15 +6,12 @@ export default {
|
|
|
6
6
|
justify-content: flex-start;
|
|
7
7
|
@apply --horizontal;
|
|
8
8
|
flex-wrap: wrap;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
|
|
11
9
|
}
|
|
12
10
|
item-node:not(:first-child){
|
|
13
11
|
max-width: 200px;
|
|
14
12
|
}
|
|
15
13
|
div {
|
|
16
14
|
opacity: .9;
|
|
17
|
-
overflow: hidden;
|
|
18
15
|
}
|
|
19
16
|
div:hover {
|
|
20
17
|
opacity: 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.110",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|