update tslint -> eslint
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
<app-card *ngIf="user$|async as user" heading="Hallo {{user.name}}">
|
||||
<app-card *ngIf="user$ | async as user" heading="Hallo {{ user.name }}">
|
||||
<p>
|
||||
<span *ngIf="getUserRoles(user.role).length===0" class="warn">Es wurden noch keine Berechtigungen zugeteilt, bitte wende Dich an den Administrator!</span>
|
||||
<span>{{transdormUserRoles(user.role)}}</span>
|
||||
<span *ngIf="getUserRoles(user.role).length === 0" class="warn"
|
||||
>Es wurden noch keine Berechtigungen zugeteilt, bitte wende Dich an den
|
||||
Administrator!</span
|
||||
>
|
||||
<span>{{ transdormUserRoles(user.role) }}</span>
|
||||
</p>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>bevorzugte Anzeige der Akkorde</mat-label>
|
||||
<mat-select (ngModelChange)="onChordModeChanged(user.id, $event)" [ngModel]="user.chordMode">
|
||||
<mat-select
|
||||
(ngModelChange)="onChordModeChanged(user.id, $event)"
|
||||
[ngModel]="user.chordMode"
|
||||
>
|
||||
<mat-option [value]="null"></mat-option>
|
||||
<mat-option value="hide">nur den Liedtext anzeigen</mat-option>
|
||||
<mat-option value="onlyFirst">in Strophen die Akkorde nur für die erste anzeigen</mat-option>
|
||||
<mat-option value="onlyFirst"
|
||||
>in Strophen die Akkorde nur für die erste anzeigen
|
||||
</mat-option>
|
||||
<mat-option value="show">alle anzeigen</mat-option>
|
||||
</mat-select>
|
||||
<mat-hint>Das ist nur die Voreinstellung, die Anzeige kann für jedes Lied geändert werden.</mat-hint>
|
||||
<mat-hint
|
||||
>Das ist nur die Voreinstellung, die Anzeige kann für jedes Lied geändert
|
||||
werden.
|
||||
</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
@@ -20,5 +31,4 @@
|
||||
</app-button-row>
|
||||
</app-card>
|
||||
|
||||
|
||||
<app-users *appRole="['admin']"></app-users>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('InfoComponent', () => {
|
||||
let component: InfoComponent;
|
||||
let fixture: ComponentFixture<InfoComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [InfoComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [InfoComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(InfoComponent);
|
||||
@@ -20,6 +21,6 @@ describe('InfoComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,16 +8,15 @@ import {faSignOutAlt} from '@fortawesome/free-solid-svg-icons/faSignOutAlt';
|
||||
@Component({
|
||||
selector: 'app-info',
|
||||
templateUrl: './info.component.html',
|
||||
styleUrls: ['./info.component.less']
|
||||
styleUrls: ['./info.component.less'],
|
||||
})
|
||||
export class InfoComponent implements OnInit {
|
||||
public user$: Observable<User>;
|
||||
public faSignOut = faSignOutAlt;
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
}
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
ngOnInit() {
|
||||
public ngOnInit(): void {
|
||||
this.user$ = this.userService.user$;
|
||||
}
|
||||
|
||||
@@ -27,5 +26,4 @@ export class InfoComponent implements OnInit {
|
||||
|
||||
public getUserRoles = (roles: string): string[] => roles?.split(';') ?? [];
|
||||
public transdormUserRoles = (roles: string): string => this.getUserRoles(roles).join(', ');
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ import {RolePipe} from './role.pipe';
|
||||
describe('RolePipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new RolePipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
void expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
|
||||
@Pipe({
|
||||
name: 'role'
|
||||
name: 'role',
|
||||
})
|
||||
export class RolePipe implements PipeTransform {
|
||||
|
||||
transform(role: string): string {
|
||||
public transform(role: string): string {
|
||||
switch (role) {
|
||||
case 'contributor':
|
||||
return 'Mitarbeiter';
|
||||
@@ -20,8 +18,6 @@ export class RolePipe implements PipeTransform {
|
||||
return 'Lobpreisleiter';
|
||||
case 'presenter':
|
||||
return 'Präsentator';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
<div *ngIf="edit" class="users">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Name</mat-label>
|
||||
<input (change)="onNameChanged(id, $event)" [ngModel]="name" matInput>
|
||||
<input (change)="onNameChanged(id, $event)" [ngModel]="name" matInput/>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Rolle</mat-label>
|
||||
<mat-select (ngModelChange)="onRoleChanged(id, $event)" [ngModel]="roles" multiple>
|
||||
<mat-option *ngFor="let role of ROLE_TYPES" [value]="role">{{role | role}}</mat-option>
|
||||
<mat-select
|
||||
(ngModelChange)="onRoleChanged(id, $event)"
|
||||
[ngModel]="roles"
|
||||
multiple
|
||||
>
|
||||
<mat-option *ngFor="let role of ROLE_TYPES" [value]="role">{{
|
||||
role | role
|
||||
}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<button (click)="edit=false" mat-icon-button>
|
||||
<button (click)="edit = false" mat-icon-button>
|
||||
<fa-icon [icon]="faClose"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div (click)="edit=true" *ngIf="!edit" class="users list-item">
|
||||
<span>{{name}}</span>
|
||||
<span><span *ngFor="let role of roles">{{role|role}}, </span></span>
|
||||
<div (click)="edit = true" *ngIf="!edit" class="users list-item">
|
||||
<span>{{ name }}</span>
|
||||
<span
|
||||
><span *ngFor="let role of roles">{{ role | role }}, </span></span
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('UserComponent', () => {
|
||||
let component: UserComponent;
|
||||
let fixture: ComponentFixture<UserComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [UserComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UserComponent);
|
||||
@@ -20,6 +21,6 @@ describe('UserComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ import {faTimes} from '@fortawesome/free-solid-svg-icons/faTimes';
|
||||
@Component({
|
||||
selector: 'app-user',
|
||||
templateUrl: './user.component.html',
|
||||
styleUrls: ['./user.component.less']
|
||||
styleUrls: ['./user.component.less'],
|
||||
})
|
||||
export class UserComponent {
|
||||
public id: string;
|
||||
@@ -17,10 +17,10 @@ export class UserComponent {
|
||||
public edit = false;
|
||||
public faClose = faTimes;
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
}
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
@Input() set user(value: User) {
|
||||
@Input()
|
||||
public set user(value: User) {
|
||||
this.id = value.id;
|
||||
this.name = value.name;
|
||||
this.roles = this.getRoleArray(value.role);
|
||||
@@ -31,12 +31,12 @@ export class UserComponent {
|
||||
await this.userService.update$(id, {role});
|
||||
}
|
||||
|
||||
public async onNameChanged(id: string, name: any): Promise<void> {
|
||||
await this.userService.update$(id, {name: name.target.value});
|
||||
public async onNameChanged(id: string, name: Event): Promise<void> {
|
||||
const target = name.target as HTMLInputElement;
|
||||
await this.userService.update$(id, {name: target.value});
|
||||
}
|
||||
|
||||
public getRoleArray(role): string[] {
|
||||
public getRoleArray(role: string): string[] {
|
||||
return role ? role.split(';') : [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<app-card heading="registrierte Benutzer">
|
||||
<app-user *ngFor="let user of users$|async" [user]="user"></app-user>
|
||||
<app-user *ngFor="let user of users$ | async" [user]="user"></app-user>
|
||||
</app-card>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('UsersComponent', () => {
|
||||
let component: UsersComponent;
|
||||
let fixture: ComponentFixture<UsersComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UsersComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [UsersComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UsersComponent);
|
||||
@@ -20,6 +21,6 @@ describe('UsersComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import {User} from '../../../../services/user/user';
|
||||
@Component({
|
||||
selector: 'app-users',
|
||||
templateUrl: './users.component.html',
|
||||
styleUrls: ['./users.component.less']
|
||||
styleUrls: ['./users.component.less'],
|
||||
})
|
||||
export class UsersComponent {
|
||||
public users$: Observable<User[]>;
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
public constructor(private userService: UserService) {
|
||||
this.users$ = userService.list$();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ import {AuthMessagePipe} from './auth-message.pipe';
|
||||
describe('AuthMessagePipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new AuthMessagePipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
void expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'authMessage'
|
||||
name: 'authMessage',
|
||||
})
|
||||
export class AuthMessagePipe implements PipeTransform {
|
||||
|
||||
transform(code: string): string {
|
||||
public transform(code: string): string {
|
||||
switch (code) {
|
||||
case 'auth/user-not-found':
|
||||
return 'Benutzer wurde nicht gefunden';
|
||||
case 'auth/wrong-password':
|
||||
return 'Passwort ist falsch';
|
||||
default :
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +1,40 @@
|
||||
<!--<app-card>
|
||||
<div [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Addresse</mat-label>
|
||||
<input (keyup.enter)="onLogin()" formControlName="user" matInput>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Passwort</mat-label>
|
||||
<input (keyup.enter)="onLogin()" formControlName="pass" matInput type="password">
|
||||
</mat-form-field>
|
||||
<app-button-row>
|
||||
<app-button (click)="onLogin()" [icon]="faSignIn">Anmelden</app-button>
|
||||
<app-button [icon]="faNewPassword" routerLink="/user/password">Passwort zurücksetzen</app-button>
|
||||
<app-button [icon]="faNewUser" routerLink="/user/new">neuen Benutzer anlegen</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{errorMessage|authMessage}}</p>
|
||||
</app-button-row>
|
||||
|
||||
</div>
|
||||
|
||||
</app-card>-->
|
||||
|
||||
<div class="frame">
|
||||
<app-logo></app-logo>
|
||||
<div class="login">
|
||||
<div [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Addresse</mat-label>
|
||||
<input (keyup.enter)="onLogin()" formControlName="user" matInput>
|
||||
<input (keyup.enter)="onLogin()" formControlName="user" matInput/>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Passwort</mat-label>
|
||||
<input (keyup.enter)="onLogin()" formControlName="pass" matInput type="password">
|
||||
<input
|
||||
(keyup.enter)="onLogin()"
|
||||
formControlName="pass"
|
||||
matInput
|
||||
type="password"
|
||||
/>
|
||||
</mat-form-field>
|
||||
<p *ngIf="errorMessage" class="error">{{errorMessage|authMessage}}</p>
|
||||
<button (click)="onLogin()" class="btn-login" color="primary" mat-stroked-button>Anmelden</button>
|
||||
<button class="btn-password" mat-stroked-button routerLink="/user/password">Passwort zurücksetzen</button>
|
||||
<button class="btn-user" mat-stroked-button routerLink="/user/new">neuen Benutzer anlegen</button>
|
||||
|
||||
|
||||
<p *ngIf="errorMessage" class="error">{{ errorMessage | authMessage }}</p>
|
||||
<button
|
||||
(click)="onLogin()"
|
||||
class="btn-login"
|
||||
color="primary"
|
||||
mat-stroked-button
|
||||
>
|
||||
Anmelden
|
||||
</button>
|
||||
<button
|
||||
class="btn-password"
|
||||
mat-stroked-button
|
||||
routerLink="/user/password"
|
||||
>
|
||||
Passwort zurücksetzen
|
||||
</button>
|
||||
<button class="btn-user" mat-stroked-button routerLink="/user/new">
|
||||
neuen Benutzer anlegen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('LoginComponent', () => {
|
||||
let component: LoginComponent;
|
||||
let fixture: ComponentFixture<LoginComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [LoginComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [LoginComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoginComponent);
|
||||
@@ -20,6 +21,6 @@ describe('LoginComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,39 +3,37 @@ import {FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {faSignInAlt} from '@fortawesome/free-solid-svg-icons/faSignInAlt';
|
||||
import {faWindowRestore} from '@fortawesome/free-solid-svg-icons/faWindowRestore';
|
||||
import {faUserPlus} from '@fortawesome/free-solid-svg-icons/faUserPlus';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.less']
|
||||
styleUrls: ['./login.component.less'],
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
public form: FormGroup;
|
||||
public errorMessage: string;
|
||||
public faSignIn = faSignInAlt;
|
||||
public faNewPassword = faWindowRestore;
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
constructor(private userService: UserService, private router: Router) {
|
||||
}
|
||||
public constructor(private userService: UserService, private router: Router) {}
|
||||
|
||||
ngOnInit() {
|
||||
public ngOnInit(): void {
|
||||
this.form = new FormGroup({
|
||||
user: new FormControl(null, [Validators.required, Validators.email]),
|
||||
pass: new FormControl(null, [Validators.required]),
|
||||
});
|
||||
}
|
||||
|
||||
public async onLogin() {
|
||||
public async onLogin(): Promise<void> {
|
||||
this.form.updateValueAndValidity();
|
||||
if (this.form.valid) {
|
||||
try {
|
||||
await this.userService.login(this.form.value.user, this.form.value.pass);
|
||||
const value = this.form.value as {user: string; pass: string};
|
||||
await this.userService.login(value.user, value.pass);
|
||||
await this.router.navigateByUrl('/');
|
||||
} catch (ex) {
|
||||
this.errorMessage = ex.code;
|
||||
} catch ({code}) {
|
||||
this.errorMessage = code as string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('LogoutComponent', () => {
|
||||
let component: LogoutComponent;
|
||||
let fixture: ComponentFixture<LogoutComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [LogoutComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [LogoutComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LogoutComponent);
|
||||
@@ -20,6 +21,6 @@ describe('LogoutComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,13 +5,12 @@ import {UserService} from '../../../services/user/user.service';
|
||||
@Component({
|
||||
selector: 'app-logout',
|
||||
templateUrl: './logout.component.html',
|
||||
styleUrls: ['./logout.component.less']
|
||||
styleUrls: ['./logout.component.less'],
|
||||
})
|
||||
export class LogoutComponent implements AfterViewInit {
|
||||
constructor(private userService: UserService, private router: Router) {
|
||||
}
|
||||
public constructor(private userService: UserService, private router: Router) {}
|
||||
|
||||
public async ngAfterViewInit() {
|
||||
public async ngAfterViewInit(): Promise<void> {
|
||||
await this.userService.logout();
|
||||
await this.router.navigateByUrl('/');
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<app-card [formGroup]="form" closeLink="../" heading="neuen Benutzer anlegen">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Name</mat-label>
|
||||
<input formControlName="name" matInput>
|
||||
<input formControlName="name" matInput/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Adresse</mat-label>
|
||||
<input formControlName="email" matInput>
|
||||
<input formControlName="email" matInput/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Passwort</mat-label>
|
||||
<input formControlName="password" matInput type="password">
|
||||
<input formControlName="password" matInput type="password"/>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
<app-button (click)="onCreate()" [icon]="faNewUser">Benutzer anlegen</app-button>
|
||||
<app-button (click)="onCreate()" [icon]="faNewUser"
|
||||
>Benutzer anlegen
|
||||
</app-button>
|
||||
</app-button-row>
|
||||
</app-card>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('NewComponent', () => {
|
||||
let component: NewComponent;
|
||||
let fixture: ComponentFixture<NewComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [NewComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [NewComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NewComponent);
|
||||
@@ -20,6 +21,6 @@ describe('NewComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,16 +6,15 @@ import {faUserPlus} from '@fortawesome/free-solid-svg-icons/faUserPlus';
|
||||
@Component({
|
||||
selector: 'app-new',
|
||||
templateUrl: './new.component.html',
|
||||
styleUrls: ['./new.component.less']
|
||||
styleUrls: ['./new.component.less'],
|
||||
})
|
||||
export class NewComponent implements OnInit {
|
||||
public form: FormGroup;
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
constructor(private fb: FormBuilder, private userService: UserService) {
|
||||
}
|
||||
public constructor(private fb: FormBuilder, private userService: UserService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
public ngOnInit(): void {
|
||||
this.form = this.fb.group({
|
||||
email: new FormControl(null, [Validators.required, Validators.email]),
|
||||
name: new FormControl(null, [Validators.required]),
|
||||
@@ -27,7 +26,12 @@ export class NewComponent implements OnInit {
|
||||
this.form.updateValueAndValidity();
|
||||
if (this.form.valid) {
|
||||
try {
|
||||
await this.userService.createNewUser(this.form.value.email, this.form.value.name, this.form.value.password);
|
||||
const value = this.form.value as {
|
||||
email: string;
|
||||
name: string;
|
||||
password: string;
|
||||
};
|
||||
await this.userService.createNewUser(value.email, value.name, value.password);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<app-card>
|
||||
Eine E-Mail mit dem neuen Passwort wurde gesendet.
|
||||
Darin ist der link enthalten, über den das neue Passwort eingegeben werden kann.
|
||||
Eine E-Mail mit dem neuen Passwort wurde gesendet. Darin ist der link
|
||||
enthalten, über den das neue Passwort eingegeben werden kann.
|
||||
</app-card>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('PasswordSendComponent', () => {
|
||||
let component: PasswordSendComponent;
|
||||
let fixture: ComponentFixture<PasswordSendComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PasswordSendComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [PasswordSendComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordSendComponent);
|
||||
@@ -20,6 +21,6 @@ describe('PasswordSendComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-password-send',
|
||||
templateUrl: './password-send.component.html',
|
||||
styleUrls: ['./password-send.component.less']
|
||||
styleUrls: ['./password-send.component.less'],
|
||||
})
|
||||
export class PasswordSendComponent implements OnInit {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
export class PasswordSendComponent {}
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
<div [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Addresse</mat-label>
|
||||
<input (keyup.enter)="onResetPassword()" formControlName="user" matInput>
|
||||
<input
|
||||
(keyup.enter)="onResetPassword()"
|
||||
formControlName="user"
|
||||
matInput
|
||||
/>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
<app-button (click)="onResetPassword()" [icon]="faNewPassword">neues Passwort anfordern</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{errorMessage|authMessage}}</p>
|
||||
<app-button (click)="onResetPassword()" [icon]="faNewPassword"
|
||||
>neues Passwort anfordern
|
||||
</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{ errorMessage | authMessage }}</p>
|
||||
</app-button-row>
|
||||
|
||||
</div>
|
||||
|
||||
</app-card>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('PasswordComponent', () => {
|
||||
let component: PasswordComponent;
|
||||
let fixture: ComponentFixture<PasswordComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PasswordComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [PasswordComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordComponent);
|
||||
@@ -20,6 +21,6 @@ describe('PasswordComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {AbstractControl, FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {faWindowRestore} from '@fortawesome/free-solid-svg-icons/faWindowRestore';
|
||||
@@ -7,32 +7,33 @@ import {faWindowRestore} from '@fortawesome/free-solid-svg-icons/faWindowRestore
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
styleUrls: ['./password.component.less']
|
||||
styleUrls: ['./password.component.less'],
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
public form: FormGroup;
|
||||
public errorMessage: string;
|
||||
public faNewPassword = faWindowRestore;
|
||||
|
||||
constructor(public userService: UserService, private router: Router) {
|
||||
}
|
||||
public constructor(public userService: UserService, private router: Router) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
const required = (c: AbstractControl) => Validators.required(c);
|
||||
const email = Validators.email;
|
||||
this.form = new FormGroup({
|
||||
user: new FormControl(null, [Validators.required, Validators.email])
|
||||
user: new FormControl(null, [required, email]),
|
||||
});
|
||||
}
|
||||
|
||||
public async onResetPassword() {
|
||||
public async onResetPassword(): Promise<void> {
|
||||
this.form.updateValueAndValidity();
|
||||
if (this.form.valid) {
|
||||
try {
|
||||
await this.userService.changePassword(this.form.value.user);
|
||||
const value = this.form.value as {user: string};
|
||||
await this.userService.changePassword(value.user);
|
||||
await this.router.navigateByUrl('/user/password-send');
|
||||
} catch (ex) {
|
||||
this.errorMessage = ex.code;
|
||||
} catch ({code}) {
|
||||
this.errorMessage = code as string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,44 +8,42 @@ import {PasswordComponent} from './password/password.component';
|
||||
import {PasswordSendComponent} from './password-send/password-send.component';
|
||||
import {NewComponent} from './new/new.component';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'info',
|
||||
pathMatch: 'full'
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
component: LoginComponent
|
||||
component: LoginComponent,
|
||||
},
|
||||
{
|
||||
path: 'logout',
|
||||
component: LogoutComponent
|
||||
component: LogoutComponent,
|
||||
},
|
||||
{
|
||||
path: 'password',
|
||||
component: PasswordComponent
|
||||
component: PasswordComponent,
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: NewComponent
|
||||
component: NewComponent,
|
||||
},
|
||||
{
|
||||
path: 'password-send',
|
||||
component: PasswordSendComponent
|
||||
component: PasswordSendComponent,
|
||||
},
|
||||
{
|
||||
path: 'info',
|
||||
component: InfoComponent,
|
||||
canActivate: [AngularFireAuthGuard],
|
||||
data: {authGuardPipe: () => redirectUnauthorizedTo(['user', 'login'])}
|
||||
data: {authGuardPipe: () => redirectUnauthorizedTo(['user', 'login'])},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class UserRoutingModule {
|
||||
}
|
||||
export class UserRoutingModule {}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {ButtonModule} from '../../widget-modules/components/button/button.module
|
||||
import {LogoModule} from '../../widget-modules/components/logo/logo.module';
|
||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [LoginComponent, AuthMessagePipe, InfoComponent, LogoutComponent, RolePipe, PasswordComponent, PasswordSendComponent, UsersComponent, UserComponent, NewComponent],
|
||||
imports: [
|
||||
@@ -41,9 +40,6 @@ import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||
ButtonModule,
|
||||
LogoModule,
|
||||
FontAwesomeModule,
|
||||
|
||||
|
||||
]
|
||||
],
|
||||
})
|
||||
export class UserModule {
|
||||
}
|
||||
export class UserModule {}
|
||||
|
||||
Reference in New Issue
Block a user