diff --git a/src/main/webapp/app/overview/discussion-section/discussion-section.component.ts b/src/main/webapp/app/overview/discussion-section/discussion-section.component.ts index 63d5873cc3b1..7a27ab65a2dc 100644 --- a/src/main/webapp/app/overview/discussion-section/discussion-section.component.ts +++ b/src/main/webapp/app/overview/discussion-section/discussion-section.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, ElementRef, OnDestroy, QueryList, ViewChild, ViewChildren, effect, input } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, OnDestroy, QueryList, ViewChild, ViewChildren, effect, inject, input } from '@angular/core'; import interact from 'interactjs'; import { Exercise } from 'app/entities/exercise.model'; import { Lecture } from 'app/entities/lecture.model'; @@ -59,14 +59,14 @@ export class DiscussionSectionComponent extends CourseDiscussionDirective implem faArrowLeft = faArrowLeft; faLongArrowRight = faLongArrowRight; - constructor( - protected metisService: MetisService, - private channelService: ChannelService, - private activatedRoute: ActivatedRoute, - private router: Router, - private formBuilder: FormBuilder, - ) { - super(metisService); + protected metisService = inject(MetisService); + private channelService = inject(ChannelService); + private activatedRoute = inject(ActivatedRoute); + private router = inject(Router); + private formBuilder = inject(FormBuilder); + + constructor() { + super(); effect(() => this.loadData(this.exercise(), this.lecture())); } diff --git a/src/main/webapp/app/shared/metis/answer-post.service.ts b/src/main/webapp/app/shared/metis/answer-post.service.ts index 3f9549e0ef2f..660692556020 100644 --- a/src/main/webapp/app/shared/metis/answer-post.service.ts +++ b/src/main/webapp/app/shared/metis/answer-post.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -9,11 +9,9 @@ type EntityResponseType = HttpResponse; @Injectable({ providedIn: 'root' }) export class AnswerPostService extends PostingService { - public resourceUrl = 'api/courses/'; + protected http = inject(HttpClient); - constructor(protected http: HttpClient) { - super(); - } + public resourceUrl = 'api/courses/'; /** * creates an answerPost diff --git a/src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts b/src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts index 344575e50c6d..d7644bc5daea 100644 --- a/src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts +++ b/src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts @@ -4,7 +4,6 @@ import { Component, EventEmitter, HostListener, - Inject, Input, OnChanges, OnInit, @@ -12,6 +11,7 @@ import { Renderer2, ViewChild, ViewContainerRef, + inject, input, } from '@angular/core'; import { AnswerPost } from 'app/entities/metis/answer-post.model'; @@ -59,6 +59,10 @@ import { EmojiPickerComponent } from 'app/shared/metis/emoji/emoji-picker.compon ], }) export class AnswerPostComponent extends PostingDirective implements OnInit, OnChanges { + changeDetector = inject(ChangeDetectorRef); + renderer = inject(Renderer2); + private document = inject(DOCUMENT); + @Input() lastReadDate?: dayjs.Dayjs; @Input() isLastAnswer: boolean; @Output() openPostingCreateEditModal = new EventEmitter(); @@ -83,14 +87,6 @@ export class AnswerPostComponent extends PostingDirective implements mayDelete: boolean = false; @ViewChild(AnswerPostReactionsBarComponent) private reactionsBarComponent!: AnswerPostReactionsBarComponent; - constructor( - public changeDetector: ChangeDetectorRef, - public renderer: Renderer2, - @Inject(DOCUMENT) private document: Document, - ) { - super(); - } - ngOnInit() { super.ngOnInit(); this.assignPostingToAnswerPost(); diff --git a/src/main/webapp/app/shared/metis/conversations/channel.service.ts b/src/main/webapp/app/shared/metis/conversations/channel.service.ts index 52e91237f14a..40575e536751 100644 --- a/src/main/webapp/app/shared/metis/conversations/channel.service.ts +++ b/src/main/webapp/app/shared/metis/conversations/channel.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ChannelDTO, ChannelIdAndNameDTO } from 'app/entities/metis/conversation/channel.model'; @@ -8,13 +8,11 @@ import { AccountService } from 'app/core/auth/account.service'; @Injectable({ providedIn: 'root' }) export class ChannelService { - public resourceUrl = '/api/courses/'; + private http = inject(HttpClient); + private conversationService = inject(ConversationService); + private accountService = inject(AccountService); - constructor( - private http: HttpClient, - private conversationService: ConversationService, - private accountService: AccountService, - ) {} + public resourceUrl = '/api/courses/'; getChannelsOfCourse(courseId: number): Observable> { return this.http.get(`${this.resourceUrl}${courseId}/channels/overview`, { diff --git a/src/main/webapp/app/shared/metis/conversations/conversation.service.ts b/src/main/webapp/app/shared/metis/conversations/conversation.service.ts index 5bf109a6a476..62f6d982f39c 100644 --- a/src/main/webapp/app/shared/metis/conversations/conversation.service.ts +++ b/src/main/webapp/app/shared/metis/conversations/conversation.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -32,13 +32,11 @@ export enum ConversationMemberSearchFilter { } @Injectable({ providedIn: 'root' }) export class ConversationService { - public resourceUrl = '/api/courses/'; + protected http = inject(HttpClient); + protected translationService = inject(TranslateService); + protected accountService = inject(AccountService); - constructor( - protected http: HttpClient, - protected translationService: TranslateService, - protected accountService: AccountService, - ) {} + public resourceUrl = '/api/courses/'; getConversationName(conversation: ConversationDTO | undefined, showLogin = false): string { if (!conversation) { diff --git a/src/main/webapp/app/shared/metis/conversations/group-chat.service.ts b/src/main/webapp/app/shared/metis/conversations/group-chat.service.ts index 16bf49e5727a..1411a823af96 100644 --- a/src/main/webapp/app/shared/metis/conversations/group-chat.service.ts +++ b/src/main/webapp/app/shared/metis/conversations/group-chat.service.ts @@ -3,18 +3,16 @@ import { OneToOneChatDTO } from 'app/entities/metis/conversation/one-to-one-chat import { GroupChatDTO } from 'app/entities/metis/conversation/group-chat.model'; import { Observable, map } from 'rxjs'; import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { AccountService } from 'app/core/auth/account.service'; @Injectable({ providedIn: 'root' }) export class GroupChatService { - public resourceUrl = 'api/courses/'; + private http = inject(HttpClient); + private conversationService = inject(ConversationService); + private accountService = inject(AccountService); - constructor( - private http: HttpClient, - private conversationService: ConversationService, - private accountService: AccountService, - ) {} + public resourceUrl = 'api/courses/'; create(courseId: number, loginsOfChatPartners: string[]): Observable> { return this.http diff --git a/src/main/webapp/app/shared/metis/conversations/one-to-one-chat.service.ts b/src/main/webapp/app/shared/metis/conversations/one-to-one-chat.service.ts index 92ed92e33bf2..242a69116c6a 100644 --- a/src/main/webapp/app/shared/metis/conversations/one-to-one-chat.service.ts +++ b/src/main/webapp/app/shared/metis/conversations/one-to-one-chat.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ConversationService } from 'app/shared/metis/conversations/conversation.service'; @@ -7,12 +7,10 @@ import { OneToOneChatDTO } from 'app/entities/metis/conversation/one-to-one-chat @Injectable({ providedIn: 'root' }) export class OneToOneChatService { - public resourceUrl = '/api/courses/'; + private http = inject(HttpClient); + private conversationService = inject(ConversationService); - constructor( - private http: HttpClient, - private conversationService: ConversationService, - ) {} + public resourceUrl = '/api/courses/'; create(courseId: number, loginOfChatPartner: string): Observable> { return this.http diff --git a/src/main/webapp/app/shared/metis/course-discussion.directive.ts b/src/main/webapp/app/shared/metis/course-discussion.directive.ts index d579b0d9dcb2..ea3138a18b61 100644 --- a/src/main/webapp/app/shared/metis/course-discussion.directive.ts +++ b/src/main/webapp/app/shared/metis/course-discussion.directive.ts @@ -1,4 +1,4 @@ -import { Directive } from '@angular/core'; +import { Directive, inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { faFilter, faLongArrowAltDown, faLongArrowAltUp, faPlus, faSearch, faTimes } from '@fortawesome/free-solid-svg-icons'; import { PostContextFilter, PostSortCriterion, SortDirection } from 'app/shared/metis/metis.util'; @@ -12,6 +12,8 @@ import { MetisService } from 'app/shared/metis/metis.service'; providers: [MetisService], }) export abstract class CourseDiscussionDirective { + protected metisService = inject(MetisService); + searchText?: string; currentPostContextFilter: PostContextFilter; formGroup: FormGroup; @@ -37,8 +39,6 @@ export abstract class CourseDiscussionDirective { faLongArrowAltUp = faLongArrowAltUp; faLongArrowAltDown = faLongArrowAltDown; - protected constructor(protected metisService: MetisService) {} - /** * on changing any filter, the metis service is invoked to deliver all posts for the * currently set context, filtered on the server diff --git a/src/main/webapp/app/shared/metis/message/message-inline-input/message-inline-input.component.ts b/src/main/webapp/app/shared/metis/message/message-inline-input/message-inline-input.component.ts index 84c0de7e1c10..c4e798250709 100644 --- a/src/main/webapp/app/shared/metis/message/message-inline-input/message-inline-input.component.ts +++ b/src/main/webapp/app/shared/metis/message/message-inline-input/message-inline-input.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core'; import { AnswerPost } from 'app/entities/metis/answer-post.model'; import { MetisService } from 'app/shared/metis/metis.service'; import { FormBuilder, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; @@ -21,16 +21,12 @@ import { TranslateDirective } from 'app/shared/language/translate.directive'; imports: [FormsModule, ReactiveFormsModule, PostingMarkdownEditorComponent, TranslateDirective, PostingButtonComponent, ArtemisSharedCommonModule], }) export class MessageInlineInputComponent extends PostingCreateEditDirective implements OnInit { - warningDismissed = false; + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); + protected localStorageService = inject(LocalStorageService); - constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - protected localStorageService: LocalStorageService, - ) { - super(metisService, modalService, formBuilder); - } + warningDismissed = false; ngOnInit(): void { super.ngOnInit(); diff --git a/src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts b/src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts index 09779d8301a7..762d12d4c680 100644 --- a/src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts +++ b/src/main/webapp/app/shared/metis/message/message-reply-inline-input/message-reply-inline-input.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation, input } from '@angular/core'; +import { Component, EventEmitter, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation, inject, input } from '@angular/core'; import { AnswerPost } from 'app/entities/metis/answer-post.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { MetisService } from 'app/shared/metis/metis.service'; @@ -21,6 +21,11 @@ import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; imports: [FormsModule, ReactiveFormsModule, PostingMarkdownEditorComponent, TranslateDirective, PostingButtonComponent, ArtemisSharedCommonModule], }) export class MessageReplyInlineInputComponent extends PostingCreateEditDirective implements OnInit, OnChanges { + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); + protected localStorageService = inject(LocalStorageService); + warningDismissed = false; readonly activeConversation = input(); @@ -28,15 +33,6 @@ export class MessageReplyInlineInputComponent extends PostingCreateEditDirective @Output() valueChange = new EventEmitter(); - constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - protected localStorageService: LocalStorageService, - ) { - super(metisService, modalService, formBuilder); - } - ngOnInit(): void { super.ngOnInit(); this.warningDismissed = !!this.localStorageService.retrieve('chatWarningDismissed'); diff --git a/src/main/webapp/app/shared/metis/metis-conversation.service.ts b/src/main/webapp/app/shared/metis/metis-conversation.service.ts index b21b4074294d..36884c815470 100644 --- a/src/main/webapp/app/shared/metis/metis-conversation.service.ts +++ b/src/main/webapp/app/shared/metis/metis-conversation.service.ts @@ -1,4 +1,4 @@ -import { Injectable, OnDestroy } from '@angular/core'; +import { Injectable, OnDestroy, inject } from '@angular/core'; import { EMPTY, Observable, ReplaySubject, Subject, Subscription, catchError, finalize, map, of, switchMap, tap } from 'rxjs'; import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { ConversationService } from 'app/shared/metis/conversations/conversation.service'; @@ -26,6 +26,16 @@ import { NotificationService } from 'app/shared/notification/notification.servic */ @Injectable() export class MetisConversationService implements OnDestroy { + private groupChatService = inject(GroupChatService); + private oneToOneChatService = inject(OneToOneChatService); + private channelService = inject(ChannelService); + protected conversationService = inject(ConversationService); + private jhiWebsocketService = inject(JhiWebsocketService); + private accountService = inject(AccountService); + private alertService = inject(AlertService); + private router = inject(Router); + private notificationService = inject(NotificationService); + // Stores the conversation of the course where the current user is a member private conversationsOfUser: ConversationDTO[] = []; _conversationsOfUser$: ReplaySubject = new ReplaySubject(1); @@ -52,17 +62,7 @@ export class MetisConversationService implements OnDestroy { private _isServiceSetup$: ReplaySubject = new ReplaySubject(1); - constructor( - private groupChatService: GroupChatService, - private oneToOneChatService: OneToOneChatService, - private channelService: ChannelService, - protected conversationService: ConversationService, - private jhiWebsocketService: JhiWebsocketService, - private accountService: AccountService, - private alertService: AlertService, - private router: Router, - private notificationService: NotificationService, - ) { + constructor() { this.accountService.identity().then((user: User) => { this.userId = user.id!; }); diff --git a/src/main/webapp/app/shared/metis/metis.service.ts b/src/main/webapp/app/shared/metis/metis.service.ts index d5c40e6dcd27..2f719ba0f325 100644 --- a/src/main/webapp/app/shared/metis/metis.service.ts +++ b/src/main/webapp/app/shared/metis/metis.service.ts @@ -36,6 +36,14 @@ import { cloneDeep } from 'lodash-es'; @Injectable() export class MetisService implements OnDestroy { + protected postService = inject(PostService); + protected answerPostService = inject(AnswerPostService); + protected reactionService = inject(ReactionService); + protected accountService = inject(AccountService); + protected exerciseService = inject(ExerciseService); + private jhiWebsocketService = inject(JhiWebsocketService); + private conversationService = inject(ConversationService); + private posts$: ReplaySubject = new ReplaySubject(1); private tags$: BehaviorSubject = new BehaviorSubject([]); private totalNumberOfPosts$: ReplaySubject = new ReplaySubject(1); @@ -53,16 +61,9 @@ export class MetisService implements OnDestroy { private courseWideTopicSubscription: Subscription; private savedPostService: SavedPostService = inject(SavedPostService); - constructor( - protected postService: PostService, - protected answerPostService: AnswerPostService, - protected reactionService: ReactionService, - protected accountService: AccountService, - protected exerciseService: ExerciseService, - private jhiWebsocketService: JhiWebsocketService, - private conversationService: ConversationService, - notificationService: NotificationService, - ) { + constructor() { + const notificationService = inject(NotificationService); + this.accountService.identity().then((user: User) => { this.user = user!; }); diff --git a/src/main/webapp/app/shared/metis/post.service.ts b/src/main/webapp/app/shared/metis/post.service.ts index ed859078e07c..613632847903 100644 --- a/src/main/webapp/app/shared/metis/post.service.ts +++ b/src/main/webapp/app/shared/metis/post.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -13,11 +13,9 @@ type EntityArrayResponseType = HttpResponse; @Injectable({ providedIn: 'root' }) export class PostService extends PostingService { - public resourceUrl = 'api/courses/'; + protected http = inject(HttpClient); - constructor(protected http: HttpClient) { - super(); - } + public resourceUrl = 'api/courses/'; /** * creates a post diff --git a/src/main/webapp/app/shared/metis/post/post.component.ts b/src/main/webapp/app/shared/metis/post/post.component.ts index dc0a0070ef8f..9355c3b273c6 100644 --- a/src/main/webapp/app/shared/metis/post/post.component.ts +++ b/src/main/webapp/app/shared/metis/post/post.component.ts @@ -5,7 +5,6 @@ import { Component, EventEmitter, HostListener, - Inject, Input, OnChanges, OnInit, @@ -13,6 +12,7 @@ import { Renderer2, ViewChild, ViewContainerRef, + inject, input, } from '@angular/core'; import { Post } from 'app/entities/metis/post.model'; @@ -76,6 +76,14 @@ import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; ], }) export class PostComponent extends PostingDirective implements OnInit, OnChanges, AfterContentChecked { + metisService = inject(MetisService); + changeDetector = inject(ChangeDetectorRef); + private oneToOneChatService = inject(OneToOneChatService); + private metisConversationService = inject(MetisConversationService); + private router = inject(Router); + renderer = inject(Renderer2); + private document = inject(DOCUMENT); + @Input() lastReadDate?: dayjs.Dayjs; @Input() readOnlyMode: boolean; @Input() previewMode: boolean; @@ -122,18 +130,6 @@ export class PostComponent extends PostingDirective implements OnInit, OnC dropdownPosition = { x: 0, y: 0 }; @ViewChild(PostReactionsBarComponent) protected reactionsBarComponent!: PostReactionsBarComponent; - constructor( - public metisService: MetisService, - public changeDetector: ChangeDetectorRef, - private oneToOneChatService: OneToOneChatService, - private metisConversationService: MetisConversationService, - private router: Router, - public renderer: Renderer2, - @Inject(DOCUMENT) private document: Document, - ) { - super(); - } - get reactionsBar() { return this.reactionsBarComponent; } diff --git a/src/main/webapp/app/shared/metis/posting-content/enlarge-slide-image/enlarge-slide-image.component.ts b/src/main/webapp/app/shared/metis/posting-content/enlarge-slide-image/enlarge-slide-image.component.ts index 8decae042f16..2b28611cda42 100644 --- a/src/main/webapp/app/shared/metis/posting-content/enlarge-slide-image/enlarge-slide-image.component.ts +++ b/src/main/webapp/app/shared/metis/posting-content/enlarge-slide-image/enlarge-slide-image.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; export interface DialogData { @@ -10,5 +10,5 @@ export interface DialogData { standalone: true, }) export class EnlargeSlideImageComponent { - constructor(@Inject(MAT_DIALOG_DATA) public data: DialogData) {} + data = inject(MAT_DIALOG_DATA); } diff --git a/src/main/webapp/app/shared/metis/posting-content/posting-content-part/posting-content-part.components.ts b/src/main/webapp/app/shared/metis/posting-content/posting-content-part/posting-content-part.components.ts index b079bc9b40a3..8bef9d1357a7 100644 --- a/src/main/webapp/app/shared/metis/posting-content/posting-content-part/posting-content-part.components.ts +++ b/src/main/webapp/app/shared/metis/posting-content/posting-content-part/posting-content-part.components.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core'; import { PostingContentPart, ReferenceType } from '../../metis.util'; import { FileService } from 'app/shared/http/file.service'; @@ -33,6 +33,10 @@ import { HtmlForPostingMarkdownPipe } from 'app/shared/pipes/html-for-posting-ma imports: [RouterLink, FaIconComponent, TranslateDirective, HtmlForPostingMarkdownPipe], }) export class PostingContentPartComponent implements OnInit { + private fileService = inject(FileService); + private dialog = inject(MatDialog); + private accountService = inject(AccountService); + @Input() postingContentPart: PostingContentPart; @Output() userReferenceClicked = new EventEmitter(); @Output() channelReferenceClicked = new EventEmitter(); @@ -54,12 +58,6 @@ export class PostingContentPartComponent implements OnInit { processedContentBeforeReference: string; processedContentAfterReference: string; - constructor( - private fileService: FileService, - private dialog: MatDialog, - private accountService: AccountService, - ) {} - ngOnInit() { this.processContent(); } diff --git a/src/main/webapp/app/shared/metis/posting-content/posting-content.components.ts b/src/main/webapp/app/shared/metis/posting-content/posting-content.components.ts index f4e775957682..84657503785d 100644 --- a/src/main/webapp/app/shared/metis/posting-content/posting-content.components.ts +++ b/src/main/webapp/app/shared/metis/posting-content/posting-content.components.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, input, output, signal } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, inject, input, output, signal } from '@angular/core'; import { Params } from '@angular/router'; import { faAngleDown, faAngleUp } from '@fortawesome/free-solid-svg-icons'; import { Post } from 'app/entities/metis/post.model'; @@ -23,6 +23,8 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; imports: [ArtemisSharedModule, FaIconComponent, NgStyle, PostingContentPartComponent, LinkPreviewContainerComponent], }) export class PostingContentComponent implements OnInit, OnChanges, OnDestroy { + private metisService = inject(MetisService); + @Input() content?: string; @Input() previewMode?: boolean; @Input() author?: User; @@ -49,8 +51,6 @@ export class PostingContentComponent implements OnInit, OnChanges, OnDestroy { faAngleUp = faAngleUp; faAngleDown = faAngleDown; - constructor(private metisService: MetisService) {} - /** * on initialization: calculate posting parts to be displayed */ diff --git a/src/main/webapp/app/shared/metis/posting-create-edit-modal/answer-post-create-edit-modal/answer-post-create-edit-modal.component.ts b/src/main/webapp/app/shared/metis/posting-create-edit-modal/answer-post-create-edit-modal/answer-post-create-edit-modal.component.ts index c7fa757323b3..2568df40e6a7 100644 --- a/src/main/webapp/app/shared/metis/posting-create-edit-modal/answer-post-create-edit-modal/answer-post-create-edit-modal.component.ts +++ b/src/main/webapp/app/shared/metis/posting-create-edit-modal/answer-post-create-edit-modal/answer-post-create-edit-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, ViewContainerRef, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, Input, Output, ViewContainerRef, ViewEncapsulation, inject } from '@angular/core'; import { PostingCreateEditModalDirective } from 'app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive'; import { AnswerPost } from 'app/entities/metis/answer-post.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; @@ -23,13 +23,9 @@ export class AnswerPostCreateEditModalComponent extends PostingCreateEditModalDi isInputOpen = false; @Output() postingUpdated = new EventEmitter(); - constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - ) { - super(metisService, modalService, formBuilder); - } + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); /** * renders the ng-template to edit or create an answerPost diff --git a/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-create-edit-modal.component.ts b/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-create-edit-modal.component.ts index 19aeb661ad7b..a1c40e9cd568 100644 --- a/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-create-edit-modal.component.ts +++ b/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-create-edit-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, OnInit, inject } from '@angular/core'; import { PostingCreateEditModalDirective } from 'app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive'; import { NgbAccordionBody, @@ -61,6 +61,11 @@ import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; ], }) export class PostCreateEditModalComponent extends PostingCreateEditModalDirective implements OnInit, OnChanges { + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); + private router = inject(Router); + @Input() isCommunicationPage: boolean; exercises?: Exercise[]; @@ -81,15 +86,6 @@ export class PostCreateEditModalComponent extends PostingCreateEditModalDirectiv faAngleUp = faAngleUp; faAngleDown = faAngleDown; - constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - private router: Router, - ) { - super(metisService, modalService, formBuilder); - } - /** * on initialization: reset all input field of the modal, determine the post context; * subscribe to the form control changes of the context selector in order to show the Announcement info box on selection; diff --git a/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-tag-selector/post-tag-selector.component.ts b/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-tag-selector/post-tag-selector.component.ts index 6a4be5084f27..398655cf6d42 100644 --- a/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-tag-selector/post-tag-selector.component.ts +++ b/src/main/webapp/app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-tag-selector/post-tag-selector.component.ts @@ -1,4 +1,4 @@ -import { AfterContentChecked, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; +import { AfterContentChecked, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild, inject } from '@angular/core'; import { Observable, Subscription, map, startWith } from 'rxjs'; import { MetisService } from 'app/shared/metis/metis.service'; import { COMMA, ENTER, TAB } from '@angular/cdk/keycodes'; @@ -34,6 +34,9 @@ import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; ], }) export class PostTagSelectorComponent implements OnInit, OnChanges, OnDestroy, AfterContentChecked { + private metisService = inject(MetisService); + private changeDetector = inject(ChangeDetectorRef); + @Input() postTags?: string[]; @Output() postTagsChange = new EventEmitter(); @@ -51,11 +54,6 @@ export class PostTagSelectorComponent implements OnInit, OnChanges, OnDestroy, A // Icons faTimes = faTimes; - constructor( - private metisService: MetisService, - private changeDetector: ChangeDetectorRef, - ) {} - /** * on initialization: subscribes to existing post tags used in this course (will be shown in dropdown of tag selector), * copies the input post tags to string tags, so that they are shown in the selector diff --git a/src/main/webapp/app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive.ts b/src/main/webapp/app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive.ts index 9461099accd6..2c6b3ef28bca 100644 --- a/src/main/webapp/app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive.ts +++ b/src/main/webapp/app/shared/metis/posting-create-edit-modal/posting-create-edit-modal.directive.ts @@ -1,4 +1,4 @@ -import { Directive, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; +import { Directive, OnChanges, OnInit, TemplateRef, ViewChild, inject } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Posting } from 'app/entities/metis/posting.model'; @@ -7,17 +7,13 @@ import { PostingCreateEditDirective } from 'app/shared/metis/posting-create-edit @Directive() export abstract class PostingCreateEditModalDirective extends PostingCreateEditDirective implements OnInit, OnChanges { + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); + @ViewChild('postingEditor') postingEditor: TemplateRef; modalTitle: string; - protected constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - ) { - super(metisService, modalService, formBuilder); - } - /** * on initialization: sets the content, and the modal title (edit or create) */ diff --git a/src/main/webapp/app/shared/metis/posting-create-edit.directive.ts b/src/main/webapp/app/shared/metis/posting-create-edit.directive.ts index 5d327cbe390e..d4fdffa8e3b3 100644 --- a/src/main/webapp/app/shared/metis/posting-create-edit.directive.ts +++ b/src/main/webapp/app/shared/metis/posting-create-edit.directive.ts @@ -1,4 +1,4 @@ -import { Directive, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'; +import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, inject } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { Posting } from 'app/entities/metis/posting.model'; @@ -12,6 +12,10 @@ const MAX_CONTENT_LENGTH = 5000; @Directive() export abstract class PostingCreateEditDirective implements OnInit, OnChanges { + protected metisService = inject(MetisService); + protected modalService = inject(NgbModal); + protected formBuilder = inject(FormBuilder); + @Input() posting: T; @Output() onCreate: EventEmitter = new EventEmitter(); @Output() isModalOpen = new EventEmitter(); @@ -24,12 +28,6 @@ export abstract class PostingCreateEditDirective implements O formGroup: FormGroup; readonly EditType = PostingEditType; - protected constructor( - protected metisService: MetisService, - protected modalService: NgbModal, - protected formBuilder: FormBuilder, - ) {} - get editType(): PostingEditType { return this.posting.id ? PostingEditType.UPDATE : PostingEditType.CREATE; } diff --git a/src/main/webapp/app/shared/metis/posting-footer/post-footer/post-footer.component.ts b/src/main/webapp/app/shared/metis/posting-footer/post-footer/post-footer.component.ts index 1855040e260e..60b452c751c6 100644 --- a/src/main/webapp/app/shared/metis/posting-footer/post-footer/post-footer.component.ts +++ b/src/main/webapp/app/shared/metis/posting-footer/post-footer/post-footer.component.ts @@ -11,6 +11,7 @@ import { SimpleChanges, ViewChild, ViewContainerRef, + inject, } from '@angular/core'; import { PostingFooterDirective } from 'app/shared/metis/posting-footer/posting-footer.directive'; import { Post } from 'app/entities/metis/post.model'; @@ -36,6 +37,9 @@ interface PostGroup { imports: [AnswerPostComponent, AnswerPostCreateEditModalComponent, ArtemisSharedCommonModule], }) export class PostFooterComponent extends PostingFooterDirective implements OnInit, OnDestroy, AfterContentChecked, OnChanges { + private metisService = inject(MetisService); + protected changeDetector = inject(ChangeDetectorRef); + @Input() lastReadDate?: dayjs.Dayjs; @Input() readOnlyMode = false; @Input() previewMode = false; @@ -58,13 +62,6 @@ export class PostFooterComponent extends PostingFooterDirective implements courseId!: number; groupedAnswerPosts: PostGroup[] = []; - constructor( - private metisService: MetisService, - protected changeDetector: ChangeDetectorRef, - ) { - super(); - } - ngOnInit(): void { this.courseId = this.metisService.getCourse().id!; this.isAtLeastTutorInCourse = this.metisService.metisUserIsAtLeastTutorInCourse(); diff --git a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts index f3a8f9cd6637..89da98f22beb 100644 --- a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts +++ b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts @@ -62,6 +62,14 @@ import { NgStyle } from '@angular/common'; imports: [ArtemisMarkdownEditorModule, PostingContentComponent, NgStyle], }) export class PostingMarkdownEditorComponent implements OnInit, ControlValueAccessor, AfterContentChecked, AfterViewInit { + private cdref = inject(ChangeDetectorRef); + private metisService = inject(MetisService); + private courseManagementService = inject(CourseManagementService); + private lectureService = inject(LectureService); + private channelService = inject(ChannelService); + viewContainerRef = inject(ViewContainerRef); + private positionBuilder = inject(OverlayPositionBuilder); + @ViewChild(MarkdownEditorMonacoComponent, { static: true }) markdownEditor: MarkdownEditorMonacoComponent; @Input() maxContentLength: number; @@ -83,16 +91,6 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces protected readonly MarkdownEditorHeight = MarkdownEditorHeight; private overlay = inject(Overlay); - constructor( - private cdref: ChangeDetectorRef, - private metisService: MetisService, - private courseManagementService: CourseManagementService, - private lectureService: LectureService, - private channelService: ChannelService, - public viewContainerRef: ViewContainerRef, - private positionBuilder: OverlayPositionBuilder, - ) {} - /** * on initialization: sets commands that will be available as formatting buttons during creation/editing of postings */ diff --git a/src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts b/src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts index 711498ed023c..5bcae58205d4 100644 --- a/src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts +++ b/src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnChanges, OnInit, Output, output } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, inject, output } from '@angular/core'; import { Reaction } from 'app/entities/metis/reaction.model'; import { PostingsReactionsBarDirective } from 'app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive'; import { AnswerPost } from 'app/entities/metis/answer-post.model'; @@ -55,9 +55,7 @@ export class AnswerPostReactionsBarComponent extends PostingsReactionsBarDirecti @Input() isEmojiCount: boolean = false; @Output() postingUpdated = new EventEmitter(); - constructor(metisService: MetisService) { - super(metisService); - } + protected metisService = inject(MetisService); ngOnInit() { super.ngOnInit(); diff --git a/src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts b/src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts index c0f6160c350d..d1918010e905 100644 --- a/src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts +++ b/src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild, output } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild, inject, output } from '@angular/core'; import { Reaction } from 'app/entities/metis/reaction.model'; import { Post } from 'app/entities/metis/post.model'; import { PostingsReactionsBarDirective } from 'app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive'; @@ -50,6 +50,8 @@ import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; ], }) export class PostReactionsBarComponent extends PostingsReactionsBarDirective implements OnInit, OnChanges, OnDestroy { + private accountService = inject(AccountService); + pinTooltip: string; displayPriority: DisplayPriority; canPin = false; @@ -84,12 +86,7 @@ export class PostReactionsBarComponent extends PostingsReactionsBarDirective reaction.count >= 1); diff --git a/src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts b/src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts index c8877be83b9c..13c043f3fe98 100644 --- a/src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts +++ b/src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts @@ -1,4 +1,4 @@ -import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, output } from '@angular/core'; +import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, inject, output } from '@angular/core'; import { Posting } from 'app/entities/metis/posting.model'; import { MetisService } from 'app/shared/metis/metis.service'; import { EmojiData } from '@ctrl/ngx-emoji-mart/ngx-emoji'; @@ -44,6 +44,8 @@ interface ReactionMetaDataMap { @Directive() export abstract class PostingsReactionsBarDirective implements OnInit, OnChanges { + protected metisService = inject(MetisService); + pinEmojiId: string = PIN_EMOJI_ID; archiveEmojiId: string = ARCHIVE_EMOJI_ID; speechBalloonId: string = SPEECH_BALLOON_ID; @@ -104,8 +106,6 @@ export abstract class PostingsReactionsBarDirective implement */ reactionMetaDataMap: ReactionMetaDataMap = {}; - protected constructor(protected metisService: MetisService) {} - /** * on initialization: updates the current posting and its reactions, * invokes metis service to check user authority diff --git a/src/main/webapp/app/shared/metis/reaction.service.ts b/src/main/webapp/app/shared/metis/reaction.service.ts index b91bb9ef145f..78402334d69b 100644 --- a/src/main/webapp/app/shared/metis/reaction.service.ts +++ b/src/main/webapp/app/shared/metis/reaction.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -9,9 +9,9 @@ type EntityResponseType = HttpResponse; @Injectable({ providedIn: 'root' }) export class ReactionService { - public resourceUrl = 'api/courses/'; + protected http = inject(HttpClient); - constructor(protected http: HttpClient) {} + public resourceUrl = 'api/courses/'; /** * creates a reaction