Skip to content

armgit / posta

Public Imported from GitHub
0

Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.

fix: templates page header search input display

Jude mpoyob04a2bd7f67d
diff --git a/web/src/views/templates/Templates.vue b/web/src/views/templates/Templates.vue
index 8409557..3788dc4 100644
--- a/web/src/views/templates/Templates.vue
+++ b/web/src/views/templates/Templates.vue
@@ -29,7 +29,7 @@ const pageable = ref<Pageable>({
empty: true,
});
const loading = ref(true);
-const search = ref('');
+const search = ref("");
let searchTimeout: ReturnType<typeof setTimeout> | null = null;
const showModal = ref(false);
@@ -180,7 +180,9 @@ async function handleImportFile(event: Event) {
}
await loadTemplates(pageable.value.current_page);
} catch (e: any) {
- const msg = e?.response?.data?.message || "Failed to import template. Please check the file format.";
+ const msg =
+ e?.response?.data?.message ||
+ "Failed to import template. Please check the file format.";
notify.error(msg);
} finally {
importing.value = false;
@@ -196,7 +198,7 @@ function formatDate(dateStr: string): string {
});
}
const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {
- closeModal()
+ closeModal();
});
onMounted(() => {
@@ -217,16 +219,25 @@ onMounted(() => {
style="display: none"
@change="handleImportFile"
/>
- <button class="btn btn-secondary" @click="router.push('/templates/preview')">Preview Template</button>
- <button v-if="wsStore.canEdit" class="btn btn-secondary" :disabled="importing" @click="triggerImport">
+ <button class="btn btn-secondary" @click="router.push('/templates/preview')">
+ Preview Template
+ </button>
+ <button
+ v-if="wsStore.canEdit"
+ class="btn btn-secondary"
+ :disabled="importing"
+ @click="triggerImport"
+ >
{{ importing ? "Importing..." : "Import" }}
</button>
- <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">Create Template</button>
+ <button v-if="wsStore.canEdit" class="btn btn-primary" @click="openCreate">
+ Create Template
+ </button>
</div>
</div>
<div class="card">
- <div class="flex gap-2 mb-4">
+ <div class="card-header">
<input
v-model="search"
class="form-input"
@@ -236,118 +247,136 @@ onMounted(() => {
/>
</div>
- <div v-if="loading" class="loading-page">
- <div class="spinner"></div>
- </div>
-
- <div v-else>
- <div v-if="templates.length === 0" class="empty-state">
- <h3>{{ search ? 'No Results' : 'No Templates' }}</h3>
- <p>{{ search ? 'No templates match your search.' : 'Create your first template to reuse email layouts.' }}</p>
+ <div v-if="loading" class="loading-page">
+ <div class="spinner"></div>
</div>
- <template v-else>
- <div class="table-wrapper">
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Language</th>
- <th>Active Version</th>
- <th>Created</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
- <tr
- v-for="tmpl in templates"
- :key="tmpl.id"
- class="cursor-pointer"
- @click="router.push({ name: 'template-detail', params: { id: tmpl.id } })"
- >
- <td>
- <div>{{ tmpl.name }}</div>
- <div v-if="tmpl.description" class="text-muted text-sm">
- {{ tmpl.description }}
- </div>
- </td>
- <td>
- <span class="badge badge-neutral">{{ tmpl.default_language }}</span>
- </td>
- <td>
- <span v-if="tmpl.active_version_id" class="badge badge-success"
- >v{{ tmpl.active_version?.version || "?" }}</span
- >
- <span v-else class="text-muted">&mdash;</span>
- </td>
- <td>{{ formatDate(tmpl.created_at) }}</td>
- <td>
- <div class="flex gap-2">
- <button
- class="btn btn-primary btn-sm"
- @click.stop="
- router.push({ name: 'template-detail', params: { id: tmpl.id } })
- "
- >
- Versions
- </button>
- <button
- class="btn btn-secondary btn-sm"
- @click.stop="
- router.push({ name: 'template-preview', params: { id: tmpl.id } })
- "
- >
- Preview
- </button>
- <button v-if="wsStore.canEdit" class="btn btn-secondary btn-sm" @click.stop="openEdit(tmpl)">
- Edit
- </button>
- <button
- class="btn btn-secondary btn-sm"
- @click.stop="exportTemplate(tmpl)"
- >
- Export
- </button>
- <button
- v-if="wsStore.canEdit"
- class="btn btn-danger btn-sm"
- @click.stop="deleteTemplate(tmpl)"
- >
- Delete
- </button>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
+ <div v-else>
+ <div v-if="templates.length === 0" class="empty-state">
+ <h3>{{ search ? "No Results" : "No Templates" }}</h3>
+ <p>
+ {{
+ search
+ ? "No templates match your search."
+ : "Create your first template to reuse email layouts."
+ }}
+ </p>
</div>
- <div class="pagination">
- <span class="pagination-info">
- Page {{ pageable.current_page + 1 }} of {{ pageable.total_pages }} ({{
- pageable.total_elements
- }}
- templates)
- </span>
- <div class="pagination-buttons">
- <button
- class="btn btn-secondary btn-sm"
- :disabled="pageable.current_page === 0"
- @click="loadTemplates(pageable.current_page - 1)"
- >
- Previous
- </button>
- <button
- class="btn btn-secondary btn-sm"
- :disabled="pageable.current_page >= pageable.total_pages - 1"
- @click="loadTemplates(pageable.current_page + 1)"
- >
- Next
- </button>
+ <template v-else>
+ <div class="table-wrapper">
+ <table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Language</th>
+ <th>Active Version</th>
+ <th>Created</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr
+ v-for="tmpl in templates"
+ :key="tmpl.id"
+ class="cursor-pointer"
+ @click="
+ router.push({ name: 'template-detail', params: { id: tmpl.id } })
+ "
+ >
+ <td>
+ <div>{{ tmpl.name }}</div>
+ <div v-if="tmpl.description" class="text-muted text-sm">
+ {{ tmpl.description }}
+ </div>
+ </td>
+ <td>
+ <span class="badge badge-neutral">{{ tmpl.default_language }}</span>
+ </td>
+ <td>
+ <span v-if="tmpl.active_version_id" class="badge badge-success"
+ >v{{ tmpl.active_version?.version || "?" }}</span
+ >
+ <span v-else class="text-muted">&mdash;</span>
+ </td>
+ <td>{{ formatDate(tmpl.created_at) }}</td>
+ <td>
+ <div class="flex gap-2">
+ <button
+ class="btn btn-primary btn-sm"
+ @click.stop="
+ router.push({
+ name: 'template-detail',
+ params: { id: tmpl.id },
+ })
+ "
+ >
+ Versions
+ </button>
+ <button
+ class="btn btn-secondary btn-sm"
+ @click.stop="
+ router.push({
+ name: 'template-preview',
+ params: { id: tmpl.id },
+ })
+ "
+ >
+ Preview
+ </button>
+ <button
+ v-if="wsStore.canEdit"
+ class="btn btn-secondary btn-sm"
+ @click.stop="openEdit(tmpl)"
+ >
+ Edit
+ </button>
+ <button
+ class="btn btn-secondary btn-sm"
+ @click.stop="exportTemplate(tmpl)"
+ >
+ Export
+ </button>
+ <button
+ v-if="wsStore.canEdit"
+ class="btn btn-danger btn-sm"
+ @click.stop="deleteTemplate(tmpl)"
+ >
+ Delete
+ </button>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
</div>
- </div>
- </template>
- </div>
+
+ <div class="pagination">
+ <span class="pagination-info">
+ Page {{ pageable.current_page + 1 }} of {{ pageable.total_pages }} ({{
+ pageable.total_elements
+ }}
+ templates)
+ </span>
+ <div class="pagination-buttons">
+ <button
+ class="btn btn-secondary btn-sm"
+ :disabled="pageable.current_page === 0"
+ @click="loadTemplates(pageable.current_page - 1)"
+ >
+ Previous
+ </button>
+ <button
+ class="btn btn-secondary btn-sm"
+ :disabled="pageable.current_page >= pageable.total_pages - 1"
+ @click="loadTemplates(pageable.current_page + 1)"
+ >
+ Next
+ </button>
+ </div>
+ </div>
+ </template>
+ </div>
</div>
<!-- Create/Edit Template Modal -->