diff --git a/static/index.html b/static/index.html
index 97c5381..f5acaaf 100644
--- a/static/index.html
+++ b/static/index.html
@@ -209,6 +209,50 @@
Устройства не найдены. Нажмите "Сканировать".
+
+
+
+ Гостевые ключи
+
+
+
+
+
+
+
+
+
+
+
+ Новый ключ создан -- скопируйте!
+
+
+
{{ lastCreatedKey }}
+
+
+
+
+
+
+
+ {{ k.name }}
+ админ
+ гость
+ {{ k.active ? 'активен' : 'отозван' }}
+
+
{{ k.key.slice(0, 12) }}...{{ k.key.slice(-6) }}
+
+
+
+
+
+
+
Гостевых ключей нет
+
+
@@ -235,6 +279,7 @@
newTask: { target_id: '', state: true },
tasks: [], allScenes: {},
toasts: [], toastCounter: 0,
+ apiKeys: [], newKeyName: '', newKeyAdmin: false, lastCreatedKey: '',
}
},
methods: {
@@ -289,6 +334,7 @@
if (dData) this.devices = Array.isArray(dData) ? dData : Object.values(dData);
if (sData) this.allScenes = sData;
if (this.isAdmin) this.fetchTasks();
+ if (this.isAdmin) this.fetchApiKeys();
} finally { this.isFetching = false; }
},
@@ -340,6 +386,39 @@
const res = await this.request('/schedules/once', 'POST', { target_id: id, hours_from_now: 4, is_group: true, state: false });
if (res) { this.toast('Таймер 4ч', 'success'); this.fetchTasks(); }
},
+
+ // ─── API-ключи ───────────────────────────────
+ async fetchApiKeys() {
+ const data = await this.request('/api-keys');
+ if (data) this.apiKeys = data;
+ },
+ async createApiKey() {
+ const name = this.newKeyName.trim();
+ if (!name) return;
+ const res = await this.request('/api-keys', 'POST', { name, is_admin: this.newKeyAdmin });
+ if (res) {
+ this.lastCreatedKey = res.key;
+ this.newKeyName = '';
+ this.newKeyAdmin = false;
+ this.toast(`Ключ "${name}" создан`, 'success');
+ this.fetchApiKeys();
+ }
+ },
+ async revokeApiKey(key, name) {
+ if (confirm(`Отозвать ключ "${name}"?`)) {
+ await this.request(`/api-keys/${key}`, 'DELETE');
+ this.toast(`Ключ "${name}" отозван`, 'success');
+ this.fetchApiKeys();
+ }
+ },
+ async activateApiKey(key, name) {
+ await this.request(`/api-keys/${key}/activate`, 'POST');
+ this.toast(`Ключ "${name}" активирован`, 'success');
+ this.fetchApiKeys();
+ },
+ copyKey(key) {
+ navigator.clipboard.writeText(key).then(() => this.toast('Скопировано', 'success'));
+ },
},
async mounted() { if (this.apiKey) await this.initApp(); }
}).mount('#app')