feat(api,userbot,frontend): add accounts from the web ui and isolate per-account settings
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import {
|
||||
createPolicy,
|
||||
deletePolicy,
|
||||
@@ -16,6 +15,7 @@
|
||||
import CaptureToggleList from "$lib/components/policy/CaptureToggleList.svelte";
|
||||
import Icon from "$lib/components/ui/Icon.svelte";
|
||||
import Spinner from "$lib/components/ui/Spinner.svelte";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
import { chats } from "$lib/stores/chats.svelte";
|
||||
import { toasts } from "$lib/stores/toasts.svelte";
|
||||
|
||||
@@ -110,7 +110,8 @@
|
||||
p.id === record.id ? { ...p, [key]: value } : p
|
||||
);
|
||||
try {
|
||||
await updatePolicy(record.id, next);
|
||||
const saved = await updatePolicy(record.id, next);
|
||||
policies = policies.map((p) => (p.id === record.id ? saved : p));
|
||||
} catch {
|
||||
toasts.error("Не удалось сохранить политику");
|
||||
await reload();
|
||||
@@ -143,7 +144,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
async function load(_account: number | null) {
|
||||
loading = true;
|
||||
chats.load();
|
||||
try {
|
||||
await reload();
|
||||
@@ -152,6 +154,10 @@
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
load(accounts.selectedId);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -159,7 +165,10 @@
|
||||
<div class="card">
|
||||
<div class="card-head">
|
||||
<span class="card-title">{title}</span>
|
||||
{#if onremove}
|
||||
{#if record.account_id === null}
|
||||
<span class="shared">для всех аккаунтов</span>
|
||||
{/if}
|
||||
{#if onremove && record.account_id !== null}
|
||||
<button
|
||||
type="button"
|
||||
class="remove"
|
||||
@@ -303,6 +312,11 @@
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
.shared {
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.remove {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user