From ee7a9cb823282886c9022e42e4e84c981a0d0da3 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 08:57:21 -0400 Subject: [PATCH 01/11] Start integrating completeness report UI --- .../web/routes/data_submissions.py | 9 ++- .../web/src/components/CompletenessReport.ts | 42 ++++++++++++ nad_ch/controllers/web/src/index.ts | 2 + .../web/templates/data_submissions/show.html | 66 ++++++++++++++++++- 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 nad_ch/controllers/web/src/components/CompletenessReport.ts diff --git a/nad_ch/controllers/web/routes/data_submissions.py b/nad_ch/controllers/web/routes/data_submissions.py index 95a79b0..90676d3 100644 --- a/nad_ch/controllers/web/routes/data_submissions.py +++ b/nad_ch/controllers/web/routes/data_submissions.py @@ -1,4 +1,4 @@ -from flask import Blueprint, current_app, render_template, g +from flask import Blueprint, current_app, render_template, g, jsonify from flask_login import login_required, current_user from nad_ch.application.use_cases.data_submissions import ( get_data_submission, @@ -39,3 +39,10 @@ def reports(): def view_report(submission_id): view_model = get_data_submission(g.ctx, submission_id) return render_template("data_submissions/show.html", submission=view_model) + + +@submissions_bp.route("/api/reports/") +@login_required +def view_report_json(submission_id): + view_model = get_data_submission(g.ctx, submission_id) + return jsonify(view_model.report) diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.ts b/nad_ch/controllers/web/src/components/CompletenessReport.ts new file mode 100644 index 0000000..97f168d --- /dev/null +++ b/nad_ch/controllers/web/src/components/CompletenessReport.ts @@ -0,0 +1,42 @@ +import { AlpineComponent } from 'alpinejs'; +import { BASE_URL } from '../config'; + +export interface CompletenessReportComponent { + id: number; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + report: any; + isGroupedByStatus: boolean; + buttonText: string; + getStatusTagClass(status: string): string; +} + +export function CompletenessReport( + id: string, +): AlpineComponent { + return { + id: parseInt(id), + report: [], + isGroupedByStatus: false, + async init(): Promise { + const response = await fetch(`${BASE_URL}/api/reports/${this.id}`); + const reportData = await response.json(); + this.report = JSON.parse(reportData); + console.log(this.report); + }, + get buttonText(): string { + return this.isGroupedByStatus ? 'Ungroup by Status' : 'Group by Status'; + }, + getStatusTagClass(status: string): string { + switch (status) { + case 'No error': + return 'usa-tag__success'; + case 'Updated by calculation': + return 'usa-tag__warning'; + case 'Rejected': + return 'usa-tag__error'; + default: + return 'usa-tag__info'; + } + }, + }; +} diff --git a/nad_ch/controllers/web/src/index.ts b/nad_ch/controllers/web/src/index.ts index 3f40917..c2210df 100644 --- a/nad_ch/controllers/web/src/index.ts +++ b/nad_ch/controllers/web/src/index.ts @@ -2,6 +2,7 @@ import '@uswds/uswds/css/uswds.css'; import '@uswds/uswds'; import Alpine from 'alpinejs'; import { MappingForm } from './components/MappingForm'; +import { CompletenessReport } from './components/CompletenessReport'; declare global { interface Window { @@ -12,6 +13,7 @@ declare global { document.addEventListener('alpine:init', () => { Alpine.data('MappingForm', MappingForm); + Alpine.data('CompletenessReport', CompletenessReport); }); window.Alpine = Alpine; diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index a0d073b..1c10ff5 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -88,7 +88,71 @@

Yes

- {# Table goes here #} +
+
+ +
+
+ Grouped by Status +
+
+ + + + + + + + + + + + + +
Submitted Field + + * + + NAD Field + StatusEmptyPopulated
+
+
{% else %}

No such submission exists.

From 7e4d78b9a1fa03b3237d3dd33f6441fec0e4feac Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 09:02:04 -0400 Subject: [PATCH 02/11] Add tag styles --- .../web/sass/components/_usa-tag.scss | 38 +++++++ nad_ch/controllers/web/sass/index.scss | 1 + .../web/templates/data_submissions/show.html | 98 ++++++++++--------- 3 files changed, 91 insertions(+), 46 deletions(-) create mode 100644 nad_ch/controllers/web/sass/components/_usa-tag.scss diff --git a/nad_ch/controllers/web/sass/components/_usa-tag.scss b/nad_ch/controllers/web/sass/components/_usa-tag.scss new file mode 100644 index 0000000..af5ef37 --- /dev/null +++ b/nad_ch/controllers/web/sass/components/_usa-tag.scss @@ -0,0 +1,38 @@ +.usa-tag__success { + border-radius: 4px; + border: 1px solid var(--Green-cool-vivid-green-cool-vivid-10v, #b7f5bd); + background: var(--Green-cool-vivid-green-cool-vivid-10v, #b7f5bd); + color: black; + display: inline-flex; + padding: 2px 8px; + align-items: center; +} + +.usa-tag__info { + border-radius: 4px; + background: var(--Blue-vivid-blue-vivid-10v, #cfe8ff); + color: black; + display: inline-flex; + padding: 2px 8px; + align-items: center; +} + +.usa-tag__warning { + border-radius: 4px; + border: 1px solid var(--Warning-warning, #ffbe2e); + background: var(--Warning-warning, #ffbe2e); + color: black; + display: inline-flex; + padding: 2px 8px; + align-items: center; +} + +.usa-tag__error { + border-radius: 4px; + border: 1px solid var(--Error-error-dark, #b50909); + background: var(--Error-error-dark, #b50909); + color: white; + display: inline-flex; + padding: 2px 8px; + align-items: center; +} diff --git a/nad_ch/controllers/web/sass/index.scss b/nad_ch/controllers/web/sass/index.scss index 93525e7..06b9995 100644 --- a/nad_ch/controllers/web/sass/index.scss +++ b/nad_ch/controllers/web/sass/index.scss @@ -9,3 +9,4 @@ @import 'components/usa-select'; @import 'components/usa-sidenav'; @import 'components/usa-table'; +@import 'components/usa-tag'; diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index 1c10ff5..9a59cff 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -100,57 +100,63 @@

Yes

Grouped by Status
- - - - - - - - - - - - - -
Submitted Field - - * - - NAD Field - StatusEmptyPopulated
+ + + + + +
From a8d4b97990de0d4afa94de444603a194a5f60a37 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 09:08:02 -0400 Subject: [PATCH 03/11] Add toggle button styles --- .../web/sass/components/_usa-button.scss | 60 +++++++++++++++++++ .../web/src/components/CompletenessReport.ts | 6 ++ .../web/templates/data_submissions/show.html | 1 + 3 files changed, 67 insertions(+) diff --git a/nad_ch/controllers/web/sass/components/_usa-button.scss b/nad_ch/controllers/web/sass/components/_usa-button.scss index e4c047f..5378b21 100644 --- a/nad_ch/controllers/web/sass/components/_usa-button.scss +++ b/nad_ch/controllers/web/sass/components/_usa-button.scss @@ -8,3 +8,63 @@ width: auto; height: 30px; } + +@mixin rounded-border { + border-radius: 99px; +} + +@mixin focus-style { + // Override for outline-offset when focused and not disabled + &:not([disabled]):focus, + &:not([disabled]).usa-focus { + outline: 0; + } +} + +.usa-button-group-toggle { + justify-content: space-between; +} + +.usa-button-toggle-on, +.usa-button-toggle-off { + @include rounded-border; + @include focus-style; + color: var(--Primary-primary-dark, #1a4480); + display: flex; + justify-content: center; + align-items: center; + min-height: 50px; + min-width: 200px; +} + +.usa-button-toggle-on { + background: var(--Blue-vivid-blue-vivid-5v, #e8f5ff); + + &:hover { + background: var(--Blue-vivid-blue-vivid-10v, #cfe8ff); + color: var(--Primary-primary-dark, #1a4480); + } + + &:active { + background: var(--Primary-primary-dark, #1a4480); + color: var(--Base-base-lightest, #f0f0f0); + } +} + +.usa-button-toggle-off { + background: var(--Base-base-lightest, #f0f0f0); + border: 2px solid var(--Primary-primary-dark, #1a4480); + border-radius: 99px; + color: var(--Primary-primary-dark, #1a4480); + + &:hover { + border: 2px solid var(--Primary-primary-dark, #1a4480); + background: var(--Blue-vivid-blue-vivid-10v, #cfe8ff); + color: var(--Primary-primary-dark, #1a4480); + } + + &:active { + color: var(--Base-base-lightest, #f0f0f0); + background: var(--Primary-primary-dark, #1a4480); + } +} diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.ts b/nad_ch/controllers/web/src/components/CompletenessReport.ts index 97f168d..4ea3b84 100644 --- a/nad_ch/controllers/web/src/components/CompletenessReport.ts +++ b/nad_ch/controllers/web/src/components/CompletenessReport.ts @@ -7,6 +7,7 @@ export interface CompletenessReportComponent { report: any; isGroupedByStatus: boolean; buttonText: string; + toggleButtonClass: string; getStatusTagClass(status: string): string; } @@ -26,6 +27,11 @@ export function CompletenessReport( get buttonText(): string { return this.isGroupedByStatus ? 'Ungroup by Status' : 'Group by Status'; }, + get toggleButtonClass(): string { + return this.isGroupedByStatus + ? 'usa-button-toggle-on' + : 'usa-button-toggle-off'; + }, getStatusTagClass(status: string): string { switch (status) { case 'No error': diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index 9a59cff..7de56db 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -92,6 +92,7 @@

Yes

From de6e4df02199633c92904f1115c8dbe7e29691ce Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 09:27:12 -0400 Subject: [PATCH 04/11] Group features by status --- .../web/src/components/CompletenessReport.ts | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.ts b/nad_ch/controllers/web/src/components/CompletenessReport.ts index 4ea3b84..c35acc6 100644 --- a/nad_ch/controllers/web/src/components/CompletenessReport.ts +++ b/nad_ch/controllers/web/src/components/CompletenessReport.ts @@ -1,13 +1,42 @@ import { AlpineComponent } from 'alpinejs'; import { BASE_URL } from '../config'; +type CompletenessReport = { + features: Feature[]; + overview: Overview; +}; + +type Overview = { + data_update_required: boolean; + etl_update_required: boolean; + feature_count: number; + features_flagged: number; +}; + +type Feature = { + provided_feature_name: string; + nad_feature_name: string; + populated_count: number; + null_count: number; + required: boolean; + status: string; + populated_percentage: string; + null_percentage: string; +}; + +type GroupedFeature = { + status: string; + features: Feature[]; +}; + export interface CompletenessReportComponent { id: number; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - report: any; + report: CompletenessReport | null; + groupedFeatures: GroupedFeature[]; isGroupedByStatus: boolean; buttonText: string; toggleButtonClass: string; + groupFeatures(features: Feature[]): GroupedFeature[]; getStatusTagClass(status: string): string; } @@ -16,13 +45,35 @@ export function CompletenessReport( ): AlpineComponent { return { id: parseInt(id), - report: [], + report: null, + groupedFeatures: [], isGroupedByStatus: false, async init(): Promise { const response = await fetch(`${BASE_URL}/api/reports/${this.id}`); const reportData = await response.json(); this.report = JSON.parse(reportData); + if (this.report) { + this.groupedFeatures = this.groupFeatures(this.report.features); + } console.log(this.report); + console.log(this.groupedFeatures); + }, + groupFeatures(features: Feature[]): GroupedFeature[] { + const groupedByStatus = features.reduce>( + (acc, obj) => { + if (!acc[obj.status]) { + acc[obj.status] = []; + } + acc[obj.status].push(obj); + return acc; + }, + {}, + ); + + return Object.keys(groupedByStatus).map((status) => ({ + status: status, + features: groupedByStatus[status], + })); }, get buttonText(): string { return this.isGroupedByStatus ? 'Ungroup by Status' : 'Group by Status'; From 1023c5d26610778f80b4f334c720d35ad9b6d4fc Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 09:40:43 -0400 Subject: [PATCH 05/11] Add percentages --- .../web/templates/data_submissions/show.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index 7de56db..796a30f 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -138,7 +138,10 @@

Yes

- +
Yes > - +
Date: Thu, 28 Mar 2024 10:11:35 -0400 Subject: [PATCH 06/11] Add grouped by status display --- .../web/src/components/CompletenessReport.ts | 32 ++++++-- .../web/templates/data_submissions/show.html | 75 ++++++++++++++++++- 2 files changed, 95 insertions(+), 12 deletions(-) diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.ts b/nad_ch/controllers/web/src/components/CompletenessReport.ts index c35acc6..89ba4a1 100644 --- a/nad_ch/controllers/web/src/components/CompletenessReport.ts +++ b/nad_ch/controllers/web/src/components/CompletenessReport.ts @@ -31,6 +31,7 @@ type GroupedFeature = { export interface CompletenessReportComponent { id: number; + isLoading: boolean; report: CompletenessReport | null; groupedFeatures: GroupedFeature[]; isGroupedByStatus: boolean; @@ -45,18 +46,33 @@ export function CompletenessReport( ): AlpineComponent { return { id: parseInt(id), - report: null, + isLoading: true, + report: { + features: [], + overview: { + data_update_required: false, + etl_update_required: false, + feature_count: 0, + features_flagged: 0, + }, + }, groupedFeatures: [], isGroupedByStatus: false, async init(): Promise { - const response = await fetch(`${BASE_URL}/api/reports/${this.id}`); - const reportData = await response.json(); - this.report = JSON.parse(reportData); - if (this.report) { - this.groupedFeatures = this.groupFeatures(this.report.features); + try { + const response = await fetch(`${BASE_URL}/api/reports/${this.id}`); + const reportData = await response.json(); + this.report = JSON.parse(reportData); + if (this.report) { + this.groupedFeatures = this.groupFeatures(this.report.features); + } + } catch (error) { + console.error('Failed to load report:', error); + } finally { + this.isLoading = false; + console.log(this.report); + console.log(this.groupedFeatures); } - console.log(this.report); - console.log(this.groupedFeatures); }, groupFeatures(features: Feature[]): GroupedFeature[] { const groupedByStatus = features.reduce>( diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index 796a30f..2e5c218 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -18,7 +18,6 @@ type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" - aria-controls="extended-mega-nav-section-one" :class="showSummary ? 'usa-current' : ''" @click="showSummary = true; showCompleteness = false" > @@ -31,7 +30,6 @@ type="button" class="usa-accordion__button usa-nav__link" aria-expanded="false" - aria-controls="extended-mega-nav-section-two" :class="showCompleteness ? 'usa-current' : ''" @click="showSummary = false; showCompleteness = true" > @@ -97,9 +95,78 @@

Yes

x-text="buttonText" >
-
- Grouped by Status + +
+ + + + + + + + + + + +
Submitted Field + + * + + NAD Field + StatusEmptyPopulated
+
From fe4f06d0d82e75759de8042f6abc2208c19dcc49 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 12:36:08 -0400 Subject: [PATCH 07/11] Extract fetch call to humble function and test CompletenessReport component --- .../src/components/CompletenessReport.spec.ts | 121 ++++++++++++++++++ .../web/src/components/CompletenessReport.ts | 11 +- nad_ch/controllers/web/src/services.ts | 8 ++ 3 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 nad_ch/controllers/web/src/components/CompletenessReport.spec.ts create mode 100644 nad_ch/controllers/web/src/services.ts diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts b/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts new file mode 100644 index 0000000..b1f5db4 --- /dev/null +++ b/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts @@ -0,0 +1,121 @@ +/** + * @jest-environment jsdom + */ + +import { + CompletenessReport, + CompletenessReportComponent, +} from './CompletenessReport'; +import { AlpineComponent } from 'alpinejs'; +import { fetchReportData } from '../services'; + +jest.mock('../services', () => ({ + fetchReportData: jest.fn(), +})); + +describe('CompletenessReportComponent', () => { + let component: AlpineComponent; + const mockReportData = { + features: [ + { + provided_feature_name: 'AddNum_Pre', + nad_feature_name: 'AddNum_Pre', + populated_count: 1141, + null_count: 0, + required: false, + status: 'No error', + populated_percentage: '100%', + null_percentage: '0%', + }, + { + provided_feature_name: 'Add_Number', + nad_feature_name: 'Add_Number', + populated_count: 1141, + null_count: 0, + required: true, + status: 'No error', + populated_percentage: '100%', + null_percentage: '0%', + }, + ], + overview: { + data_update_required: false, + etl_update_required: false, + feature_count: 10, + features_flagged: 2, + }, + }; + + beforeEach(() => { + (fetchReportData as jest.Mock).mockResolvedValue(mockReportData); + component = CompletenessReport('1'); + }); + + it('initializes with default data', () => { + expect(component.id).toBe(1); + expect(component.isLoading).toBe(true); + expect(component.groupedFeatures).toEqual([]); + expect(component.isGroupedByStatus).toBe(false); + }); + + it('loads report data on init', async () => { + await component.init(); + expect(fetchReportData).toHaveBeenCalledWith(1); + expect(component.isLoading).toBe(false); + expect(component.report).toEqual(mockReportData); + }); + + it('groups features by status', () => { + // Assuming mockReportData contains features with varying statuses + component.report = mockReportData; // Set report data directly for testing + const groupedFeatures = component.groupFeatures(mockReportData.features); + expect(groupedFeatures).toEqual([ + { + status: 'No error', + features: [ + { + provided_feature_name: 'AddNum_Pre', + nad_feature_name: 'AddNum_Pre', + populated_count: 1141, + null_count: 0, + required: false, + status: 'No error', + populated_percentage: '100%', + null_percentage: '0%', + }, + { + provided_feature_name: 'Add_Number', + nad_feature_name: 'Add_Number', + populated_count: 1141, + null_count: 0, + required: true, + status: 'No error', + populated_percentage: '100%', + null_percentage: '0%', + }, + ], + }, + ]); + }); + + it('computes buttonText based on isGroupedByStatus', () => { + expect(component.buttonText).toBe('Group by Status'); + component.isGroupedByStatus = true; + expect(component.buttonText).toBe('Ungroup by Status'); + }); + + it('computes toggleButtonClass based on isGroupedByStatus', () => { + expect(component.toggleButtonClass).toBe('usa-button-toggle-off'); + component.isGroupedByStatus = true; + expect(component.toggleButtonClass).toBe('usa-button-toggle-on'); + }); + + it('gets status tag class based on different statuses', () => { + expect(component.getStatusTagClass('No error')).toBe('usa-tag__success'); + expect(component.getStatusTagClass('Updated by calculation')).toBe( + 'usa-tag__warning', + ); + expect(component.getStatusTagClass('Rejected')).toBe('usa-tag__error'); + expect(component.getStatusTagClass('Other')).toBe('usa-tag__info'); + }); +}); diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.ts b/nad_ch/controllers/web/src/components/CompletenessReport.ts index 89ba4a1..c286172 100644 --- a/nad_ch/controllers/web/src/components/CompletenessReport.ts +++ b/nad_ch/controllers/web/src/components/CompletenessReport.ts @@ -1,7 +1,7 @@ import { AlpineComponent } from 'alpinejs'; -import { BASE_URL } from '../config'; +import { fetchReportData } from '../services'; -type CompletenessReport = { +export type CompletenessReport = { features: Feature[]; overview: Overview; }; @@ -37,6 +37,7 @@ export interface CompletenessReportComponent { isGroupedByStatus: boolean; buttonText: string; toggleButtonClass: string; + init(): Promise; groupFeatures(features: Feature[]): GroupedFeature[]; getStatusTagClass(status: string): string; } @@ -60,9 +61,7 @@ export function CompletenessReport( isGroupedByStatus: false, async init(): Promise { try { - const response = await fetch(`${BASE_URL}/api/reports/${this.id}`); - const reportData = await response.json(); - this.report = JSON.parse(reportData); + this.report = await fetchReportData(this.id); if (this.report) { this.groupedFeatures = this.groupFeatures(this.report.features); } @@ -70,8 +69,6 @@ export function CompletenessReport( console.error('Failed to load report:', error); } finally { this.isLoading = false; - console.log(this.report); - console.log(this.groupedFeatures); } }, groupFeatures(features: Feature[]): GroupedFeature[] { diff --git a/nad_ch/controllers/web/src/services.ts b/nad_ch/controllers/web/src/services.ts new file mode 100644 index 0000000..6760736 --- /dev/null +++ b/nad_ch/controllers/web/src/services.ts @@ -0,0 +1,8 @@ +import { BASE_URL } from './config'; +import { CompletenessReport } from './components/CompletenessReport'; + +export async function fetchReportData(id: number): Promise { + const response = await fetch(`${BASE_URL}/api/reports/${id}`); + const reportData = await response.json(); + return JSON.parse(reportData); +} From 63e5e504c23e7caf81a0fd97070cc3a128f8cccf Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 12:49:56 -0400 Subject: [PATCH 08/11] Use actual report data in template --- nad_ch/application/view_models.py | 3 +-- .../web/src/components/CompletenessReport.spec.ts | 3 +-- nad_ch/controllers/web/src/services.ts | 2 +- .../web/templates/data_submissions/show.html | 10 +++++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nad_ch/application/view_models.py b/nad_ch/application/view_models.py index b063507..3fb036a 100644 --- a/nad_ch/application/view_models.py +++ b/nad_ch/application/view_models.py @@ -104,8 +104,7 @@ class DataSubmissionViewModel(ViewModel): def create_data_submission_vm(submission: DataSubmission) -> DataSubmissionViewModel: report_json = [] if submission.report is not None: - enriched_report = enrich_report(submission.report) - report_json = json.dumps(enriched_report) + report_json = enrich_report(submission.report) return DataSubmissionViewModel( id=submission.id, diff --git a/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts b/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts index b1f5db4..7909a5c 100644 --- a/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts +++ b/nad_ch/controllers/web/src/components/CompletenessReport.spec.ts @@ -66,8 +66,7 @@ describe('CompletenessReportComponent', () => { }); it('groups features by status', () => { - // Assuming mockReportData contains features with varying statuses - component.report = mockReportData; // Set report data directly for testing + component.report = mockReportData; const groupedFeatures = component.groupFeatures(mockReportData.features); expect(groupedFeatures).toEqual([ { diff --git a/nad_ch/controllers/web/src/services.ts b/nad_ch/controllers/web/src/services.ts index 6760736..8a285a9 100644 --- a/nad_ch/controllers/web/src/services.ts +++ b/nad_ch/controllers/web/src/services.ts @@ -4,5 +4,5 @@ import { CompletenessReport } from './components/CompletenessReport'; export async function fetchReportData(id: number): Promise { const response = await fetch(`${BASE_URL}/api/reports/${id}`); const reportData = await response.json(); - return JSON.parse(reportData); + return reportData; } diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index 2e5c218..a69264d 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -54,25 +54,25 @@
-

1141

+

{{ submission.report.overview.feature_count }}

Total records submitted

-

0

+

{{ submission.report.overview.feature_count }}

Records added to NAD

-

537

+

{{ submission.report.overview.features_flagged }}

Records flagged

-

Yes

+

{{ submission.report.overview.etl_update_required }}

ETL update required

-

Yes

+

{{ submission.report.overview.data_update_required }}

Data update required

From e86c8668b57d156fcc5eaaa416394229e3e70d78 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 28 Mar 2024 13:10:56 -0400 Subject: [PATCH 09/11] Update dev seed script to add report --- .../web/templates/data_submissions/show.html | 4 +- scripts/seed.py | 156 +++++++++++++++++- 2 files changed, 157 insertions(+), 3 deletions(-) diff --git a/nad_ch/controllers/web/templates/data_submissions/show.html b/nad_ch/controllers/web/templates/data_submissions/show.html index a69264d..e4b3124 100644 --- a/nad_ch/controllers/web/templates/data_submissions/show.html +++ b/nad_ch/controllers/web/templates/data_submissions/show.html @@ -113,8 +113,8 @@

{{ submission.report.overview.data_update_required }}