Files
OpenVPN-Monitoring-Simple/APP_UI/src/components/ConfirmModal.vue
T
ayurishchevandClaude Sonnet 5.5 897c82ab88 UI review, stage 3: cleanup, shared chart code, confirmations, routing
useTrafficChart composable replaces the duplicated chart code in Analytics
and HistoryModal; theme observer is released on unmount; blob URLs are
revoked. ConfirmModal gets a unique id; confirm() in Server/PKI and
SweetAlert2 in Account are replaced by ConfirmModal and toasts, sweetalert2
and sass removed. Separate authApiClient for /api/auth. 404 redirect, lazy
Clients, token-based isAuthenticated, theme from prefers-color-scheme set
before mount. BaseModal reactive size, NewClientModal name check and focus
on opened, HistoryModal ignores stale answers. Login.vue.bak, the dead
global axios interceptor and empty <p> removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-07 13:10:41 +03:00

52 lines
1.4 KiB
Vue

<template>
<BaseModal :id="modalId" :title="title" ref="modal">
<template #body>
<p class="text-main" style="white-space: pre-line;">{{ message }}</p>
</template>
<template #footer>
<button v-if="showCancel" type="button" class="btn-action btn-action-secondary" @click="close">Cancel</button>
<button type="button" class="btn-action" :class="confirmBtnClass" @click="confirm">
{{ confirmText }}
</button>
</template>
</BaseModal>
</template>
<script setup>
import { ref, useId } from 'vue';
import BaseModal from './BaseModal.vue';
// Unique element id: several ConfirmModal instances may live on one page
const modalId = `confirm-${useId()}`;
const emit = defineEmits(['confirm']);
const modal = ref(null);
const title = ref('');
const message = ref('');
const confirmText = ref('Confirm');
const confirmBtnClass = ref('btn-action-danger');
const showCancel = ref(true);
const data = ref(null);
const open = (opts) => {
title.value = opts.title || 'Are you sure?';
message.value = opts.message || '';
confirmText.value = opts.confirmText || 'Confirm';
confirmBtnClass.value = opts.confirmBtnClass || 'btn-action-danger';
showCancel.value = opts.showCancel !== false;
data.value = opts.data || null;
modal.value.show();
};
const close = () => {
modal.value.hide();
};
const confirm = () => {
emit('confirm', data.value);
close();
};
defineExpose({ open, close });
</script>