From 5f268cea8a81f952413fef2fee3346c3d4dffa9d Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 9 Sep 2017 13:42:04 +0200 Subject: [PATCH] Add edit profile page --- static/src/app/app.routing.ts | 4 ++ .../app/profile/edit-profile.component.css | 0 .../app/profile/edit-profile.component.html | 71 +++++++++++++++++++ .../src/app/profile/edit-profile.component.ts | 40 +++++++++++ static/src/app/profile/edit-profile.module.ts | 15 ++++ 5 files changed, 130 insertions(+) create mode 100644 static/src/app/profile/edit-profile.component.css create mode 100644 static/src/app/profile/edit-profile.component.html create mode 100644 static/src/app/profile/edit-profile.component.ts create mode 100644 static/src/app/profile/edit-profile.module.ts diff --git a/static/src/app/app.routing.ts b/static/src/app/app.routing.ts index 8c7d093..22cf518 100644 --- a/static/src/app/app.routing.ts +++ b/static/src/app/app.routing.ts @@ -23,6 +23,10 @@ export const appRoutes: Routes = [ path: RouteConfig.loginPath, component: LoginComponent }, + { + path: RouteConfig.editProfilePath, + loadChildren: './profile/edit-profile.module#EditProfileModule' + }, { path: RouteConfig.signUpPath, component: SignupComponent diff --git a/static/src/app/profile/edit-profile.component.css b/static/src/app/profile/edit-profile.component.css new file mode 100644 index 0000000..e69de29 diff --git a/static/src/app/profile/edit-profile.component.html b/static/src/app/profile/edit-profile.component.html new file mode 100644 index 0000000..b2dae9b --- /dev/null +++ b/static/src/app/profile/edit-profile.component.html @@ -0,0 +1,71 @@ +
+ +

Profil editieren

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/static/src/app/profile/edit-profile.component.ts b/static/src/app/profile/edit-profile.component.ts new file mode 100644 index 0000000..71aca3b --- /dev/null +++ b/static/src/app/profile/edit-profile.component.ts @@ -0,0 +1,40 @@ +import {Component} from "@angular/core"; +import {AppUser, Squad} from "../models/model-interfaces"; +import {Observable} from "rxjs/Observable"; +import {AppUserService} from "../services/app-user-service/app-user.service"; +import {SquadService} from "../services/squad-service/squad.service"; +import {LoginService} from "../services/login-service/login-service"; +import {Router} from "@angular/router"; + + +@Component({ + selector: 'edit-profile', + templateUrl: './edit-profile.component.html', + styleUrls: ['./edit-profile.component.css'] +}) +export class EditProfileComponent { + + user = {}; + + showSuccessLabel = false; + + constructor(private appUserService: AppUserService, + private loginService: LoginService, + private router: Router) { + } + + ngOnInit() { + this.user = this.appUserService.getUsers(); + } + + deleteUser(user) { + if (confirm('Bistdu dir sicher dass du deinen Nutzer Account "' + user.username + '" loeschen willst?')) { + this.appUserService.deleteUser(user) + .subscribe((res) => { + this.loginService.logout(); + // TODO: redirect to / + }) + } + } + +} diff --git a/static/src/app/profile/edit-profile.module.ts b/static/src/app/profile/edit-profile.module.ts new file mode 100644 index 0000000..8e51ca9 --- /dev/null +++ b/static/src/app/profile/edit-profile.module.ts @@ -0,0 +1,15 @@ +import {NgModule} from "@angular/core"; +import {SharedModule} from "../shared.module"; +import {AppUserService} from "../services/app-user-service/app-user.service"; +import {CommonModule} from "@angular/common"; +import {RouterModule} from "@angular/router"; +import {EditProfileComponent} from "./edit-profile.component"; +import {AppUserStore} from "../services/stores/app-user.store"; + +@NgModule({ + declarations: [EditProfileComponent], + imports: [CommonModule, SharedModule, RouterModule.forChild([{path: '', component: EditProfileComponent}])], + providers: [AppUserStore, AppUserService] +}) +export class EditProfileModule { +}