create-expo-updates-server 0.1.6 → 0.2.0
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/dist/template/.dockerignore +16 -0
- package/dist/template/README.md +51 -660
- package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
- package/dist/template/app/api/admin/device-targets/route.ts +91 -0
- package/dist/template/app/api/admin/devices/route.test.ts +41 -0
- package/dist/template/app/api/admin/devices/route.ts +15 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
- package/dist/template/app/api/device-heartbeat/route.ts +2 -0
- package/dist/template/app/globals.css +114 -15
- package/dist/template/app/layout.tsx +12 -4
- package/dist/template/app/login/page.tsx +22 -18
- package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
- package/dist/template/app/updates/devices/page.tsx +264 -0
- package/dist/template/app/updates/embedded/page.tsx +102 -68
- package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
- package/dist/template/app/updates/layout.tsx +6 -1
- package/dist/template/app/updates/page.tsx +262 -212
- package/dist/template/components/admin/admin-shell.tsx +196 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -0
- package/dist/template/components/admin/theme-provider.tsx +15 -0
- package/dist/template/components/ui/alert.tsx +65 -0
- package/dist/template/components/ui/badge.tsx +47 -0
- package/dist/template/components/ui/button.tsx +63 -0
- package/dist/template/components/ui/card.tsx +91 -0
- package/dist/template/components/ui/chart.tsx +373 -0
- package/dist/template/components/ui/checkbox.tsx +31 -0
- package/dist/template/components/ui/dialog.tsx +158 -0
- package/dist/template/components/ui/dropdown-menu.tsx +256 -0
- package/dist/template/components/ui/input.tsx +20 -0
- package/dist/template/components/ui/label.tsx +23 -0
- package/dist/template/components/ui/native-select.tsx +61 -0
- package/dist/template/components/ui/popover.tsx +88 -0
- package/dist/template/components/ui/scroll-area.tsx +57 -0
- package/dist/template/components/ui/select.tsx +189 -0
- package/dist/template/components/ui/separator.tsx +27 -0
- package/dist/template/components/ui/sheet.tsx +142 -0
- package/dist/template/components/ui/sidebar.tsx +736 -0
- package/dist/template/components/ui/skeleton.tsx +13 -0
- package/dist/template/components/ui/switch.tsx +34 -0
- package/dist/template/components/ui/table.tsx +115 -0
- package/dist/template/components/ui/tabs.tsx +90 -0
- package/dist/template/components/ui/textarea.tsx +17 -0
- package/dist/template/components/ui/tooltip.tsx +56 -0
- package/dist/template/components.json +22 -0
- package/dist/template/docs/admin-ui.md +35 -0
- package/dist/template/docs/device-targeting.md +129 -0
- package/dist/template/docs/doctor.md +137 -0
- package/dist/template/docs/expo-app-setup.md +174 -47
- package/dist/template/docs/getting-started.md +105 -146
- package/dist/template/docs/getting-started.ru.md +106 -191
- package/dist/template/docs/index.md +14 -33
- package/dist/template/docs/installation-telemetry.md +233 -0
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
- package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
- package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
- package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
- package/dist/template/docs/migrations/schema.sql +868 -6
- package/dist/template/docs/npm-installer.md +15 -30
- package/dist/template/docs/operations-guide.md +87 -0
- package/dist/template/docs/ota-client-lifecycle.md +263 -0
- package/dist/template/docs/ota-update-policy.md +36 -2
- package/dist/template/docs/supabase-setup.md +4 -0
- package/dist/template/hooks/use-mobile.ts +21 -0
- package/dist/template/lib/utils.ts +6 -0
- package/dist/template/package-lock.json +2325 -101
- package/dist/template/package.json +13 -3
- package/dist/template/scripts/configure-expo-app.mjs +11 -15
- package/dist/template/scripts/doctor.mjs +51 -0
- package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
- package/dist/template/scripts/lib/device-identity.test.ts +29 -0
- package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
- package/dist/template/scripts/lib/doctor.mjs +208 -0
- package/dist/template/scripts/lib/doctor.test.mjs +262 -0
- package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
- package/dist/template/scripts/lib/ota-client.test.ts +55 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
- package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
- package/dist/template/scripts/tests/device-analytics.mjs +126 -0
- package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
- package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
- package/dist/template/scripts/tests/device-targeting.mjs +39 -0
- package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
- package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
- package/dist/template/scripts/tests/manifest-identity.sql +204 -0
- package/dist/template/src/client/admin-types.ts +1 -0
- package/dist/template/src/client/devices/analytics.tsx +429 -0
- package/dist/template/src/client/devices/device-name.tsx +82 -0
- package/dist/template/src/client/devices/registry.tsx +399 -0
- package/dist/template/src/client/devices/use-devices-report.ts +108 -0
- package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
- package/dist/template/src/client/devices/version-groups.test.ts +57 -0
- package/dist/template/src/client/devices/version-groups.ts +101 -0
- package/dist/template/src/client/distribution-control.tsx +135 -81
- package/dist/template/src/client/guard-action-combobox.tsx +13 -24
- package/dist/template/src/client/i18n/en.json +286 -0
- package/dist/template/src/client/i18n/messages.test.ts +42 -0
- package/dist/template/src/client/i18n/messages.ts +31 -0
- package/dist/template/src/client/i18n/provider.tsx +55 -0
- package/dist/template/src/client/i18n/use-formatters.ts +38 -0
- package/dist/template/src/client/logout-button.tsx +3 -1
- package/dist/template/src/client/update-audience-editor.tsx +285 -0
- package/dist/template/src/client/update-policy-editor.tsx +53 -41
- package/dist/template/src/server/controllers/manifest.test.ts +250 -7
- package/dist/template/src/server/controllers/manifest.ts +39 -31
- package/dist/template/src/server/devices/audience.test.ts +48 -0
- package/dist/template/src/server/devices/audience.ts +86 -0
- package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
- package/dist/template/src/server/devices/heartbeat.ts +75 -0
- package/dist/template/src/server/devices/report-types.ts +114 -0
- package/dist/template/src/server/devices/report.test.ts +29 -0
- package/dist/template/src/server/devices/report.ts +27 -0
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
- package/dist/template/src/server/lib/admin-updates.ts +32 -168
- package/dist/template/src/server/lib/supabase.js +10 -10
- package/dist/template/src/server/lib/supabase.test.ts +11 -0
- package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
- package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
- package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
- package/dist/template/src/server/manifest/manifest-response.ts +1 -1
- package/dist/template/templates/expo-app/ota-client/README.md +59 -0
- package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
- package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
- package/dist/template/templates/expo-app/ota-client/index.js +3 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
- package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
- package/dist/template-manifest.json +578 -73
- package/lib/cli.mjs +4 -6
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useI18n } from "@/src/client/i18n/provider";
|
|
3
|
+
|
|
4
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
5
|
+
|
|
6
|
+
import { NativeSelect } from "@/components/ui/native-select";
|
|
7
|
+
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import { Card } from "@/components/ui/card";
|
|
2
10
|
|
|
3
11
|
import {
|
|
4
12
|
deleteUpdate,
|
|
@@ -9,7 +17,7 @@ import {
|
|
|
9
17
|
updateJsonFile,
|
|
10
18
|
} from "@/src/client/admin-api";
|
|
11
19
|
import { UpdateDetail } from "@/src/client/admin-types";
|
|
12
|
-
import
|
|
20
|
+
import UpdateAudienceEditor from "@/src/client/update-audience-editor";
|
|
13
21
|
import UpdatePolicyEditor from "@/src/client/update-policy-editor";
|
|
14
22
|
import Link from "next/link";
|
|
15
23
|
import { useParams, useRouter } from "next/navigation";
|
|
@@ -30,6 +38,7 @@ function prettyJson(value: unknown): string {
|
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
export default function UpdateDetailsPage() {
|
|
41
|
+
const { t } = useI18n();
|
|
33
42
|
const params = useParams<{ encodedKey: string }>();
|
|
34
43
|
const router = useRouter();
|
|
35
44
|
const encodedKey = params.encodedKey;
|
|
@@ -199,7 +208,7 @@ export default function UpdateDetailsPage() {
|
|
|
199
208
|
try {
|
|
200
209
|
await updateJsonFile(encodedKey, selectedFile, parsed);
|
|
201
210
|
await reload();
|
|
202
|
-
setSuccess(
|
|
211
|
+
setSuccess(t("Файл {0} обновлён", [selectedFile]));
|
|
203
212
|
} catch (saveError: unknown) {
|
|
204
213
|
setError((saveError as Error).message || "Ошибка сохранения");
|
|
205
214
|
} finally {
|
|
@@ -209,7 +218,9 @@ export default function UpdateDetailsPage() {
|
|
|
209
218
|
|
|
210
219
|
const handleRollback = async () => {
|
|
211
220
|
const confirmed = window.confirm(
|
|
212
|
-
|
|
221
|
+
t(
|
|
222
|
+
"Вы действительно хотите начать распространение предыдущей версии обновления?",
|
|
223
|
+
),
|
|
213
224
|
);
|
|
214
225
|
if (!confirmed) {
|
|
215
226
|
return;
|
|
@@ -221,7 +232,7 @@ export default function UpdateDetailsPage() {
|
|
|
221
232
|
try {
|
|
222
233
|
await rollbackUpdate(encodedKey);
|
|
223
234
|
await reload();
|
|
224
|
-
setSuccess("Rollback активирован");
|
|
235
|
+
setSuccess(t("Rollback активирован"));
|
|
225
236
|
} catch (rollbackError: unknown) {
|
|
226
237
|
setError((rollbackError as Error).message || "Rollback не выполнен");
|
|
227
238
|
} finally {
|
|
@@ -231,7 +242,7 @@ export default function UpdateDetailsPage() {
|
|
|
231
242
|
|
|
232
243
|
const handlePromote = async () => {
|
|
233
244
|
const confirmed = window.confirm(
|
|
234
|
-
"Вернуть распространение к последнему апдейту (promote)?",
|
|
245
|
+
t("Вернуть распространение к последнему апдейту (promote)?"),
|
|
235
246
|
);
|
|
236
247
|
if (!confirmed) {
|
|
237
248
|
return;
|
|
@@ -243,7 +254,7 @@ export default function UpdateDetailsPage() {
|
|
|
243
254
|
try {
|
|
244
255
|
await promoteUpdate(encodedKey);
|
|
245
256
|
await reload();
|
|
246
|
-
setSuccess("Promote выполнен: распространение возвращено к latest");
|
|
257
|
+
setSuccess(t("Promote выполнен: распространение возвращено к latest"));
|
|
247
258
|
} catch (promoteError: unknown) {
|
|
248
259
|
setError((promoteError as Error).message || "Promote не выполнен");
|
|
249
260
|
} finally {
|
|
@@ -263,7 +274,9 @@ export default function UpdateDetailsPage() {
|
|
|
263
274
|
const disabled = detail.status !== "disabled";
|
|
264
275
|
await setUpdateDisabled(encodedKey, disabled);
|
|
265
276
|
await reload();
|
|
266
|
-
setSuccess(
|
|
277
|
+
setSuccess(
|
|
278
|
+
disabled ? t("Апдейт деактивирован") : t("Апдейт активирован"),
|
|
279
|
+
);
|
|
267
280
|
} catch (toggleError: unknown) {
|
|
268
281
|
setError((toggleError as Error).message || "Не удалось изменить статус");
|
|
269
282
|
} finally {
|
|
@@ -277,7 +290,7 @@ export default function UpdateDetailsPage() {
|
|
|
277
290
|
return;
|
|
278
291
|
}
|
|
279
292
|
|
|
280
|
-
const confirmed = window.confirm("Удалить апдейт полностью из bucket?");
|
|
293
|
+
const confirmed = window.confirm(t("Удалить апдейт полностью из bucket?"));
|
|
281
294
|
if (!confirmed) {
|
|
282
295
|
return;
|
|
283
296
|
}
|
|
@@ -296,37 +309,32 @@ export default function UpdateDetailsPage() {
|
|
|
296
309
|
};
|
|
297
310
|
|
|
298
311
|
return (
|
|
299
|
-
<
|
|
300
|
-
<div className="
|
|
301
|
-
<header className="
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
Embedded
|
|
315
|
-
</Link>
|
|
316
|
-
<h1 className="mt-1 text-xl font-semibold">Детали апдейта</h1>
|
|
317
|
-
</div>
|
|
318
|
-
<LogoutButton />
|
|
312
|
+
<div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
|
|
313
|
+
<div className="space-y-6">
|
|
314
|
+
<header className="space-y-2">
|
|
315
|
+
<Link
|
|
316
|
+
href="/updates"
|
|
317
|
+
className="inline-flex items-center text-xs text-muted-foreground hover:text-primary"
|
|
318
|
+
>
|
|
319
|
+
{t("← Все обновления")}
|
|
320
|
+
</Link>
|
|
321
|
+
<h1 className="text-2xl font-semibold tracking-tight">
|
|
322
|
+
{t("Детали обновления")}
|
|
323
|
+
</h1>
|
|
324
|
+
<p className="text-sm text-muted-foreground">
|
|
325
|
+
{t("Метаданные, политика доставки и управление публикацией.")}
|
|
326
|
+
</p>
|
|
319
327
|
</header>
|
|
320
328
|
|
|
321
329
|
{loading ? (
|
|
322
|
-
<div className="rounded-xl border border-
|
|
323
|
-
Загрузка...
|
|
330
|
+
<div className="rounded-xl border border-border bg-card p-5 ">
|
|
331
|
+
{t("Загрузка...")}
|
|
324
332
|
</div>
|
|
325
333
|
) : null}
|
|
326
334
|
|
|
327
335
|
{error ? (
|
|
328
336
|
<div className="rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300">
|
|
329
|
-
{error}
|
|
337
|
+
{t(error)}
|
|
330
338
|
</div>
|
|
331
339
|
) : null}
|
|
332
340
|
|
|
@@ -347,31 +355,34 @@ export default function UpdateDetailsPage() {
|
|
|
347
355
|
{channelState.rollbackActive ? (
|
|
348
356
|
<section className="rounded-xl border border-orange-300 bg-orange-50 p-4 dark:border-orange-700 dark:bg-orange-950/30">
|
|
349
357
|
<p className="text-sm font-medium text-orange-900 dark:text-orange-200">
|
|
350
|
-
⚠️ Rollback активен в этом канале/платформе.
|
|
358
|
+
{t("⚠️ Rollback активен в этом канале/платформе.")}
|
|
351
359
|
</p>
|
|
352
360
|
<p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
|
|
353
|
-
Сейчас раздаётся updateId:
|
|
361
|
+
{t("Сейчас раздаётся updateId: ")}
|
|
362
|
+
{channelState.activeUpdateId}
|
|
354
363
|
</p>
|
|
355
364
|
<p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
|
|
356
|
-
|
|
357
|
-
|
|
365
|
+
{t(
|
|
366
|
+
"Новые апдейты автоматически игнорируются до выполнения Promote.",
|
|
367
|
+
)}
|
|
358
368
|
</p>
|
|
359
369
|
</section>
|
|
360
370
|
) : null}
|
|
361
371
|
|
|
362
372
|
{detail.isIgnoredByRollback ? (
|
|
363
|
-
<section className="rounded-xl border border-
|
|
364
|
-
<p className="text-sm font-medium text-
|
|
365
|
-
Этот апдейт сейчас не доставляется.
|
|
373
|
+
<section className="rounded-xl border border-border bg-muted/30 p-4 ">
|
|
374
|
+
<p className="text-sm font-medium text-foreground">
|
|
375
|
+
{t("Этот апдейт сейчас не доставляется.")}
|
|
366
376
|
</p>
|
|
367
|
-
<p className="mt-1 text-xs text-
|
|
368
|
-
|
|
369
|
-
|
|
377
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
378
|
+
{t(
|
|
379
|
+
"Причина: активен rollback, автодоставка новых апдейтов выключена.",
|
|
380
|
+
)}
|
|
370
381
|
</p>
|
|
371
382
|
</section>
|
|
372
383
|
) : null}
|
|
373
384
|
|
|
374
|
-
<
|
|
385
|
+
<Card className="grid gap-4 rounded-xl border border-border bg-card p-5 md:grid-cols-2 lg:grid-cols-4 shadow-none">
|
|
375
386
|
<Info label="Runtime" value={detail.runtimeVersion} />
|
|
376
387
|
<Info label="Platform" value={detail.platform} />
|
|
377
388
|
<Info label="Channel" value={detail.channel} />
|
|
@@ -381,13 +392,16 @@ export default function UpdateDetailsPage() {
|
|
|
381
392
|
value={detail.createdAt || detail.createdAtPath}
|
|
382
393
|
/>
|
|
383
394
|
<Info label="Status" value={detail.status} />
|
|
384
|
-
<Info
|
|
395
|
+
<Info
|
|
396
|
+
label="Latest"
|
|
397
|
+
value={detail.isLatest ? t("Да") : t("Нет")}
|
|
398
|
+
/>
|
|
385
399
|
<Info
|
|
386
400
|
label="Rollback"
|
|
387
|
-
value={detail.isRollbackActive ? "Активен" : "Нет"}
|
|
401
|
+
value={detail.isRollbackActive ? t("Активен") : t("Нет")}
|
|
388
402
|
/>
|
|
389
403
|
<Info
|
|
390
|
-
label="Доставка"
|
|
404
|
+
label={t("Доставка")}
|
|
391
405
|
value={
|
|
392
406
|
detail.isIgnoredByRollback
|
|
393
407
|
? "Ignored by rollback"
|
|
@@ -408,80 +422,89 @@ export default function UpdateDetailsPage() {
|
|
|
408
422
|
className="md:col-span-2 lg:col-span-2"
|
|
409
423
|
/>
|
|
410
424
|
<Info
|
|
411
|
-
label="Комментарий"
|
|
425
|
+
label={t("Комментарий")}
|
|
412
426
|
value={detail.comment || "-"}
|
|
413
427
|
className="md:col-span-2 lg:col-span-2"
|
|
414
428
|
/>
|
|
415
429
|
<Info
|
|
416
|
-
label="Активный update ID"
|
|
430
|
+
label={t("Активный update ID")}
|
|
417
431
|
value={channelState.activeUpdateId || "-"}
|
|
418
432
|
className="md:col-span-2 lg:col-span-2"
|
|
419
433
|
/>
|
|
420
|
-
</
|
|
434
|
+
</Card>
|
|
421
435
|
|
|
436
|
+
<UpdateAudienceEditor
|
|
437
|
+
key={encodedKey}
|
|
438
|
+
encodedKey={encodedKey}
|
|
439
|
+
platform={detail.platform}
|
|
440
|
+
/>
|
|
422
441
|
<UpdatePolicyEditor
|
|
423
442
|
key={`${encodedKey}-${detail.policyVersion}-${detail.policyPublishedAt || "draft"}`}
|
|
424
443
|
encodedKey={encodedKey}
|
|
425
444
|
onSaved={reload}
|
|
426
445
|
/>
|
|
427
446
|
|
|
428
|
-
<
|
|
447
|
+
<Card className="gap-4 p-5 shadow-none">
|
|
429
448
|
<div className="flex flex-wrap gap-2">
|
|
430
449
|
{canRollback ? (
|
|
431
|
-
<
|
|
450
|
+
<Button
|
|
451
|
+
variant="outline"
|
|
452
|
+
size="sm"
|
|
432
453
|
type="button"
|
|
433
454
|
onClick={handleRollback}
|
|
434
455
|
disabled={saving}
|
|
435
|
-
className="rounded-md border border-orange-300 bg-orange-50 px-4 py-4 text-sm text-orange-800 hover:bg-orange-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-orange-700 dark:bg-orange-950/30 dark:text-orange-300 dark:hover:bg-orange-950/50"
|
|
436
456
|
>
|
|
437
457
|
Rollback
|
|
438
|
-
</
|
|
458
|
+
</Button>
|
|
439
459
|
) : null}
|
|
440
460
|
{canPromote ? (
|
|
441
|
-
<
|
|
461
|
+
<Button
|
|
462
|
+
variant="default"
|
|
463
|
+
size="sm"
|
|
442
464
|
type="button"
|
|
443
465
|
onClick={handlePromote}
|
|
444
466
|
disabled={saving}
|
|
445
|
-
className="rounded-md border border-emerald-300 bg-emerald-50 px-4 py-4 text-sm text-emerald-800 hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-emerald-700 dark:bg-emerald-950/30 dark:text-emerald-300 dark:hover:bg-emerald-950/50"
|
|
446
467
|
>
|
|
447
468
|
Promote
|
|
448
|
-
</
|
|
469
|
+
</Button>
|
|
449
470
|
) : null}
|
|
450
471
|
{showToggleDisabledButton ? (
|
|
451
|
-
<
|
|
472
|
+
<Button
|
|
473
|
+
variant="outline"
|
|
474
|
+
size="sm"
|
|
452
475
|
type="button"
|
|
453
476
|
onClick={handleToggleDisabled}
|
|
454
477
|
disabled={saving}
|
|
455
|
-
className="rounded-md border border-amber-300 px-4 py-4 text-sm text-amber-700 hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-amber-700 dark:text-amber-300 dark:hover:bg-amber-950/40"
|
|
456
478
|
>
|
|
457
479
|
{detail.status === "disabled"
|
|
458
|
-
? "Активировать"
|
|
459
|
-
: "Деактивировать"}
|
|
460
|
-
</
|
|
480
|
+
? t("Активировать")
|
|
481
|
+
: t("Деактивировать")}
|
|
482
|
+
</Button>
|
|
461
483
|
) : null}
|
|
462
484
|
{canDelete ? (
|
|
463
|
-
<
|
|
485
|
+
<Button
|
|
486
|
+
variant="destructive"
|
|
487
|
+
size="sm"
|
|
464
488
|
type="button"
|
|
465
489
|
onClick={handleDelete}
|
|
466
490
|
disabled={saving}
|
|
467
|
-
className="rounded-md border border-red-300 px-4 py-4 text-sm text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/40"
|
|
468
491
|
>
|
|
469
|
-
Удалить апдейт
|
|
470
|
-
</
|
|
492
|
+
{t("Удалить апдейт")}
|
|
493
|
+
</Button>
|
|
471
494
|
) : null}
|
|
472
495
|
</div>
|
|
473
|
-
</
|
|
496
|
+
</Card>
|
|
474
497
|
|
|
475
|
-
<
|
|
498
|
+
<Card className="gap-4 p-5 shadow-none">
|
|
476
499
|
<div className="flex flex-wrap items-center gap-2">
|
|
477
|
-
<label className="text-sm">JSON
|
|
478
|
-
<
|
|
500
|
+
<label className="text-sm">{t("JSON файл")}</label>
|
|
501
|
+
<NativeSelect
|
|
479
502
|
value={selectedFile}
|
|
480
503
|
onChange={(event) =>
|
|
481
504
|
setSelectedFile(event.target.value as EditableFile)
|
|
482
505
|
}
|
|
483
|
-
aria-label="Выбор JSON файла"
|
|
484
|
-
className="rounded-md border border-
|
|
506
|
+
aria-label={t("Выбор JSON файла")}
|
|
507
|
+
className="rounded-md border border-input bg-background px-2 py-2 text-sm "
|
|
485
508
|
>
|
|
486
509
|
<option value="update-info.json">update-info.json</option>
|
|
487
510
|
<option value="update-meta.json">update-meta.json</option>
|
|
@@ -489,8 +512,10 @@ export default function UpdateDetailsPage() {
|
|
|
489
512
|
<option value="channel-latest.json">
|
|
490
513
|
channel latest.json
|
|
491
514
|
</option>
|
|
492
|
-
</
|
|
493
|
-
<
|
|
515
|
+
</NativeSelect>
|
|
516
|
+
<Button
|
|
517
|
+
variant="outline"
|
|
518
|
+
size="sm"
|
|
494
519
|
type="button"
|
|
495
520
|
onClick={handleSaveJson}
|
|
496
521
|
disabled={
|
|
@@ -498,35 +523,36 @@ export default function UpdateDetailsPage() {
|
|
|
498
523
|
channelLatestLocked ||
|
|
499
524
|
updateMetaDistributionLocked
|
|
500
525
|
}
|
|
501
|
-
className="rounded-md border border-zinc-300 px-4 py-4 text-sm hover:bg-zinc-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-zinc-700 dark:hover:bg-zinc-800"
|
|
502
526
|
>
|
|
503
|
-
Сохранить JSON
|
|
504
|
-
</
|
|
527
|
+
{t("Сохранить JSON")}
|
|
528
|
+
</Button>
|
|
505
529
|
</div>
|
|
506
530
|
{channelLatestLocked ? (
|
|
507
531
|
<p className="mt-2 text-xs text-orange-700 dark:text-orange-300">
|
|
508
|
-
|
|
509
|
-
|
|
532
|
+
{t(
|
|
533
|
+
"Редактирование channel latest.json заблокировано: активен rollback или глобальный аварийный выключатель.",
|
|
534
|
+
)}
|
|
510
535
|
</p>
|
|
511
536
|
) : null}
|
|
512
537
|
{updateMetaDistributionLocked ? (
|
|
513
538
|
<p className="mt-2 text-xs text-red-700 dark:text-red-300">
|
|
514
|
-
|
|
515
|
-
|
|
539
|
+
{t(
|
|
540
|
+
"Активация через update-meta.json недоступна при глобальной блокировке. Деактивация с isActive=false остаётся доступна.",
|
|
541
|
+
)}
|
|
516
542
|
</p>
|
|
517
543
|
) : null}
|
|
518
|
-
<
|
|
544
|
+
<Textarea
|
|
519
545
|
value={editorValue}
|
|
520
546
|
onChange={(event) => setEditorValue(event.target.value)}
|
|
521
|
-
aria-label="Редактор JSON"
|
|
522
|
-
className="mt-3 h-120 w-full rounded-md border border-
|
|
547
|
+
aria-label={t("Редактор JSON")}
|
|
548
|
+
className="mt-3 h-120 w-full rounded-md border border-border bg-muted/30 p-3 font-mono text-xs outline-none ring-blue-500 focus:ring-2 "
|
|
523
549
|
spellCheck={false}
|
|
524
550
|
/>
|
|
525
|
-
</
|
|
551
|
+
</Card>
|
|
526
552
|
</>
|
|
527
553
|
) : null}
|
|
528
554
|
</div>
|
|
529
|
-
</
|
|
555
|
+
</div>
|
|
530
556
|
);
|
|
531
557
|
}
|
|
532
558
|
|
|
@@ -541,10 +567,8 @@ function Info({
|
|
|
541
567
|
}) {
|
|
542
568
|
return (
|
|
543
569
|
<div className={className}>
|
|
544
|
-
<p className="text-xs
|
|
545
|
-
|
|
546
|
-
</p>
|
|
547
|
-
<p className="mt-1 break-all text-sm">{value}</p>
|
|
570
|
+
<p className="text-xs text-muted-foreground">{label}</p>
|
|
571
|
+
<p className="mt-1.5 break-all text-sm font-medium">{value}</p>
|
|
548
572
|
</div>
|
|
549
573
|
);
|
|
550
574
|
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useI18n } from "@/src/client/i18n/provider";
|
|
3
|
+
|
|
4
|
+
import { RefreshCw, SlidersHorizontal, X } from "lucide-react";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import { Input } from "@/components/ui/input";
|
|
7
|
+
import { Label } from "@/components/ui/label";
|
|
8
|
+
import {
|
|
9
|
+
NativeSelect,
|
|
10
|
+
NativeSelectOption,
|
|
11
|
+
} from "@/components/ui/native-select";
|
|
12
|
+
import { Badge } from "@/components/ui/badge";
|
|
13
|
+
import { Card, CardContent } from "@/components/ui/card";
|
|
14
|
+
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
|
|
15
|
+
import { Skeleton } from "@/components/ui/skeleton";
|
|
16
|
+
import { Analytics, useKindNames } from "@/src/client/devices/analytics";
|
|
17
|
+
import { Registry } from "@/src/client/devices/registry";
|
|
18
|
+
import {
|
|
19
|
+
useDevicesReport,
|
|
20
|
+
type Filters,
|
|
21
|
+
} from "@/src/client/devices/use-devices-report";
|
|
22
|
+
export default function DevicesPage() {
|
|
23
|
+
const { t, formatLocale } = useI18n();
|
|
24
|
+
const kindNames = useKindNames();
|
|
25
|
+
const {
|
|
26
|
+
filters,
|
|
27
|
+
setFilters,
|
|
28
|
+
applied,
|
|
29
|
+
report,
|
|
30
|
+
error,
|
|
31
|
+
loading,
|
|
32
|
+
apply,
|
|
33
|
+
reset,
|
|
34
|
+
refresh,
|
|
35
|
+
paginate,
|
|
36
|
+
} = useDevicesReport();
|
|
37
|
+
const dirty = JSON.stringify(filters) !== JSON.stringify(applied);
|
|
38
|
+
const activeFilters = Object.entries(applied).filter(
|
|
39
|
+
([key, value]) => key !== "days" && value,
|
|
40
|
+
).length;
|
|
41
|
+
const update = (key: keyof Filters, value: string) =>
|
|
42
|
+
setFilters((previous) => ({ ...previous, [key]: value }));
|
|
43
|
+
const options = report?.options;
|
|
44
|
+
return (
|
|
45
|
+
<main className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
|
|
46
|
+
<header className="flex flex-wrap items-start justify-between gap-4">
|
|
47
|
+
<div>
|
|
48
|
+
<p className="mb-1 text-xs font-medium uppercase tracking-[.16em] text-muted-foreground">
|
|
49
|
+
{t("Аналитика приложения")}
|
|
50
|
+
</p>
|
|
51
|
+
<h1 className="text-2xl font-semibold tracking-tight md:text-[28px]">
|
|
52
|
+
{t("Установки")}
|
|
53
|
+
</h1>
|
|
54
|
+
<p className="mt-1 text-sm text-muted-foreground">
|
|
55
|
+
{t("Версии, активность и переход на OTA в одном месте.")}
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
<Button variant="outline" disabled={loading} onClick={refresh}>
|
|
59
|
+
<RefreshCw
|
|
60
|
+
className={loading ? "animate-spin motion-reduce:animate-none" : ""}
|
|
61
|
+
/>
|
|
62
|
+
{loading ? t("Обновление…") : t("Обновить")}
|
|
63
|
+
</Button>
|
|
64
|
+
</header>
|
|
65
|
+
<Card className="gap-0 py-5 shadow-none">
|
|
66
|
+
<CardContent>
|
|
67
|
+
<div className="mb-4 flex items-center gap-2 text-sm font-medium">
|
|
68
|
+
<SlidersHorizontal className="size-4 text-muted-foreground" />
|
|
69
|
+
{t("Фильтры")}
|
|
70
|
+
{activeFilters > 0 && (
|
|
71
|
+
<Badge variant="secondary">{activeFilters}</Badge>
|
|
72
|
+
)}
|
|
73
|
+
<span className="ml-auto text-xs font-normal text-muted-foreground">
|
|
74
|
+
{t("Вся выборка")}
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
<form
|
|
78
|
+
onSubmit={(e) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
apply();
|
|
81
|
+
}}
|
|
82
|
+
className="grid grid-cols-2 items-end gap-3 lg:grid-cols-3 2xl:grid-cols-6"
|
|
83
|
+
>
|
|
84
|
+
<Filter
|
|
85
|
+
label={t("Период активности")}
|
|
86
|
+
id="days"
|
|
87
|
+
value={filters.days}
|
|
88
|
+
onChange={(v) => update("days", v)}
|
|
89
|
+
items={[
|
|
90
|
+
["1", t("24 часа")],
|
|
91
|
+
["7", t("7 дней")],
|
|
92
|
+
["30", t("30 дней")],
|
|
93
|
+
]}
|
|
94
|
+
/>
|
|
95
|
+
<Filter
|
|
96
|
+
label={t("Платформа")}
|
|
97
|
+
id="platform"
|
|
98
|
+
value={filters.platform}
|
|
99
|
+
onChange={(v) => update("platform", v)}
|
|
100
|
+
items={[
|
|
101
|
+
["", t("Все платформы")],
|
|
102
|
+
...["android", "ios"].map((v) => [
|
|
103
|
+
v,
|
|
104
|
+
v === "ios" ? "iOS" : "Android",
|
|
105
|
+
]),
|
|
106
|
+
]}
|
|
107
|
+
/>
|
|
108
|
+
<Filter
|
|
109
|
+
label={t("Канал")}
|
|
110
|
+
id="channel"
|
|
111
|
+
value={filters.channel}
|
|
112
|
+
onChange={(v) => update("channel", v)}
|
|
113
|
+
items={[
|
|
114
|
+
["", t("Все каналы")],
|
|
115
|
+
...(options?.channels || []).map((v) => [v, v]),
|
|
116
|
+
]}
|
|
117
|
+
/>
|
|
118
|
+
<Filter
|
|
119
|
+
label="Runtime"
|
|
120
|
+
id="runtime"
|
|
121
|
+
value={filters.runtime}
|
|
122
|
+
onChange={(v) => update("runtime", v)}
|
|
123
|
+
items={[
|
|
124
|
+
["", t("Все runtime")],
|
|
125
|
+
...(options?.runtimes || []).map((v) => [v, v]),
|
|
126
|
+
]}
|
|
127
|
+
/>
|
|
128
|
+
<Filter
|
|
129
|
+
label={t("Тип запуска")}
|
|
130
|
+
id="launchKind"
|
|
131
|
+
value={filters.launchKind}
|
|
132
|
+
onChange={(v) => update("launchKind", v)}
|
|
133
|
+
items={[["", t("Все типы")], ...Object.entries(kindNames)]}
|
|
134
|
+
/>
|
|
135
|
+
<div className="grid gap-2">
|
|
136
|
+
<Label htmlFor="installation-search">Installation ID</Label>
|
|
137
|
+
<Input
|
|
138
|
+
id="installation-search"
|
|
139
|
+
placeholder={t("ID или часть ID")}
|
|
140
|
+
value={filters.search}
|
|
141
|
+
maxLength={36}
|
|
142
|
+
pattern="[a-fA-F0-9\-]*"
|
|
143
|
+
title={t("Часть UUID: цифры, буквы a–f и дефисы")}
|
|
144
|
+
onChange={(e) => update("search", e.target.value)}
|
|
145
|
+
className="bg-background/40"
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
<div className="flex flex-wrap items-center gap-2 col-span-2 lg:col-span-3 2xl:col-span-6">
|
|
149
|
+
<Button type="submit" size="sm" disabled={loading}>
|
|
150
|
+
{t("Применить")}
|
|
151
|
+
</Button>
|
|
152
|
+
<Button
|
|
153
|
+
type="button"
|
|
154
|
+
size="sm"
|
|
155
|
+
variant="ghost"
|
|
156
|
+
onClick={reset}
|
|
157
|
+
disabled={loading}
|
|
158
|
+
>
|
|
159
|
+
<X />
|
|
160
|
+
{t("Сбросить")}
|
|
161
|
+
</Button>
|
|
162
|
+
{dirty && (
|
|
163
|
+
<span className="text-xs text-muted-foreground">
|
|
164
|
+
{t("Есть неприменённые изменения")}
|
|
165
|
+
</span>
|
|
166
|
+
)}
|
|
167
|
+
<span className="ml-auto text-xs text-muted-foreground">
|
|
168
|
+
{report && !loading
|
|
169
|
+
? t("Данные на {0}", [
|
|
170
|
+
new Date(report.coverage.generatedAt).toLocaleTimeString(
|
|
171
|
+
formatLocale,
|
|
172
|
+
{ hour: "2-digit", minute: "2-digit" },
|
|
173
|
+
),
|
|
174
|
+
])
|
|
175
|
+
: ""}
|
|
176
|
+
</span>
|
|
177
|
+
</div>
|
|
178
|
+
</form>
|
|
179
|
+
</CardContent>
|
|
180
|
+
</Card>
|
|
181
|
+
{error && (
|
|
182
|
+
<Alert variant="destructive" role="alert">
|
|
183
|
+
<AlertTitle>{t("Не удалось обновить данные")}</AlertTitle>
|
|
184
|
+
<AlertDescription>
|
|
185
|
+
{t(error)}
|
|
186
|
+
{report && t(" Ниже показан предыдущий успешный результат.")}
|
|
187
|
+
<Button
|
|
188
|
+
variant="outline"
|
|
189
|
+
size="sm"
|
|
190
|
+
onClick={refresh}
|
|
191
|
+
disabled={loading}
|
|
192
|
+
>
|
|
193
|
+
{t("Повторить")}
|
|
194
|
+
</Button>
|
|
195
|
+
</AlertDescription>
|
|
196
|
+
</Alert>
|
|
197
|
+
)}
|
|
198
|
+
{loading && !report ? (
|
|
199
|
+
<div
|
|
200
|
+
role="status"
|
|
201
|
+
aria-label={t("Загрузка статистики")}
|
|
202
|
+
className="space-y-4"
|
|
203
|
+
>
|
|
204
|
+
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
|
205
|
+
{[0, 1, 2, 3].map((i) => (
|
|
206
|
+
<Skeleton key={i} className="h-32 rounded-xl" />
|
|
207
|
+
))}
|
|
208
|
+
</div>
|
|
209
|
+
<Skeleton className="h-80 rounded-xl" />
|
|
210
|
+
<Skeleton className="h-64 rounded-xl" />
|
|
211
|
+
</div>
|
|
212
|
+
) : report ? (
|
|
213
|
+
<div
|
|
214
|
+
className={loading ? "space-y-6 opacity-60" : "space-y-6"}
|
|
215
|
+
aria-busy={loading}
|
|
216
|
+
>
|
|
217
|
+
<Analytics report={report} />
|
|
218
|
+
<Registry report={report} loading={loading} paginate={paginate} />
|
|
219
|
+
<p className="text-xs leading-5 text-muted-foreground">
|
|
220
|
+
{t(
|
|
221
|
+
"Метрика считает установки приложения, а не уникальных людей. Сводка и реестр отражают последнее состояние; график — состояние на конец каждого дня. Переустановка может изменить Installation ID.",
|
|
222
|
+
)}
|
|
223
|
+
</p>
|
|
224
|
+
</div>
|
|
225
|
+
) : null}
|
|
226
|
+
</main>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
function Filter({
|
|
230
|
+
label,
|
|
231
|
+
id,
|
|
232
|
+
value,
|
|
233
|
+
onChange,
|
|
234
|
+
items,
|
|
235
|
+
}: {
|
|
236
|
+
label: string;
|
|
237
|
+
id: string;
|
|
238
|
+
value: string;
|
|
239
|
+
onChange: (value: string) => void;
|
|
240
|
+
items: string[][];
|
|
241
|
+
}) {
|
|
242
|
+
return (
|
|
243
|
+
<div className="grid min-w-0 gap-2">
|
|
244
|
+
<Label htmlFor={`filter-${id}`}>{label}</Label>
|
|
245
|
+
<div className="[&>div]:w-full">
|
|
246
|
+
<NativeSelect
|
|
247
|
+
id={`filter-${id}`}
|
|
248
|
+
value={value}
|
|
249
|
+
onChange={(e) => onChange(e.target.value)}
|
|
250
|
+
className="bg-background/40"
|
|
251
|
+
>
|
|
252
|
+
{!items.some(([v]) => v === value) && (
|
|
253
|
+
<NativeSelectOption value={value}>{value}</NativeSelectOption>
|
|
254
|
+
)}
|
|
255
|
+
{items.map(([v, text]) => (
|
|
256
|
+
<NativeSelectOption key={v} value={v}>
|
|
257
|
+
{text}
|
|
258
|
+
</NativeSelectOption>
|
|
259
|
+
))}
|
|
260
|
+
</NativeSelect>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
}
|