feat: dashboard & report APIs with real DB stats
Backend: - Add /dashboard/stats API (data_sources, tables, columns, labeled, sensitive, projects) - Add /dashboard/distribution API (level/cat/source distribution, project progress, heatmap) - Add /reports/stats API (total/auto/manual/reviewed counts + level distribution) - Fix report download: add template relationship to ClassificationProject - All stats computed from real DB queries Frontend: - Dashboard.vue: replace all hardcoded data with API-driven computed charts - Report.vue: replace all hardcoded data with API-driven charts - Add dashboard.ts and report.ts API clients
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import request from './request'
|
||||
|
||||
export interface DashboardStats {
|
||||
data_sources: number
|
||||
tables: number
|
||||
columns: number
|
||||
labeled: number
|
||||
sensitive: number
|
||||
projects: number
|
||||
}
|
||||
|
||||
export interface LevelDistItem {
|
||||
name: string
|
||||
code: string
|
||||
color: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface CategoryDistItem {
|
||||
name: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface SourceDistItem {
|
||||
source: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface ProjectProgressItem {
|
||||
id: number
|
||||
name: string
|
||||
status: string
|
||||
progress: number
|
||||
planned_end: string | null
|
||||
}
|
||||
|
||||
export interface HeatmapItem {
|
||||
source_name: string
|
||||
level_code: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface DashboardDistribution {
|
||||
level_distribution: LevelDistItem[]
|
||||
category_distribution: CategoryDistItem[]
|
||||
source_distribution: SourceDistItem[]
|
||||
project_progress: ProjectProgressItem[]
|
||||
heatmap: HeatmapItem[]
|
||||
}
|
||||
|
||||
export function getDashboardStats() {
|
||||
return request.get('/dashboard/stats')
|
||||
}
|
||||
|
||||
export function getDashboardDistribution() {
|
||||
return request.get('/dashboard/distribution')
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import request from './request'
|
||||
|
||||
export interface ReportStats {
|
||||
total: number
|
||||
auto: number
|
||||
manual: number
|
||||
reviewed: number
|
||||
level_distribution: {
|
||||
name: string
|
||||
code: string
|
||||
count: number
|
||||
}[]
|
||||
}
|
||||
|
||||
export function getReportStats() {
|
||||
return request.get('/reports/stats')
|
||||
}
|
||||
|
||||
export function downloadReport(projectId: number) {
|
||||
const token = localStorage.getItem('pdg_token')
|
||||
const url = `/api/v1/reports/projects/${projectId}/download`
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `report_project_${projectId}.docx`
|
||||
if (token) {
|
||||
a.setAttribute('data-token', token)
|
||||
}
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
}
|
||||
Reference in New Issue
Block a user