Oilshop / Views /Backup /Index.cshtml
almakhmri253-stack
Add automated daily/weekly database backup system with admin UI
9ba9d1b
Raw History Blame Contribute Delete
4.26 kB
@model IEnumerable<OilShopManagement.Services.BackupFileInfo>
@{
ViewData["Title"] = L.T("النسخ الاحتياطية","Database Backups");
}
<div class="d-flex align-items-center justify-content-between mb-4">
<h4 class="fw-bold mb-0">
<i class="bi bi-archive me-2 text-success"></i>@L.T("النسخ الاحتياطية","Database Backups")
</h4>
<form method="post" action="/Backup/Create">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-success rounded-pill px-4">
<i class="bi bi-cloud-arrow-down me-2"></i>@L.T("إنشاء نسخة الآن","Backup Now")
</button>
</form>
</div>
@if (TempData["Success"] != null)
{
<div class="alert alert-success alert-dismissible fade show">
<i class="bi bi-check-circle me-2"></i>@TempData["Success"]
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
<div class="row mb-3">
<div class="col-md-4">
<div class="card border-0 bg-success-subtle text-center p-3">
<div class="fs-2 fw-bold text-success">@Model.Count(f => f.FileName.StartsWith("daily"))</div>
<div class="small text-muted">@L.T("نسخ يومية","Daily Backups")</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-0 bg-primary-subtle text-center p-3">
<div class="fs-2 fw-bold text-primary">@Model.Count(f => f.FileName.StartsWith("weekly"))</div>
<div class="small text-muted">@L.T("نسخ أسبوعية","Weekly Backups")</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-0 bg-warning-subtle text-center p-3">
<div class="fs-2 fw-bold text-warning">@((Model.Sum(f => f.SizeBytes) / 1024.0).ToString("N0")) KB</div>
<div class="small text-muted">@L.T("الحجم الكلي","Total Size")</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>@L.T("اسم الملف","File Name")</th>
<th>@L.T("النوع","Type")</th>
<th>@L.T("التاريخ","Date")</th>
<th>@L.T("الحجم","Size")</th>
<th>@L.T("تحميل","Download")</th>
</tr>
</thead>
<tbody>
@foreach (var f in Model)
{
var isWeekly = f.FileName.StartsWith("weekly");
<tr>
<td class="font-monospace small">@f.FileName</td>
<td>
@if (isWeekly)
{ <span class="badge bg-primary">@L.T("أسبوعية","Weekly")</span> }
else
{ <span class="badge bg-success">@L.T("يومية","Daily")</span> }
</td>
<td>@f.CreatedAt.ToString("dd/MM/yyyy HH:mm") UTC</td>
<td>@((f.SizeBytes / 1024.0).ToString("N1")) KB</td>
<td>
<a href="/Backup/Download?fileName=@f.FileName"
class="btn btn-sm btn-outline-success rounded-pill">
<i class="bi bi-download me-1"></i>@L.T("تحميل","Download")
</a>
</td>
</tr>
}
@if (!Model.Any())
{
<tr>
<td colspan="5" class="text-center text-muted py-5">
<i class="bi bi-archive fs-2 d-block mb-2"></i>
@L.T("لا توجد نسخ احتياطية بعد","No backups yet — click Backup Now")
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>