diff --git a/APP_UI/src/composables/useApi.js b/APP_UI/src/composables/useApi.js index b3e4b48..ad7dcc6 100644 --- a/APP_UI/src/composables/useApi.js +++ b/APP_UI/src/composables/useApi.js @@ -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, diff --git a/APP_UI/src/views/Analytics.vue b/APP_UI/src/views/Analytics.vue index e4978e3..23e9b22 100644 --- a/APP_UI/src/views/Analytics.vue +++ b/APP_UI/src/views/Analytics.vue @@ -109,12 +109,12 @@ All Good

-
+
-
{{ cert.common_name }}
+
{{ cert.username }}
Expires: {{ cert.expiration_date }}
- {{ cert.days_left }} days + {{ cert.days_remaining }} days
@@ -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,