Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Migrate client code for complaints #10085

Merged
merged 6 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/webapp/app/assessment/assessment-shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AssessmentComplaintAlertComponent } from './assessment-complaint-alert/
import { ScoreDisplayComponent } from '../shared/score-display/score-display.component';
import { UnreferencedFeedbackDetailComponent } from 'app/assessment/unreferenced-feedback-detail/unreferenced-feedback-detail.component';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { ArtemisComplaintsForTutorModule } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.module';
import { AssessmentLocksComponent } from 'app/assessment/assessment-locks/assessment-locks.component';
import { RouterModule } from '@angular/router';
import { assessmentLocksRoute } from 'app/assessment/assessment-locks/assessment-locks.route';
Expand All @@ -18,13 +17,14 @@ import { ArtemisFeedbackModule } from 'app/exercises/shared/feedback/feedback.mo
import { AssessmentNoteComponent } from 'app/assessment/assessment-note/assessment-note.component';
import { FeedbackContentPipe } from 'app/shared/pipes/feedback-content.pipe';
import { QuotePipe } from 'app/shared/pipes/quote.pipe';
import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component';

const ENTITY_STATES = [...assessmentLocksRoute];

@NgModule({
imports: [
ArtemisSharedModule,
ArtemisComplaintsForTutorModule,
ComplaintsForTutorComponent,
ArtemisSharedComponentModule,
RouterModule.forChild(ENTITY_STATES),
ArtemisMarkdownModule,
Expand Down
10 changes: 4 additions & 6 deletions src/main/webapp/app/complaints/complaint-response.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,12 +12,10 @@ type EntityResponseType = HttpResponse<ComplaintResponse>;

@Injectable({ providedIn: 'root' })
export class ComplaintResponseService {
private resourceUrl = 'api/complaints';
private http = inject(HttpClient);
private accountService = inject(AccountService);

constructor(
private http: HttpClient,
private accountService: AccountService,
) {}
private resourceUrl = 'api/complaints';

/**
* Checks if a complaint response is locked for the currently logged-in user
Expand Down
10 changes: 4 additions & 6 deletions src/main/webapp/app/complaints/complaint.service.ts
Original file line number Diff line number Diff line change
@@ -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 dayjs from 'dayjs/esm';
Expand Down Expand Up @@ -31,12 +31,10 @@ export interface IComplaintService {

@Injectable({ providedIn: 'root' })
export class ComplaintService implements IComplaintService {
private resourceUrl = 'api/complaints';
private http = inject(HttpClient);
private complaintResponseService = inject(ComplaintResponseService);

constructor(
private http: HttpClient,
private complaintResponseService: ComplaintResponseService,
) {}
private resourceUrl = 'api/complaints';

/**
* Checks if a complaint is locked for the currently logged-in user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, inject } from '@angular/core';
import { Exercise, getCourseFromExercise } from 'app/entities/exercise.model';
import { Complaint, ComplaintType } from 'app/entities/complaint.model';
import { ComplaintService } from 'app/complaints/complaint.service';
Expand All @@ -14,13 +14,26 @@ import dayjs from 'dayjs/esm';
import { HttpResponse } from '@angular/common/http';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { ComplaintsFormComponent } from 'app/complaints/form/complaints-form.component';
import { ComplaintRequestComponent } from 'app/complaints/request/complaint-request.component';
import { ComplaintResponseComponent } from 'app/complaints/response/complaint-response.component';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-complaint-student-view',
templateUrl: './complaints-student-view.component.html',
styleUrls: ['../complaints.scss'],
standalone: true,
imports: [TranslateDirective, FaIconComponent, ComplaintsFormComponent, ComplaintRequestComponent, ComplaintResponseComponent, ArtemisTranslatePipe],
})
export class ComplaintsStudentViewComponent implements OnInit {
private complaintService = inject(ComplaintService);
private serverDateService = inject(ArtemisServerDateService);
private accountService = inject(AccountService);
private courseService = inject(CourseManagementService);

@Input() exercise: Exercise;
@Input() participation: StudentParticipation;
@Input() result?: Result;
Expand All @@ -46,13 +59,6 @@ export class ComplaintsStudentViewComponent implements OnInit {
// Icons
faInfoCircle = faInfoCircle;

constructor(
private complaintService: ComplaintService,
private serverDateService: ArtemisServerDateService,
private accountService: AccountService,
private courseService: CourseManagementService,
) {}

/**
* Loads the number of allowed complaints and feedback requests
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core';
import { AlertService } from 'app/core/util/alert.service';
import { HttpErrorResponse } from '@angular/common/http';
import { ComplaintResponseService } from 'app/complaints/complaint-response.service';
Expand All @@ -13,15 +13,27 @@ import { Submission } from 'app/entities/submission.model';
import { isAllowedToRespondToComplaintAction } from 'app/assessment/assessment.service';
import { Course } from 'app/entities/course.model';
import { ComplaintAction, ComplaintResponseUpdateDTO } from 'app/entities/complaint-response-dto.model';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { FormsModule } from '@angular/forms';
import { TextareaModule } from 'app/shared/textarea/textarea.module';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

export type AssessmentAfterComplaint = { complaintResponse: ComplaintResponse; onSuccess: () => void; onError: () => void };

@Component({
selector: 'jhi-complaints-for-tutor-form',
templateUrl: './complaints-for-tutor.component.html',
providers: [],
standalone: true,
imports: [TranslateDirective, FormsModule, TextareaModule, ArtemisSharedCommonModule, ArtemisTranslatePipe],
})
export class ComplaintsForTutorComponent implements OnInit {
private alertService = inject(AlertService);
private complaintResponseService = inject(ComplaintResponseService);
private activatedRoute = inject(ActivatedRoute);
private router = inject(Router);
private location = inject(Location);

@Input() complaint: Complaint;
@Input() isTestRun = false;
@Input() isAssessor = false;
Expand All @@ -43,14 +55,6 @@ export class ComplaintsForTutorComponent implements OnInit {
course?: Course;
maxComplaintResponseTextLimit: number;

constructor(
private alertService: AlertService,
private complaintResponseService: ComplaintResponseService,
private activatedRoute: ActivatedRoute,
private router: Router,
private location: Location,
) {}

ngOnInit(): void {
this.course = getCourseFromExercise(this.exercise!);

Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/webapp/app/complaints/complaints.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { ComplaintResponseComponent } from 'app/complaints/response/complaint-re
import { TextareaModule } from 'app/shared/textarea/textarea.module';

@NgModule({
imports: [ArtemisSharedModule, TextareaModule],
declarations: [ComplaintsFormComponent, ComplaintsStudentViewComponent, ComplaintRequestComponent, ComplaintResponseComponent],
imports: [ArtemisSharedModule, TextareaModule, ComplaintsFormComponent, ComplaintsStudentViewComponent, ComplaintRequestComponent, ComplaintResponseComponent],
exports: [ComplaintsStudentViewComponent],
providers: [ComplaintService],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core';
import { ComplaintService } from 'app/complaints/complaint.service';
import { AlertService } from 'app/core/util/alert.service';
import { ComplaintType } from 'app/entities/complaint.model';
import { Course } from 'app/entities/course.model';
import { Exercise, getCourseFromExercise } from 'app/entities/exercise.model';
import { onError } from 'app/shared/util/global.utils';
import { ComplaintRequestDTO } from 'app/entities/complaint-request-dto.model';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { FormsModule } from '@angular/forms';
import { TextareaModule } from 'app/shared/textarea/textarea.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-complaint-form',
templateUrl: './complaints-form.component.html',
styleUrls: ['../complaints.scss'],
standalone: true,
imports: [TranslateDirective, FormsModule, TextareaModule, ArtemisTranslatePipe],
})
export class ComplaintsFormComponent implements OnInit {
private complaintService = inject(ComplaintService);
private alertService = inject(AlertService);

@Input() exercise: Exercise;
@Input() resultId: number;
@Input() examId?: number;
Expand All @@ -27,11 +36,6 @@ export class ComplaintsFormComponent implements OnInit {

readonly ComplaintType = ComplaintType;

constructor(
private complaintService: ComplaintService,
private alertService: AlertService,
) {}

ngOnInit(): void {
this.course = getCourseFromExercise(this.exercise);
this.maxComplaintTextLimit = this.course?.maxComplaintTextLimit ?? 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { AlertService } from 'app/core/util/alert.service';
import { ComplaintService } from 'app/complaints/complaint.service';
import { CourseManagementService } from 'app/course/manage/course-management.service';
Expand All @@ -8,20 +8,36 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Course } from 'app/entities/course.model';
import { Observable, combineLatestWith } from 'rxjs';
import { StudentParticipation } from 'app/entities/participation/student-participation.model';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { SortService } from 'app/shared/service/sort.service';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
import { TranslateService } from '@ngx-translate/core';
import { onError } from 'app/shared/util/global.utils';
import { getLinkToSubmissionAssessment } from 'app/utils/navigation.utils';
import { faExclamationTriangle, faFolderOpen, faSort } from '@fortawesome/free-solid-svg-icons';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { FormsModule } from '@angular/forms';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-complaint-list',
templateUrl: './list-of-complaints.component.html',
providers: [],
standalone: true,
imports: [TranslateDirective, FormsModule, ArtemisSharedCommonModule, FaIconComponent, NgbTooltip, ArtemisTranslatePipe],
})
export class ListOfComplaintsComponent implements OnInit {
complaintService = inject(ComplaintService);
private alertService = inject(AlertService);
private route = inject(ActivatedRoute);
private router = inject(Router);
private modalService = inject(NgbModal);
private sortService = inject(SortService);
private translateService = inject(TranslateService);
private artemisDatePipe = inject(ArtemisDatePipe);
private courseManagementService = inject(CourseManagementService);

readonly ComplaintType = ComplaintType;

public complaints: Complaint[] = [];
Expand Down Expand Up @@ -49,18 +65,6 @@ export class ListOfComplaintsComponent implements OnInit {

readonly FILTER_OPTION_ADDRESSED_COMPLAINTS = 4; // the number passed by the chart through the route indicating that only addressed complaints should be shown

constructor(
public complaintService: ComplaintService,
private alertService: AlertService,
private route: ActivatedRoute,
private router: Router,
private modalService: NgbModal,
private sortService: SortService,
private translateService: TranslateService,
private artemisDatePipe: ArtemisDatePipe,
private courseManagementService: CourseManagementService,
) {}

ngOnInit(): void {
this.route.params.pipe(combineLatestWith(this.route.queryParams, this.route.data)).subscribe((result) => {
const params = result[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { ListOfComplaintsComponent } from './list-of-complaints.component';
import { ComplaintService } from 'app/complaints/complaint.service';
import { RouterModule } from '@angular/router';
import { listOfComplaintsRoute } from 'app/complaints/list-of-complaints/list-of-complaints.route';
import { ArtemisSharedModule } from 'app/shared/shared.module';

const ENTITY_STATES = [...listOfComplaintsRoute];

@NgModule({
imports: [ArtemisSharedModule, RouterModule.forChild(ENTITY_STATES)],
declarations: [ListOfComplaintsComponent],
imports: [RouterModule.forChild(ENTITY_STATES), ListOfComplaintsComponent],
exports: [ListOfComplaintsComponent],
providers: [ComplaintService],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { Component, Input } from '@angular/core';
import { Complaint, ComplaintType } from 'app/entities/complaint.model';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { FormsModule } from '@angular/forms';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-complaint-request',
templateUrl: './complaint-request.component.html',
standalone: true,
imports: [NgbTooltip, TranslateDirective, FormsModule, ArtemisSharedCommonModule, ArtemisTranslatePipe],
})
export class ComplaintRequestComponent {
@Input() complaint: Complaint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Component, Input } from '@angular/core';
import { Complaint, ComplaintType } from 'app/entities/complaint.model';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule } from '@angular/forms';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-complaint-response',
templateUrl: './complaint-response.component.html',
standalone: true,
imports: [NgbTooltip, FormsModule, ArtemisSharedCommonModule, ArtemisTranslatePipe],
})
export class ComplaintResponseComponent {
@Input() complaint: Complaint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { ArtemisParticipationModule } from 'app/exercises/shared/participation/p
import { ArtemisModelingExerciseManagementModule } from 'app/exercises/modeling/manage/modeling-exercise-management.module';
import { ArtemisCourseScoresModule } from 'app/course/course-scores/course-scores.module';
import { ArtemisExerciseScoresModule } from 'app/exercises/shared/exercise-scores/exercise-scores.module';
import { ArtemisComplaintsForTutorModule } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.module';
import { ArtemisFileUploadAssessmentModule } from 'app/exercises/file-upload/assess/file-upload-assessment.module';
import { ArtemisModelingAssessmentEditorModule } from 'app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.module';
import { NgxDatatableModule } from '@siemens/ngx-datatable';
Expand Down Expand Up @@ -68,6 +67,7 @@ import { SubmissionResultStatusModule } from 'app/overview/submission-result-sta
import { ImageCropperModalComponent } from 'app/course/manage/image-cropper-modal.component';
import { HeaderCourseComponent } from 'app/overview/header-course.component';
import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown-editor.module';
import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -95,7 +95,7 @@ import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown
ArtemisColorSelectorModule,
ArtemisDashboardsModule,
ArtemisParticipationModule,
ArtemisComplaintsForTutorModule,
ComplaintsForTutorComponent,
ArtemisListOfComplaintsModule,
ArtemisFileUploadAssessmentModule,
ArtemisModelingAssessmentEditorModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { FormDateTimePickerModule } from 'app/shared/date-time-picker/date-time-
import { FormsModule } from '@angular/forms';
import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module';
import { ProgrammingAssessmentRepoExportButtonComponent } from 'app/exercises/programming/assess/repo-export/programming-assessment-repo-export-button.component';
import { ArtemisComplaintsForTutorModule } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.module';
import { ProgrammingAssessmentRepoExportDialogComponent } from 'app/exercises/programming/assess/repo-export/programming-assessment-repo-export-dialog.component';
import { ArtemisProgrammingAssessmentRoutingModule } from 'app/exercises/programming/assess/programming-assessment.route';
import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module';
Expand All @@ -18,6 +17,7 @@ import { AssessmentInstructionsModule } from 'app/assessment/assessment-instruct
import { ArtemisHeaderExercisePageWithDetailsModule } from 'app/exercises/shared/exercise-headers/exercise-headers.module';
import { OrionTutorAssessmentComponent } from 'app/orion/assessment/orion-tutor-assessment.component';
import { SubmissionResultStatusModule } from 'app/overview/submission-result-status.module';
import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component';

@NgModule({
imports: [
Expand All @@ -26,7 +26,7 @@ import { SubmissionResultStatusModule } from 'app/overview/submission-result-sta
FormDateTimePickerModule,
FormsModule,
FeatureToggleModule,
ArtemisComplaintsForTutorModule,
ComplaintsForTutorComponent,
ArtemisProgrammingAssessmentRoutingModule,
ArtemisAssessmentSharedModule,
ArtemisCodeEditorModule,
Expand Down
Loading
Loading