Add edit profile page

feature/user-self-management
Florian Hartwich 2017-09-09 13:42:04 +02:00
parent 9e632989ee
commit 5f268cea8a
5 changed files with 130 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,71 @@
<div class="overview">
<h2>Profil editieren</h2>
<!--<span *ngIf="showSuccessLabel"-->
<!--class="label label-success label-small"-->
<!--style="margin-left: inherit">-->
<!--Erfolgreich gespeichert-->
<!--</span>-->
<!--<div class="pull-left" style="margin-top:20px;">-->
<!--<div class="table-container" style="width: 75%; min-width: 500px">-->
<!--<table class="table table-hover">-->
<!--<thead>-->
<!--<tr class="table-head">-->
<!--<th class="col-sm-1" style="border-radius: 10px 0 0 0;">Username</th>-->
<!--<th class="col-sm-1">Activated</th>-->
<!--<th class="col-sm-1">Secret</th>-->
<!--<th class="col-sm-1">Fraktion/ Squad</th>-->
<!--<th class="col-sm-1">Permission</th>-->
<!--<th class="col-sm-1 text-center" style="border-radius: 0 10px 0 0;"></th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody *ngFor="let user of users$ | async">-->
<!--<tr class="cell-outline">-->
<!--<td>-->
<!--{{user.username}}-->
<!--</td>-->
<!--<td style="font-weight: bold">-->
<!--<select id="activated" name="activated" class="form-control btn dropdown-toggle"-->
<!--[(ngModel)]="user.activated" (change)="updateAppUser(user)">-->
<!--<option value="true">activated</option>-->
<!--<option value="false">deactivated</option>-->
<!--</select>-->
<!--</td>-->
<!--<td>-->
<!--{{user.secret}}-->
<!--</td>-->
<!--<td>-->
<!--<select class="form-control"-->
<!--name="squad"-->
<!--id="squad"-->
<!--[(ngModel)]="user.squad"-->
<!--[compareWith]="equals"-->
<!--(change)="updateAppUser(user)">-->
<!--<option [value]="0">Ohne Fraktion/ Squad</option>-->
<!--<option *ngFor="let squad of squads" [ngValue]="squad">-->
<!--{{squad.fraction == 'BLUFOR'? 'NATO' : 'CSAT'}}: {{squad.name}}-->
<!--</option>-->
<!--</select>-->
<!--</td>-->
<!--<td>-->
<!--<select id="permission" name="permission" class="form-control btn dropdown-toggle"-->
<!--[(ngModel)]="user.permission" (change)="updateAppUser(user)">-->
<!--<option value="0">User</option>-->
<!--<option value="1">SQL</option>-->
<!--<option value="2">HL</option>-->
<!--<option value="3">MT</option>-->
<!--<option value="4">Admin</option>-->
<!--</select>-->
<!--</td>-->
<!--<td class="text-center">-->
<!--<span class="glyphicon glyphicon-trash trash" title="Löschen" (click)="deleteUser(user)"></span>-->
<!--</td>-->
<!--</tr>-->
<!--</tbody>-->
<!--</table>-->
<!--</div>-->
<!--</div>-->
</div>

View File

@ -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 /
})
}
}
}

View File

@ -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 {
}