odant-work 1.0.103 → 1.0.104
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/$user/handlers/pages/form/system/agent/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/settings/$handler/class.js +292 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +11 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +14 -11
- package/$server/$folder/$file/$html/handlers/preview/$handler/preview.js +7 -0
- package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +11 -0
- package/$server/$folder/$file/$md/handlers/preview/$handler/preview.js +29 -8
- package/$server/$folder/$file/$office/handlers/preview/$handler/preview.js +6 -0
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +34 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +14 -11
- package/$server/$folder/$file/$task/handlers/preview/$handler/preview.js +1 -0
- package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +9 -0
- package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +15 -0
- package/$server/$folder/handlers/pages/form/$handler/class.js +10 -2
- package/$server/$folder/handlers/pages/form/folder/$handler/class.js +523 -25
- package/$server/$folder/lib/explorer/explorer.js +63 -0
- package/$server/$folder/lib/tree/tree.js +45 -14
- package/NODES/$node/handlers/pages/form/network/$handler/class.js +552 -36
- package/oda/components/icon/icon.js +20 -7
- package/package.json +1 -1
- package/sources/client.js +24 -0
- package/sources/host/websocket.js +17 -0
- package/sources/modules/agent/index.js +25 -6
- package/sources/modules/agent/permissions.js +4 -2
- package/sources/modules/agent/scope.js +72 -5
- package/sources/modules/agent/session.js +59 -6
- package/sources/modules/agent/tools/work/classes.js +16 -1
- package/sources/modules/license/index.js +120 -0
- package/sources/modules/nodes/registry.js +57 -7
- package/sources/modules/trainer/local-engine.js +22 -9
- package/sources/modules/user-profile/user-profile.js +0 -129
- package/sources/modules/user-profile/user-tokens.js +426 -85
- package/sources/server/access/gateway.js +1 -0
- package/sources/server/folder.js +5 -1
- package/sources/server/node.js +16 -0
- package/sources/server/server.js +14 -5
- package/sources/server/user.js +3 -0
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* Сеть серверов WORK (/NODES):
|
|
3
|
+
* - поиск публичных и собственных серверов на центре поддержки (work.odant.org) и подключение в 1 клик;
|
|
4
|
+
* - публикация текущего сервера в каталоге сети WORK;
|
|
5
|
+
* - ручное подключение закрытых/LAN серверов по URL со сверкой отпечатка;
|
|
6
|
+
* - список подключённых серверов и интерактивный граф сети.
|
|
4
7
|
*/
|
|
5
8
|
const COLORS = {
|
|
6
9
|
self: '#3f51b5',
|
|
7
|
-
active: '#
|
|
8
|
-
remote: '#
|
|
9
|
-
pending: '#
|
|
10
|
-
key_changed: '#
|
|
11
|
-
id_changed: '#
|
|
10
|
+
active: '#16a34a',
|
|
11
|
+
remote: '#64748b',
|
|
12
|
+
pending: '#d97706',
|
|
13
|
+
key_changed: '#dc2626',
|
|
14
|
+
id_changed: '#dc2626'
|
|
15
|
+
};
|
|
16
|
+
const STATUS_LABELS = {
|
|
17
|
+
self: 'Этот сервер',
|
|
18
|
+
active: 'Активен',
|
|
19
|
+
remote: 'Через соседей',
|
|
20
|
+
pending: 'Ожидает',
|
|
21
|
+
key_changed: 'Ключ изменился',
|
|
22
|
+
id_changed: 'ID изменился'
|
|
12
23
|
};
|
|
13
24
|
function esc(s) {
|
|
14
25
|
return String(s ?? '').replace(/[&<>"']/g, c => ({
|
|
@@ -44,7 +55,7 @@ function render(graph) {
|
|
|
44
55
|
const lines = graph.edges.map(e => {
|
|
45
56
|
const a = pos.get(e.from),
|
|
46
57
|
b = pos.get(e.to);
|
|
47
|
-
return a && b ? `<line x1="${a.x}" y1="${a.y}" x2="${b.x}" y2="${b.y}" stroke="#
|
|
58
|
+
return a && b ? `<line x1="${a.x}" y1="${a.y}" x2="${b.x}" y2="${b.y}" stroke="#94a3b8" stroke-width="1.5"/>` : '';
|
|
48
59
|
}).join('');
|
|
49
60
|
const nodes = graph.nodes.map(n => {
|
|
50
61
|
const p = pos.get(n.id);
|
|
@@ -53,31 +64,232 @@ function render(graph) {
|
|
|
53
64
|
const title = [n.label, n.origin, 'id ' + n.id, n.status, n.error].filter(Boolean).map(esc).join('\n');
|
|
54
65
|
return `<g><title>${title}</title>` + `<circle cx="${p.x}" cy="${p.y}" r="${r}" fill="${color}" stroke="#fff" stroke-width="2"/>` + `<text x="${p.x}" y="${p.y + r + 14}" text-anchor="middle" font-size="12" fill="currentColor">${esc(n.label)}</text></g>`;
|
|
55
66
|
}).join('');
|
|
56
|
-
return `<svg viewBox="0 0 ${size} ${size}" width="100%" style="max-height:
|
|
67
|
+
return `<svg viewBox="0 0 ${size} ${size}" width="100%" style="max-height: 460px;">${lines}${nodes}</svg>`;
|
|
57
68
|
}
|
|
58
69
|
export default {
|
|
59
70
|
icon: 'carbon:network-3',
|
|
60
71
|
label: 'Сеть',
|
|
61
72
|
component: {
|
|
73
|
+
imports: 'oda//icon, oda//button',
|
|
62
74
|
template: /* html */`
|
|
63
75
|
<style>
|
|
64
76
|
:host {
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
flex: 1;
|
|
80
|
+
min-height: 0;
|
|
67
81
|
overflow: auto;
|
|
68
|
-
padding:
|
|
82
|
+
padding: 20px 24px 32px;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
background: var(--content-background, #ffffff);
|
|
85
|
+
color: var(--content-color, #1f2937);
|
|
86
|
+
font-family: var(--font-family, system-ui, -apple-system, sans-serif);
|
|
87
|
+
}
|
|
88
|
+
.page {
|
|
89
|
+
width: min(1040px, 100%);
|
|
90
|
+
margin: 0 auto;
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 16px;
|
|
94
|
+
}
|
|
95
|
+
.header {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: flex-start;
|
|
98
|
+
justify-content: space-between;
|
|
99
|
+
gap: 12px;
|
|
100
|
+
flex-wrap: wrap;
|
|
101
|
+
}
|
|
102
|
+
.title-row {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: 12px;
|
|
106
|
+
}
|
|
107
|
+
.title-ico {
|
|
108
|
+
width: 40px;
|
|
109
|
+
height: 40px;
|
|
110
|
+
border-radius: 10px;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 14%, transparent);
|
|
115
|
+
color: var(--accent-color, #2563eb);
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
}
|
|
118
|
+
h2 {
|
|
119
|
+
margin: 0;
|
|
120
|
+
font-size: 18px;
|
|
121
|
+
font-weight: 700;
|
|
122
|
+
}
|
|
123
|
+
.subtitle {
|
|
124
|
+
margin: 3px 0 0;
|
|
125
|
+
font-size: 13px;
|
|
126
|
+
opacity: 0.75;
|
|
127
|
+
}
|
|
128
|
+
.card {
|
|
129
|
+
border: 1px solid var(--subtle-border, var(--border-color, rgba(128, 128, 128, 0.25)));
|
|
130
|
+
border-radius: 12px;
|
|
131
|
+
background: var(--subtle-background, rgba(128, 128, 128, 0.03));
|
|
132
|
+
padding: 16px;
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
gap: 12px;
|
|
136
|
+
}
|
|
137
|
+
.card-head {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: space-between;
|
|
141
|
+
gap: 10px;
|
|
142
|
+
flex-wrap: wrap;
|
|
143
|
+
}
|
|
144
|
+
.card-head h3 {
|
|
145
|
+
margin: 0;
|
|
146
|
+
font-size: 15px;
|
|
147
|
+
font-weight: 600;
|
|
148
|
+
}
|
|
149
|
+
.row {
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
gap: 8px;
|
|
153
|
+
flex-wrap: wrap;
|
|
154
|
+
}
|
|
155
|
+
.input {
|
|
156
|
+
flex: 1 1 240px;
|
|
157
|
+
min-width: 180px;
|
|
158
|
+
padding: 9px 12px;
|
|
159
|
+
border-radius: 8px;
|
|
160
|
+
border: 1px solid var(--control-border-color, var(--border-color, #cbd5e1));
|
|
161
|
+
background: var(--content-background, #ffffff);
|
|
162
|
+
color: var(--content-color, #1f2937);
|
|
163
|
+
font: inherit;
|
|
164
|
+
font-size: 13.5px;
|
|
165
|
+
box-sizing: border-box;
|
|
69
166
|
}
|
|
70
|
-
.
|
|
167
|
+
.btn {
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
gap: 6px;
|
|
172
|
+
min-height: 36px;
|
|
173
|
+
padding: 0 14px;
|
|
174
|
+
border-radius: 8px;
|
|
175
|
+
border: 1px solid var(--control-border-color, var(--border-color, #cbd5e1));
|
|
176
|
+
background: var(--content-background, #ffffff);
|
|
177
|
+
color: var(--content-color, #1f2937);
|
|
178
|
+
font: inherit;
|
|
179
|
+
font-size: 13.5px;
|
|
180
|
+
font-weight: 600;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
white-space: nowrap;
|
|
183
|
+
}
|
|
184
|
+
.btn:hover:not(:disabled) {
|
|
185
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 7%, var(--content-background, #ffffff));
|
|
186
|
+
}
|
|
187
|
+
.btn:disabled {
|
|
188
|
+
opacity: 0.55;
|
|
189
|
+
cursor: not-allowed;
|
|
190
|
+
}
|
|
191
|
+
.btn-primary {
|
|
192
|
+
background: var(--accent-color, #2563eb);
|
|
193
|
+
border-color: var(--accent-color, #2563eb);
|
|
194
|
+
color: #ffffff;
|
|
195
|
+
}
|
|
196
|
+
.btn-primary:hover:not(:disabled) {
|
|
197
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 88%, #000000);
|
|
198
|
+
}
|
|
199
|
+
.btn-sm {
|
|
200
|
+
min-height: 30px;
|
|
201
|
+
padding: 0 10px;
|
|
202
|
+
font-size: 12.5px;
|
|
203
|
+
}
|
|
204
|
+
.grid {
|
|
205
|
+
display: grid;
|
|
206
|
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
207
|
+
gap: 10px;
|
|
208
|
+
}
|
|
209
|
+
.node-card {
|
|
210
|
+
border: 1px solid var(--subtle-border, var(--border-color, rgba(128, 128, 128, 0.24)));
|
|
211
|
+
border-radius: 10px;
|
|
212
|
+
background: var(--content-background, #ffffff);
|
|
213
|
+
padding: 12px 14px;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
71
216
|
gap: 8px;
|
|
217
|
+
}
|
|
218
|
+
.node-top {
|
|
219
|
+
display: flex;
|
|
220
|
+
align-items: flex-start;
|
|
221
|
+
justify-content: space-between;
|
|
222
|
+
gap: 8px;
|
|
223
|
+
}
|
|
224
|
+
.node-title {
|
|
225
|
+
font-weight: 600;
|
|
226
|
+
font-size: 14px;
|
|
227
|
+
}
|
|
228
|
+
.node-meta {
|
|
229
|
+
font-size: 12.5px;
|
|
230
|
+
opacity: 0.76;
|
|
231
|
+
line-height: 1.4;
|
|
232
|
+
word-break: break-word;
|
|
233
|
+
}
|
|
234
|
+
.mono {
|
|
235
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
236
|
+
font-size: 11.5px;
|
|
237
|
+
}
|
|
238
|
+
.badge {
|
|
239
|
+
display: inline-flex;
|
|
72
240
|
align-items: center;
|
|
73
|
-
padding
|
|
241
|
+
padding: 2px 8px;
|
|
242
|
+
border-radius: 999px;
|
|
243
|
+
font-size: 11.5px;
|
|
244
|
+
font-weight: 600;
|
|
245
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 12%, transparent);
|
|
246
|
+
color: var(--accent-color, #2563eb);
|
|
247
|
+
white-space: nowrap;
|
|
248
|
+
}
|
|
249
|
+
.badge.ok {
|
|
250
|
+
background: rgba(22, 163, 74, 0.14);
|
|
251
|
+
color: #15803d;
|
|
252
|
+
}
|
|
253
|
+
.badge.warn {
|
|
254
|
+
background: rgba(217, 119, 6, 0.14);
|
|
255
|
+
color: #b45309;
|
|
256
|
+
}
|
|
257
|
+
.badge.bad {
|
|
258
|
+
background: rgba(220, 38, 38, 0.14);
|
|
259
|
+
color: #dc2626;
|
|
260
|
+
}
|
|
261
|
+
.notice {
|
|
262
|
+
padding: 9px 12px;
|
|
263
|
+
border-radius: 8px;
|
|
264
|
+
font-size: 13px;
|
|
265
|
+
font-weight: 500;
|
|
266
|
+
background: rgba(16, 185, 129, 0.12);
|
|
267
|
+
color: #047857;
|
|
268
|
+
}
|
|
269
|
+
.notice[error] {
|
|
270
|
+
background: rgba(220, 38, 38, 0.1);
|
|
271
|
+
color: var(--error-color, #dc2626);
|
|
272
|
+
}
|
|
273
|
+
.confirm-box {
|
|
274
|
+
border: 1px solid #d97706;
|
|
275
|
+
border-radius: 10px;
|
|
276
|
+
background: color-mix(in srgb, #f59e0b 8%, var(--content-background, #ffffff));
|
|
277
|
+
padding: 12px 14px;
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-direction: column;
|
|
280
|
+
gap: 8px;
|
|
281
|
+
}
|
|
282
|
+
.legend {
|
|
283
|
+
display: flex;
|
|
284
|
+
flex-wrap: wrap;
|
|
285
|
+
gap: 12px;
|
|
286
|
+
font-size: 12.5px;
|
|
287
|
+
opacity: 0.85;
|
|
74
288
|
}
|
|
75
289
|
.legend span {
|
|
76
290
|
display: inline-flex;
|
|
77
291
|
align-items: center;
|
|
78
|
-
gap:
|
|
79
|
-
margin-right: 12px;
|
|
80
|
-
font-size: small;
|
|
292
|
+
gap: 5px;
|
|
81
293
|
}
|
|
82
294
|
.legend i {
|
|
83
295
|
width: 10px;
|
|
@@ -86,37 +298,341 @@ export default {
|
|
|
86
298
|
display: inline-block;
|
|
87
299
|
}
|
|
88
300
|
.empty {
|
|
89
|
-
padding:
|
|
90
|
-
opacity: .
|
|
301
|
+
padding: 20px;
|
|
302
|
+
opacity: .68;
|
|
91
303
|
text-align: center;
|
|
304
|
+
font-size: 13.5px;
|
|
92
305
|
}
|
|
93
306
|
</style>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
307
|
+
|
|
308
|
+
<div class="page">
|
|
309
|
+
<div class="header">
|
|
310
|
+
<div class="title-row">
|
|
311
|
+
<div class="title-ico">
|
|
312
|
+
<oda-icon icon="carbon:network-3" icon-size="22"></oda-icon>
|
|
313
|
+
</div>
|
|
314
|
+
<div>
|
|
315
|
+
<h2>Сеть серверов WORK</h2>
|
|
316
|
+
<p class="subtitle">Поиск организаций и серверов через {{hubHostLabel}}, безопасное подключение и граф федерации.</p>
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
<div class="row" ~if="isBoss">
|
|
320
|
+
<span class="badge" :class="selfPublished ? 'ok' : ''">{{selfPublished ? 'Опубликован в каталоге' : 'Скрыт из каталога'}}</span>
|
|
321
|
+
<button class="btn btn-sm" :disabled="publishing" @tap="togglePublish">
|
|
322
|
+
{{publishing ? 'Сохраняю…' : (selfPublished ? 'Скрыть из каталога' : 'Опубликовать сервер')}}
|
|
323
|
+
</button>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<div ~if="notice" class="notice" :error="!!noticeError">{{notice}}</div>
|
|
328
|
+
|
|
329
|
+
<div class="card" ~if="isBoss">
|
|
330
|
+
<div class="card-head">
|
|
331
|
+
<h3>Поиск серверов на сервере поддержки ({{hubHostLabel}})</h3>
|
|
332
|
+
<span class="badge" ~if="publicOrigin">Наш адрес: {{publicOrigin}}</span>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="row">
|
|
335
|
+
<input class="input" type="text" placeholder="Название организации, ИНН, имя сервера, домен или ID узла" ::value="searchQuery" @keydown.enter="discover">
|
|
336
|
+
<button class="btn btn-primary" :disabled="discovering" @tap="discover">
|
|
337
|
+
<oda-icon icon="icons:search" icon-size="16"></oda-icon>
|
|
338
|
+
<span>{{discovering ? 'Поиск…' : 'Найти'}}</span>
|
|
339
|
+
</button>
|
|
340
|
+
</div>
|
|
341
|
+
<div ~if="discoverError" class="notice" error>{{discoverError}}</div>
|
|
342
|
+
<div ~if="!discovering && !discoverError && !discovered.length" class="empty">
|
|
343
|
+
Подходящие серверы в каталоге не найдены. Вы можете подключить сервер напрямую по адресу ниже.
|
|
344
|
+
</div>
|
|
345
|
+
<div class="grid" ~if="discovered.length">
|
|
346
|
+
<div class="node-card" ~for="discovered">
|
|
347
|
+
<div class="node-top">
|
|
348
|
+
<div class="node-title">{{$for.item.serverName || $for.item.companyName || $for.item.serverId}}</div>
|
|
349
|
+
<span class="badge ok" ~if="$for.item.connected">Подключён</span>
|
|
350
|
+
<span class="badge" ~if="!$for.item.connected && $for.item.own">Ваш сервер</span>
|
|
351
|
+
<span class="badge" ~if="!$for.item.connected && !$for.item.own && $for.item.discoverable">Публичный</span>
|
|
352
|
+
</div>
|
|
353
|
+
<div class="node-meta">
|
|
354
|
+
<div ~if="$for.item.companyName">{{$for.item.companyName}}<span ~if="$for.item.inn"> · ИНН {{$for.item.inn}}</span></div>
|
|
355
|
+
<div ~if="$for.item.origin">{{$for.item.origin}}</div>
|
|
356
|
+
<div class="mono" ~if="$for.item.fingerprint">Отпечаток: {{$for.item.fingerprint}}</div>
|
|
357
|
+
</div>
|
|
358
|
+
<div class="row" style="justify-content:flex-end; margin-top:auto;">
|
|
359
|
+
<button ~if="$for.item.connected && $for.item.nodePath" class="btn btn-sm" @tap="openNode($for.item.nodePath)">Открыть</button>
|
|
360
|
+
<button ~if="!$for.item.connected" class="btn btn-sm btn-primary" :disabled="!$for.item.origin || connectingOrigin === $for.item.origin" @tap="connectCatalog($for.item)">
|
|
361
|
+
{{connectingOrigin === $for.item.origin ? 'Подключаю…' : 'Подключить'}}
|
|
362
|
+
</button>
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
<div class="card" ~if="isBoss">
|
|
369
|
+
<div class="card-head">
|
|
370
|
+
<h3>Подключить сервер по прямому адресу (URL)</h3>
|
|
371
|
+
</div>
|
|
372
|
+
<div class="row">
|
|
373
|
+
<input class="input" type="text" placeholder="https://work.company.ru или http://192.168.1.50:8001" ::value="manualOrigin" @keydown.enter="previewManual">
|
|
374
|
+
<input class="input" style="max-width:240px;" type="text" placeholder="Название (необязательно)" ::value="manualLabel">
|
|
375
|
+
<button class="btn" :disabled="!manualOrigin || manualBusy" @tap="previewManual">
|
|
376
|
+
{{manualBusy ? 'Проверка…' : 'Проверить узел'}}
|
|
377
|
+
</button>
|
|
378
|
+
</div>
|
|
379
|
+
<div class="confirm-box" ~if="pendingConfirm">
|
|
380
|
+
<div style="font-weight:600; font-size:13.5px;">
|
|
381
|
+
{{pendingConfirm.fingerprintMismatch ? 'Внимание: отпечаток ключа отличается от каталога!' : 'Подтвердите подключение узла'}}
|
|
382
|
+
</div>
|
|
383
|
+
<div class="node-meta">
|
|
384
|
+
<div><b>{{pendingConfirm.card.label}}</b> ({{pendingConfirm.card.origin}})</div>
|
|
385
|
+
<div class="mono">ID: {{pendingConfirm.card.id}} · Отпечаток: {{pendingConfirm.card.fingerprint}}</div>
|
|
386
|
+
</div>
|
|
387
|
+
<div class="row">
|
|
388
|
+
<button class="btn btn-sm btn-primary" :disabled="manualBusy" @tap="confirmManual">Подтвердить и подключить</button>
|
|
389
|
+
<button class="btn btn-sm" @tap="pendingConfirm = null">Отмена</button>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
|
|
394
|
+
<div class="card">
|
|
395
|
+
<div class="card-head">
|
|
396
|
+
<h3>Подключённые узлы ({{connectedNodes.length}})</h3>
|
|
397
|
+
<button class="btn btn-sm" @tap="reloadGraph">
|
|
398
|
+
<oda-icon icon="icons:refresh" icon-size="15"></oda-icon>
|
|
399
|
+
<span>Обновить</span>
|
|
400
|
+
</button>
|
|
401
|
+
</div>
|
|
402
|
+
<div ~if="!connectedNodes.length" class="empty">Подключённых внешних серверов пока нет.</div>
|
|
403
|
+
<div class="grid" ~if="connectedNodes.length">
|
|
404
|
+
<div class="node-card" ~for="connectedNodes">
|
|
405
|
+
<div class="node-top">
|
|
406
|
+
<div class="node-title">{{$for.item.label || $for.item.id}}</div>
|
|
407
|
+
<span class="badge" :class="$for.item.statusClass">{{$for.item.statusText}}</span>
|
|
408
|
+
</div>
|
|
409
|
+
<div class="node-meta">
|
|
410
|
+
<div ~if="$for.item.origin">{{$for.item.origin}}</div>
|
|
411
|
+
<div class="mono">ID: {{$for.item.id}}</div>
|
|
412
|
+
<div ~if="$for.item.error" style="color:var(--error-color, #dc2626);">{{$for.item.error}}</div>
|
|
413
|
+
</div>
|
|
414
|
+
<div class="row" style="justify-content:flex-end; margin-top:auto;">
|
|
415
|
+
<button ~if="isBoss && $for.item.path" class="btn btn-sm" @tap="refreshOne($for.item.path)">Проверить связь</button>
|
|
416
|
+
<button ~if="$for.item.path" class="btn btn-sm" @tap="openNode($for.item.path)">Открыть</button>
|
|
417
|
+
</div>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
<div class="card">
|
|
423
|
+
<div class="card-head">
|
|
424
|
+
<h3>Граф сети WORK</h3>
|
|
425
|
+
<div class="row">
|
|
426
|
+
<label style="font-size:13px;">Глубина
|
|
427
|
+
<select ::value="depth" style="padding:4px 8px; border-radius:6px; border:1px solid var(--border-color, #cbd5e1); background:var(--content-background); color:var(--content-color);">
|
|
428
|
+
<option value="1">1</option>
|
|
429
|
+
<option value="2">2</option>
|
|
430
|
+
<option value="3">3</option>
|
|
431
|
+
</select>
|
|
432
|
+
</label>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
<div class="legend">
|
|
436
|
+
<span><i style="background:#3f51b5"></i>наш сервер</span>
|
|
437
|
+
<span><i style="background:#16a34a"></i>активен</span>
|
|
438
|
+
<span><i style="background:#64748b"></i>через соседей</span>
|
|
439
|
+
<span><i style="background:#d97706"></i>ожидает</span>
|
|
440
|
+
<span><i style="background:#dc2626"></i>ключ изменился</span>
|
|
441
|
+
</div>
|
|
442
|
+
<div ~html="svgHtml"></div>
|
|
103
443
|
</div>
|
|
104
444
|
</div>
|
|
105
|
-
<div flex ~html="svg"></div>
|
|
106
445
|
`,
|
|
446
|
+
$item: null,
|
|
107
447
|
depth: {
|
|
108
448
|
$def: 2,
|
|
109
449
|
set() {
|
|
110
|
-
this.
|
|
450
|
+
this.reloadGraph();
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
isBoss: false,
|
|
454
|
+
hubUrl: 'https://work.odant.org',
|
|
455
|
+
publicOrigin: '',
|
|
456
|
+
selfPublished: false,
|
|
457
|
+
searchQuery: '',
|
|
458
|
+
discovered: [],
|
|
459
|
+
discovering: false,
|
|
460
|
+
discoverError: '',
|
|
461
|
+
connectingOrigin: '',
|
|
462
|
+
manualOrigin: '',
|
|
463
|
+
manualLabel: '',
|
|
464
|
+
manualBusy: false,
|
|
465
|
+
pendingConfirm: null,
|
|
466
|
+
publishing: false,
|
|
467
|
+
notice: '',
|
|
468
|
+
noticeError: false,
|
|
469
|
+
connectedNodes: [],
|
|
470
|
+
svgHtml: '<div class="empty">Загрузка графа…</div>',
|
|
471
|
+
get hubHostLabel() {
|
|
472
|
+
try {
|
|
473
|
+
return new URL(this.hubUrl || 'https://work.odant.org').host;
|
|
474
|
+
} catch {
|
|
475
|
+
return 'work.odant.org';
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
attached() {
|
|
479
|
+
this._initAll();
|
|
480
|
+
},
|
|
481
|
+
async _initAll() {
|
|
482
|
+
try {
|
|
483
|
+
const roles = await WORK?.roles?.().catch(() => []);
|
|
484
|
+
this.isBoss = Boolean(WORK?.DEV_MODE || (Array.isArray(roles) && roles.includes('BOSS')));
|
|
485
|
+
} catch {
|
|
486
|
+
this.isBoss = Boolean(WORK?.DEV_MODE);
|
|
487
|
+
}
|
|
488
|
+
await this.reloadGraph();
|
|
489
|
+
if (this.isBoss) {
|
|
490
|
+
await this.discover();
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
setNotice(text, isError = false) {
|
|
494
|
+
this.notice = String(text || '');
|
|
495
|
+
this.noticeError = Boolean(isError);
|
|
496
|
+
},
|
|
497
|
+
async reloadGraph() {
|
|
498
|
+
try {
|
|
499
|
+
const graph = await this.$item?.fetch?.('network_graph', { depth: this.depth });
|
|
500
|
+
this.svgHtml = render(graph);
|
|
501
|
+
const nodes = (graph?.nodes || []).filter(n => !n.self && n.known);
|
|
502
|
+
this.connectedNodes = nodes.map(n => ({
|
|
503
|
+
...n,
|
|
504
|
+
statusText: STATUS_LABELS[n.status] || n.status || 'Подключён',
|
|
505
|
+
statusClass: n.status === 'active' ? 'ok' : (n.status === 'key_changed' || n.status === 'id_changed') ? 'bad' : 'warn'
|
|
506
|
+
}));
|
|
507
|
+
} catch (e) {
|
|
508
|
+
this.svgHtml = '<div class="empty">' + esc(e?.message || e) + '</div>';
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
async discover() {
|
|
512
|
+
if (!this.isBoss || !this.$item?.fetch) return;
|
|
513
|
+
this.discovering = true;
|
|
514
|
+
this.discoverError = '';
|
|
515
|
+
try {
|
|
516
|
+
const res = await this.$item.fetch('network_discover', { query: this.searchQuery || '' });
|
|
517
|
+
if (res?.hubUrl) this.hubUrl = res.hubUrl;
|
|
518
|
+
this.publicOrigin = res?.publicOrigin || '';
|
|
519
|
+
this.selfPublished = Boolean(res?.selfPublished);
|
|
520
|
+
this.discovered = Array.isArray(res?.items) ? res.items : [];
|
|
521
|
+
} catch (e) {
|
|
522
|
+
this.discoverError = e?.message || String(e || '');
|
|
523
|
+
} finally {
|
|
524
|
+
this.discovering = false;
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
async togglePublish() {
|
|
528
|
+
if (this.publishing || !this.$item?.fetch) return;
|
|
529
|
+
const next = !this.selfPublished;
|
|
530
|
+
let publicOrigin = this.publicOrigin;
|
|
531
|
+
if (next && !publicOrigin) {
|
|
532
|
+
publicOrigin = prompt('Укажите публичный URL этого сервера (например https://work.company.ru), по которому к нему будут подключаться другие серверы WORK:', location.origin) || '';
|
|
533
|
+
if (!publicOrigin.trim()) return;
|
|
534
|
+
}
|
|
535
|
+
this.publishing = true;
|
|
536
|
+
this.setNotice('');
|
|
537
|
+
try {
|
|
538
|
+
const res = await this.$item.fetch('network_publish', {}, {
|
|
539
|
+
discoverable: next,
|
|
540
|
+
...(publicOrigin ? { publicOrigin: publicOrigin.trim() } : {})
|
|
541
|
+
});
|
|
542
|
+
this.selfPublished = Boolean(res?.discoverable);
|
|
543
|
+
if (res?.origin) this.publicOrigin = res.origin;
|
|
544
|
+
this.setNotice(this.selfPublished ? 'Сервер опубликован в каталоге сети WORK' : 'Сервер скрыт из каталога сети WORK');
|
|
545
|
+
} catch (e) {
|
|
546
|
+
this.setNotice(e?.message || String(e || ''), true);
|
|
547
|
+
} finally {
|
|
548
|
+
this.publishing = false;
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
async connectCatalog(srv) {
|
|
552
|
+
if (!srv?.origin || this.connectingOrigin) return;
|
|
553
|
+
this.connectingOrigin = srv.origin;
|
|
554
|
+
this.setNotice('');
|
|
555
|
+
try {
|
|
556
|
+
const res = await this.$item.fetch('node_add', {}, {
|
|
557
|
+
origin: srv.origin,
|
|
558
|
+
fingerprint: srv.fingerprint || '',
|
|
559
|
+
label: srv.serverName || srv.companyName || ''
|
|
560
|
+
});
|
|
561
|
+
if (res?.confirm) {
|
|
562
|
+
this.pendingConfirm = res;
|
|
563
|
+
} else {
|
|
564
|
+
this.setNotice(`Сервер «${srv.serverName || srv.origin}» подключён`);
|
|
565
|
+
await Promise.all([this.reloadGraph(), this.discover()]);
|
|
566
|
+
}
|
|
567
|
+
} catch (e) {
|
|
568
|
+
this.setNotice(e?.message || String(e || ''), true);
|
|
569
|
+
} finally {
|
|
570
|
+
this.connectingOrigin = '';
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
async previewManual() {
|
|
574
|
+
const origin = String(this.manualOrigin || '').trim();
|
|
575
|
+
if (!origin || this.manualBusy) return;
|
|
576
|
+
this.manualBusy = true;
|
|
577
|
+
this.setNotice('');
|
|
578
|
+
this.pendingConfirm = null;
|
|
579
|
+
try {
|
|
580
|
+
const res = await this.$item.fetch('node_add', {}, {
|
|
581
|
+
origin,
|
|
582
|
+
label: String(this.manualLabel || '').trim()
|
|
583
|
+
});
|
|
584
|
+
if (res?.confirm) {
|
|
585
|
+
this.pendingConfirm = res;
|
|
586
|
+
} else if (res?.added) {
|
|
587
|
+
this.manualOrigin = '';
|
|
588
|
+
this.manualLabel = '';
|
|
589
|
+
this.setNotice('Сервер подключён: ' + res.added);
|
|
590
|
+
await Promise.all([this.reloadGraph(), this.discover()]);
|
|
591
|
+
}
|
|
592
|
+
} catch (e) {
|
|
593
|
+
this.setNotice(e?.message || String(e || ''), true);
|
|
594
|
+
} finally {
|
|
595
|
+
this.manualBusy = false;
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
async confirmManual() {
|
|
599
|
+
const card = this.pendingConfirm?.card;
|
|
600
|
+
if (!card || this.manualBusy) return;
|
|
601
|
+
this.manualBusy = true;
|
|
602
|
+
try {
|
|
603
|
+
const res = await this.$item.fetch('node_add', {}, {
|
|
604
|
+
origin: card.origin,
|
|
605
|
+
fingerprint: card.fingerprint,
|
|
606
|
+
label: String(this.manualLabel || '').trim() || card.label
|
|
607
|
+
});
|
|
608
|
+
this.pendingConfirm = null;
|
|
609
|
+
this.manualOrigin = '';
|
|
610
|
+
this.manualLabel = '';
|
|
611
|
+
this.setNotice('Сервер подключён: ' + (res?.added || card.origin));
|
|
612
|
+
await Promise.all([this.reloadGraph(), this.discover()]);
|
|
613
|
+
} catch (e) {
|
|
614
|
+
this.setNotice(e?.message || String(e || ''), true);
|
|
615
|
+
} finally {
|
|
616
|
+
this.manualBusy = false;
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
async refreshOne(nodePath) {
|
|
620
|
+
try {
|
|
621
|
+
const item = await WORK.get_item(nodePath);
|
|
622
|
+
await item?.fetch?.('node_refresh');
|
|
623
|
+
this.setNotice('Карточка узла обновлена');
|
|
624
|
+
await this.reloadGraph();
|
|
625
|
+
} catch (e) {
|
|
626
|
+
this.setNotice(e?.message || String(e || ''), true);
|
|
111
627
|
}
|
|
112
628
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
629
|
+
async openNode(nodePath) {
|
|
630
|
+
const item = await WORK.get_item(nodePath).catch(() => null);
|
|
631
|
+
if (item && typeof window.execute === 'function')
|
|
632
|
+
window.execute(item);
|
|
117
633
|
},
|
|
118
634
|
reload() {
|
|
119
|
-
this.
|
|
635
|
+
this.reloadGraph();
|
|
120
636
|
}
|
|
121
637
|
}
|
|
122
638
|
};
|