From 71e890a94b9f04f096127fade0508d2da1261de9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 8 Apr 2024 14:08:29 +0200 Subject: [PATCH] profile page wip --- matsen-tool/src/app/app-routing.module.ts | 22 ++++++--- matsen-tool/src/app/app.module.ts | 4 +- .../two-column/two-column.component.html | 7 +++ .../src/app/profile/profile.component.html | 13 ++++++ .../src/app/profile/profile.component.scss | 0 .../src/app/profile/profile.component.spec.ts | 23 ++++++++++ .../src/app/profile/profile.component.ts | 46 +++++++++++++++++++ matsen-tool/src/assets/i18n/de.json | 1 + 8 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 matsen-tool/src/app/profile/profile.component.html create mode 100644 matsen-tool/src/app/profile/profile.component.scss create mode 100644 matsen-tool/src/app/profile/profile.component.spec.ts create mode 100644 matsen-tool/src/app/profile/profile.component.ts diff --git a/matsen-tool/src/app/app-routing.module.ts b/matsen-tool/src/app/app-routing.module.ts index 41725cc..8b20657 100644 --- a/matsen-tool/src/app/app-routing.module.ts +++ b/matsen-tool/src/app/app-routing.module.ts @@ -14,6 +14,7 @@ import {ContactsDetailComponent} from "@app/contacts/contacts-detail/contacts-de import {TasksComponent} from "@app/tasks/tasks.component"; import {SalesComponent} from "@app/sales/sales.component"; import {SalesDetailComponent} from "@app/sales/sales-detail/sales-detail.component"; +import {ProfileComponent} from "@app/profile/profile.component"; const accountModule = () => import('./account/account.module').then(x => x.AccountModule); const usersModule = () => import('./users/users.module').then(x => x.UsersModule); @@ -63,8 +64,8 @@ const routes: Routes = [ component: TwoColumnComponent, canActivate: [AuthGuard], children: [ - {path: '', component: ProductsComponent, data: {dataType: 'product'}}, - {path: ':id', component: ProductsDetailComponent, data: {dataType: 'product-detail'}}, + {path: '', component: ProductsComponent}, + {path: ':id', component: ProductsDetailComponent}, ] }, { @@ -72,7 +73,7 @@ const routes: Routes = [ component: TwoColumnComponent, canActivate: [AuthGuard], children: [ - {path: '', component: TasksComponent, data: {dataType: 'task'}}, + {path: '', component: TasksComponent}, ] }, { @@ -80,7 +81,7 @@ const routes: Routes = [ component: TwoColumnComponent, canActivate: [AuthGuard], children: [ - {path: '', component: DocumentsComponent, data: {dataType: 'document'}}, + {path: '', component: DocumentsComponent}, ] }, { @@ -88,11 +89,18 @@ const routes: Routes = [ component: TwoColumnComponent, canActivate: [AuthGuard], children: [ - {path: '', component: SalesComponent, data: {dataType: 'sales'}}, - {path: ':id', component: SalesDetailComponent, data: {dataType: 'sales-detail'}}, + {path: '', component: SalesComponent}, + {path: ':id', component: SalesDetailComponent}, + ] + }, + { + path: 'profile', + component: TwoColumnComponent, + canActivate: [AuthGuard], + children: [ + {path: '', component: ProfileComponent}, ] }, - // otherwise redirect to home {path: '**', redirectTo: ''} ]; diff --git a/matsen-tool/src/app/app.module.ts b/matsen-tool/src/app/app.module.ts index 89b1a63..1301f15 100644 --- a/matsen-tool/src/app/app.module.ts +++ b/matsen-tool/src/app/app.module.ts @@ -47,6 +47,7 @@ import { SalesComponent } from './sales/sales.component'; import { SalesDetailComponent } from './sales/sales-detail/sales-detail.component'; import { NewSaleComponent } from './sales/new-sale/new-sale.component'; import { ToggleComponent } from './_components/toggle/toggle.component'; +import { ProfileComponent } from './profile/profile.component'; export function apiConfigFactory(): Configuration { const params: ConfigurationParameters = { @@ -114,7 +115,8 @@ export function HttpLoaderFactory(http: HttpClient) { SalesComponent, SalesDetailComponent, NewSaleComponent, - ToggleComponent + ToggleComponent, + ProfileComponent ], providers: [ {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, diff --git a/matsen-tool/src/app/layout/two-column/two-column.component.html b/matsen-tool/src/app/layout/two-column/two-column.component.html index d4463d1..671342e 100644 --- a/matsen-tool/src/app/layout/two-column/two-column.component.html +++ b/matsen-tool/src/app/layout/two-column/two-column.component.html @@ -50,6 +50,13 @@ +
diff --git a/matsen-tool/src/app/profile/profile.component.html b/matsen-tool/src/app/profile/profile.component.html new file mode 100644 index 0000000..f9f09c5 --- /dev/null +++ b/matsen-tool/src/app/profile/profile.component.html @@ -0,0 +1,13 @@ +
+
+
+
+

{{ user.firstName }} {{ user.lastName }}

+
+
Email:
+
{{ user.email }}
+
+
+
+
+
diff --git a/matsen-tool/src/app/profile/profile.component.scss b/matsen-tool/src/app/profile/profile.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/matsen-tool/src/app/profile/profile.component.spec.ts b/matsen-tool/src/app/profile/profile.component.spec.ts new file mode 100644 index 0000000..7d6e545 --- /dev/null +++ b/matsen-tool/src/app/profile/profile.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfileComponent } from './profile.component'; + +describe('ProfileComponent', () => { + let component: ProfileComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ProfileComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ProfileComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/matsen-tool/src/app/profile/profile.component.ts b/matsen-tool/src/app/profile/profile.component.ts new file mode 100644 index 0000000..c092e50 --- /dev/null +++ b/matsen-tool/src/app/profile/profile.component.ts @@ -0,0 +1,46 @@ +import {AfterViewInit, Component, OnInit} from '@angular/core'; +import {User} from "@app/_models"; +import {Router} from "@angular/router"; +import {AccountService} from "@app/_services"; +import {Subscription} from "rxjs"; +import {PartnerJsonld, UserJsonld, UserService} from "@app/core/api/v1"; +import {ApiConverter} from "@app/_helpers/api.converter"; + +@Component({ + selector: 'app-profile', + templateUrl: './profile.component.html', + styleUrl: './profile.component.scss' +}) +export class ProfileComponent implements OnInit { + + protected userSub: Subscription; + protected user: UserJsonld; + + constructor( + private router: Router, + private accountService: AccountService, + private userService: UserService, + protected apiConverter: ApiConverter + ) { + this.userSub = new Subscription(); + this.user = {} as UserJsonld; + } + + ngOnInit() { + this.getUserData(); + } + + getUserData() { + const user = this.accountService.userValue; + if (user?.id !== null && user?.id !== undefined) { + this.userSub = this.userService.usersIdGet( + this.apiConverter.extractId(user.id) + ).subscribe( + data => { + this.user = data; + } + ); + } + + } +} diff --git a/matsen-tool/src/assets/i18n/de.json b/matsen-tool/src/assets/i18n/de.json index 9ec75d3..af3b6e5 100644 --- a/matsen-tool/src/assets/i18n/de.json +++ b/matsen-tool/src/assets/i18n/de.json @@ -20,6 +20,7 @@ "products": "Produkte", "documents": "Dokumente", "sales": "Verkäufe", + "profile": "Profil", "tasks": "Aufgaben", "contacts": "Kontakte", "posts": "Notizen",