Deploy: 2026-05-23 22:54:24

This commit is contained in:
Hamza-Ayed
2026-05-23 22:54:25 +03:00
parent 739697cfdb
commit 5eb848064d
5 changed files with 237 additions and 5 deletions

View File

@@ -580,6 +580,12 @@
</a>
<div class="nav-actions">
<button class="btn btn-glass" @click="exportChatsHistory()" :disabled="exportLoading">
<svg width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="margin: 0;" x-show="!exportLoading">
<path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
<span x-text="exportLoading ? t('exporting') : t('export_chats')">تصدير المحادثات</span>
</button>
<button class="btn btn-glass" @click="toggleLanguage()">
<span x-text="lang === 'ar' ? 'English' : 'العربية'"></span>
</button>
@@ -806,7 +812,10 @@
save_changes: 'حفظ وترقية الباقة',
saving: 'جاري الحفظ والترقية...',
success_update: 'تم تحديث اشتراك الشركة وترقية الباقة بنجاح!',
fail_update: 'فشل تفعيل الاشتراك الجديد. يرجى المحاولة لاحقاً.'
fail_update: 'فشل تفعيل الاشتراك الجديد. يرجى المحاولة لاحقاً.',
export_chats: 'تصدير المحادثات',
exporting: 'جاري التصدير...',
export_success: 'تم تصدير سجل المحادثات بنجاح!'
},
en: {
logout: 'Log Out',
@@ -835,7 +844,10 @@
save_changes: 'Apply Subscription',
saving: 'Updating...',
success_update: 'Company subscription plan updated successfully!',
fail_update: 'Failed to update subscription. Please try again.'
fail_update: 'Failed to update subscription. Please try again.',
export_chats: 'Export Chats',
exporting: 'Exporting...',
export_success: 'Chat history exported successfully!'
}
};
@@ -858,6 +870,7 @@
duration_days: 30
},
isSubmitting: false,
exportLoading: false,
toast: {
show: false,
message: '',
@@ -912,6 +925,32 @@
this.redirectToLogin();
},
async exportChatsHistory() {
this.exportLoading = true;
try {
const response = await fetch('/api/admin/export-chats', {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.token}`,
'Accept': 'application/json'
}
});
const result = await response.json();
this.exportLoading = false;
if (result.status === 'success') {
this.showToast(this.t('export_success'), false);
window.open(result.download_url, '_blank');
} else {
this.showToast(result.error || 'Failed to export chats', true);
}
} catch (err) {
this.exportLoading = false;
this.showToast('Network error while exporting chats', true);
}
},
async fetchStats() {
try {
const response = await fetch('/api/admin/stats', {