front end updates
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import AdminLayout from '@/Layouts/AdminLayout.vue'
|
||||
import { Link } from '@inertiajs/vue3'
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||
import { faUserGroup, faKey, faGears, faFileWord } from '@fortawesome/free-solid-svg-icons'
|
||||
import { faUserGroup, faKey, faGears, faFileWord, faEnvelopeOpenText, faInbox, faAt } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
const cards = [
|
||||
{
|
||||
@@ -39,6 +39,29 @@ const cards = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
category: 'Email',
|
||||
items: [
|
||||
{
|
||||
title: 'Email predloge',
|
||||
description: 'Upravljanje HTML / tekst email predlog',
|
||||
route: 'admin.email-templates.index',
|
||||
icon: faEnvelopeOpenText,
|
||||
},
|
||||
{
|
||||
title: 'Email dnevniki',
|
||||
description: 'Pregled poslanih emailov in statusov',
|
||||
route: 'admin.email-logs.index',
|
||||
icon: faInbox,
|
||||
},
|
||||
{
|
||||
title: 'Mail profili',
|
||||
description: 'SMTP profili, nastavitve in testiranje povezave',
|
||||
route: 'admin.mail-profiles.index',
|
||||
icon: faAt,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ const props = defineProps({
|
||||
profiles: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
const createOpen = ref(false);
|
||||
const editTarget = ref(null);
|
||||
const createOpen = ref(false); // create modal
|
||||
const editOpen = ref(false); // edit modal
|
||||
const editTarget = ref(null); // profile being edited
|
||||
|
||||
const form = useForm({
|
||||
name: "",
|
||||
@@ -39,6 +40,22 @@ function openCreate() {
|
||||
editTarget.value = null;
|
||||
}
|
||||
|
||||
function openEdit(p) {
|
||||
// populate form with existing profile data (exclude password which is write-only)
|
||||
form.reset();
|
||||
form.name = p.name || "";
|
||||
form.host = p.host || "";
|
||||
form.port = p.port || 587;
|
||||
form.encryption = p.encryption || "";
|
||||
form.username = p.username || "";
|
||||
form.password = ""; // empty -> keep existing unless user fills
|
||||
form.from_address = p.from_address || "";
|
||||
form.from_name = p.from_name || "";
|
||||
form.priority = p.priority ?? 10;
|
||||
editTarget.value = p;
|
||||
editOpen.value = true;
|
||||
}
|
||||
|
||||
function closeCreate() {
|
||||
if (form.processing) return;
|
||||
createOpen.value = false;
|
||||
@@ -53,6 +70,37 @@ function submitCreate() {
|
||||
});
|
||||
}
|
||||
|
||||
function closeEdit() {
|
||||
if (form.processing) return;
|
||||
editOpen.value = false;
|
||||
editTarget.value = null;
|
||||
}
|
||||
|
||||
function submitEdit() {
|
||||
if (!editTarget.value) return;
|
||||
// Build payload excluding empty password
|
||||
const payload = {
|
||||
name: form.name,
|
||||
host: form.host,
|
||||
port: form.port,
|
||||
encryption: form.encryption || null,
|
||||
username: form.username || null,
|
||||
from_address: form.from_address,
|
||||
from_name: form.from_name || null,
|
||||
priority: form.priority,
|
||||
};
|
||||
if (form.password && form.password.trim() !== "") {
|
||||
payload.password = form.password.trim();
|
||||
}
|
||||
form.transform(() => payload).put(route("admin.mail-profiles.update", editTarget.value.id), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
editOpen.value = false;
|
||||
editTarget.value = null;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function toggleActive(p) {
|
||||
window.axios
|
||||
.post(route("admin.mail-profiles.toggle", p.id))
|
||||
@@ -160,9 +208,11 @@ const statusClass = (p) => {
|
||||
<FontAwesomeIcon :icon="faPaperPlane" class="w-3.5 h-3.5" /> Pošlji test
|
||||
</button>
|
||||
<button
|
||||
@click="openEdit(p)"
|
||||
class="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border text-indigo-600 border-indigo-300 bg-indigo-50 hover:bg-indigo-100"
|
||||
title="Uredi profil"
|
||||
>
|
||||
<FontAwesomeIcon :icon="faArrowsRotate" class="w-3.5 h-3.5" /> Shrani
|
||||
<FontAwesomeIcon :icon="faArrowsRotate" class="w-3.5 h-3.5" /> Uredi
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -241,6 +291,61 @@ const statusClass = (p) => {
|
||||
</button>
|
||||
</template>
|
||||
</DialogModal>
|
||||
<!-- Edit Modal -->
|
||||
<DialogModal :show="editOpen" max-width="2xl" @close="closeEdit">
|
||||
<template #title> Uredi Mail profil </template>
|
||||
<template #content>
|
||||
<form @submit.prevent="submitEdit" id="edit-mail-profile" class="space-y-5">
|
||||
<div class="grid gap-4 grid-cols-2">
|
||||
<div>
|
||||
<label class="label">Ime</label>
|
||||
<input v-model="form.name" type="text" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Host</label>
|
||||
<input v-model="form.host" type="text" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Port</label>
|
||||
<input v-model="form.port" type="number" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Encryption</label>
|
||||
<select v-model="form.encryption" class="input">
|
||||
<option value="">(None)</option>
|
||||
<option value="tls">TLS</option>
|
||||
<option value="ssl">SSL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Username</label>
|
||||
<input v-model="form.username" type="text" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Password (nova, če spreminjaš)</label>
|
||||
<input v-model="form.password" type="password" class="input" autocomplete="new-password" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">From naslov</label>
|
||||
<input v-model="form.from_address" type="email" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">From ime</label>
|
||||
<input v-model="form.from_name" type="text" class="input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Prioriteta</label>
|
||||
<input v-model="form.priority" type="number" class="input" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500">Pusti geslo prazno, če želiš obdržati obstoječe.</p>
|
||||
</form>
|
||||
</template>
|
||||
<template #footer>
|
||||
<button type="button" @click="closeEdit" class="px-4 py-2 text-sm rounded-md border bg-white hover:bg-gray-50">Prekliči</button>
|
||||
<button form="edit-mail-profile" type="submit" :disabled="form.processing" class="px-4 py-2 text-sm rounded-md bg-indigo-600 text-white hover:bg-indigo-500 disabled:opacity-50">Shrani</button>
|
||||
</template>
|
||||
</DialogModal>
|
||||
</AdminLayout>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user