Skip to content

Commit

Permalink
use ned inject and made to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer committed Oct 1, 2024

Verified

This commit was signed with the committer’s verified signature.
abernix Jesse Rosenberger
1 parent 92997cc commit ebcad87
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { faUser } from '@fortawesome/free-solid-svg-icons';
import { ProfileService } from 'app/shared/layouts/profiles/profile.service';
import { PROFILE_LOCALVC } from 'app/app.constants';
import { User } from 'app/core/user/user.model';
import { AccountService } from 'app/core/auth/account.service';
import { tap } from 'rxjs';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { RouterModule } from '@angular/router';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

/**
* UserSettingsContainerComponent serves as the common ground for different settings
*/
@Component({
selector: 'jhi-user-settings',
templateUrl: 'user-settings-container.component.html',
standalone: true,
styleUrls: ['user-settings-container.component.scss'],
imports: [TranslateDirective, RouterModule, FontAwesomeModule],
})
export class UserSettingsContainerComponent implements OnInit {
private readonly profileService = inject(ProfileService);
private readonly accountService = inject(AccountService);

// Icons
faUser = faUser;

currentUser?: User;
localVCEnabled = false;
isAtLeastTutor = false;

constructor(
private profileService: ProfileService,
private accountService: AccountService,
) {}

ngOnInit() {
this.profileService.getProfileInfo().subscribe((profileInfo) => {
this.localVCEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALVC);
@@ -38,7 +41,6 @@ export class UserSettingsContainerComponent implements OnInit {
tap((user: User) => {
this.currentUser = user;
this.authorizeTutor();
console.log(this.currentUser.authorities);
return this.currentUser;
}),
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NgModule } from '@angular/core';
import { UserSettingsContainerComponent } from 'app/shared/user-settings/user-settings-container/user-settings-container.component';
import { AccountInformationComponent } from 'app/shared/user-settings/account-information/account-information.component';
import { NotificationSettingsComponent } from 'app/shared/user-settings/notification-settings/notification-settings.component';
import { ArtemisSharedModule } from 'app/shared/shared.module';
@@ -16,7 +15,6 @@ import { IdeSettingsComponent } from 'app/shared/user-settings/ide-preferences/i
@NgModule({
imports: [RouterModule.forChild(userSettingsState), ArtemisSharedModule, ArtemisSharedComponentModule, ClipboardModule, FormDateTimePickerModule],
declarations: [
UserSettingsContainerComponent,
AccountInformationComponent,
NotificationSettingsComponent,
ScienceSettingsComponent,
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { of } from 'rxjs';
import { Router, RouterModule } from '@angular/router';
import { ArtemisTestModule } from '../../test.module';
import { MockNgbModalService } from '../../helpers/mocks/service/mock-ngb-modal.service';
import { MockTranslateService, TranslatePipeMock } from '../../helpers/mocks/service/mock-translate.service';
import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service';
import { TranslateService } from '@ngx-translate/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { PROFILE_LOCALVC } from 'app/app.constants';
@@ -27,8 +27,7 @@ describe('UserSettingsContainerComponent', () => {
};

await TestBed.configureTestingModule({
imports: [ArtemisTestModule, RouterModule],
declarations: [UserSettingsContainerComponent, TranslatePipeMock],
imports: [UserSettingsContainerComponent, ArtemisTestModule, RouterModule],
providers: [
{ provide: ProfileService, useValue: profileServiceMock },
{ provide: TranslateService, useClass: MockTranslateService },

0 comments on commit ebcad87

Please sign in to comment.