Files
OpenVPN-Monitoring-Simple/APP_UI/src/components/BaseModal.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

76 lines
1.7 KiB
Vue

<template>
<Teleport to="body">
<div class="modal fade" :id="id" tabindex="-1" aria-hidden="true" ref="modalRef">
<div class="modal-dialog modal-dialog-centered" :class="sizeClass">
<div class="modal-content">
<div class="modal-header border-0 pb-0">
<slot name="header">
<h5 class="modal-title fw-bold" style="color: var(--text-heading);">{{ title }}</h5>
</slot>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<slot name="body"></slot>
</div>
<div class="modal-footer border-0 pt-0" v-if="$slots.footer">
<slot name="footer"></slot>
</div>
</div>
</div>
</div>
</Teleport>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { Modal } from 'bootstrap';
const props = defineProps({
id: {
type: String,
required: true
},
title: {
type: String,
default: ''
},
size: {
type: String,
default: '' // 'modal-sm', 'modal-lg', 'modal-xl'
}
});
const emit = defineEmits(['opened', 'closed']);
const modalRef = ref(null);
let bsModal = null;
const sizeClass = computed(() => props.size || '');
const show = () => {
bsModal?.show();
};
const hide = () => {
bsModal?.hide();
};
onMounted(() => {
bsModal = new Modal(modalRef.value);
modalRef.value.addEventListener('shown.bs.modal', () => {
emit('opened');
});
modalRef.value.addEventListener('hidden.bs.modal', () => {
emit('closed');
});
});
onUnmounted(() => {
bsModal?.dispose();
});
defineExpose({ show, hide });
</script>