mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
110 lines
2.5 KiB
JavaScript
110 lines
2.5 KiB
JavaScript
import { vaultService } from "../services/vault-service.js";
|
|
|
|
export function showVaultManager() {
|
|
if (document.querySelector(".vault-manager-overlay")) return;
|
|
|
|
new window.IgnisUI.VaultManager({
|
|
target: document.body,
|
|
props: { vaultService },
|
|
});
|
|
}
|
|
|
|
export function showMessageDialog(title, message) {
|
|
return new Promise((resolve) => {
|
|
const dialog = new window.IgnisUI.MessageDialog({
|
|
target: document.body,
|
|
props: { title, message },
|
|
});
|
|
|
|
dialog.$on("confirm", () => {
|
|
dialog.$destroy();
|
|
resolve();
|
|
});
|
|
});
|
|
}
|
|
|
|
export function showConfirmDialog(
|
|
title,
|
|
message,
|
|
description,
|
|
confirmText = "OK",
|
|
) {
|
|
return new Promise((resolve) => {
|
|
const dialog = new window.IgnisUI.ConfirmDialog({
|
|
target: document.body,
|
|
props: { title, message, description, confirmText },
|
|
});
|
|
|
|
dialog.$on("confirm", () => {
|
|
dialog.$destroy();
|
|
resolve(true);
|
|
});
|
|
|
|
dialog.$on("cancel", () => {
|
|
dialog.$destroy();
|
|
resolve(false);
|
|
});
|
|
});
|
|
}
|
|
|
|
export function showPluginInstallDialog(vaultId) {
|
|
return new Promise((resolve) => {
|
|
const dialog = new window.IgnisUI.PluginInstallDialog({
|
|
target: document.body,
|
|
});
|
|
|
|
dialog.$on("install", async () => {
|
|
try {
|
|
await fetch("/api/vault/install-plugin", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ vault: vaultId }),
|
|
});
|
|
} catch (e) {
|
|
console.error("[ignis] Failed to install plugin:", e);
|
|
}
|
|
dialog.$destroy();
|
|
resolve("install");
|
|
});
|
|
|
|
dialog.$on("dismiss", async () => {
|
|
try {
|
|
await fetch("/api/vault/install-plugin", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ vault: vaultId, dismiss: true }),
|
|
});
|
|
} catch (e) {
|
|
console.error("[ignis] Failed to dismiss plugin prompt:", e);
|
|
}
|
|
dialog.$destroy();
|
|
resolve("dismiss");
|
|
});
|
|
});
|
|
}
|
|
|
|
export function showPromptDialog(
|
|
title,
|
|
label,
|
|
placeholder = "",
|
|
value = "",
|
|
confirmText = "OK",
|
|
) {
|
|
return new Promise((resolve) => {
|
|
const dialog = new window.IgnisUI.PromptDialog({
|
|
target: document.body,
|
|
props: { title, label, placeholder, value, confirmText },
|
|
});
|
|
|
|
dialog.$on("confirm", (event) => {
|
|
dialog.$destroy();
|
|
resolve(event.detail);
|
|
});
|
|
|
|
dialog.$on("cancel", () => {
|
|
dialog.$destroy();
|
|
resolve(null);
|
|
});
|
|
});
|
|
}
|