diff --git a/src/app/announcement/announcement.component.ts b/src/app/announcement/announcement.component.ts index 3e58704a532..f648f2fe7f1 100644 --- a/src/app/announcement/announcement.component.ts +++ b/src/app/announcement/announcement.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, ViewEncapsulation, Inject } from '@angular/core'; +import { Component, EventEmitter, Input, Output, ViewEncapsulation, inject } from '@angular/core'; import { Announcement } from '../domain/announcement'; import { MatDialogRef, @@ -22,11 +22,11 @@ import { CdkScrollable } from '@angular/cdk/scrolling'; templateUrl: './announcement.component.html' }) export class AnnouncementComponent { + dialog = inject(MatDialog); + @Input() announcement: Announcement = new Announcement(); @Output() dismiss: EventEmitter = new EventEmitter(); - constructor(public dialog: MatDialog) {} - protected showAnnouncementDetails(): void { this.dialog.open(AnnouncementDialogComponent, { data: this.announcement, @@ -48,8 +48,6 @@ export class AnnouncementComponent { templateUrl: 'announcement-dialog.component.html' }) export class AnnouncementDialogComponent { - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: Announcement - ) {} + dialogRef = inject>(MatDialogRef); + data = inject(MAT_DIALOG_DATA); } diff --git a/src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.ts b/src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.ts index 6f0853e190c..f1134d5a1b7 100644 --- a/src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.ts +++ b/src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { ComponentTypeButtonComponent } from '../../../../assets/wise5/authoringTool/components/component-type-button/component-type-button.component'; @@ -10,12 +10,10 @@ import { ComponentTypeService } from '../../../../assets/wise5/services/componen templateUrl: 'choose-new-component.component.html' }) export class ChooseNewComponent { - protected componentTypes: any[]; + private componentTypeService = inject(ComponentTypeService); + private dialogRef = inject(MatDialogRef); - constructor( - private componentTypeService: ComponentTypeService, - private dialogRef: MatDialogRef - ) {} + protected componentTypes: any[]; ngOnInit(): void { this.componentTypes = this.componentTypeService.getComponentTypes(); diff --git a/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts b/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts index 94a3858b113..24468551674 100644 --- a/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts +++ b/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts @@ -1,4 +1,4 @@ -import { Directive, Input } from '@angular/core'; +import { Directive, inject, Input } from '@angular/core'; import { ComponentContent } from '../../../assets/wise5/common/ComponentContent'; import { Component } from '../../../assets/wise5/common/Component'; import { NotebookService } from '../../../assets/wise5/services/notebookService'; @@ -8,17 +8,15 @@ import { moveObjectDown, moveObjectUp } from '../../../assets/wise5/common/array @Directive() export abstract class EditAdvancedComponentComponent { + protected nodeService = inject(TeacherNodeService); + protected notebookService = inject(NotebookService); + protected teacherProjectService = inject(TeacherProjectService); + component: Component; componentContent: ComponentContent; @Input() componentId: string; @Input() nodeId: string; - constructor( - protected nodeService: TeacherNodeService, - protected notebookService: NotebookService, - protected teacherProjectService: TeacherProjectService - ) {} - ngOnInit(): void { this.componentContent = this.teacherProjectService.getComponent(this.nodeId, this.componentId); this.component = new Component(this.componentContent, this.nodeId); diff --git a/src/app/authoring-tool/edit-advanced-component/edit-component-default-feedback/edit-component-default-feedback.component.ts b/src/app/authoring-tool/edit-advanced-component/edit-component-default-feedback/edit-component-default-feedback.component.ts index c4b9e1010ca..0162407a46f 100644 --- a/src/app/authoring-tool/edit-advanced-component/edit-component-default-feedback/edit-component-default-feedback.component.ts +++ b/src/app/authoring-tool/edit-advanced-component/edit-component-default-feedback/edit-component-default-feedback.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { TeacherProjectService } from '../../../../assets/wise5/services/teacherProjectService'; @@ -24,12 +24,12 @@ import { MatFormFieldModule } from '@angular/material/form-field'; templateUrl: 'edit-component-default-feedback.component.html' }) export class EditComponentDefaultFeedback { + private projectService = inject(TeacherProjectService); + @Input() componentContent: any; protected feedbackChanged: Subject = new Subject(); private feedbackChangedSubscription: Subscription; - constructor(private projectService: TeacherProjectService) {} - ngOnInit(): void { this.feedbackChangedSubscription = this.feedbackChanged .pipe(debounceTime(1000), distinctUntilChanged()) diff --git a/src/app/authoring-tool/edit-common-advanced/edit-common-advanced.component.ts b/src/app/authoring-tool/edit-common-advanced/edit-common-advanced.component.ts index cd5ab289ac2..526b61f62b9 100644 --- a/src/app/authoring-tool/edit-common-advanced/edit-common-advanced.component.ts +++ b/src/app/authoring-tool/edit-common-advanced/edit-common-advanced.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { Component as WISEComponent } from '../../../assets/wise5/common/Component'; import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; import { EditConnectedComponentsComponent } from '../edit-connected-components/edit-connected-components.component'; @@ -33,11 +33,11 @@ import { EditComponentConstraintsComponent } from '../edit-component-constraints templateUrl: './edit-common-advanced.component.html' }) export class EditCommonAdvancedComponent { + protected projectService = inject(TeacherProjectService); + @Input() allowedConnectedComponentTypes: string[] = []; @Input() component: WISEComponent; - constructor(protected projectService: TeacherProjectService) {} - protected connectedComponentsChanged(connectedComponents: any[]): void { this.component.content.connectedComponents = connectedComponents; this.projectService.nodeChanged(); diff --git a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts index 92d606db2b1..4a16bbea122 100644 --- a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts +++ b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts @@ -5,8 +5,8 @@ import { createComponent, ElementRef, EnvironmentInjector, - Inject, - ViewChild + ViewChild, + inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; @@ -22,13 +22,12 @@ import { components } from '../../../assets/wise5/components/Components'; templateUrl: './edit-component-advanced.component.html' }) export class EditComponentAdvancedComponent { + private applicationRef = inject(ApplicationRef); + protected component = inject(MAT_DIALOG_DATA); + private injector = inject(EnvironmentInjector); + @ViewChild('component') private componentElementRef: ElementRef; private componentRef: ComponentRef; - constructor( - private applicationRef: ApplicationRef, - @Inject(MAT_DIALOG_DATA) protected component: WISEComponent, - private injector: EnvironmentInjector - ) {} ngAfterViewInit(): void { this.componentRef = createComponent(components[this.component.content.type].authoringAdvanced, { diff --git a/src/app/authoring-tool/edit-component-field.component.ts b/src/app/authoring-tool/edit-component-field.component.ts index a8fe4df789d..bdd456c2b51 100644 --- a/src/app/authoring-tool/edit-component-field.component.ts +++ b/src/app/authoring-tool/edit-component-field.component.ts @@ -1,16 +1,16 @@ -import { Directive, Input } from '@angular/core'; +import { Directive, inject, Input } from '@angular/core'; import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { TeacherProjectService } from '../../assets/wise5/services/teacherProjectService'; @Directive() export abstract class EditComponentFieldComponent { + private projectService = inject(TeacherProjectService); + @Input() componentContent: any; protected inputChanged: Subject = new Subject(); protected inputChangedSubscription: Subscription; - constructor(private projectService: TeacherProjectService) {} - ngOnInit(): void { this.inputChangedSubscription = this.inputChanged .pipe(debounceTime(1000), distinctUntilChanged()) diff --git a/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts b/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts index 91af05c6b8e..ff5c8a8703e 100644 --- a/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts +++ b/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, inject, Input } from '@angular/core'; import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { NotificationService } from '../../../assets/wise5/services/notificationService'; @@ -27,6 +27,9 @@ import { MatButtonModule } from '@angular/material/button'; templateUrl: 'edit-component-json.component.html' }) export class EditComponentJsonComponent { + private notificationService = inject(NotificationService); + private projectService = inject(TeacherProjectService); + @Input() component: WISEComponent; protected componentContentJSONString: string; protected jsonChanged: Subject = new Subject(); @@ -34,11 +37,6 @@ export class EditComponentJsonComponent { private subscriptions: Subscription = new Subscription(); private validComponentContentJSONString: string; - constructor( - private notificationService: NotificationService, - private projectService: TeacherProjectService - ) {} - ngOnInit(): void { this.setComponentContentJsonString(); this.subscriptions.add( diff --git a/src/app/authoring-tool/edit-component-peer-grouping-tag/edit-component-peer-grouping-tag.component.ts b/src/app/authoring-tool/edit-component-peer-grouping-tag/edit-component-peer-grouping-tag.component.ts index 6a33ceb93c9..112cc533a15 100644 --- a/src/app/authoring-tool/edit-component-peer-grouping-tag/edit-component-peer-grouping-tag.component.ts +++ b/src/app/authoring-tool/edit-component-peer-grouping-tag/edit-component-peer-grouping-tag.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; import { SelectPeerGroupingAuthoringComponent } from '../../../assets/wise5/authoringTool/peer-grouping/select-peer-grouping-authoring/select-peer-grouping-authoring.component'; @@ -11,9 +11,9 @@ import { SelectPeerGroupingAuthoringComponent } from '../../../assets/wise5/auth />` }) export class EditComponentPeerGroupingTagComponent { - @Input() componentContent: any; + private projectService = inject(TeacherProjectService); - constructor(private projectService: TeacherProjectService) {} + @Input() componentContent: any; peerGroupingTagChanged(tag: string): void { this.componentContent.peerGroupingTag = tag; diff --git a/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts b/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts index a2b667fb10c..1758995bd33 100644 --- a/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts +++ b/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; @@ -21,11 +21,11 @@ import { MatFormFieldModule } from '@angular/material/form-field'; templateUrl: 'edit-component-rubric.component.html' }) export class EditComponentRubricComponent { + private projectService = inject(TeacherProjectService); + @Input() componentContent: any; protected showRubricAuthoring: boolean; - constructor(private projectService: TeacherProjectService) {} - protected save(): void { this.projectService.componentChanged(); } diff --git a/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts b/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts index ae7998727e0..683c64390bc 100644 --- a/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts +++ b/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; @@ -36,12 +36,12 @@ import { MatFormFieldModule } from '@angular/material/form-field'; templateUrl: 'edit-component-tags.component.html' }) export class EditComponentTagsComponent { + private projectService = inject(TeacherProjectService); + @Input() componentContent: any; protected tagChanged: Subject = new Subject(); private tagChangedSubscription: Subscription; - constructor(private projectService: TeacherProjectService) {} - ngOnInit(): void { this.tagChangedSubscription = this.tagChanged .pipe(debounceTime(1000), distinctUntilChanged()) diff --git a/src/app/authoring-tool/edit-connected-components-with-background/edit-connected-components-with-background.component.ts b/src/app/authoring-tool/edit-connected-components-with-background/edit-connected-components-with-background.component.ts index 3dd56d4fd7e..491d8568cd3 100644 --- a/src/app/authoring-tool/edit-connected-components-with-background/edit-connected-components-with-background.component.ts +++ b/src/app/authoring-tool/edit-connected-components-with-background/edit-connected-components-with-background.component.ts @@ -1,17 +1,10 @@ import { Component } from '@angular/core'; -import { ProjectService } from '../../../assets/wise5/services/projectService'; import { EditConnectedComponentsComponent } from '../edit-connected-components/edit-connected-components.component'; -@Component({ - template: '' -}) +@Component({ template: ''}) // this class needs to be a component to extends parent class and be used as a base class export class EditConnectedComponentsWithBackgroundComponent extends EditConnectedComponentsComponent { componentTypesThatCanImportWorkAsBackground: string[] = []; - constructor(protected projectService: ProjectService) { - super(projectService); - } - canConnectedComponentTypeImportWorkAsBackground(connectedComponent: any): boolean { return this.componentTypesThatCanImportWorkAsBackground.includes( this.getConnectedComponentType(connectedComponent) diff --git a/src/app/authoring-tool/edit-connected-components/edit-connected-components.component.ts b/src/app/authoring-tool/edit-connected-components/edit-connected-components.component.ts index 87aa82c6b45..6a66280963d 100644 --- a/src/app/authoring-tool/edit-connected-components/edit-connected-components.component.ts +++ b/src/app/authoring-tool/edit-connected-components/edit-connected-components.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core'; import { ProjectService } from '../../../assets/wise5/services/projectService'; import { EditConnectedComponentsAddButtonComponent } from '../edit-connected-components-add-button/edit-connected-components-add-button.component'; import { EditConnectedComponentDefaultSelectsComponent } from '../edit-connected-component-default-selects/edit-connected-component-default-selects.component'; @@ -22,8 +22,7 @@ export class EditConnectedComponentsComponent implements OnInit { @Input() connectedComponents: any[] = []; @Output() connectedComponentsChanged: EventEmitter = new EventEmitter(); nodeIds: string[]; - - constructor(protected projectService: ProjectService) {} + protected projectService: ProjectService = inject(ProjectService); ngOnInit(): void { if (this.connectedComponents == null) { diff --git a/src/app/authoring-tool/edit-question-bank/edit-question-bank.component.ts b/src/app/authoring-tool/edit-question-bank/edit-question-bank.component.ts index 5596a6499e4..c85bc58b567 100644 --- a/src/app/authoring-tool/edit-question-bank/edit-question-bank.component.ts +++ b/src/app/authoring-tool/edit-question-bank/edit-question-bank.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatCheckbox, MatCheckboxChange } from '@angular/material/checkbox'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -27,13 +27,13 @@ import { SelectStepAndComponentComponent } from '../select-step-and-component/se templateUrl: './edit-question-bank.component.html' }) export class EditQuestionBankComponent implements OnInit { + private projectService = inject(TeacherProjectService); + protected allowedReferenceComponentTypes: string[] = ['MultipleChoice', 'OpenResponse']; @Input() componentContent: any; protected inputChanged: Subject = new Subject(); private subscriptions: Subscription = new Subscription(); - constructor(private projectService: TeacherProjectService) {} - ngOnInit(): void { this.subscriptions.add( this.inputChanged.pipe(debounceTime(1000), distinctUntilChanged()).subscribe(() => { diff --git a/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts b/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts index cbb73359e90..e2e4898cb37 100644 --- a/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts +++ b/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatDividerModule } from '@angular/material/divider'; import { MatTabsModule } from '@angular/material/tabs'; @@ -16,19 +16,17 @@ import { AddStepTarget } from '../../../domain/addStepTarget'; templateUrl: './choose-import-unit.component.html' }) export class ChooseImportUnitComponent { + private configService = inject(ConfigService); + private projectLibraryService = inject(ProjectLibraryService); + private route = inject(ActivatedRoute); + private router = inject(Router); + protected importType: 'step' | 'component'; protected libraryProjects: any[]; protected myProjects: any[]; private subscriptions: Subscription = new Subscription(); protected target: AddStepTarget; - constructor( - private configService: ConfigService, - private projectLibraryService: ProjectLibraryService, - private route: ActivatedRoute, - private router: Router - ) {} - ngOnInit(): void { this.importType = history.state.importType; this.target = history.state; diff --git a/src/app/authoring-tool/select-component/select-component.component.ts b/src/app/authoring-tool/select-component/select-component.component.ts index 73ece440b21..9bf77d88bed 100644 --- a/src/app/authoring-tool/select-component/select-component.component.ts +++ b/src/app/authoring-tool/select-component/select-component.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, SimpleChanges } from '@angular/core'; +import { Component, EventEmitter, Input, Output, SimpleChanges, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; @@ -11,6 +11,8 @@ import { ComponentContent } from '../../../assets/wise5/common/ComponentContent' templateUrl: './select-component.component.html' }) export class SelectComponentComponent { + private projectService = inject(ProjectService); + @Input() allowedComponentTypes: string[] = []; @Output() componentChangedEvent: EventEmitter = new EventEmitter(); @Input() componentId: string; @@ -19,8 +21,6 @@ export class SelectComponentComponent { @Input() nodeId: string; @Input() thisComponentId: string; - constructor(private projectService: ProjectService) {} - ngOnChanges(changes: SimpleChanges): void { if (changes.nodeId) { this.nodeId = changes.nodeId.currentValue; diff --git a/src/app/authoring-tool/select-step-and-component/select-step-and-component.component.ts b/src/app/authoring-tool/select-step-and-component/select-step-and-component.component.ts index 1b82ef6f430..e5026a7b012 100644 --- a/src/app/authoring-tool/select-step-and-component/select-step-and-component.component.ts +++ b/src/app/authoring-tool/select-step-and-component/select-step-and-component.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Input, Output, inject } from '@angular/core'; import { ReferenceComponent } from '../../domain/referenceComponent'; import { SelectStepComponent } from '../select-step/select-step.component'; import { SelectComponentComponent } from '../select-component/select-component.component'; @@ -20,14 +20,14 @@ import { SelectComponentComponent } from '../select-component/select-component.c />` }) export class SelectStepAndComponentComponent { + private changeDetector = inject(ChangeDetectorRef); + @Input() allowedComponentTypes: string[] = []; @Output() componentChange: EventEmitter = new EventEmitter(); @Input() referenceComponent: ReferenceComponent; @Output() stepChange: EventEmitter = new EventEmitter(); @Input() thisComponentId: string; - constructor(private changeDetector: ChangeDetectorRef) {} - protected stepChanged(nodeId: string): void { this.referenceComponent.nodeId = nodeId; this.changeDetector.detectChanges(); diff --git a/src/app/authoring-tool/select-step/select-step.component.ts b/src/app/authoring-tool/select-step/select-step.component.ts index 210e18354c6..d76b7a2fbf4 100644 --- a/src/app/authoring-tool/select-step/select-step.component.ts +++ b/src/app/authoring-tool/select-step/select-step.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; @@ -17,13 +17,13 @@ import { ProjectService } from '../../../assets/wise5/services/projectService'; ` }) export class SelectStepComponent { + private projectService = inject(ProjectService); + @Input() nodeId: string; protected nodeIds: string[] = []; protected nodeToPositionAndTitle: Map = new Map(); @Output() stepChangedEvent: EventEmitter = new EventEmitter(); - constructor(private projectService: ProjectService) {} - ngOnInit(): void { this.nodeIds = this.projectService.getStepNodeIds(); this.nodeIds.forEach((nodeId) => diff --git a/src/app/common/edit-profile/edit-profile.component.ts b/src/app/common/edit-profile/edit-profile.component.ts index 066745a106f..3fbdbe37e50 100644 --- a/src/app/common/edit-profile/edit-profile.component.ts +++ b/src/app/common/edit-profile/edit-profile.component.ts @@ -1,14 +1,12 @@ +import { inject } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { UnlinkGoogleAccountConfirmComponent } from '../../modules/shared/unlink-google-account-confirm/unlink-google-account-confirm.component'; export abstract class EditProfileComponent { changed: boolean = false; - - constructor( - public dialog: MatDialog, - public snackBar: MatSnackBar - ) {} + dialog = inject(MatDialog); + snackBar = inject(MatSnackBar); handleUpdateProfileResponse(response) { if (response.status === 'success') { diff --git a/src/app/common/project-language-chooser/project-language-chooser.component.ts b/src/app/common/project-language-chooser/project-language-chooser.component.ts index e961f44154f..5020f5be364 100644 --- a/src/app/common/project-language-chooser/project-language-chooser.component.ts +++ b/src/app/common/project-language-chooser/project-language-chooser.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, inject } from '@angular/core'; import { Language } from '../../domain/language'; import { ProjectLocale } from '../../domain/projectLocale'; import { MatMenuModule } from '@angular/material/menu'; @@ -14,14 +14,14 @@ import { ProjectService } from '../../../assets/wise5/services/projectService'; templateUrl: './project-language-chooser.component.html' }) export class ProjectLanguageChooserComponent implements OnChanges { + private projectService = inject(ProjectService); + protected availableLanguages: Language[]; @Output() languageChangedEvent = new EventEmitter(); @Input() projectLocale: ProjectLocale; protected selectedLanguage: Language; @Input() tooltip: string = $localize`Select language`; - constructor(private projectService: ProjectService) {} - ngOnChanges(): void { this.availableLanguages = this.projectLocale.getAvailableLanguages(); this.selectedLanguage = this.projectService.currentLanguage(); diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 285f0064901..b58bb284906 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -1,5 +1,5 @@ import { ActivatedRoute, RouterLink } from '@angular/router'; -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core'; import { ConfigService } from '../../services/config.service'; import { finalize } from 'rxjs/operators'; import { @@ -52,6 +52,14 @@ import { MatProgressBar } from '@angular/material/progress-bar'; templateUrl: './contact-form.component.html' }) export class ContactFormComponent implements OnInit { + private configService = inject(ConfigService); + private fb = inject(FormBuilder); + private libraryService = inject(LibraryService); + private recaptchaV3Service = inject(ReCaptchaV3Service); + private route = inject(ActivatedRoute); + private studentService = inject(StudentService); + private userService = inject(UserService); + protected complete: boolean = false; protected contactFormGroup: FormGroup = this.fb.group({ name: new FormControl('', [Validators.required]), @@ -72,16 +80,6 @@ export class ContactFormComponent implements OnInit { private runId: number; protected teachers: any[] = []; - constructor( - private fb: FormBuilder, - private userService: UserService, - private configService: ConfigService, - private studentService: StudentService, - private libraryService: LibraryService, - private recaptchaV3Service: ReCaptchaV3Service, - private route: ActivatedRoute - ) {} - ngOnInit(): void { this.isSignedIn = this.userService.isSignedIn(); this.isStudent = this.userService.isStudent(); diff --git a/src/app/curriculum/curriculum.component.ts b/src/app/curriculum/curriculum.component.ts index f9a82eb2d6a..4fbd9e55c84 100644 --- a/src/app/curriculum/curriculum.component.ts +++ b/src/app/curriculum/curriculum.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { ConfigService } from '../services/config.service'; import { LibraryFiltersComponent } from '../modules/library/library-filters/library-filters.component'; import { LibraryService } from '../services/library.service'; @@ -27,18 +27,16 @@ import { ProjectFilterValues } from '../domain/projectFilterValues'; templateUrl: './curriculum.component.html' }) export class CurriculumComponent { + protected configService = inject(ConfigService); + private libraryService = inject(LibraryService); + private router = inject(Router); + private userService = inject(UserService); + private numMyUnitsVisible: number = 0; private numPublicUnitsVisible: number = 0; protected showMyUnits: boolean; private subscriptions: Subscription = new Subscription(); - constructor( - protected configService: ConfigService, - private libraryService: LibraryService, - private userService: UserService, - private router: Router - ) {} - ngOnInit(): void { this.showMyUnits = this.userService.isTeacher(); this.getLibraryProjects(); diff --git a/src/app/discourse-feed/discourse-feed.component.ts b/src/app/discourse-feed/discourse-feed.component.ts index c43f051a3a3..d64cf4e5206 100644 --- a/src/app/discourse-feed/discourse-feed.component.ts +++ b/src/app/discourse-feed/discourse-feed.component.ts @@ -1,23 +1,19 @@ import { HttpClient } from '@angular/common/http'; -import { Directive, Input } from '@angular/core'; +import { Directive, inject, Input } from '@angular/core'; @Directive() export abstract class DiscourseFeedComponent { + protected http = inject(HttpClient); + @Input() baseUrl: string; @Input() category: string; protected isLoaded: boolean; @Input() queryString: string; protected topics: any; - constructor(protected http: HttpClient) {} - ngOnInit(): void { this.http.get(this.getUrl()).subscribe(({ topic_list }: any) => { - this.topics = topic_list.topics - .filter((topic) => { - return !topic.pinned_globally; - }) - .slice(0, 3); + this.topics = topic_list.topics.filter((topic) => !topic.pinned_globally).slice(0, 3); this.isLoaded = true; }); } diff --git a/src/app/forgot/forgot-user-password-complete/forgot-user-password-complete.component.ts b/src/app/forgot/forgot-user-password-complete/forgot-user-password-complete.component.ts index a1046b5f2c9..d94647dbd2d 100644 --- a/src/app/forgot/forgot-user-password-complete/forgot-user-password-complete.component.ts +++ b/src/app/forgot/forgot-user-password-complete/forgot-user-password-complete.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { Router } from '@angular/router'; import { MatButton } from '@angular/material/button'; import { MatCard, MatCardContent } from '@angular/material/card'; @@ -8,9 +8,9 @@ import { MatCard, MatCardContent } from '@angular/material/card'; templateUrl: './forgot-user-password-complete.component.html' }) export class ForgotUserPasswordCompleteComponent { - @Input() username: string; + private router = inject(Router); - constructor(private router: Router) {} + @Input() username: string; protected goToLoginPage(): void { this.router.navigate(['/login', { username: this.username }]); diff --git a/src/app/forgot/student/forgot-student-password-change/forgot-student-password-change.component.ts b/src/app/forgot/student/forgot-student-password-change/forgot-student-password-change.component.ts index 17d73bd8a6b..4bf3531dad1 100644 --- a/src/app/forgot/student/forgot-student-password-change/forgot-student-password-change.component.ts +++ b/src/app/forgot/student/forgot-student-password-change/forgot-student-password-change.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, Input } from '@angular/core'; +import { ChangeDetectorRef, Component, Input, inject } from '@angular/core'; import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { Router, RouterLink } from '@angular/router'; import { StudentService } from '../../../student/student.service'; @@ -28,6 +28,11 @@ import { MatCard, MatCardContent } from '@angular/material/card'; ] }) export class ForgotStudentPasswordChangeComponent { + private changeDetectorRef = inject(ChangeDetectorRef); + private fb = inject(FormBuilder); + private router = inject(Router); + private studentService = inject(StudentService); + @Input() answer: string; changePasswordFormGroup: FormGroup = this.fb.group({}); protected message: string = ''; @@ -35,13 +40,6 @@ export class ForgotStudentPasswordChangeComponent { @Input() questionKey: string; @Input() username: string; - constructor( - private changeDetectorRef: ChangeDetectorRef, - private fb: FormBuilder, - private router: Router, - private studentService: StudentService - ) {} - ngAfterViewChecked(): void { this.changeDetectorRef.detectChanges(); } diff --git a/src/app/forgot/student/forgot-student-password-security/forgot-student-password-security.component.ts b/src/app/forgot/student/forgot-student-password-security/forgot-student-password-security.component.ts index 66a9b759076..420e022c878 100644 --- a/src/app/forgot/student/forgot-student-password-security/forgot-student-password-security.component.ts +++ b/src/app/forgot/student/forgot-student-password-security/forgot-student-password-security.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; import { FormBuilder, @@ -38,6 +38,12 @@ import { MatCard, MatCardContent } from '@angular/material/card'; ] }) export class ForgotStudentPasswordSecurityComponent { + private configService = inject(ConfigService); + private fb = inject(FormBuilder); + private recaptchaV3Service = inject(ReCaptchaV3Service); + private router = inject(Router); + private studentService = inject(StudentService); + protected answer: string; protected answerSecurityQuestionFormGroup: FormGroup = this.fb.group({ answer: new FormControl('', [Validators.required]) @@ -49,14 +55,6 @@ export class ForgotStudentPasswordSecurityComponent { @Input() questionKey: string; @Input() username: string; - constructor( - private configService: ConfigService, - private fb: FormBuilder, - private recaptchaV3Service: ReCaptchaV3Service, - private router: Router, - private studentService: StudentService - ) {} - async submit() { this.processing = true; this.clearMessage(); diff --git a/src/app/forgot/student/forgot-student-password/forgot-student-password.component.ts b/src/app/forgot/student/forgot-student-password/forgot-student-password.component.ts index a334290cc38..d72c1cda7ce 100644 --- a/src/app/forgot/student/forgot-student-password/forgot-student-password.component.ts +++ b/src/app/forgot/student/forgot-student-password/forgot-student-password.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { FormBuilder, FormControl, @@ -36,6 +36,10 @@ import { MatCard, MatCardContent } from '@angular/material/card'; ] }) export class ForgotStudentPasswordComponent { + private fb = inject(FormBuilder); + private router = inject(Router); + private studentService = inject(StudentService); + protected forgotStudentPasswordFormGroup: FormGroup = this.fb.group({ username: new FormControl('', [Validators.required]) }); @@ -43,12 +47,6 @@ export class ForgotStudentPasswordComponent { protected showForgotUsernameLink: boolean = false; protected processing: boolean = false; - constructor( - private fb: FormBuilder, - private router: Router, - private studentService: StudentService - ) {} - submit(): void { this.processing = true; this.clearMessage(); diff --git a/src/app/forgot/student/forgot-student-username/forgot-student-username.component.ts b/src/app/forgot/student/forgot-student-username/forgot-student-username.component.ts index d9d96435171..7e6c360a1be 100644 --- a/src/app/forgot/student/forgot-student-username/forgot-student-username.component.ts +++ b/src/app/forgot/student/forgot-student-username/forgot-student-username.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { FormBuilder, FormControl, @@ -43,6 +43,11 @@ import { MatCard, MatCardContent } from '@angular/material/card'; ] }) export class ForgotStudentUsernameComponent implements OnInit { + private fb = inject(FormBuilder); + private router = inject(Router); + private utilService = inject(UtilService); + private studentService = inject(StudentService); + months: any[] = [ { value: 1, text: $localize`01 (Jan)` }, { value: 2, text: $localize`02 (Feb)` }, @@ -70,13 +75,6 @@ export class ForgotStudentUsernameComponent implements OnInit { showSearchResults: boolean = false; processing: boolean = false; - constructor( - private fb: FormBuilder, - private router: Router, - private utilService: UtilService, - private studentService: StudentService - ) {} - ngOnInit() { this.forgotStudentUsernameFormGroup.controls['birthMonth'].valueChanges.subscribe((value) => { this.setBirthDayOptions(); diff --git a/src/app/forgot/teacher/forgot-teacher-password-change/forgot-teacher-password-change.component.ts b/src/app/forgot/teacher/forgot-teacher-password-change/forgot-teacher-password-change.component.ts index 66d2c49007a..0cfcfcf1419 100644 --- a/src/app/forgot/teacher/forgot-teacher-password-change/forgot-teacher-password-change.component.ts +++ b/src/app/forgot/teacher/forgot-teacher-password-change/forgot-teacher-password-change.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, Input } from '@angular/core'; +import { ChangeDetectorRef, Component, Input, inject } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; import { AbstractControl, @@ -33,6 +33,11 @@ import { MatCard, MatCardContent } from '@angular/material/card'; templateUrl: './forgot-teacher-password-change.component.html' }) export class ForgotTeacherPasswordChangeComponent { + private changeDetectorRef = inject(ChangeDetectorRef); + private fb = inject(FormBuilder); + private router = inject(Router); + private teacherService = inject(TeacherService); + changePasswordFormGroup: FormGroup = this.fb.group({}); protected isSubmitButtonEnabled: boolean = true; protected message: string = ''; @@ -41,13 +46,6 @@ export class ForgotTeacherPasswordChangeComponent { @Input() username: string = null; @Input() verificationCode: string; - constructor( - private changeDetectorRef: ChangeDetectorRef, - private fb: FormBuilder, - private router: Router, - private teacherService: TeacherService - ) {} - ngAfterViewChecked(): void { this.changeDetectorRef.detectChanges(); } diff --git a/src/app/forgot/teacher/forgot-teacher-password-verify/forgot-teacher-password-verify.component.ts b/src/app/forgot/teacher/forgot-teacher-password-verify/forgot-teacher-password-verify.component.ts index 73ee6e30bb2..f22c27f2019 100644 --- a/src/app/forgot/teacher/forgot-teacher-password-verify/forgot-teacher-password-verify.component.ts +++ b/src/app/forgot/teacher/forgot-teacher-password-verify/forgot-teacher-password-verify.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { FormBuilder, FormControl, @@ -35,6 +35,10 @@ import { MatDividerModule } from '@angular/material/divider'; templateUrl: './forgot-teacher-password-verify.component.html' }) export class ForgotTeacherPasswordVerifyComponent { + private fb = inject(FormBuilder); + private router = inject(Router); + private teacherService = inject(TeacherService); + @Input() username: string = null; protected verificationCodeFormGroup: FormGroup = this.fb.group({ verificationCode: new FormControl('', [Validators.required]) @@ -45,12 +49,6 @@ export class ForgotTeacherPasswordVerifyComponent { protected isSubmitButtonEnabled: boolean = true; protected showForgotPasswordLink: boolean = false; - constructor( - private fb: FormBuilder, - private router: Router, - private teacherService: TeacherService - ) {} - getControlField(fieldName) { return this.verificationCodeFormGroup.get(fieldName); } diff --git a/src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts b/src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts index 3acbd9bdb83..7cf38c651db 100644 --- a/src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts +++ b/src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { Router, RouterLink } from '@angular/router'; import { FormBuilder, @@ -37,6 +37,12 @@ import { MatCard, MatCardContent } from '@angular/material/card'; templateUrl: './forgot-teacher-password.component.html' }) export class ForgotTeacherPasswordComponent { + private configService = inject(ConfigService); + private fb = inject(FormBuilder); + private recaptchaV3Service = inject(ReCaptchaV3Service); + private router = inject(Router); + private teacherService = inject(TeacherService); + protected forgotTeacherPasswordFormGroup: FormGroup = this.fb.group({ username: new FormControl('', [Validators.required]) }); @@ -45,14 +51,6 @@ export class ForgotTeacherPasswordComponent { protected showForgotUsernameLink: boolean = false; protected processing: boolean = false; - constructor( - private configService: ConfigService, - private fb: FormBuilder, - private recaptchaV3Service: ReCaptchaV3Service, - private router: Router, - private teacherService: TeacherService - ) {} - getControlFieldValue(fieldName) { return this.forgotTeacherPasswordFormGroup.get(fieldName).value; } diff --git a/src/app/forgot/teacher/forgot-teacher-username/forgot-teacher-username.component.ts b/src/app/forgot/teacher/forgot-teacher-username/forgot-teacher-username.component.ts index 90a0d2032b8..32763483c6c 100644 --- a/src/app/forgot/teacher/forgot-teacher-username/forgot-teacher-username.component.ts +++ b/src/app/forgot/teacher/forgot-teacher-username/forgot-teacher-username.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { FormBuilder, FormControl, @@ -35,18 +35,16 @@ import { MatCard, MatCardContent } from '@angular/material/card'; ] }) export class ForgotTeacherUsernameComponent { + private fb = inject(FormBuilder); + private router = inject(Router); + private teacherService = inject(TeacherService); + protected forgotTeacherUsernameFormGroup: FormGroup = this.fb.group({ email: new FormControl('', [Validators.required, Validators.email]) }); protected message: string = ''; protected processing: boolean = false; - constructor( - private fb: FormBuilder, - private router: Router, - private teacherService: TeacherService - ) {} - getControlFieldValue(fieldName) { return this.forgotTeacherUsernameFormGroup.get(fieldName).value; } diff --git a/src/app/home/discourse-latest-news/discourse-latest-news.component.ts b/src/app/home/discourse-latest-news/discourse-latest-news.component.ts index fdaf5e4a325..fc5c056f9a8 100644 --- a/src/app/home/discourse-latest-news/discourse-latest-news.component.ts +++ b/src/app/home/discourse-latest-news/discourse-latest-news.component.ts @@ -1,5 +1,4 @@ -import { HttpClient } from '@angular/common/http'; -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { BreakpointObserver } from '@angular/cdk/layout'; import { DiscourseFeedComponent } from '../../discourse-feed/discourse-feed.component'; import { CommonModule } from '@angular/common'; @@ -12,14 +11,13 @@ import { MatIconModule } from '@angular/material/icon'; templateUrl: 'discourse-latest-news.component.html' }) export class DiscourseLatestNewsComponent extends DiscourseFeedComponent { + private breakpointObserver = inject(BreakpointObserver); + protected smallScreen: boolean; protected xsScreen: boolean; - constructor( - protected http: HttpClient, - private breakpointObserver: BreakpointObserver - ) { - super(http); + ngOnInit(): void { + super.ngOnInit(); this.breakpointObserver .observe(['(max-width: 40rem)', '(max-width: 48rem)']) .subscribe((result) => { diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 839479af8a7..3a6378a1ea4 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, SecurityContext } from '@angular/core'; +import { Component, OnInit, SecurityContext, inject } from '@angular/core'; import { bounceIn, flipInX, flipInY, jackInTheBox, rotateIn, zoomIn } from '../animations'; import { DomSanitizer } from '@angular/platform-browser'; import { ConfigService } from '../services/config.service'; @@ -32,6 +32,10 @@ import { CallToActionComponent } from '../modules/shared/call-to-action/call-to- templateUrl: './home.component.html' }) export class HomeComponent implements OnInit { + private breakpointObserver = inject(BreakpointObserver); + private configService = inject(ConfigService); + private sanitizer = inject(DomSanitizer); + discourseNewsCategory: string; discourseUrl: string; isDiscourseNewsAvailable: boolean = false; @@ -114,17 +118,10 @@ export class HomeComponent implements OnInit { ]; protected smScreen: boolean; - constructor( - private breakpointObserver: BreakpointObserver, - private configService: ConfigService, - private sanitizer: DomSanitizer - ) { + ngOnInit(): void { this.breakpointObserver.observe(['(min-width: 40rem)']).subscribe((result) => { this.smScreen = result.matches; }); - } - - ngOnInit() { this.configService.getConfig().subscribe((config: Config) => { if (config != null) { this.discourseUrl = this.configService.getDiscourseURL(); diff --git a/src/app/login/login-home/login-home.component.ts b/src/app/login/login-home/login-home.component.ts index 6412e298f5a..11fc61e5ac3 100644 --- a/src/app/login/login-home/login-home.component.ts +++ b/src/app/login/login-home/login-home.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, OnInit, ViewChild, inject } from '@angular/core'; import { Router, ActivatedRoute, RouterLink } from '@angular/router'; import { UserService } from '../../services/user.service'; import { ConfigService } from '../../services/config.service'; @@ -32,6 +32,12 @@ import { MatDivider } from '@angular/material/divider'; templateUrl: './login-home.component.html' }) export class LoginHomeComponent implements OnInit { + private configService = inject(ConfigService); + private recaptchaV3Service = inject(ReCaptchaV3Service); + private router = inject(Router); + private route = inject(ActivatedRoute); + private userService = inject(UserService); + accessCode: string = ''; credentials: any = { username: '', password: '', recaptchaResponse: null }; protected googleAuthenticationEnabled: boolean = false; @@ -44,14 +50,6 @@ export class LoginHomeComponent implements OnInit { @ViewChild('recaptchaRef', { static: false }) recaptchaRef: any; protected showSocialLogin: boolean; - constructor( - private configService: ConfigService, - private router: Router, - private route: ActivatedRoute, - private recaptchaV3Service: ReCaptchaV3Service, - private userService: UserService - ) {} - ngOnInit(): void { this.configService.getConfig().subscribe((config) => { if (config != null) { diff --git a/src/app/modules/google-sign-in/google-sign-in-button/google-sign-in-button.component.ts b/src/app/modules/google-sign-in/google-sign-in-button/google-sign-in-button.component.ts index 0258d08c0eb..5a05146663d 100644 --- a/src/app/modules/google-sign-in/google-sign-in-button/google-sign-in-button.component.ts +++ b/src/app/modules/google-sign-in/google-sign-in-button/google-sign-in-button.component.ts @@ -1,15 +1,5 @@ declare var google: any; -import { - AfterViewInit, - Component, - ElementRef, - EventEmitter, - Input, - NgZone, - Output, - ViewChild, - ViewEncapsulation -} from '@angular/core'; +import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, Output, ViewChild, ViewEncapsulation, inject } from '@angular/core'; import jwt_decode from 'jwt-decode'; import { ConfigService } from '../../../services/config.service'; import { GoogleUser } from '../GoogleUser'; @@ -21,15 +11,13 @@ import { GoogleUser } from '../GoogleUser'; template: '
' }) export class GoogleSignInButtonComponent implements AfterViewInit { + private configService = inject(ConfigService); + private ngZone = inject(NgZone); + @ViewChild('googleButton') private googleButton: ElementRef; @Output() signedIn = new EventEmitter(); @Input() text: string = 'signin_with'; - constructor( - private configService: ConfigService, - private ngZone: NgZone - ) {} - ngAfterViewInit(): void { google.accounts.id.initialize({ client_id: this.configService.getGoogleClientId(), diff --git a/src/app/modules/header/header-account-menu/header-account-menu.component.ts b/src/app/modules/header/header-account-menu/header-account-menu.component.ts index aeda8ac27cb..0ef166c6f3c 100644 --- a/src/app/modules/header/header-account-menu/header-account-menu.component.ts +++ b/src/app/modules/header/header-account-menu/header-account-menu.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, SimpleChanges } from '@angular/core'; +import { Component, OnInit, Input, SimpleChanges, inject } from '@angular/core'; import { ConfigService } from '../../../services/config.service'; import { User } from '../../../domain/user'; import { HttpClient } from '@angular/common/http'; @@ -15,6 +15,9 @@ import { RouterModule } from '@angular/router'; templateUrl: './header-account-menu.component.html' }) export class HeaderAccountMenuComponent implements OnInit { + private configService = inject(ConfigService); + private http = inject(HttpClient); + protected firstName: string = ''; protected isPreviousAdmin: boolean; protected lastName: string = ''; @@ -23,11 +26,6 @@ export class HeaderAccountMenuComponent implements OnInit { private switchToOriginalUserURL = '/api/logout/impersonate'; @Input() user: User; - constructor( - private configService: ConfigService, - private http: HttpClient - ) {} - ngOnInit(): void { this.configService.getConfig().subscribe((config) => { this.logOutURL = config.logOutURL; diff --git a/src/app/modules/header/header.component.ts b/src/app/modules/header/header.component.ts index e3cbe8b0e86..0deb1d859da 100644 --- a/src/app/modules/header/header.component.ts +++ b/src/app/modules/header/header.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { Router, RouterModule } from '@angular/router'; import { User } from '../../domain/user'; import { UserService } from '../../services/user.service'; @@ -23,15 +23,15 @@ import { MatToolbarModule } from '@angular/material/toolbar'; templateUrl: './header.component.html' }) export class HeaderComponent implements OnInit { + private router = inject(Router); + private userService = inject(UserService); + private utilService = inject(UtilService); + protected location: string = ''; protected roles: string[] = []; protected user: User; - constructor( - private router: Router, - private userService: UserService, - private utilService: UtilService - ) { + constructor() { this.router.events.subscribe(() => { this.setLocation(); }); diff --git a/src/app/modules/library/copy-project-dialog/copy-project-dialog.component.ts b/src/app/modules/library/copy-project-dialog/copy-project-dialog.component.ts index c1a82d76e8a..9b9b00c9abd 100644 --- a/src/app/modules/library/copy-project-dialog/copy-project-dialog.component.ts +++ b/src/app/modules/library/copy-project-dialog/copy-project-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatDialogModule, MatDialog, @@ -18,15 +18,15 @@ import { Project } from '../../../domain/project'; templateUrl: './copy-project-dialog.component.html' }) export class CopyProjectDialogComponent { + dialog = inject(MatDialog); + dialogRef = inject>(MatDialogRef); + private libraryService = inject(LibraryService); + project = inject(MAT_DIALOG_DATA); + private snackBar = inject(MatSnackBar); + protected isCopying: boolean = false; - constructor( - public dialog: MatDialog, - public dialogRef: MatDialogRef, - private libraryService: LibraryService, - @Inject(MAT_DIALOG_DATA) public project: Project, - private snackBar: MatSnackBar - ) { + constructor() { this.libraryService.newProjectSource$.subscribe(() => { this.dialog.closeAll(); }); diff --git a/src/app/modules/library/discourse-category-activity/discourse-category-activity.component.ts b/src/app/modules/library/discourse-category-activity/discourse-category-activity.component.ts index c0183c09e9d..53a04055b56 100644 --- a/src/app/modules/library/discourse-category-activity/discourse-category-activity.component.ts +++ b/src/app/modules/library/discourse-category-activity/discourse-category-activity.component.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; @@ -10,6 +10,8 @@ import { MatIconModule } from '@angular/material/icon'; templateUrl: 'discourse-category-activity.component.html' }) export class DiscourseCategoryActivityComponent { + private http = inject(HttpClient); + @Input() categoryURL: string = ''; protected discourseBaseUrl: string = ''; protected hasMoreTopics: boolean; @@ -17,8 +19,6 @@ export class DiscourseCategoryActivityComponent { protected topics: any[] = []; protected validCategoryURL: boolean; - constructor(private http: HttpClient) {} - ngOnInit(): void { this.retrieveCategory(); } diff --git a/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts b/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts index 33fba287af0..7a87b873332 100644 --- a/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts +++ b/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { LibraryService } from '../../../services/library.service'; import { ProjectFilterValues } from '../../../domain/projectFilterValues'; import { LibraryFiltersComponent } from '../library-filters/library-filters.component'; @@ -13,8 +13,10 @@ import { OfficialLibraryComponent } from '../official-library/official-library.c templateUrl: './home-page-project-library.component.html' }) export class HomePageProjectLibraryComponent { - constructor(private libraryService: LibraryService) { - libraryService.getOfficialLibraryProjects(); + private libraryService = inject(LibraryService); + + ngOnInit(): void { + this.libraryService.getOfficialLibraryProjects(); } ngOnDestroy(): void { diff --git a/src/app/modules/library/library-filters/library-filters.component.ts b/src/app/modules/library/library-filters/library-filters.component.ts index 8dac1800901..94a2be56e07 100644 --- a/src/app/modules/library/library-filters/library-filters.component.ts +++ b/src/app/modules/library/library-filters/library-filters.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, SimpleChanges } from '@angular/core'; +import { Component, Input, SimpleChanges, inject } from '@angular/core'; import { LibraryProject } from '../libraryProject'; import { LibraryService } from '../../../services/library.service'; import { Standard, StandardType } from '../standard'; @@ -35,6 +35,11 @@ import { LocationSelectMenuComponent } from '../../shared/location-select-menu/l templateUrl: './library-filters.component.html' }) export class LibraryFiltersComponent { + private dialog = inject(MatDialog); + protected filterValues = inject(ProjectFilterValues); + private libraryService = inject(LibraryService); + private utilService = inject(UtilService); + private communityProjects: LibraryProject[] = []; protected disciplineOptions: Discipline[] = []; protected featureOptions: Feature[] = []; @@ -53,12 +58,7 @@ export class LibraryFiltersComponent { { id: 'Other Platform', name: $localize`Other Platform` } ]; - constructor( - private dialog: MatDialog, - protected filterValues: ProjectFilterValues, - private libraryService: LibraryService, - private utilService: UtilService - ) { + constructor() { this.libraryService.officialLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { this.libraryProjects = projects; this.populateFilterOptions(); diff --git a/src/app/modules/library/library-group-thumbs/library-group-thumbs.component.ts b/src/app/modules/library/library-group-thumbs/library-group-thumbs.component.ts index 7cfd30ad659..cf03bbe3779 100644 --- a/src/app/modules/library/library-group-thumbs/library-group-thumbs.component.ts +++ b/src/app/modules/library/library-group-thumbs/library-group-thumbs.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, inject } from '@angular/core'; import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; import { LibraryGroup } from '../libraryGroup'; @@ -8,11 +8,11 @@ import { LibraryGroup } from '../libraryGroup'; templateUrl: './library-group-thumbs.component.html' }) export class LibraryGroupThumbsComponent implements OnInit { + private sanitizer = inject(DomSanitizer); + protected children: Array = []; @Input() group: LibraryGroup = new LibraryGroup(); - constructor(private sanitizer: DomSanitizer) {} - ngOnInit(): void { this.children = this.group.children; this.children diff --git a/src/app/modules/library/library-project-details/library-project-details.component.ts b/src/app/modules/library/library-project-details/library-project-details.component.ts index cef2929978e..45ca9ac80f4 100644 --- a/src/app/modules/library/library-project-details/library-project-details.component.ts +++ b/src/app/modules/library/library-project-details/library-project-details.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { MatDialog, MatDialogRef, @@ -34,6 +34,12 @@ import { MatButtonModule } from '@angular/material/button'; templateUrl: './library-project-details.component.html' }) export class LibraryProjectDetailsComponent implements OnInit { + private configService = inject(ConfigService); + data = inject(MAT_DIALOG_DATA); + dialog = inject(MatDialog); + dialogRef = inject>(MatDialogRef); + private userService = inject(UserService); + protected authorsString: string = ''; protected canPreview: boolean; protected isCopy: boolean; @@ -52,14 +58,6 @@ export class LibraryProjectDetailsComponent implements OnInit { }; protected standards: any; - constructor( - private configService: ConfigService, - @Inject(MAT_DIALOG_DATA) public data: any, - public dialog: MatDialog, - public dialogRef: MatDialogRef, - private userService: UserService - ) {} - ngOnInit(): void { this.isTeacher = this.userService.isTeacher(); this.isRunProject = this.data.isRunProject; diff --git a/src/app/modules/library/library-project-menu/library-project-menu.component.ts b/src/app/modules/library/library-project-menu/library-project-menu.component.ts index aeec8aed79e..80fd3ff5ec6 100644 --- a/src/app/modules/library/library-project-menu/library-project-menu.component.ts +++ b/src/app/modules/library/library-project-menu/library-project-menu.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Project } from '../../../domain/project'; import { TeacherService } from '../../../teacher/teacher.service'; @@ -20,6 +20,12 @@ import { CopyProjectDialogComponent } from '../copy-project-dialog/copy-project- templateUrl: './library-project-menu.component.html' }) export class LibraryProjectMenuComponent { + private archiveProjectService = inject(ArchiveProjectService); + private configService = inject(ConfigService); + private dialog = inject(MatDialog); + private teacherService = inject(TeacherService); + private userService = inject(UserService); + protected archived: boolean; protected canEdit: boolean; protected canShare: boolean; @@ -29,14 +35,6 @@ export class LibraryProjectMenuComponent { @Input() project: Project; protected publishUnitUrl: string; - constructor( - private archiveProjectService: ArchiveProjectService, - private configService: ConfigService, - private dialog: MatDialog, - private teacherService: TeacherService, - private userService: UserService - ) {} - ngOnInit(): void { this.canEdit = this.isOwner() || this.isSharedOwnerWithEditPermission(); this.canShare = this.isOwner() && !this.isRun; diff --git a/src/app/modules/library/library-project/library-project.component.ts b/src/app/modules/library/library-project/library-project.component.ts index 26a6d255668..56b97173208 100644 --- a/src/app/modules/library/library-project/library-project.component.ts +++ b/src/app/modules/library/library-project/library-project.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit, ViewEncapsulation, Output, EventEmitter } from '@angular/core'; +import { Component, Input, OnInit, ViewEncapsulation, Output, EventEmitter, inject } from '@angular/core'; import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { LibraryProject } from '../libraryProject'; @@ -36,6 +36,10 @@ import { FormsModule } from '@angular/forms'; templateUrl: './library-project.component.html' }) export class LibraryProjectComponent implements OnInit { + private dialog = inject(MatDialog); + private projectTagService = inject(ProjectTagService); + private sanitizer = inject(DomSanitizer); + protected animateDelay: string = '0s'; protected animateDuration: string = '0s'; @Input() checked: boolean = false; @@ -45,12 +49,6 @@ export class LibraryProjectComponent implements OnInit { new EventEmitter(); private subscriptions: Subscription = new Subscription(); - constructor( - private dialog: MatDialog, - private projectTagService: ProjectTagService, - private sanitizer: DomSanitizer - ) {} - ngOnInit(): void { this.project.thumbStyle = this.getThumbStyle(this.project.projectThumb); if (this.project.isHighlighted) { diff --git a/src/app/modules/library/library/library.component.ts b/src/app/modules/library/library/library.component.ts index 3c367b3ee24..fcff7451286 100644 --- a/src/app/modules/library/library/library.component.ts +++ b/src/app/modules/library/library/library.component.ts @@ -1,4 +1,4 @@ -import { OnInit, QueryList, ViewChildren, Directive } from '@angular/core'; +import { OnInit, QueryList, ViewChildren, Directive, inject } from '@angular/core'; import { LibraryService } from '../../../services/library.service'; import { LibraryProject } from '../libraryProject'; import { PageEvent, MatPaginator } from '@angular/material/paginator'; @@ -18,10 +18,8 @@ export abstract class LibraryComponent implements OnInit { protected showFilters: boolean = false; protected subscriptions: Subscription = new Subscription(); - constructor( - protected filterValues: ProjectFilterValues, - protected libraryService: LibraryService - ) {} + protected filterValues = inject(ProjectFilterValues); + protected libraryService = inject(LibraryService); ngOnInit(): void { this.subscriptions.add(this.filterValues.updated$.subscribe(() => this.filterUpdated())); diff --git a/src/app/modules/library/personal-library/personal-library.component.ts b/src/app/modules/library/personal-library/personal-library.component.ts index 914edbee2e8..b8caa9324aa 100644 --- a/src/app/modules/library/personal-library/personal-library.component.ts +++ b/src/app/modules/library/personal-library/personal-library.component.ts @@ -2,12 +2,11 @@ import { ApplyTagsButtonComponent } from '../../../teacher/apply-tags-button/app import { ArchiveProjectsButtonComponent } from '../../../teacher/archive-projects-button/archive-projects-button.component'; import { ArchiveProjectService } from '../../../services/archive-project.service'; import { BehaviorSubject } from 'rxjs'; -import { Component, Signal, WritableSignal, computed, signal } from '@angular/core'; +import { Component, Signal, WritableSignal, computed, inject, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { LibraryComponent } from '../library/library.component'; import { LibraryProject } from '../libraryProject'; import { LibraryProjectComponent } from '../library-project/library-project.component'; -import { LibraryService } from '../../../services/library.service'; import { MatDividerModule } from '@angular/material/divider'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatPaginatorModule, PageEvent } from '@angular/material/paginator'; @@ -17,7 +16,6 @@ import { ProjectSelectionEvent } from '../../../domain/projectSelectionEvent'; import { SelectAllItemsCheckboxComponent } from '../select-all-items-checkbox/select-all-items-checkbox.component'; import { SelectTagsComponent } from '../../../teacher/select-tags/select-tags.component'; import { Tag } from '../../../domain/tag'; -import { ProjectFilterValues } from '../../../domain/projectFilterValues'; @Component({ imports: [ @@ -54,13 +52,7 @@ export class PersonalLibraryComponent extends LibraryComponent { protected sharedProjects: LibraryProject[] = []; protected showArchivedView: boolean = false; - constructor( - private archiveProjectService: ArchiveProjectService, - protected filterValues: ProjectFilterValues, - protected libraryService: LibraryService - ) { - super(filterValues, libraryService); - } + private archiveProjectService = inject(ArchiveProjectService); ngOnInit(): void { super.ngOnInit(); diff --git a/src/app/modules/library/public-unit-type-selector/public-unit-type-selector.component.ts b/src/app/modules/library/public-unit-type-selector/public-unit-type-selector.component.ts index 29789e1485f..14e6a89ee09 100644 --- a/src/app/modules/library/public-unit-type-selector/public-unit-type-selector.component.ts +++ b/src/app/modules/library/public-unit-type-selector/public-unit-type-selector.component.ts @@ -1,4 +1,4 @@ -import { Component, Directive, EventEmitter, Output } from '@angular/core'; +import { Component, Directive, EventEmitter, Output, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { ProjectFilterValues } from '../../../domain/projectFilterValues'; @@ -26,16 +26,14 @@ import { MatIconModule } from '@angular/material/icon'; templateUrl: './public-unit-type-selector.component.html' }) export class PublicUnitTypeSelectorComponent { + private dialog = inject(MatDialog); + private filterValues = inject(ProjectFilterValues); + protected communityBuilt: boolean; @Output() publicUnitTypeUpdatedEvent: EventEmitter = new EventEmitter(); protected wiseTested: boolean; - constructor( - private dialog: MatDialog, - private filterValues: ProjectFilterValues - ) {} - protected updatePublicUnitType(): void { this.filterValues.publicUnitTypeValue = []; if (this.wiseTested) { diff --git a/src/app/modules/library/share-item-dialog/share-item-dialog.component.ts b/src/app/modules/library/share-item-dialog/share-item-dialog.component.ts index 2a697b316da..126152bef5a 100644 --- a/src/app/modules/library/share-item-dialog/share-item-dialog.component.ts +++ b/src/app/modules/library/share-item-dialog/share-item-dialog.component.ts @@ -1,4 +1,4 @@ -import { OnInit, Inject, Directive } from '@angular/core'; +import { OnInit, Directive, inject } from '@angular/core'; import { FormControl } from '@angular/forms'; import { BehaviorSubject, Observable } from 'rxjs'; import { TeacherService } from '../../../teacher/teacher.service'; @@ -10,6 +10,8 @@ import { copy } from '../../../../assets/wise5/common/object/object'; @Directive() export abstract class ShareItemDialogComponent implements OnInit { + public data = inject(MAT_DIALOG_DATA); + public dialogRef = inject(MatDialogRef); project: Project; projectId: number; runId: number; @@ -19,19 +21,13 @@ export abstract class ShareItemDialogComponent implements OnInit { owner: any; sharedOwners: any[] = []; private sharedOwners$: BehaviorSubject = new BehaviorSubject(this.sharedOwners); + public snackBar = inject(MatSnackBar); + public teacherService = inject(TeacherService); - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - public teacherService: TeacherService, - public snackBar: MatSnackBar - ) { + ngOnInit(): void { this.teacherService.retrieveAllTeacherUsernames().subscribe((teacherUsernames) => { this.allTeacherUsernames = teacherUsernames; }); - } - - ngOnInit() { this.filteredTeacherUsernames = this.teacherSearchControl.valueChanges.pipe( debounceTime(1000), map((value) => this._filter(value)) diff --git a/src/app/modules/library/share-project-dialog/share-project-dialog.component.ts b/src/app/modules/library/share-project-dialog/share-project-dialog.component.ts index 74ebb46c2b8..bdf0693f1b0 100644 --- a/src/app/modules/library/share-project-dialog/share-project-dialog.component.ts +++ b/src/app/modules/library/share-project-dialog/share-project-dialog.component.ts @@ -1,13 +1,10 @@ -import { Component, Inject } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { - MAT_DIALOG_DATA, - MatDialogRef, MatDialogTitle, MatDialogContent, MatDialogActions, MatDialogClose } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { MatTableDataSource, MatTable, @@ -21,7 +18,6 @@ import { MatRowDef, MatRow } from '@angular/material/table'; -import { TeacherService } from '../../../teacher/teacher.service'; import { LibraryService } from '../../../services/library.service'; import { ShareItemDialogComponent } from '../share-item-dialog/share-item-dialog.component'; import { Project } from '../../../domain/project'; @@ -88,25 +84,16 @@ export class ShareProjectDialogComponent extends ShareItemDialogComponent { dataSource: MatTableDataSource = new MatTableDataSource(); displayedColumns: string[] = ['name', 'permissions']; duplicate: boolean = false; + public libraryService = inject(LibraryService); - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - public libraryService: LibraryService, - public teacherService: TeacherService, - public snackBar: MatSnackBar - ) { - super(dialogRef, data, teacherService, snackBar); - this.project = data.project; - this.projectId = data.project.id; + ngOnInit(): void { + super.ngOnInit(); + this.project = this.data.project; + this.projectId = this.data.project.id; this.libraryService.getProjectInfo(this.projectId).subscribe((project: Project) => { this.project = project; this.populateSharedOwners(project.sharedOwners); }); - } - - ngOnInit() { - super.ngOnInit(); this.getSharedOwners().subscribe((sharedOwners) => { let owners = [...sharedOwners]; owners.reverse(); diff --git a/src/app/modules/mobile-menu/mobile-menu.component.ts b/src/app/modules/mobile-menu/mobile-menu.component.ts index 42463d35bca..0541bd70878 100644 --- a/src/app/modules/mobile-menu/mobile-menu.component.ts +++ b/src/app/modules/mobile-menu/mobile-menu.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { UserService } from '../../services/user.service'; import { UtilService } from '../../services/util.service'; import { RouterModule } from '@angular/router'; @@ -13,12 +13,10 @@ import { MatIconModule } from '@angular/material/icon'; templateUrl: './mobile-menu.component.html' }) export class MobileMenuComponent implements OnInit { - protected signedIn: boolean; + private userService = inject(UserService); + private utilService = inject(UtilService); - constructor( - private userService: UserService, - private utilService: UtilService - ) {} + protected signedIn: boolean; ngOnInit(): void { this.getUser(); diff --git a/src/app/modules/shared/edit-password/edit-password.component.ts b/src/app/modules/shared/edit-password/edit-password.component.ts index 50b666ae2a0..456d43c9e82 100644 --- a/src/app/modules/shared/edit-password/edit-password.component.ts +++ b/src/app/modules/shared/edit-password/edit-password.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core'; +import { ChangeDetectorRef, Component, OnInit, ViewChild, inject } from '@angular/core'; import { FormControl, FormGroup, @@ -36,6 +36,12 @@ import { MatProgressBar } from '@angular/material/progress-bar'; templateUrl: './edit-password.component.html' }) export class EditPasswordComponent implements OnInit { + private changeDetectorRef = inject(ChangeDetectorRef); + dialog = inject(MatDialog); + private fb = inject(FormBuilder); + snackBar = inject(MatSnackBar); + private userService = inject(UserService); + @ViewChild('changePasswordForm', { static: false }) changePasswordForm; isSaving: boolean = false; isGoogleUser: boolean = false; @@ -46,14 +52,6 @@ export class EditPasswordComponent implements OnInit { newPasswordFormGroup: this.newPasswordFormGroup }); - constructor( - private changeDetectorRef: ChangeDetectorRef, - public dialog: MatDialog, - private fb: FormBuilder, - public snackBar: MatSnackBar, - private userService: UserService - ) {} - ngOnInit(): void { this.userService.getUser().subscribe((user) => { this.isGoogleUser = user.isGoogleUser; diff --git a/src/app/modules/shared/hero-section/hero-section.component.ts b/src/app/modules/shared/hero-section/hero-section.component.ts index ef0072a1e20..931c2298366 100644 --- a/src/app/modules/shared/hero-section/hero-section.component.ts +++ b/src/app/modules/shared/hero-section/hero-section.component.ts @@ -1,14 +1,6 @@ import { BreakpointObserver } from '@angular/cdk/layout'; import { CommonModule } from '@angular/common'; -import { - Component, - ContentChild, - Input, - TemplateRef, - ViewEncapsulation, - ViewChild, - ElementRef -} from '@angular/core'; +import { Component, ContentChild, Input, TemplateRef, ViewEncapsulation, ViewChild, ElementRef, inject } from '@angular/core'; import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; @Component({ @@ -19,6 +11,9 @@ import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; templateUrl: './hero-section.component.html' }) export class HeroSectionComponent { + private breakpointObserver = inject(BreakpointObserver); + private sanitizer = inject(DomSanitizer); + @ViewChild('bgRef') bgRef: ElementRef; protected bgStyle: SafeStyle; @Input() headline: string; @@ -31,10 +26,7 @@ export class HeroSectionComponent { @ContentChild('taglineTemplate', { static: false }) taglineRef: TemplateRef; protected xsScreen: boolean; - constructor( - private breakpointObserver: BreakpointObserver, - private sanitizer: DomSanitizer - ) { + constructor() { this.breakpointObserver.observe(['(max-width: 40rem)']).subscribe((result) => { this.xsScreen = result.matches; }); diff --git a/src/app/modules/shared/unlink-google-account-confirm/unlink-google-account-confirm.component.ts b/src/app/modules/shared/unlink-google-account-confirm/unlink-google-account-confirm.component.ts index 8535154998d..8d2dfd7651c 100644 --- a/src/app/modules/shared/unlink-google-account-confirm/unlink-google-account-confirm.component.ts +++ b/src/app/modules/shared/unlink-google-account-confirm/unlink-google-account-confirm.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatDialog, MatDialogTitle, @@ -25,7 +25,8 @@ import { MatButton } from '@angular/material/button'; templateUrl: './unlink-google-account-confirm.component.html' }) export class UnlinkGoogleAccountConfirmComponent { - constructor(public dialog: MatDialog) {} + dialog = inject(MatDialog); + continue() { this.dialog.closeAll(); diff --git a/src/app/modules/shared/unlink-google-account-password/unlink-google-account-password.component.ts b/src/app/modules/shared/unlink-google-account-password/unlink-google-account-password.component.ts index 84864012921..1cfd4fd694a 100644 --- a/src/app/modules/shared/unlink-google-account-password/unlink-google-account-password.component.ts +++ b/src/app/modules/shared/unlink-google-account-password/unlink-google-account-password.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component } from '@angular/core'; +import { ChangeDetectorRef, Component, inject } from '@angular/core'; import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatDialog, @@ -32,16 +32,14 @@ import { MatProgressBar } from '@angular/material/progress-bar'; templateUrl: './unlink-google-account-password.component.html' }) export class UnlinkGoogleAccountPasswordComponent { + private changeDetectorRef = inject(ChangeDetectorRef); + private fb = inject(FormBuilder); + dialog = inject(MatDialog); + private userService = inject(UserService); + isSaving: boolean = false; newPasswordFormGroup: FormGroup = this.fb.group({}); - constructor( - private changeDetectorRef: ChangeDetectorRef, - private fb: FormBuilder, - public dialog: MatDialog, - private userService: UserService - ) {} - ngAfterViewChecked(): void { this.changeDetectorRef.detectChanges(); } diff --git a/src/app/modules/shared/unlink-google-account-success/unlink-google-account-success.component.ts b/src/app/modules/shared/unlink-google-account-success/unlink-google-account-success.component.ts index 8f486b7089c..e5ebe449d81 100644 --- a/src/app/modules/shared/unlink-google-account-success/unlink-google-account-success.component.ts +++ b/src/app/modules/shared/unlink-google-account-success/unlink-google-account-success.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { Teacher } from '../../../domain/teacher'; import { UserService } from '../../../services/user.service'; import { @@ -23,9 +23,9 @@ import { MatButton } from '@angular/material/button'; templateUrl: 'unlink-google-account-success.component.html' }) export class UnlinkGoogleAccountSuccessComponent { - username: string; + private userService = inject(UserService); - constructor(private userService: UserService) {} + username: string; ngOnInit() { const user = this.userService.getUser().getValue(); diff --git a/src/app/news/news.component.ts b/src/app/news/news.component.ts index 8e1f8733627..fab6be82f81 100644 --- a/src/app/news/news.component.ts +++ b/src/app/news/news.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { NewsService } from '../services/news.service'; import { News } from '../domain/news'; import { DomSanitizer } from '@angular/platform-browser'; @@ -29,15 +29,13 @@ import { DatePipe } from '@angular/common'; templateUrl: './news.component.html' }) export class NewsComponent implements OnInit { + private newsService = inject(NewsService); + protected sanitizer = inject(DomSanitizer); + allNewsItems: any = []; showAll: boolean = false; - constructor( - private newsService: NewsService, - protected sanitizer: DomSanitizer - ) {} - - ngOnInit() { + ngOnInit(): void { this.newsService.getAllNews().subscribe((allNewsItems: News[]) => { this.allNewsItems = allNewsItems; }); diff --git a/src/app/notebook/notebook-item/notebook-item.component.ts b/src/app/notebook/notebook-item/notebook-item.component.ts index 0ef1d626e41..4f0fbb58e54 100644 --- a/src/app/notebook/notebook-item/notebook-item.component.ts +++ b/src/app/notebook/notebook-item/notebook-item.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output, inject } from '@angular/core'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { Subscription } from 'rxjs'; import { DialogWithConfirmComponent } from '../../../assets/wise5/directives/dialog-with-confirm/dialog-with-confirm.component'; @@ -25,6 +25,11 @@ import { MatButtonModule } from '@angular/material/button'; templateUrl: 'notebook-item.component.html' }) export class NotebookItemComponent { + private configService = inject(ConfigService); + private dialog = inject(MatDialog); + private notebookService = inject(NotebookService); + private projectService = inject(ProjectService); + protected canDelete: boolean; protected canRevive: boolean; protected color: string; @@ -39,13 +44,6 @@ export class NotebookItemComponent { @Output() onSelect: EventEmitter = new EventEmitter(); private type: string; - constructor( - private configService: ConfigService, - private dialog: MatDialog, - private notebookService: NotebookService, - private projectService: ProjectService - ) {} - ngOnInit(): void { this.item = this.note; this.type = this.item ? this.item.type : null; diff --git a/src/app/notebook/notebook-launcher/notebook-launcher.component.ts b/src/app/notebook/notebook-launcher/notebook-launcher.component.ts index 8bea999e762..1af785a0ee3 100644 --- a/src/app/notebook/notebook-launcher/notebook-launcher.component.ts +++ b/src/app/notebook/notebook-launcher/notebook-launcher.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { NotebookService } from '../../../assets/wise5/services/notebookService'; import { ProjectService } from '../../../assets/wise5/services/projectService'; import { Subscription } from 'rxjs'; @@ -12,15 +12,13 @@ import { MatTooltipModule } from '@angular/material/tooltip'; templateUrl: 'notebook-launcher.component.html' }) export class NotebookLauncherComponent { + private notebookService = inject(NotebookService); + private projectService = inject(ProjectService); + protected label: string = ''; @Input() notebookConfig: any; private subscription: Subscription = new Subscription(); - constructor( - private notebookService: NotebookService, - private projectService: ProjectService - ) {} - ngOnInit(): void { this.setLabel(); this.subscription.add(this.projectService.projectParsed$.subscribe(() => this.setLabel())); diff --git a/src/app/notebook/notebook-notes/notebook-notes.component.ts b/src/app/notebook/notebook-notes/notebook-notes.component.ts index ef964c2d18b..f6dfb6cb2b4 100644 --- a/src/app/notebook/notebook-notes/notebook-notes.component.ts +++ b/src/app/notebook/notebook-notes/notebook-notes.component.ts @@ -1,7 +1,5 @@ -import { Component, Input, ViewEncapsulation } from '@angular/core'; +import { Component, Input, ViewEncapsulation, inject } from '@angular/core'; import { Subscription } from 'rxjs'; -import { ConfigService } from '../../../assets/wise5/services/configService'; -import { NotebookService } from '../../../assets/wise5/services/notebookService'; import { ProjectService } from '../../../assets/wise5/services/projectService'; import { StudentDataService } from '../../../assets/wise5/services/studentDataService'; import { NotebookParentComponent } from '../notebook-parent/notebook-parent.component'; @@ -31,6 +29,9 @@ import { MatIconModule } from '@angular/material/icon'; encapsulation: ViewEncapsulation.None }) export class NotebookNotesComponent extends NotebookParentComponent { + private dataService = inject(StudentDataService); + private projectService = inject(ProjectService); + protected groups = []; private groupNameToGroup = {}; protected hasPrivateNotes: boolean = false; @@ -42,15 +43,6 @@ export class NotebookNotesComponent extends NotebookParentComponent { private subscriptions: Subscription = new Subscription(); @Input() viewOnly: boolean; - constructor( - configService: ConfigService, - private dataService: StudentDataService, - NotebookService: NotebookService, - private projectService: ProjectService - ) { - super(configService, NotebookService); - } - ngOnInit(): void { super.ngOnInit(); this.setLabel(); @@ -59,7 +51,7 @@ export class NotebookNotesComponent extends NotebookParentComponent { this.hasPrivateNotes = this.isHasPrivateNotes(); this.subscriptions.add( - this.NotebookService.notebookUpdated$.subscribe(({ notebookItem }) => { + this.notebookService.notebookUpdated$.subscribe(({ notebookItem }) => { if ( (notebookItem.groups == null || notebookItem.groups.length === 0) && notebookItem.type === 'note' @@ -74,7 +66,7 @@ export class NotebookNotesComponent extends NotebookParentComponent { ); this.subscriptions.add( - this.NotebookService.insertMode$.subscribe((args) => { + this.notebookService.insertMode$.subscribe((args) => { this.insertArgs = args; if (args.visibleSpace) { this.selectedTabIndex = args.visibleSpace === 'public' ? 1 : 0; @@ -83,10 +75,10 @@ export class NotebookNotesComponent extends NotebookParentComponent { ); this.subscriptions.add( - this.NotebookService.publicNotebookItemsRetrieved$.subscribe(() => { + this.notebookService.publicNotebookItemsRetrieved$.subscribe(() => { for (const group of this.groups) { if (group.name !== 'private') { - group.items = this.NotebookService.publicNotebookItems[group.name]; + group.items = this.notebookService.publicNotebookItems[group.name]; } } }) @@ -99,7 +91,7 @@ export class NotebookNotesComponent extends NotebookParentComponent { }) ); - this.NotebookService.retrievePublicNotebookItems('public'); + this.notebookService.retrievePublicNotebookItems('public'); } ngOnDestroy(): void { @@ -209,20 +201,20 @@ export class NotebookNotesComponent extends NotebookParentComponent { } protected addNote(): void { - this.NotebookService.addNote(this.dataService.getCurrentNodeId()); + this.notebookService.addNote(this.dataService.getCurrentNodeId()); } protected select({ event, note }: any): void { if (this.insertArgs.insertMode) { this.insertArgs.notebookItem = note; - this.NotebookService.broadcastNotebookItemChosen(this.insertArgs); + this.notebookService.broadcastNotebookItemChosen(this.insertArgs); } else { const isEditMode = !this.viewOnly; - this.NotebookService.editNote(this.dataService.getCurrentNodeId(), note, isEditMode); + this.notebookService.editNote(this.dataService.getCurrentNodeId(), note, isEditMode); } } protected close(): void { - this.NotebookService.closeNotes(); + this.notebookService.closeNotes(); } } diff --git a/src/app/notebook/notebook-parent/notebook-parent.component.ts b/src/app/notebook/notebook-parent/notebook-parent.component.ts index 6bac762a01a..09b9638d560 100644 --- a/src/app/notebook/notebook-parent/notebook-parent.component.ts +++ b/src/app/notebook/notebook-parent/notebook-parent.component.ts @@ -1,44 +1,42 @@ -import { Directive, Input } from '@angular/core'; +import { Directive, Input, inject } from '@angular/core'; import { copy } from '../../../assets/wise5/common/object/object'; import { ConfigService } from '../../../assets/wise5/services/configService'; import { NotebookService } from '../../../assets/wise5/services/notebookService'; @Directive() export class NotebookParentComponent { + configService = inject(ConfigService); + notebookService = inject(NotebookService); + @Input() config: any; @Input() mode: string; @Input() workgroupId: number; notebook: any; - constructor( - public ConfigService: ConfigService, - public NotebookService: NotebookService - ) {} - ngOnInit(): void { if (this.workgroupId == null) { - this.workgroupId = this.ConfigService.getWorkgroupId(); + this.workgroupId = this.configService.getWorkgroupId(); } if (this.config == null) { this.setConfig(); } - this.notebook = this.NotebookService.getNotebookByWorkgroup(this.workgroupId); + this.notebook = this.notebookService.getNotebookByWorkgroup(this.workgroupId); } setConfig(): void { if (this.isStudentNotebook()) { - this.config = copy(this.NotebookService.getStudentNotebookConfig()); + this.config = copy(this.notebookService.getStudentNotebookConfig()); } else { - this.config = copy(this.NotebookService.getTeacherNotebookConfig()); + this.config = copy(this.notebookService.getTeacherNotebookConfig()); } } isStudentNotebook(): boolean { return ( - this.ConfigService.getMode() === 'studentRun' || - this.ConfigService.getMode() === 'preview' || - ((this.ConfigService.isRunOwner() || this.ConfigService.isRunSharedTeacher()) && - this.ConfigService.getWorkgroupId() !== this.workgroupId) + this.configService.getMode() === 'studentRun' || + this.configService.getMode() === 'preview' || + ((this.configService.isRunOwner() || this.configService.isRunSharedTeacher()) && + this.configService.getWorkgroupId() !== this.workgroupId) ); } } diff --git a/src/app/notebook/notebook-report/notebook-report.component.ts b/src/app/notebook/notebook-report/notebook-report.component.ts index 25d67d2c76f..1ef718ddc43 100644 --- a/src/app/notebook/notebook-report/notebook-report.component.ts +++ b/src/app/notebook/notebook-report/notebook-report.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; @@ -11,8 +11,6 @@ import { replaceWiseLinks } from '../../../assets/wise5/common/wise-link/wise-link'; import { WiseTinymceEditorComponent } from '../../../assets/wise5/directives/wise-tinymce-editor/wise-tinymce-editor.component'; -import { ConfigService } from '../../../assets/wise5/services/configService'; -import { NotebookService } from '../../../assets/wise5/services/notebookService'; import { ProjectService } from '../../../assets/wise5/services/projectService'; import { NotebookParentComponent } from '../notebook-parent/notebook-parent.component'; import { BreakpointObserver } from '@angular/cdk/layout'; @@ -32,6 +30,9 @@ import { BreakpointObserver } from '@angular/cdk/layout'; templateUrl: 'notebook-report.component.html' }) export class NotebookReportComponent extends NotebookParentComponent { + private breakpointObserver = inject(BreakpointObserver); + private projectService = inject(ProjectService); + private autoSaveIntervalMS: number = 30000; private autoSaveIntervalId: any; protected collapsed: boolean = true; @@ -45,23 +46,14 @@ export class NotebookReportComponent extends NotebookParentComponent { protected saveTime: number = null; private subscriptions: Subscription = new Subscription(); - constructor( - private breakpointObserver: BreakpointObserver, - configService: ConfigService, - notebookService: NotebookService, - private projectService: ProjectService - ) { - super(configService, notebookService); + ngOnInit(): void { + super.ngOnInit(); this.breakpointObserver.observe(['(max-width: 40rem)']).subscribe((result) => { if (!this.collapsed) { this.collapsed = true; this.fullscreen(); } }); - } - - ngOnInit(): void { - super.ngOnInit(); this.reportId = this.config.itemTypes.report.notes[0].reportId; this.setReportItem(); if (this.reportItem == null) { @@ -74,7 +66,7 @@ export class NotebookReportComponent extends NotebookParentComponent { this.isAddNoteButtonAvailable = this.config.itemTypes.note.enabled; this.subscriptions.add( - this.NotebookService.showReportAnnotations$.subscribe(() => { + this.notebookService.showReportAnnotations$.subscribe(() => { if (this.collapsed) { this.toggleCollapse(); } @@ -105,18 +97,18 @@ export class NotebookReportComponent extends NotebookParentComponent { } private setReportItem(): void { - this.reportItem = this.NotebookService.getLatestNotebookReportItemByReportId( + this.reportItem = this.notebookService.getLatestNotebookReportItemByReportId( this.reportId, this.workgroupId ); if (this.reportItem) { this.hasReport = true; - const clientSaveTime = this.ConfigService.convertToClientTimestamp( + const clientSaveTime = this.configService.convertToClientTimestamp( this.reportItem.serverSaveTime ); this.saveTime = clientSaveTime; } else { - this.reportItem = this.NotebookService.getTemplateReportItemByReportId(this.reportId); + this.reportItem = this.notebookService.getTemplateReportItemByReportId(this.reportId); } if (this.reportItem != null) { this.reportItemContent = this.projectService.injectAssetPaths( @@ -132,7 +124,7 @@ export class NotebookReportComponent extends NotebookParentComponent { } if (this.full) { this.full = false; - this.NotebookService.setReportFullScreen(false); + this.notebookService.setReportFullScreen(false); } this.collapsed = !this.collapsed; } @@ -144,17 +136,17 @@ export class NotebookReportComponent extends NotebookParentComponent { } else { this.full = !this.full; } - this.NotebookService.setReportFullScreen(this.full); + this.notebookService.setReportFullScreen(this.full); } protected addNotebookItemContent($event: any): void { - this.NotebookService.setInsertMode({ insertMode: true, requester: 'report' }); - this.NotebookService.setNotesVisible(true); + this.notebookService.setInsertMode({ insertMode: true, requester: 'report' }); + this.notebookService.setNotesVisible(true); } protected changed(value: string): void { this.dirty = true; - this.reportItem.content.content = this.ConfigService.removeAbsoluteAssetPaths( + this.reportItem.content.content = this.configService.removeAbsoluteAssetPaths( insertWiseLinks(value) ); this.saveTime = null; @@ -170,7 +162,7 @@ export class NotebookReportComponent extends NotebookParentComponent { } protected saveNotebookReportItem(): void { - this.NotebookService.saveNotebookItem( + this.notebookService.saveNotebookItem( this.reportItem.id, this.reportItem.nodeId, this.reportItem.localNotebookItemId, @@ -185,7 +177,7 @@ export class NotebookReportComponent extends NotebookParentComponent { // set the reportNotebookItemId to the newly-incremented id so that future saves during this // visit will be an update instead of an insert. this.reportItem.id = result.id; - this.saveTime = this.ConfigService.convertToClientTimestamp(result.serverSaveTime); + this.saveTime = this.configService.convertToClientTimestamp(result.serverSaveTime); } }); } diff --git a/src/app/possible-score/possible-score.component.ts b/src/app/possible-score/possible-score.component.ts index 732d8457948..123e44fb7a6 100644 --- a/src/app/possible-score/possible-score.component.ts +++ b/src/app/possible-score/possible-score.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, inject } from '@angular/core'; import { ProjectService } from '../../assets/wise5/services/projectService'; @Component({ @@ -6,11 +6,11 @@ import { ProjectService } from '../../assets/wise5/services/projectService'; templateUrl: 'possible-score.component.html' }) export class PossibleScoreComponent { + private projectService = inject(ProjectService); + protected hidePossibleScores: boolean; @Input() maxScore: number; - constructor(private projectService: ProjectService) {} - ngOnInit(): void { this.hidePossibleScores = this.projectService.getThemeSettings().hidePossibleScores; } diff --git a/src/app/preview/modules/choose-branch-path-dialog/choose-branch-path-dialog.component.ts b/src/app/preview/modules/choose-branch-path-dialog/choose-branch-path-dialog.component.ts index b7e18830aa7..7ec984053ef 100644 --- a/src/app/preview/modules/choose-branch-path-dialog/choose-branch-path-dialog.component.ts +++ b/src/app/preview/modules/choose-branch-path-dialog/choose-branch-path-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; import { MatListModule } from '@angular/material/list'; @@ -10,5 +10,5 @@ import { MatListModule } from '@angular/material/list'; templateUrl: './choose-branch-path-dialog.component.html' }) export class ChooseBranchPathDialogComponent { - constructor(@Inject(MAT_DIALOG_DATA) protected paths: any) {} + protected paths = inject(MAT_DIALOG_DATA); } diff --git a/src/app/register/abstract-register-user.component.ts b/src/app/register/abstract-register-user.component.ts index dd03d70719c..2d0c3268f90 100644 --- a/src/app/register/abstract-register-user.component.ts +++ b/src/app/register/abstract-register-user.component.ts @@ -1,21 +1,19 @@ import { Router } from '@angular/router'; import { UserService } from '../services/user.service'; import { ConfigService } from '../services/config.service'; -import { Directive, OnInit } from '@angular/core'; +import { Directive, OnInit, inject } from '@angular/core'; import { GoogleUser } from '../modules/google-sign-in/GoogleUser'; @Directive() export abstract class AbstractRegisterUserComponent implements OnInit { + private configService = inject(ConfigService); + private router = inject(Router); + private userService = inject(UserService); + protected googleAuthenticationEnabled: boolean = false; protected abstract joinFormPath: string; protected microsoftAuthenticationEnabled: boolean = false; - constructor( - private configService: ConfigService, - private router: Router, - private userService: UserService - ) {} - ngOnInit(): void { this.configService.getConfig().subscribe((config) => { if (config != null) { diff --git a/src/app/register/register-google-user-already-exists/register-google-user-already-exists.component.ts b/src/app/register/register-google-user-already-exists/register-google-user-already-exists.component.ts index 9ecd557d174..f1d831351d9 100644 --- a/src/app/register/register-google-user-already-exists/register-google-user-already-exists.component.ts +++ b/src/app/register/register-google-user-already-exists/register-google-user-already-exists.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { ConfigService } from '../../services/config.service'; import { MatCard, MatCardContent, MatCardActions } from '@angular/material/card'; import { MatButton } from '@angular/material/button'; @@ -10,7 +10,7 @@ import { MatButton } from '@angular/material/button'; styleUrl: './register-google-user-already-exists.component.scss' }) export class RegisterGoogleUserAlreadyExistsComponent { - constructor(private configService: ConfigService) {} + private configService = inject(ConfigService); public socialSignIn(socialPlatform: string) { window.location.href = `${this.configService.getContextPath()}/api/google-login`; diff --git a/src/app/register/register-home/register-home.component.ts b/src/app/register/register-home/register-home.component.ts index 59d590815e3..fd4a6f72000 100644 --- a/src/app/register/register-home/register-home.component.ts +++ b/src/app/register/register-home/register-home.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { CallToActionComponent } from '../../modules/shared/call-to-action/call-to-action.component'; @@ -10,11 +10,11 @@ import { CallToActionComponent } from '../../modules/shared/call-to-action/call- templateUrl: './register-home.component.html' }) export class RegisterHomeComponent implements OnInit { + private activatedRoute = inject(ActivatedRoute); + googleUserNotFoundError: boolean; protected microsoftUserNotFoundError: boolean; - constructor(private activatedRoute: ActivatedRoute) {} - ngOnInit() { this.activatedRoute.queryParams.subscribe((params) => { this.googleUserNotFoundError = params['googleUserNotFound'] === 'true'; diff --git a/src/app/register/register-student-form/register-student-form.component.ts b/src/app/register/register-student-form/register-student-form.component.ts index 98b24fbcb49..eebd1871a60 100644 --- a/src/app/register/register-student-form/register-student-form.component.ts +++ b/src/app/register/register-student-form/register-student-form.component.ts @@ -1,22 +1,17 @@ -import { ActivatedRoute, Router } from '@angular/router'; -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; + +import { Component, inject, OnInit } from '@angular/core'; import { Student } from '../../domain/student'; import { StudentService } from '../../student/student.service'; import { FormControl, FormGroup, Validators, - FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { UtilService } from '../../services/util.service'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { RegisterUserFormComponent } from '../register-user-form/register-user-form.component'; import { HttpErrorResponse } from '@angular/common/http'; -import { ReCaptchaV3Service } from 'ng-recaptcha-2'; import { NewPasswordAndConfirmComponent } from '../../password/new-password-and-confirm/new-password-and-confirm.component'; -import { ConfigService } from '../../services/config.service'; import { MatCard, MatCardContent } from '@angular/material/card'; import { MatFormField, MatLabel, MatError } from '@angular/material/form-field'; import { MatInput } from '@angular/material/input'; @@ -76,24 +71,12 @@ export class RegisterStudentFormComponent extends RegisterUserFormComponent impl securityQuestions: object; user: Student = new Student(); - constructor( - private changeDetectorRef: ChangeDetectorRef, - private configService: ConfigService, - protected fb: FormBuilder, - private recaptchaV3Service: ReCaptchaV3Service, - private router: Router, - private route: ActivatedRoute, - protected snackBar: MatSnackBar, - private studentService: StudentService, - private utilService: UtilService - ) { - super(fb, snackBar); + private studentService = inject(StudentService); + + ngOnInit() { this.studentService.retrieveSecurityQuestions().subscribe((response) => { this.securityQuestions = response; }); - } - - ngOnInit() { this.route.params.subscribe((params) => { this.user.googleUserId = params['gID']; this.user.microsoftUserId = params['mID']; diff --git a/src/app/register/register-teacher-form/register-teacher-form.component.ts b/src/app/register/register-teacher-form/register-teacher-form.component.ts index d81c4d2d6de..4ad2aba0911 100644 --- a/src/app/register/register-teacher-form/register-teacher-form.component.ts +++ b/src/app/register/register-teacher-form/register-teacher-form.component.ts @@ -1,22 +1,17 @@ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Component, inject, OnInit } from '@angular/core'; import { Teacher } from '../../domain/teacher'; import { TeacherService } from '../../teacher/teacher.service'; import { FormControl, FormGroup, Validators, - FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { UtilService } from '../../services/util.service'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { RegisterUserFormComponent } from '../register-user-form/register-user-form.component'; import { HttpErrorResponse } from '@angular/common/http'; -import { ReCaptchaV3Service, RecaptchaV3Module } from 'ng-recaptcha-2'; +import { RecaptchaV3Module } from 'ng-recaptcha-2'; import { NewPasswordAndConfirmComponent } from '../../password/new-password-and-confirm/new-password-and-confirm.component'; -import { ConfigService } from '../../services/config.service'; import { SchoolLevel, schoolLevels } from '../../domain/profile.constants'; import { MatCard, MatCardContent } from '@angular/material/card'; import { MatFormField, MatLabel, MatError, MatHint } from '@angular/material/form-field'; @@ -73,19 +68,7 @@ export class RegisterTeacherFormComponent extends RegisterUserFormComponent impl schoolLevels: SchoolLevel[] = schoolLevels; user: Teacher = new Teacher(); - constructor( - private changeDetectorRef: ChangeDetectorRef, - private configService: ConfigService, - protected fb: FormBuilder, - private recaptchaV3Service: ReCaptchaV3Service, - private router: Router, - private route: ActivatedRoute, - protected snackBar: MatSnackBar, - private teacherService: TeacherService, - private utilService: UtilService - ) { - super(fb, snackBar); - } + private teacherService = inject(TeacherService); ngOnInit(): void { this.route.params.subscribe((params) => { diff --git a/src/app/register/register-user-complete.component.ts b/src/app/register/register-user-complete.component.ts index 18b8472f18a..f3418a2b5d3 100644 --- a/src/app/register/register-user-complete.component.ts +++ b/src/app/register/register-user-complete.component.ts @@ -1,9 +1,13 @@ -import { Directive, OnInit } from '@angular/core'; +import { Directive, OnInit, inject } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { ConfigService } from '../services/config.service'; @Directive() export abstract class RegisterUserCompleteComponent implements OnInit { + protected configService = inject(ConfigService); + protected route = inject(ActivatedRoute); + protected router = inject(Router); + protected googleLogInURL = `${this.configService.getContextPath()}/api/google-login`; protected microsoftLogInURL = `${this.configService.getContextPath()}/api/microsoft-login?redirectUrl=/`; protected socialAccount: boolean; @@ -11,12 +15,6 @@ export abstract class RegisterUserCompleteComponent implements OnInit { protected isUsingMicrosoftId: boolean; protected username: string; - constructor( - protected configService: ConfigService, - protected route: ActivatedRoute, - protected router: Router - ) {} - ngOnInit(): void { this.route.params.subscribe(({ username, isUsingGoogleId, isUsingMicrosoftId }) => { this.username = username; diff --git a/src/app/register/register-user-form/register-user-form.component.ts b/src/app/register/register-user-form/register-user-form.component.ts index 0f75d5e51b3..1561d65dbf3 100644 --- a/src/app/register/register-user-form/register-user-form.component.ts +++ b/src/app/register/register-user-form/register-user-form.component.ts @@ -1,9 +1,23 @@ +import { ChangeDetectorRef, inject } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; import { User } from '../../domain/user'; import { injectPasswordErrors } from '../../common/password-helper'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { ReCaptchaV3Service } from 'ng-recaptcha-2'; +import { ConfigService } from '../../services/config.service'; +import { UtilService } from '../../services/util.service'; export class RegisterUserFormComponent { + protected fb = inject(FormBuilder); + protected snackBar = inject(MatSnackBar); + protected changeDetectorRef = inject(ChangeDetectorRef); + protected configService = inject(ConfigService); + protected recaptchaV3Service = inject(ReCaptchaV3Service); + protected router = inject(Router); + protected route = inject(ActivatedRoute); + protected utilService = inject(UtilService); + protected NAME_REGEX = '^[a-zA-Z]+([ -]?[a-zA-Z]+)*$'; protected confirmPasswordLabel: string = $localize`Confirm Password`; @@ -12,8 +26,6 @@ export class RegisterUserFormComponent { protected processing: boolean = false; user: User; - constructor(protected fb: FormBuilder, protected snackBar: MatSnackBar) {} - handleCreateAccountError(error: any, userObject: User): void { switch (error.messageCode) { case 'invalidPassword': diff --git a/src/app/services/accessLinkService.ts b/src/app/services/accessLinkService.ts index 219d08efbfe..5408a05c59d 100644 --- a/src/app/services/accessLinkService.ts +++ b/src/app/services/accessLinkService.ts @@ -1,9 +1,9 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { ConfigService } from './config.service'; @Injectable() export class AccessLinkService { - constructor(private configService: ConfigService) {} + private configService = inject(ConfigService); getAccessLinks(runCode: string, periods: string[]): string[] { const host = this.configService.getWISEHostname() + this.configService.getContextPath(); diff --git a/src/app/services/archive-project.service.ts b/src/app/services/archive-project.service.ts index 6fabe84feb6..9f0780a93a4 100644 --- a/src/app/services/archive-project.service.ts +++ b/src/app/services/archive-project.service.ts @@ -1,5 +1,5 @@ import { HttpClient, HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Observable, Subject, Subscription } from 'rxjs'; import { Project } from '../domain/project'; import { ArchiveProjectResponse } from '../domain/archiveProjectResponse'; @@ -8,11 +8,12 @@ import { Tag } from '../domain/tag'; @Injectable() export class ArchiveProjectService { + private http = inject(HttpClient); + private snackBar = inject(MatSnackBar); + private refreshProjectsEventSource: Subject = new Subject(); public refreshProjectsEvent$ = this.refreshProjectsEventSource.asObservable(); - constructor(private http: HttpClient, private snackBar: MatSnackBar) {} - archiveProject(project: Project, archive: boolean): void { this[archive ? 'makeArchiveProjectRequest' : 'makeUnarchiveProjectRequest'](project).subscribe({ next: (response: ArchiveProjectResponse) => { diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts index 75c6881784c..894d7a63945 100644 --- a/src/app/services/config.service.ts +++ b/src/app/services/config.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { BehaviorSubject, Observable, tap } from 'rxjs'; import { Config } from '../domain/config'; @@ -6,13 +6,13 @@ import { Announcement } from '../domain/announcement'; @Injectable() export class ConfigService { + private http = inject(HttpClient); + private userConfigUrl = '/api/user/config'; private announcementUrl = '/api/announcement'; private config$: BehaviorSubject = new BehaviorSubject(null); private timeDiff: number = 0; - constructor(private http: HttpClient) {} - getConfig(): Observable { return this.config$; } diff --git a/src/app/services/data.service.ts b/src/app/services/data.service.ts index 9d097243f0a..e6c466338d6 100644 --- a/src/app/services/data.service.ts +++ b/src/app/services/data.service.ts @@ -1,9 +1,11 @@ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Subject } from 'rxjs'; import { ProjectService } from '../../assets/wise5/services/projectService'; @Injectable() export abstract class DataService { + protected projectService = inject(ProjectService); + currentNode = null; previousStep = null; private currentNodeChangedSource: Subject = new Subject(); @@ -11,8 +13,6 @@ export abstract class DataService { private studentWorkReceivedSource: Subject = new Subject(); public studentWorkReceived$ = this.studentWorkReceivedSource.asObservable(); - constructor(protected projectService: ProjectService) {} - getCurrentNode(): any { return this.currentNode; } diff --git a/src/app/services/getWorkgroupService.ts b/src/app/services/getWorkgroupService.ts index 3f83e3f1eca..abe864a53b7 100644 --- a/src/app/services/getWorkgroupService.ts +++ b/src/app/services/getWorkgroupService.ts @@ -1,14 +1,15 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { ConfigService } from '../../assets/wise5/services/configService'; @Injectable() export class GetWorkgroupService { - constructor(private ConfigService: ConfigService, private http: HttpClient) {} + private configService = inject(ConfigService); + private http = inject(HttpClient); getAllWorkgroupsInPeriod(periodId: number) { return this.http.get( - `/api/teacher/run/${this.ConfigService.getRunId()}/period/${periodId}/workgroups` + `/api/teacher/run/${this.configService.getRunId()}/period/${periodId}/workgroups` ); } } diff --git a/src/app/services/library.service.ts b/src/app/services/library.service.ts index f2796bb7706..5888b4d01b8 100644 --- a/src/app/services/library.service.ts +++ b/src/app/services/library.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { LibraryGroup } from '../modules/library/libraryGroup'; @@ -8,6 +8,9 @@ import { Router } from '@angular/router'; @Injectable({ providedIn: 'root' }) export class LibraryService { + private http = inject(HttpClient); + private router = inject(Router); + private libraryGroupsUrl = '/api/project/library'; private communityProjectsUrl = '/api/project/community'; private personalProjectsUrl = '/api/project/personal'; @@ -32,11 +35,6 @@ export class LibraryService { public numberOfPersonalProjectsVisible = new BehaviorSubject(0); public numberOfPersonalProjectsVisible$ = this.numberOfPersonalProjectsVisible.asObservable(); - constructor( - private http: HttpClient, - private router: Router - ) {} - getOfficialLibraryProjects(): void { this.http.get(this.libraryGroupsUrl).subscribe((libraryGroups) => { const projects: LibraryProject[] = []; diff --git a/src/app/services/news.service.ts b/src/app/services/news.service.ts index 5c984fe7b65..5a3e323529c 100644 --- a/src/app/services/news.service.ts +++ b/src/app/services/news.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { News } from '../domain/news'; import { Observable } from 'rxjs'; @@ -7,9 +7,9 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class NewsService { - private newsUrl = '/api/news'; + private http = inject(HttpClient); - constructor(private http: HttpClient) {} + private newsUrl = '/api/news'; getAllNews(): Observable { const headers = new HttpHeaders({ 'Cache-Control': 'no-cache' }); diff --git a/src/app/services/projectAssetService.ts b/src/app/services/projectAssetService.ts index c51d9217b10..ce3cbf28307 100644 --- a/src/app/services/projectAssetService.ts +++ b/src/app/services/projectAssetService.ts @@ -1,7 +1,5 @@ -'use strict'; - import { HttpClient, HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { map, tap } from 'rxjs/operators'; import { forkJoin, BehaviorSubject } from 'rxjs'; import { ConfigService } from '../../assets/wise5/services/configService'; @@ -10,17 +8,17 @@ import { isAudio, isImage, isVideo } from '../../assets/wise5/common/file/file'; @Injectable() export class ProjectAssetService { + protected configService = inject(ConfigService); + protected http = inject(HttpClient); + protected projectService = inject(ProjectService); + totalSizeMax = 0; projectAssets: BehaviorSubject = new BehaviorSubject(null); totalFileSize: BehaviorSubject = new BehaviorSubject(0); totalUnusedFileSize: BehaviorSubject = new BehaviorSubject(0); projectThumbnailFileName = 'project_thumb.png'; - constructor( - protected configService: ConfigService, - protected http: HttpClient, - protected projectService: ProjectService - ) { + constructor() { this.getProjectAssets().subscribe((projectAssets) => { if (projectAssets != null) { this.calculateAssetUsage(projectAssets); diff --git a/src/app/services/updateWorkgroupService.ts b/src/app/services/updateWorkgroupService.ts index bd4cbcf0e69..6c54c17fd42 100644 --- a/src/app/services/updateWorkgroupService.ts +++ b/src/app/services/updateWorkgroupService.ts @@ -1,11 +1,12 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { ConfigService } from '../../assets/wise5/services/configService'; import { Observable } from 'rxjs'; @Injectable() export class UpdateWorkgroupService { - constructor(private configService: ConfigService, private http: HttpClient) {} + private configService = inject(ConfigService); + private http = inject(HttpClient); /** * Move student to a workgroup diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index d19e24ab221..51410968318 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -2,7 +2,7 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { ConfigService } from './config.service'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Student } from '../domain/student'; import { tap } from 'rxjs/operators'; import { Teacher } from '../domain/teacher'; @@ -10,6 +10,9 @@ import { User } from '../domain/user'; @Injectable() export class UserService { + private configService = inject(ConfigService); + private http = inject(HttpClient); + private userUrl = '/api/user/info'; private user$: BehaviorSubject = new BehaviorSubject(null); private checkGoogleUserExistsUrl = '/api/google-user/check-user-exists'; @@ -21,12 +24,7 @@ export class UserService { private contactUrl = '/api/contact'; private unlinkGoogleAccountUrl = '/api/google-user/unlink-account'; isAuthenticated = false; - redirectUrl: string; // redirect here after logging in - - constructor( - private configService: ConfigService, - private http: HttpClient - ) {} + redirectUrl: string; getUser(): BehaviorSubject { return this.user$; diff --git a/src/app/services/wiseLinkService.ts b/src/app/services/wiseLinkService.ts index 5316f5ca6b3..24d4a8cf6e7 100644 --- a/src/app/services/wiseLinkService.ts +++ b/src/app/services/wiseLinkService.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { replaceWiseLinks } from '../../assets/wise5/common/wise-link/wise-link'; import { NodeService } from '../../assets/wise5/services/nodeService'; @@ -7,11 +7,9 @@ import { scrollToElement, temporarilyHighlightElement } from '../../assets/wise5 @Injectable() export class WiseLinkService { - constructor( - private nodeService: NodeService, - private sanitizer: DomSanitizer, - private studentDataService: StudentDataService - ) {} + private nodeService = inject(NodeService); + private sanitizer = inject(DomSanitizer); + private studentDataService = inject(StudentDataService); wiseLinkClickedEventName: string = 'wiselinkclicked'; wiseLinkClickedHandler: any; diff --git a/src/app/services/workgroup.service.ts b/src/app/services/workgroup.service.ts index 3edccefe95d..932c06813c6 100644 --- a/src/app/services/workgroup.service.ts +++ b/src/app/services/workgroup.service.ts @@ -1,19 +1,18 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import { ConfigService } from '../../assets/wise5/services/configService'; @Injectable() export class WorkgroupService { - constructor( - private ConfigService: ConfigService, - private http: HttpClient - ) {} + private configService = inject(ConfigService); + private http = inject(HttpClient); + getWorkgroupsInPeriod(periodId: number): Map { const workgroups = new Map(); for (const workgroup of this.getWorkgroupsSortedById()) { if (periodId === -1 || (workgroup.periodId === periodId && workgroup.workgroupId != null)) { - workgroup.displayNames = this.ConfigService.getDisplayUsernamesByWorkgroupId( + workgroup.displayNames = this.configService.getDisplayUsernamesByWorkgroupId( workgroup.workgroupId ); workgroups.set(workgroup.workgroupId, workgroup); @@ -23,20 +22,20 @@ export class WorkgroupService { } private getWorkgroupsSortedById() { - return this.ConfigService.getClassmateUserInfos().sort((a, b) => { + return this.configService.getClassmateUserInfos().sort((a, b) => { return a.workgroupId - b.workgroupId; }); } createWorkgroup(periodId: number, memberIds: number[]): Observable { return this.http.post( - `/api/teacher/run/${this.ConfigService.getRunId()}/workgroup/create/${periodId}`, + `/api/teacher/run/${this.configService.getRunId()}/workgroup/create/${periodId}`, memberIds ); } isUserInAnyWorkgroup(user: any): boolean { - return this.ConfigService.getClassmateUserInfos().some((userInfo) => { + return this.configService.getClassmateUserInfos().some((userInfo) => { return userInfo.userIds != null && userInfo.userIds.includes(user.id); }); } diff --git a/src/app/student-teacher-common-services.module.ts b/src/app/student-teacher-common-services.module.ts index 54f5d1bacd6..66dbe982d81 100644 --- a/src/app/student-teacher-common-services.module.ts +++ b/src/app/student-teacher-common-services.module.ts @@ -59,6 +59,7 @@ import { TeacherNodeService } from '../assets/wise5/services/teacherNodeService' import { TeacherWebSocketService } from '../assets/wise5/services/teacherWebSocketService'; import { VLEProjectService } from '../assets/wise5/vle/vleProjectService'; import { WiseLinkService } from './services/wiseLinkService'; +import { DataService } from './services/data.service'; @NgModule({ providers: [ @@ -80,6 +81,7 @@ import { WiseLinkService } from './services/wiseLinkService'; ComputerAvatarService, ConfigService, CRaterService, + { provide: DataService, useExisting: StudentDataService }, DialogGuidanceService, DiscussionService, DrawService, diff --git a/src/app/student/account/edit-profile/edit-profile.component.ts b/src/app/student/account/edit-profile/edit-profile.component.ts index c04cec08089..37dc09ea869 100644 --- a/src/app/student/account/edit-profile/edit-profile.component.ts +++ b/src/app/student/account/edit-profile/edit-profile.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { FormGroup, FormControl, @@ -8,12 +8,10 @@ import { ReactiveFormsModule } from '@angular/forms'; import { finalize } from 'rxjs/operators'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { Student } from '../../../domain/student'; import { UserService } from '../../../services/user.service'; import { StudentService } from '../../student.service'; import { Subscription } from 'rxjs'; -import { MatDialog } from '@angular/material/dialog'; import { EditProfileComponent } from '../../../common/edit-profile/edit-profile.component'; import { MatFormField, MatLabel, MatError } from '@angular/material/form-field'; import { MatInput } from '@angular/material/input'; @@ -43,6 +41,10 @@ import { MatProgressBar } from '@angular/material/progress-bar'; templateUrl: './edit-profile.component.html' }) export class StudentEditProfileComponent extends EditProfileComponent { + private fb = inject(FormBuilder); + private studentService = inject(StudentService); + private userService = inject(UserService); + user: Student; languages: object[]; isSaving: boolean = false; @@ -55,24 +57,6 @@ export class StudentEditProfileComponent extends EditProfileComponent { language: new FormControl('', [Validators.required]) }); - constructor( - private fb: FormBuilder, - private studentService: StudentService, - private userService: UserService, - public dialog: MatDialog, - public snackBar: MatSnackBar - ) { - super(dialog, snackBar); - this.user = this.getUser().getValue(); - this.setControlFieldValue('firstName', this.user.firstName); - this.setControlFieldValue('lastName', this.user.lastName); - this.setControlFieldValue('username', this.user.username); - this.setControlFieldValue('language', this.user.language); - this.userService.getLanguages().subscribe((response) => { - this.languages = response; - }); - } - getUser() { return this.userService.getUser(); } @@ -82,6 +66,14 @@ export class StudentEditProfileComponent extends EditProfileComponent { } ngOnInit() { + this.user = this.getUser().getValue(); + this.setControlFieldValue('firstName', this.user.firstName); + this.setControlFieldValue('lastName', this.user.lastName); + this.setControlFieldValue('username', this.user.username); + this.setControlFieldValue('language', this.user.language); + this.userService.getLanguages().subscribe((response) => { + this.languages = response; + }); this.editProfileFormGroup.valueChanges.subscribe(() => { this.changed = true; }); diff --git a/src/app/student/add-project-dialog/add-project-dialog.component.ts b/src/app/student/add-project-dialog/add-project-dialog.component.ts index 95573d7c3a7..036fbe58a5b 100644 --- a/src/app/student/add-project-dialog/add-project-dialog.component.ts +++ b/src/app/student/add-project-dialog/add-project-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { MatDialog, MatDialogTitle, @@ -46,6 +46,10 @@ import { MatProgressBar } from '@angular/material/progress-bar'; templateUrl: './add-project-dialog.component.html' }) export class AddProjectDialogComponent implements OnInit { + dialog = inject(MatDialog); + private route = inject(ActivatedRoute); + private studentService = inject(StudentService); + validRunCodeSyntaxRegEx: any = /^[a-zA-Z]*\d{3,4}$/; registerRunRunCode: string = ''; registerRunPeriods: string[] = []; @@ -58,12 +62,6 @@ export class AddProjectDialogComponent implements OnInit { }); isAdding = false; - constructor( - public dialog: MatDialog, - private studentService: StudentService, - private route: ActivatedRoute - ) {} - ngOnInit(): void { this.route.queryParams.subscribe((params) => { if (params['accessCode'] != null) { diff --git a/src/app/student/auth.guard.ts b/src/app/student/auth.guard.ts index de8ceca5cde..be0c1f8e9b9 100644 --- a/src/app/student/auth.guard.ts +++ b/src/app/student/auth.guard.ts @@ -1,13 +1,11 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { UserService } from '../services/user.service'; @Injectable() export class AuthGuard { - constructor( - private userService: UserService, - private router: Router - ) {} + private router = inject(Router); + private userService = inject(UserService); canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { return this.checkLogin(state.url); diff --git a/src/app/student/student-home/student-home.component.ts b/src/app/student/student-home/student-home.component.ts index b96cffe4221..13db7cefbad 100644 --- a/src/app/student/student-home/student-home.component.ts +++ b/src/app/student/student-home/student-home.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { UserService } from '../../services/user.service'; import { User } from '../../domain/user'; @@ -14,12 +14,10 @@ import { StudentRunListComponent } from '../student-run-list/student-run-list.co templateUrl: './student-home.component.html' }) export class StudentHomeComponent implements OnInit { - user: User = new User(); + dialog = inject(MatDialog); + private userService = inject(UserService); - constructor( - public dialog: MatDialog, - private userService: UserService - ) {} + user: User = new User(); ngOnInit(): void { this.getUser(); diff --git a/src/app/student/student-run-list-item/student-run-list-item.component.ts b/src/app/student/student-run-list-item/student-run-list-item.component.ts index 7f5a36cc978..d806f16caf9 100644 --- a/src/app/student/student-run-list-item/student-run-list-item.component.ts +++ b/src/app/student/student-run-list-item/student-run-list-item.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, inject } from '@angular/core'; import { StudentRun } from '../student-run'; import { DomSanitizer } from '@angular/platform-browser'; import { SafeStyle } from '@angular/platform-browser'; @@ -43,6 +43,12 @@ import { MatIcon } from '@angular/material/icon'; templateUrl: './student-run-list-item.component.html' }) export class StudentRunListItemComponent implements OnInit { + private configService = inject(ConfigService); + dialog = inject(MatDialog); + private sanitizer = inject(DomSanitizer); + private studentService = inject(StudentService); + private userService = inject(UserService); + @Input() run: StudentRun = new StudentRun(); problemLink: string = ''; @@ -50,14 +56,6 @@ export class StudentRunListItemComponent implements OnInit { animateDuration: string = '0s'; animateDelay: string = '0s'; - constructor( - private sanitizer: DomSanitizer, - private configService: ConfigService, - public dialog: MatDialog, - private studentService: StudentService, - private userService: UserService - ) {} - getThumbStyle() { const DEFAULT_THUMB = 'assets/img/default-picture.svg'; const STYLE = `url(${this.run.project.projectThumb}), url(${DEFAULT_THUMB})`; diff --git a/src/app/student/student-run-list/student-run-list.component.ts b/src/app/student/student-run-list/student-run-list.component.ts index c4c41e2a0e0..b8bc81439f4 100644 --- a/src/app/student/student-run-list/student-run-list.component.ts +++ b/src/app/student/student-run-list/student-run-list.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core'; +import { Component, LOCALE_ID, OnInit, inject } from '@angular/core'; import { StudentRun } from '../student-run'; import { StudentService } from '../student.service'; import { ConfigService } from '../../services/config.service'; @@ -35,20 +35,20 @@ import { DatePipe } from '@angular/common'; templateUrl: './student-run-list.component.html' }) export class StudentRunListComponent implements OnInit { + private configService = inject(ConfigService); + private dialog = inject(MatDialog); + private localeID = inject(LOCALE_ID); + private route = inject(ActivatedRoute); + private studentService = inject(StudentService); + runs: StudentRun[] = []; filteredRuns: StudentRun[] = []; search: string = ''; loaded: boolean = false; showAll: boolean = false; - constructor( - private studentService: StudentService, - private configService: ConfigService, - private route: ActivatedRoute, - private dialog: MatDialog, - @Inject(LOCALE_ID) private localeID: string - ) { - studentService.newRunSource$.subscribe((run) => { + constructor() { + this.studentService.newRunSource$.subscribe((run) => { run.isHighlighted = true; this.runs.unshift(new StudentRun(run)); if (!this.showAll) { diff --git a/src/app/student/student.component.ts b/src/app/student/student.component.ts index d06a7ffb10a..43fc490cfea 100644 --- a/src/app/student/student.component.ts +++ b/src/app/student/student.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { Router, RouterOutlet } from '@angular/router'; import { NgClass } from '@angular/common'; @@ -8,7 +8,8 @@ import { NgClass } from '@angular/common'; templateUrl: './student.component.html' }) export class StudentComponent { - constructor(private router: Router) {} + private router = inject(Router); + protected isShowingAngularJSApp(): boolean { return ( diff --git a/src/app/student/student.service.ts b/src/app/student/student.service.ts index 5374f4c9335..b4b75d080f0 100644 --- a/src/app/student/student.service.ts +++ b/src/app/student/student.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { tap } from 'rxjs/operators'; @@ -9,6 +9,8 @@ import { StudentRun } from './student-run'; @Injectable() export class StudentService { + private http = inject(HttpClient); + private runsUrl = '/api/student/runs'; private runInfoUrl = '/api/run/info'; private runInfoByIdUrl = '/api/run/info-by-id'; @@ -27,8 +29,6 @@ export class StudentService { private newRunSource = new Subject(); newRunSource$ = this.newRunSource.asObservable(); - constructor(private http: HttpClient) {} - getRuns(): Observable { const headers = new HttpHeaders({ 'Cache-Control': 'no-cache' }); return this.http diff --git a/src/app/student/team-sign-in-dialog/team-sign-in-dialog.component.ts b/src/app/student/team-sign-in-dialog/team-sign-in-dialog.component.ts index 722bf122512..28b38a46724 100644 --- a/src/app/student/team-sign-in-dialog/team-sign-in-dialog.component.ts +++ b/src/app/student/team-sign-in-dialog/team-sign-in-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, OnInit, inject } from '@angular/core'; import { UserService } from '../../services/user.service'; import { Student } from '../../domain/student'; import { StudentRun } from '../student-run'; @@ -45,6 +45,13 @@ import { GoogleSignInButtonComponent } from '../../modules/google-sign-in/google templateUrl: './team-sign-in-dialog.component.html' }) export class TeamSignInDialogComponent implements OnInit { + private configService = inject(ConfigService); + private userService = inject(UserService); + private studentService = inject(StudentService); + private router = inject(Router); + dialogRef = inject>(MatDialogRef); + data = inject(MAT_DIALOG_DATA); + user: Student; run: StudentRun = new StudentRun(); teamMembers: any[] = []; @@ -53,14 +60,7 @@ export class TeamSignInDialogComponent implements OnInit { isGoogleAuthenticationEnabled: boolean = false; canLaunch: boolean = false; - constructor( - private configService: ConfigService, - private userService: UserService, - private studentService: StudentService, - private router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { + constructor() { this.run = this.data.run; this.user = this.getUser().getValue(); if (this.run.workgroupMembers != null) { diff --git a/src/app/student/top-bar/top-bar.component.html b/src/app/student/top-bar/top-bar.component.html index 9ce4fb2473d..36fa02dfb91 100644 --- a/src/app/student/top-bar/top-bar.component.html +++ b/src/app/student/top-bar/top-bar.component.html @@ -34,7 +34,7 @@

{{ projectName }}

+ /> }