Skip to content

Commit

Permalink
Update to Angular 19 (#270)
Browse files Browse the repository at this point in the history
* RT-1877: Update to Angular 19

* RT-1877: PatientService and ComponentObservationMapper to remove root provider declaration

* Implement code changes to improve data handling and optimize performance

* RT-1877: Add change detection in TimelineRangeSelectorComponent after view updates

* RT-1877: Fix change detection timing in TimelineRangeSelectorComponent

* RT-1877: Refactor SharedDataLayerListService to remove providedIn root scope

* RT-1877: Update maximumError size in project.json and remove unused import in observations.service.ts

* RT-1877: Resolve comment on the PR.

* RT-1877: Resolve comments in the PR.
  • Loading branch information
vdeshkar authored Mar 3, 2025
1 parent 68b32e3 commit 07354d0
Show file tree
Hide file tree
Showing 65 changed files with 12,017 additions and 12,914 deletions.
25 changes: 20 additions & 5 deletions apps/cardio-patient/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,38 @@ class MockDataLayerService implements DataLayerService {
retrieve = () => EMPTY;
}

@Component({ selector: 'fhir-chart' })
@Component({
selector: 'fhir-chart',
standalone: false,
})
class MockFhirChartComponent {
@Input() floatingContent?: TemplateRef<unknown>;
}

@Component({ selector: 'fhir-chart-summary' })
@Component({
selector: 'fhir-chart-summary',
standalone: false,
})
class MockFhirChartSummaryComponent {}

@Component({ selector: 'last-report-bp' })
@Component({
selector: 'last-report-bp',
standalone: false,
})
class MockLastReportBPComponent {}

@Component({ selector: 'report-bp' })
@Component({
selector: 'report-bp',
standalone: false,
})
class MockReportBPComponent {
@Output() resourceCreated = new EventEmitter<number>();
}

@Component({ selector: 'options-menu' })
@Component({
selector: 'options-menu',
standalone: false,
})
class MockOptionsMenuComponent {
@Input() chart?: FhirChartComponent;
}
Expand Down
6 changes: 5 additions & 1 deletion apps/cardio-patient/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import { environment } from '../environments/environment';
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: false,
})
export class AppComponent implements OnInit {
appTitle: string = environment.env.appTitle;
cdsicLogo = environment.env.cdsicLogo;
selectedIndex?: number;
showLegend = false;

constructor(readonly layerManager: DataLayerManagerService, private configService: FhirChartConfigurationService) {}
constructor(
readonly layerManager: DataLayerManagerService,
private readonly configService: FhirChartConfigurationService,
) {}

ngOnInit(): void {
this.layerManager.autoSelect(true);
Expand Down
11 changes: 3 additions & 8 deletions apps/cardio-patient/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { NgModule, inject, provideAppInitializer } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatCardModule } from '@angular/material/card';
Expand All @@ -24,16 +24,11 @@ import {
withSummaryServices,
FhirChartTagsLegendComponent,
} from '@elimuinformatics/ngx-charts-on-fhir';
import { environment } from '../environments/environment';
import { ReportBPModule } from './report-bp/report-bp.module';
import { LastReportBPModule } from './last-report-bp/last-report-bp.module';
import { OptionsMenuModule } from './options-menu/options-menu.module';
import { ObservationLayerService } from './datasets/observations.service';

function initializeFhirClientFactory(service: FhirDataService): () => Promise<void> {
return () => service.initialize(environment.clientState);
}

@NgModule({
declarations: [AppComponent],
imports: [
Expand All @@ -55,13 +50,13 @@ function initializeFhirClientFactory(service: FhirDataService): () => Promise<vo
FhirChartTagsLegendComponent,
],
providers: [
{ provide: APP_INITIALIZER, useFactory: initializeFhirClientFactory, deps: [FhirDataService], multi: true },
provideAppInitializer(() => inject(FhirDataService).initialize()),
{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { appearance: 'fill' } },
provideChartsOnFhir(
withColors('#e36667', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#c36d3c', '#f781bf', '#c46358', '#5a84a1', '#ba803f', '#90b354', '#ab7490'),
withMappers(BloodPressureMapper),
withDataLayerServices(ObservationLayerService),
withSummaryServices(ScatterDataPointSummaryService)
withSummaryServices(ScatterDataPointSummaryService),
),
],
bootstrap: [AppComponent],
Expand Down
5 changes: 4 additions & 1 deletion apps/cardio-patient/src/app/datasets/observations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export class ObservationLayerService extends DataLayerService {
},
];
query: string = '';
constructor(private fhir: FhirDataService, private converter: FhirConverter) {
constructor(
private readonly fhir: FhirDataService,
private readonly converter: FhirConverter,
) {
super();
this.query = this.getQueryfromCoding(this.codings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface LastReportedBPdata {
selector: 'last-report-bp',
templateUrl: './last-report-bp.component.html',
styleUrls: ['./last-report-bp.component.css'],
standalone: false,
})
export class LastReportBPComponent {
lastReportedBPdata?: LastReportedBPdata;
Expand All @@ -31,7 +32,7 @@ export class LastReportBPComponent {
systolic: { date: mostRecentData['systolic']?.x, value: mostRecentData['systolic']?.y },
diastolic: { date: mostRecentData['diastolic']?.x, value: mostRecentData['diastolic']?.y },
};
})
}),
)
.subscribe((layers: any) => {
if (layers.diastolic.date !== undefined && layers.systolic.date !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'options-menu',
templateUrl: './options-menu.component.html',
standalone: false,
})
export class OptionsMenuComponent {
@Input() legend?: boolean;
Expand Down
9 changes: 7 additions & 2 deletions apps/cardio-patient/src/app/report-bp/report-bp.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const BloodPressureRangeValidator: ValidatorFn = (control: AbstractControl): Val
selector: 'report-bp',
templateUrl: './report-bp.component.html',
styleUrls: ['./report-bp.component.css'],
standalone: false,
})
export class ReportBPComponent {
submitted = false;
Expand All @@ -27,10 +28,14 @@ export class ReportBPComponent {
systolic: [null, [Validators.required, Validators.min(this.min), Validators.max(this.max)]],
diastolic: [null, [Validators.required, Validators.min(this.min), Validators.max(this.max)]],
},
{ validators: [BloodPressureRangeValidator] }
{ validators: [BloodPressureRangeValidator] },
);

constructor(private fb: FormBuilder, private dataService: FhirDataService, private snackBar: MatSnackBar) {}
constructor(
private readonly fb: FormBuilder,
private readonly dataService: FhirDataService,
private readonly snackBar: MatSnackBar,
) {}

open(message: string, action = '', config?: MatSnackBarConfig) {
return this.snackBar.open(message, action, config);
Expand Down
1 change: 0 additions & 1 deletion apps/cardio/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@elimuinformatics/ngx-charts-on-fhir';

@Component({
standalone: true,
imports: [
CommonModule,
FhirChartComponent,
Expand Down
5 changes: 4 additions & 1 deletion apps/cardio/src/app/datasets/medications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { from, mergeMap } from 'rxjs';
providedIn: 'root',
})
export class MedicationLayerService extends DataLayerService {
constructor(private fhir: FhirDataService, private converter: FhirConverter) {
constructor(
private readonly fhir: FhirDataService,
private readonly converter: FhirConverter,
) {
super();
}
name = 'Medications';
Expand Down
2 changes: 1 addition & 1 deletion apps/documentation/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "3mb"
"maximumError": "3.1mb"
},
{
"type": "anyComponentStyle",
Expand Down
1 change: 1 addition & 0 deletions apps/documentation/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { Component } from '@angular/core';
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: false,
})
export class AppComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
selector: 'example-chart-layout-demo',
templateUrl: './chart-layout-demo.component.html',
styleUrls: ['./chart-layout-demo.component.css'],
standalone: true,
imports: [CommonModule, FhirChartLayoutComponent, MatIconModule, MatButtonModule],
})
export class ChartLayoutDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
@Component({
selector: 'example-chart-legend-demo',
templateUrl: './chart-legend-demo.component.html',
standalone: true,
imports: [CommonModule, FhirChartLegendComponent],
})
export class ChartLegendDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import {
DataLayerManagerService,
FhirChartLegendComponent,
FhirChartTagsLegendComponent,
} from '@elimuinformatics/ngx-charts-on-fhir';

@Component({
selector: 'example-chart-tags-legend-demo',
templateUrl: './chart-tags-legend-demo.component.html',
standalone: true,
imports: [CommonModule, FhirChartLegendComponent, FhirChartTagsLegendComponent],
imports: [CommonModule, FhirChartTagsLegendComponent],
})
export class ChartTagsLegendDemoComponent implements OnInit {
constructor(private layerManager: DataLayerManagerService) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
selector: 'example-chart-summary-demo',
templateUrl: './chart-summary-demo.component.html',
styleUrls: ['./chart-summary-demo.css'],
standalone: true,
imports: [CommonModule, FhirChartComponent, FhirChartSummaryComponent],
})
export class ChartSummaryDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import {
DataLayerManagerService,
FhirChartLegendComponent,
FhirChartComponent,
} from '@elimuinformatics/ngx-charts-on-fhir';
import { DataLayerManagerService, FhirChartComponent } from '@elimuinformatics/ngx-charts-on-fhir';

@Component({
selector: 'example-chart-demo',
templateUrl: './chart-demo.component.html',
standalone: true,
imports: [CommonModule, FhirChartComponent, FhirChartLegendComponent],
imports: [CommonModule, FhirChartComponent],
})
export class ChartDemoComponent implements OnInit {
constructor(private layerManager: DataLayerManagerService) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
@Component({
selector: 'example-floating-content-demo',
templateUrl: './floating-content-demo.component.html',
standalone: true,
imports: [CommonModule, FhirChartComponent, FhirChartLegendComponent],
})
export class FloatingContentDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
@Component({
selector: 'example-data-layer-browser-demo',
templateUrl: './data-layer-browser-demo.component.html',
standalone: true,
imports: [CommonModule, DataLayerBrowserComponent],
})
export class DataLayerBrowserDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
@Component({
selector: 'example-data-layer-list-demo',
templateUrl: './data-layer-list-demo.component.html',
standalone: true,
imports: [CommonModule, DataLayerListComponent],
})
export class DataLayerListDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
@Component({
selector: 'example-data-layer-selector-demo',
templateUrl: './data-layer-selector-demo.component.html',
standalone: true,
imports: [CommonModule, DataLayerSelectorComponent, FhirChartComponent],
})
export class DataLayerSelectorDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
@Component({
selector: 'example-patient-browser-demo',
templateUrl: './patient-browser-demo.component.html',
standalone: true,
imports: [CommonModule, PatientBrowserComponent],
})
export class PatientBrowserDemoComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
@Component({
selector: 'example-summary-range-selector-demo',
templateUrl: './summary-range-selector-demo.component.html',
standalone: true,
styleUrls: ['./summary-range-selector-demo.css'],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
@Component({
selector: 'example-timeline-range-selector-demo',
templateUrl: './timeline-range-selector-demo.component.html',
standalone: true,
imports: [CommonModule, FhirChartComponent, TimelineRangeSelectorComponent],
})
export class TimelineRangeSelectorDemoComponent implements OnInit {
Expand Down
6 changes: 4 additions & 2 deletions apps/showcase/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@elimuinformatics/ngx-charts-on-fhir';

@Component({
standalone: true,
imports: [
CommonModule,
SummaryRangeSelectorComponent,
Expand All @@ -32,7 +31,10 @@ export class AppComponent implements OnInit {
readonly toolbar: ToolbarButtonName[];
active: ToolbarButtonName | null;

constructor(readonly layerManager: DataLayerManagerService, readonly patientService: PatientService) {
constructor(
readonly layerManager: DataLayerManagerService,
readonly patientService: PatientService,
) {
if (patientService.isSinglePatientContext) {
this.toolbar = ['loading', 'browser', 'options'];
this.active = 'browser';
Expand Down
5 changes: 4 additions & 1 deletion apps/showcase/src/app/datasets/encounters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { from, mergeMap } from 'rxjs';
providedIn: 'root',
})
export class EncounterLayerService extends DataLayerService {
constructor(private fhir: FhirDataService, private converter: FhirConverter) {
constructor(
private readonly fhir: FhirDataService,
private readonly converter: FhirConverter,
) {
super();
}
name = 'Medications';
Expand Down
5 changes: 4 additions & 1 deletion apps/showcase/src/app/datasets/observations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { from, mergeMap } from 'rxjs';
providedIn: 'root',
})
export class ObservationLayerService extends DataLayerService {
constructor(private fhir: FhirDataService, private converter: FhirConverter) {
constructor(
private readonly fhir: FhirDataService,
private readonly converter: FhirConverter,
) {
super();
}
name = 'Observations';
Expand Down
2 changes: 1 addition & 1 deletion libs/ngx-charts-on-fhir/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elimuinformatics/ngx-charts-on-fhir",
"version": "6.1.7",
"version": "7.0.0",
"description": "Charts-on-FHIR: A data visualization library for SMART-on-FHIR healthcare applications",
"license": "Apache-2.0",
"homepage": "https://elimuinformatics.github.io/charts-on-fhir",
Expand Down
2 changes: 1 addition & 1 deletion libs/ngx-charts-on-fhir/src/default-fonts.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$material-icons-font-path: "material-icons/iconfont/";

@import "material-icons/iconfont/material-icons.scss";
@use "material-icons/iconfont/material-icons.scss";
@import "@fontsource/roboto/300.css";
@import "@fontsource/roboto/400.css";
@import "@fontsource/roboto/500.css";
5 changes: 3 additions & 2 deletions libs/ngx-charts-on-fhir/src/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
@use "./lib/data-layer-toolbar/data-layer-toolbar-theme" as toolbar;
@use "./lib/fhir-chart-layout/fhir-chart-layout-theme" as layout;

@import "./default-fonts.scss";
@use "./default-fonts.scss";

@include mat.core();
@include mat.elevation-classes();
@include mat.app-background();

// Define a theme.
$primary: mat.m2-define-palette(mat.$m2-indigo-palette);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { MatIconModule } from '@angular/material/icon';
import { OverlayModule } from '@angular/cdk/overlay';

@Component({
standalone: true,
imports: [CommonModule, MatButtonModule, MatIconModule, OverlayModule],
selector: 'color-picker',
templateUrl: './color-picker.component.html',
Expand Down
Loading

0 comments on commit 07354d0

Please sign in to comment.