diff --git a/src/components/project/InsightsCard.vue b/src/components/project/InsightsCard.vue new file mode 100644 index 0000000..d915aaa --- /dev/null +++ b/src/components/project/InsightsCard.vue @@ -0,0 +1,966 @@ + + + + + + + Insights + + + + + + + + + + + + + + + No insights data available + Click refresh to fetch insights + + + + + + + No chart data available + The insights response structure may need configuration + + View raw data + {{ + JSON.stringify(insightsData, null, 2) + }} + + + + + + + {{ chartConfig.title }} + + + + + + + + diff --git a/src/components/project/project.service.ts b/src/components/project/project.service.ts index 3343968..a25325a 100644 --- a/src/components/project/project.service.ts +++ b/src/components/project/project.service.ts @@ -124,4 +124,45 @@ export default class ProjectAPIService extends APIService { throw error; } } + + async getInsights(startTime?: string, endTime?: string, visualization?: string) { + try { + // Default to last hour if not specified + const now = new Date(); + const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000); + + const defaultStartTime = oneHourAgo.toISOString(); + const defaultEndTime = now.toISOString(); + + // Build parameters object + const paramsObj: Record = { + service_id: this.service_id, + start_time: startTime || defaultStartTime, + end_time: endTime || defaultEndTime, + visualization: visualization || 'top-url-by-bandwidth', // Default to specific visualization + }; + + // Validate time parameters + const validatedStartTime = validateApiParam(paramsObj.start_time); + const validatedEndTime = validateApiParam(paramsObj.end_time); + const validatedVisualization = validateApiParam(paramsObj.visualization); + + if (!validatedStartTime || !validatedEndTime || !validatedVisualization) { + throw new Error('Invalid parameters'); + } + + paramsObj.start_time = validatedStartTime; + paramsObj.end_time = validatedEndTime; + paramsObj.visualization = validatedVisualization; + + // Use secure URL building + const params = createSecureSearchParams(paramsObj); + + const response = await this.wsClient.get(`observability/log-insights?${params.toString()}`); + return response.data; + } catch (error) { + console.error(error); + throw error; + } + } } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index dc3e55a..3b3c7ab 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -16,6 +16,7 @@ import DomaCard from '@/components/domains/DomainCard.vue'; import HistCard from '@/components/project/HistoryCard.vue'; import InfoCard from '@/components/project/InfoCard.vue'; import StatCard from '@/components/project/StatCard.vue'; +import InsightsCard from '@/components/project/InsightsCard.vue'; import QueryCard from '@/components/project/QueryCard.vue'; import VersCard from '@/components/vcl/VclVersionCard.vue'; @@ -236,6 +237,7 @@ const vclVersionIsDefined = computed(() => credentialsStore.vclVersionIsDefined. /> +
No insights data available
Click refresh to fetch insights
No chart data available
The insights response structure may need configuration
{{ + JSON.stringify(insightsData, null, 2) + }}