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: Update LTI components to use Angular 18 practices #9908

Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
85274d3
push branch
raffifasaro Nov 29, 2024
41aa1f8
Inject migration
raffifasaro Nov 29, 2024
56dae8c
Standalone migration
raffifasaro Nov 29, 2024
58809be
inject launch component
raffifasaro Nov 29, 2024
29249df
inject dynamic reg comp
raffifasaro Nov 29, 2024
71769f5
signal for course card
raffifasaro Nov 29, 2024
39333d6
Inject for lti13 comps
raffifasaro Nov 30, 2024
e751ddd
Inject for admin lti config
raffifasaro Nov 30, 2024
cfc30cc
Inject for course lti comps
raffifasaro Nov 30, 2024
ad4c74b
Overview lti comps
raffifasaro Nov 30, 2024
64eaf0d
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 1, 2024
13bf094
fix input
raffifasaro Dec 1, 2024
161ec3c
Merge remote-tracking branch 'origin/chore/performance/angular-18-sig…
raffifasaro Dec 1, 2024
c752611
signals input course card fix
raffifasaro Dec 1, 2024
cb1a74c
Fix tests
raffifasaro Dec 3, 2024
4fc3c75
Fix tests 2
raffifasaro Dec 3, 2024
4fbc32f
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 3, 2024
afd9091
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 3, 2024
a6dc93a
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 4, 2024
7166c78
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 5, 2024
b65fa21
Fixes
raffifasaro Dec 5, 2024
9851a3b
Merge remote-tracking branch 'origin/chore/performance/angular-18-sig…
raffifasaro Dec 5, 2024
e5c8993
Standalone course lti components + fixes
raffifasaro Dec 5, 2024
0381c2c
test fixes
raffifasaro Dec 5, 2024
1cd64aa
fix input required
raffifasaro Dec 6, 2024
68d7843
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 6, 2024
d407cb4
reverse input required
raffifasaro Dec 6, 2024
0c60da5
Merge remote-tracking branch 'origin/chore/performance/angular-18-sig…
raffifasaro Dec 6, 2024
24100e5
fixes
raffifasaro Dec 6, 2024
3c3d5c2
fix httpclientmodule
raffifasaro Dec 6, 2024
f61ab38
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 7, 2024
e803712
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 9, 2024
87cc902
Merge branch 'develop' into chore/performance/angular-18-signal-migra…
raffifasaro Dec 11, 2024
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AlertService } from 'app/core/util/alert.service';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { finalize } from 'rxjs';
import { FormControl, FormGroup } from '@angular/forms';
Expand All @@ -12,6 +12,11 @@ import { LtiConfigurationService } from 'app/admin/lti-configuration/lti-configu
templateUrl: './edit-lti-configuration.component.html',
})
export class EditLtiConfigurationComponent implements OnInit {
private route = inject(ActivatedRoute);
private ltiConfigurationService = inject(LtiConfigurationService);
private router = inject(Router);
private alertService = inject(AlertService);

platform: LtiPlatformConfiguration;
platformConfigurationForm: FormGroup;

Expand All @@ -22,13 +27,6 @@ export class EditLtiConfigurationComponent implements OnInit {
faSave = faSave;
faPlus = faPlus;

constructor(
private route: ActivatedRoute,
private ltiConfigurationService: LtiConfigurationService,
private router: Router,
private alertService: AlertService,
) {}

/**
* Gets the configuration for the course encoded in the route and prepares the form
*/
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 { ActivatedRoute, Router } from '@angular/router';
import { Course } from 'app/entities/course.model';
import { faExclamationTriangle, faPencilAlt, faPlus, faSort, faTrash, faWrench } from '@fortawesome/free-solid-svg-icons';
Expand All @@ -17,6 +17,12 @@ import { combineLatest } from 'rxjs';
templateUrl: './lti-configuration.component.html',
})
export class LtiConfigurationComponent implements OnInit {
private router = inject(Router);
private ltiConfigurationService = inject(LtiConfigurationService);
private sortService = inject(SortService);
private alertService = inject(AlertService);
private activatedRoute = inject(ActivatedRoute);

course: Course;
platforms: LtiPlatformConfiguration[];
ascending!: boolean;
Expand All @@ -40,14 +46,6 @@ export class LtiConfigurationComponent implements OnInit {
private dialogErrorSource = new Subject<string>();
dialogError$ = this.dialogErrorSource.asObservable();

constructor(
private router: Router,
private ltiConfigurationService: LtiConfigurationService,
private sortService: SortService,
private alertService: AlertService,
private activatedRoute: ActivatedRoute,
) {}

/**
* Gets the configuration for the course encoded in the route and fetches the exercises
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { LtiPlatformConfiguration } from 'app/admin/lti-configuration/lti-configuration.model';
import { createRequestOption } from 'app/shared/util/request.util';

@Injectable({ providedIn: 'root' })
export class LtiConfigurationService {
constructor(private http: HttpClient) {}
private http = inject(HttpClient);

/**
* Sends a GET request to retrieve all lti platform configurations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
raffifasaro marked this conversation as resolved.
Show resolved Hide resolved
import { Course } from 'app/entities/course.model';
import { OnlineCourseConfiguration } from 'app/entities/online-course-configuration.model';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { Exercise } from 'app/entities/exercise.model';
import { faExclamationTriangle, faSort, faWrench } from '@fortawesome/free-solid-svg-icons';
import { SortService } from 'app/shared/service/sort.service';
import { FormsModule } from '@angular/forms';
import { TranslateDirective } from '../../../shared/language/translate.directive';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { NgbNav, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavOutlet, NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { ArtemisSharedComponentModule } from '../../../shared/components/shared-component.module';
import { ArtemisSharedCommonModule } from '../../../shared/shared-common.module';
import { ArtemisTranslatePipe } from '../../../shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-course-lti-configuration',
templateUrl: './course-lti-configuration.component.html',
standalone: true,
imports: [
FormsModule,
TranslateDirective,
RouterLink,
FaIconComponent,
NgbNav,
NgbNavItem,
NgbNavLink,
NgbNavLinkBase,
NgbNavContent,
NgbTooltip,
ArtemisSharedComponentModule,
ArtemisSharedCommonModule,
NgbNavOutlet,
ArtemisTranslatePipe,
],
})
export class CourseLtiConfigurationComponent implements OnInit {
private route = inject(ActivatedRoute);
private sortService = inject(SortService);
private courseManagementService = inject(CourseManagementService);

raffifasaro marked this conversation as resolved.
Show resolved Hide resolved
protected readonly Object = Object;

course: Course;
Expand All @@ -29,12 +57,6 @@ export class CourseLtiConfigurationComponent implements OnInit {
faExclamationTriangle = faExclamationTriangle;
faWrench = faWrench;

constructor(
private route: ActivatedRoute,
private sortService: SortService,
private courseManagementService: CourseManagementService,
) {}

/**
* Gets the configuration for the course encoded in the route and fetches the exercises
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Course } from 'app/entities/course.model';
import { finalize } from 'rxjs';
import { OnlineCourseConfiguration } from 'app/entities/online-course-configuration.model';
import { FormControl, FormGroup } from '@angular/forms';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { faBan, faSave } from '@fortawesome/free-solid-svg-icons';
import { regexValidator } from 'app/shared/form/shortname-validator.directive';
import { LOGIN_PATTERN } from 'app/shared/constants/input.constants';
Expand All @@ -13,12 +13,44 @@ import { LtiConfigurationService } from 'app/admin/lti-configuration/lti-configu
import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { combineLatest } from 'rxjs';
import { TranslateDirective } from '../../../shared/language/translate.directive';
import { ArtemisSharedComponentModule } from '../../../shared/components/shared-component.module';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { NgbDropdown, NgbDropdownButtonItem, NgbDropdownItem, NgbDropdownMenu, NgbDropdownToggle, NgbPagination, NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { KeyValuePipe } from '@angular/common';
import { ArtemisTranslatePipe } from '../../../shared/pipes/artemis-translate.pipe';
import { ArtemisSharedPipesModule } from '../../../shared/pipes/shared-pipes.module';

@Component({
selector: 'jhi-edit-course-lti-configuration',
templateUrl: './edit-course-lti-configuration.component.html',
standalone: true,
imports: [
FormsModule,
ReactiveFormsModule,
TranslateDirective,
ArtemisSharedComponentModule,
ArtemisSharedModule,
NgbDropdown,
NgbDropdownToggle,
NgbDropdownMenu,
NgbDropdownButtonItem,
NgbDropdownItem,
NgbTooltip,
NgbPagination,
FaIconComponent,
KeyValuePipe,
ArtemisTranslatePipe,
ArtemisSharedPipesModule,
],
})
export class EditCourseLtiConfigurationComponent implements OnInit {
private route = inject(ActivatedRoute);
private courseService = inject(CourseManagementService);
private router = inject(Router);
private ltiConfigurationService = inject(LtiConfigurationService);

raffifasaro marked this conversation as resolved.
Show resolved Hide resolved
@ViewChild('scrollableContent') scrollableContent: ElementRef;

course: Course;
Expand All @@ -37,13 +69,6 @@ export class EditCourseLtiConfigurationComponent implements OnInit {
faBan = faBan;
faSave = faSave;

constructor(
private route: ActivatedRoute,
private courseService: CourseManagementService,
private router: Router,
private ltiConfigurationService: LtiConfigurationService,
) {}

/**
* Gets the configuration for the course encoded in the route and prepares the form
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown
DetailModule,
SubmissionResultStatusModule,
ArtemisMarkdownEditorModule,
CourseLtiConfigurationComponent,
EditCourseLtiConfigurationComponent,
],
declarations: [
CourseManagementComponent,
Expand All @@ -138,8 +140,6 @@ import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown
CourseDetailLineChartComponent,
CourseManagementExercisesSearchComponent,
CourseGroupMembershipComponent,
CourseLtiConfigurationComponent,
EditCourseLtiConfigurationComponent,
CourseManagementTabBarComponent,
BuildQueueComponent,
ImageCropperModalComponent,
Expand Down
12 changes: 6 additions & 6 deletions src/main/webapp/app/lti/lti-course-card.component.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<div class="card" style="min-height: 80px !important">
<div
id="course-{{ course.id }}-header"
id="course-{{ course().id }}-header"
class="card-header text-white"
[routerLink]="['/lti/exercises', this.course.id]"
[routerLink]="['/lti/exercises', course().id]"
[ngStyle]="{ '--background-color-for-hover': courseColor }"
>
<a class="stretched-link" [routerLink]="['/lti/exercises', this.course.id]"></a>
<a class="stretched-link" [routerLink]="['/lti/exercises', course().id]"></a>
<div class="container">
<div class="row d-flex">
<div class="col-2 header-col image-col">
@if (course.courseIcon) {
<jhi-secured-image [cachingStrategy]="CachingStrategy.LOCAL_STORAGE" [src]="course.courseIcon" />
@if (course().courseIcon) {
<jhi-secured-image [cachingStrategy]="CachingStrategy.LOCAL_STORAGE" [src]="course().courseIcon || ''"></jhi-secured-image>
}
</div>
<div class="col-7 header-col title-col px-3">
<h5 class="card-title text-center">
{{ course.title + ' (' + course.shortName + ')' }}
{{ course().title + ' (' + course().shortName + ')' }}
</h5>
</div>
<div class="col-2 header-col course-info-col"></div>
Expand Down
18 changes: 13 additions & 5 deletions src/main/webapp/app/lti/lti-course-card.component.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { Component, Input, OnChanges } from '@angular/core';
import { Component, effect, input } from '@angular/core';
import { Course } from 'app/entities/course.model';
import { ARTEMIS_DEFAULT_COLOR } from 'app/app.constants';
import { CachingStrategy } from 'app/shared/image/secured-image.component';
import { RouterLink } from '@angular/router';
import { NgStyle } from '@angular/common';
import { ArtemisSharedModule } from 'app/shared/shared.module';

@Component({
selector: 'jhi-overview-lti-course-card',
templateUrl: './lti-course-card.component.html',
styleUrls: ['../overview/course-card.scss'],
standalone: true,
imports: [RouterLink, NgStyle, ArtemisSharedModule],
})
raffifasaro marked this conversation as resolved.
Show resolved Hide resolved
export class LtiCourseCardComponent implements OnChanges {
export class LtiCourseCardComponent {
readonly ARTEMIS_DEFAULT_COLOR = ARTEMIS_DEFAULT_COLOR;
@Input() course: Course;
course = input.required<Course>();
CachingStrategy = CachingStrategy;
courseColor: string;

ngOnChanges() {
this.courseColor = this.course.color || this.ARTEMIS_DEFAULT_COLOR;
constructor() {
effect(() => {
const courseValue = this.course();
this.courseColor = courseValue?.color || this.ARTEMIS_DEFAULT_COLOR;
});
}
}
9 changes: 7 additions & 2 deletions src/main/webapp/app/lti/lti.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ import { LtiCourseCardComponent } from 'app/lti/lti-course-card.component';
const LTI_LAUNCH_ROUTES = [...ltiLaunchState];

@NgModule({
imports: [RouterModule.forChild(LTI_LAUNCH_ROUTES), ArtemisCoreModule, ArtemisSharedModule, FormsModule, ArtemisSharedComponentModule, ArtemisSharedLibsModule],
declarations: [
imports: [
RouterModule.forChild(LTI_LAUNCH_ROUTES),
ArtemisCoreModule,
ArtemisSharedModule,
FormsModule,
ArtemisSharedComponentModule,
ArtemisSharedLibsModule,
Lti13ExerciseLaunchComponent,
Lti13DynamicRegistrationComponent,
Lti13DeepLinkingComponent,
Expand Down
29 changes: 18 additions & 11 deletions src/main/webapp/app/lti/lti13-deep-linking.component.ts
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 { ActivatedRoute, Router } from '@angular/router';
import { CourseManagementService } from 'app/course/manage/course-management.service';
import { Exercise } from 'app/entities/exercise.model';
Expand All @@ -10,12 +10,29 @@ import { Course } from 'app/entities/course.model';
import { AlertService } from 'app/core/util/alert.service';
import { onError } from 'app/shared/util/global.utils';
import { SessionStorageService } from 'ngx-webstorage';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { TranslateDirective } from '../shared/language/translate.directive';
import { ArtemisSharedComponentModule } from '../shared/components/shared-component.module';
import { ArtemisSharedCommonModule } from '../shared/shared-common.module';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { FormsModule } from '@angular/forms';

@Component({
selector: 'jhi-deep-linking',
templateUrl: './lti13-deep-linking.component.html',
standalone: true,
imports: [ArtemisSharedModule, TranslateDirective, ArtemisSharedComponentModule, ArtemisSharedCommonModule, FaIconComponent, FormsModule],
})
export class Lti13DeepLinkingComponent implements OnInit {
route = inject(ActivatedRoute);
private sortService = inject(SortService);
private courseManagementService = inject(CourseManagementService);
private http = inject(HttpClient);
private accountService = inject(AccountService);
private router = inject(Router);
private alertService = inject(AlertService);
private sessionStorageService = inject(SessionStorageService);

courseId: number;
exercises: Exercise[];
selectedExercises?: Set<number> = new Set();
Expand All @@ -29,16 +46,6 @@ export class Lti13DeepLinkingComponent implements OnInit {
faSort = faSort;
faExclamationTriangle = faExclamationTriangle;
faWrench = faWrench;
constructor(
public route: ActivatedRoute,
private sortService: SortService,
private courseManagementService: CourseManagementService,
private http: HttpClient,
private accountService: AccountService,
private router: Router,
private alertService: AlertService,
private sessionStorageService: SessionStorageService,
) {}

/**
* Initializes the component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpClient, HttpParams } from '@angular/common/http';
import { TranslateDirective } from '../shared/language/translate.directive';

@Component({
selector: 'jhi-dynamic-registration',
templateUrl: './lti13-dynamic-registration.component.html',
standalone: true,
imports: [TranslateDirective],
})
export class Lti13DynamicRegistrationComponent implements OnInit {
private route = inject(ActivatedRoute);
private http = inject(HttpClient);

courseId: number;
isRegistering = true;
registeredSuccessfully: boolean;

constructor(
private route: ActivatedRoute,
private http: HttpClient,
) {}

/**
* perform LTI 13 dynamic registration
*/
Expand Down
Loading
Loading