analytics page fix
This commit is contained in:
@@ -58,10 +58,11 @@ export function useApi() {
|
||||
};
|
||||
|
||||
const fetchCertificates = async () => {
|
||||
const res = await apiClient.get('/certificates');
|
||||
const res = await profilesApiClient.get('/profiles');
|
||||
return res.data;
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
apiClient,
|
||||
profilesApiClient,
|
||||
|
||||
@@ -109,12 +109,12 @@
|
||||
<i class="fas fa-check-circle text-success me-2"></i>All Good
|
||||
</p>
|
||||
<div v-else class="list-group list-group-flush">
|
||||
<div v-for="cert in expiringCertsList" :key="cert.common_name" class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
|
||||
<div v-for="cert in expiringCertsList" :key="cert.username" class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
|
||||
<div>
|
||||
<div class="fw-bold small">{{ cert.common_name }}</div>
|
||||
<div class="fw-bold small">{{ cert.username }}</div>
|
||||
<div class="text-muted" style="font-size: 0.75rem;">Expires: {{ cert.expiration_date }}</div>
|
||||
</div>
|
||||
<span class="badge status-warning text-dark">{{ cert.days_left }} days</span>
|
||||
<span class="badge status-warning text-dark">{{ cert.days_remaining }} days</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -202,32 +202,15 @@ const loadCerts = async () => {
|
||||
loading.certs = true;
|
||||
try {
|
||||
const res = await fetchCertificates();
|
||||
if(res.success) {
|
||||
const now = new Date();
|
||||
const warningThreshold = new Date();
|
||||
warningThreshold.setDate(now.getDate() + 45);
|
||||
|
||||
let count = 0;
|
||||
const list = [];
|
||||
|
||||
res.data.forEach(cert => {
|
||||
if (cert.status === 'revoked') return;
|
||||
const expDate = new Date(cert.expiration_date); // Assuming API returns ISO or parsable date
|
||||
|
||||
if (expDate <= warningThreshold) {
|
||||
count++;
|
||||
const diffTime = Math.abs(expDate - now);
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
|
||||
list.push({
|
||||
...cert,
|
||||
days_left: diffDays
|
||||
});
|
||||
}
|
||||
if(res.success && Array.isArray(res.data)) {
|
||||
const list = res.data.filter(cert => {
|
||||
// Only active, non-revoked, and expiring soon (within 45 days)
|
||||
return !cert.is_revoked && !cert.is_expired &&
|
||||
cert.days_remaining !== null && cert.days_remaining <= 45;
|
||||
});
|
||||
|
||||
kpi.expiringCerts = count;
|
||||
expiringCertsList.value = list.sort((a,b) => a.days_left - b.days_left);
|
||||
kpi.expiringCerts = list.length;
|
||||
expiringCertsList.value = list.sort((a,b) => (a.days_remaining || 0) - (b.days_remaining || 0));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -298,9 +281,9 @@ const renderMainChart = () => {
|
||||
mainChartInstance = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels,
|
||||
labels,
|
||||
datasets: [
|
||||
|
||||
{
|
||||
label: !isSpeedMode.value ? 'Received (MB)' : 'RX Mbps',
|
||||
data: dataRx,
|
||||
|
||||
Reference in New Issue
Block a user