-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed94963
commit 549910c
Showing
7 changed files
with
310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
CLIENT/CLIENT.FileSharing/src/app/identity/register/register.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<div class="panel"> | ||
<!-- <img class="fs-logo" src="" alt="File Sharing Logo" /> --> | ||
<div class="header"> | ||
<mat-icon>app_registration</mat-icon> | ||
<span class="title">Register</span> | ||
</div> | ||
|
||
<form #registerForm="ngForm" (ngSubmit)="onSubmit(registerForm, $event)"> | ||
<mat-form-field> | ||
<mat-label>Email</mat-label> | ||
<input | ||
matInput | ||
type="email" | ||
name="username" | ||
[formControl]="emailFormControl" | ||
required | ||
#emailInput | ||
minlength="3" | ||
maxlength="50" | ||
[errorStateMatcher]="matcher" | ||
/> | ||
@if ( | ||
emailFormControl.hasError("email") && | ||
!emailFormControl.hasError("required") | ||
) { | ||
<mat-error>Please enter a valid email address</mat-error> | ||
} | ||
@if (emailFormControl.hasError("required")) { | ||
<mat-error>Email is <strong>required</strong></mat-error> | ||
} | ||
</mat-form-field> | ||
<mat-form-field id="password-field"> | ||
<mat-label>Password</mat-label> | ||
<input | ||
matInput | ||
type="password" | ||
name="password" | ||
[(ngModel)]="password" | ||
required | ||
#passwordInput="ngModel" | ||
minlength="6" | ||
maxlength="50" | ||
/> | ||
@if (passwordInput.invalid && passwordInput.touched) { | ||
<mat-error>Password is required.</mat-error> | ||
} | ||
</mat-form-field> | ||
<mat-form-field id="confirm-password-field"> | ||
<mat-label>Confirm Password</mat-label> | ||
<input | ||
matInput | ||
type="password" | ||
name="password" | ||
[(ngModel)]="confirmPassword" | ||
required | ||
#confirmPasswordInput="ngModel" | ||
minlength="6" | ||
maxlength="50" | ||
/> | ||
@if (passwordInput.invalid && passwordInput.touched) { | ||
<mat-error>Confirm password is required.</mat-error> | ||
} | ||
</mat-form-field> | ||
<div class="selections-container"> | ||
<mat-checkbox | ||
class="keep-signed-in" | ||
[(ngModel)]="keepSignedIn" | ||
name="keepSignedIn" | ||
labelPosition="after" | ||
>Keep me signed in</mat-checkbox | ||
> | ||
<mat-form-field class="selection"> | ||
<mat-label>Language</mat-label> | ||
<mat-select [(ngModel)]="selectedLanguage" name="selectedLanguage"> | ||
@for (language of languages; track language) { | ||
<mat-option [value]="language">{{ language.label }}</mat-option> | ||
} | ||
</mat-select> | ||
</mat-form-field> | ||
</div> | ||
@if (registerErrorMessage) { | ||
<span class="error-message ng-touched ng-invalid">{{ | ||
registerErrorMessage | ||
}}</span> | ||
} | ||
<div class="buttons"> | ||
<button | ||
id="register-button" | ||
mat-flat-button | ||
color="primary" | ||
type="submit" | ||
[disabled]="registerForm.invalid" | ||
> | ||
Sign up | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div id="register-section"> | ||
<span>Already have an account?</span> | ||
<button mat-button color="primary" (click)="onGotoLogin()">Login here</button> | ||
</div> |
84 changes: 84 additions & 0 deletions
84
CLIENT/CLIENT.FileSharing/src/app/identity/register/register.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
$panel-width: 390px; | ||
|
||
:host { | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
background: #f6f6f6; | ||
} | ||
|
||
.panel { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 44px 56px 48px; | ||
border-radius: 4px; | ||
box-shadow: 0 2px 4px #727685; | ||
width: $panel-width; | ||
margin: 32px 16px 8px; | ||
|
||
.header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
.title { | ||
margin-left: 8px; | ||
font-size: 24px; | ||
line-height: 24px; | ||
} | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
margin-top: 44px; | ||
} | ||
|
||
// #password-field { | ||
// margin-top: 4px; | ||
// } | ||
|
||
.selections-container { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-top: 16px; | ||
|
||
.selection { | ||
width: 50%; | ||
} | ||
|
||
.keep-signed-in { | ||
padding-bottom: 20px; | ||
} | ||
} | ||
|
||
.error-message { | ||
text-align: center; | ||
margin-top: 4px; | ||
} | ||
|
||
.buttons { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-top: 24px; | ||
|
||
#register-button { | ||
padding-inline: 48px; | ||
margin-left: auto; | ||
} | ||
} | ||
} | ||
|
||
#login-section { | ||
width: $panel-width; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 8px; | ||
} |
28 changes: 28 additions & 0 deletions
28
CLIENT/CLIENT.FileSharing/src/app/identity/register/register.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DebugElement } from '@angular/core'; | ||
|
||
import { RegisterComponent } from './register.component'; | ||
|
||
describe('RegisterComponent', () => { | ||
let component: RegisterComponent; | ||
let fixture: ComponentFixture<RegisterComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ RegisterComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(RegisterComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
84 changes: 84 additions & 0 deletions
84
CLIENT/CLIENT.FileSharing/src/app/identity/register/register.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { | ||
FormControl, | ||
FormGroupDirective, | ||
FormsModule, | ||
NgForm, | ||
ReactiveFormsModule, | ||
Validators, | ||
} from '@angular/forms'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
import { ErrorStateMatcher } from '@angular/material/core'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { MatSelectModule } from '@angular/material/select'; | ||
import { Router } from '@angular/router'; | ||
|
||
/** Error when invalid control is dirty, touched, or submitted. */ | ||
export class MyErrorStateMatcher implements ErrorStateMatcher { | ||
isErrorState( | ||
control: FormControl | null, | ||
form: FormGroupDirective | NgForm | null, | ||
): boolean { | ||
const isSubmitted = form && form.submitted; | ||
return !!( | ||
control && | ||
control.invalid && | ||
(control.dirty || control.touched || isSubmitted) | ||
); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'fs-register', | ||
templateUrl: './register.component.html', | ||
styleUrl: './register.component.scss', | ||
standalone: true, | ||
imports: [ | ||
MatIconModule, | ||
MatFormFieldModule, | ||
MatSelectModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
MatInputModule, | ||
MatButtonModule, | ||
MatCheckboxModule, | ||
], | ||
}) | ||
export class RegisterComponent implements OnInit { | ||
public registerErrorMessage?: string; | ||
public showLanguageSelection = true; | ||
|
||
public languages = [ | ||
{ value: 'en', label: 'English' }, | ||
{ value: 'de', label: 'Deutsch' }, | ||
{ value: 'fr', label: 'Français' }, | ||
]; | ||
public selectedLanguage = 'en'; | ||
|
||
protected email?: string; | ||
protected password?: string; | ||
protected confirmPassword?: string; | ||
public keepSignedIn: boolean = false; | ||
|
||
emailFormControl = new FormControl('', [ | ||
Validators.required, | ||
Validators.email, | ||
]); | ||
|
||
matcher = new MyErrorStateMatcher(); | ||
|
||
constructor(private router: Router) {} | ||
|
||
ngOnInit() {} | ||
|
||
onGotoLogin() { | ||
this.router.navigateByUrl('/auth'); | ||
} | ||
|
||
onSubmit(form: NgForm, event: Event) { | ||
event.preventDefault(); | ||
} | ||
} |