Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
THD Navi App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Haris Zilic
THD Navi App
Commits
4bd715d1
Commit
4bd715d1
authored
4 years ago
by
Franz Raumschüssel
Browse files
Options
Downloads
Patches
Plain Diff
login added
parent
8dc1c19a
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Popup
,
!1
Popup
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/login/login.component.html
+22
-1
22 additions, 1 deletion
src/app/login/login.component.html
src/app/login/login.component.spec.ts
+16
-2
16 additions, 2 deletions
src/app/login/login.component.spec.ts
src/app/login/login.component.ts
+22
-2
22 additions, 2 deletions
src/app/login/login.component.ts
with
60 additions
and
5 deletions
src/app/login/login.component.html
+
22
−
1
View file @
4bd715d1
<p>
login works!
</p>
<div>
<h2>
{{'cLoginText'|translate}}
</h2>
<form
[formGroup]=
"loginForm"
(ngSubmit)=
"login()"
>
<p
[ngClass]=
"{ 'has-error': isSubmitted && formControls.email.errors }"
>
<input
type=
"email"
placeholder=
"E-Mail"
formControlName=
"email"
>
</p>
<div
*ngIf=
"isSubmitted && formControls.email.errors"
>
<div
*ngIf=
"formControls.email.errors.required"
>
E-Mail is required
</div>
</div>
<p
[ngClass]=
"{ 'has-error': isSubmitted && formControls.password.errors }"
>
<input
type=
"password"
placeholder=
"Password"
formControlName=
"password"
>
</p>
<div
*ngIf=
"isSubmitted && formControls.password.errors"
>
<div
*ngIf=
"formControls.password.errors.required"
>
Password is required
</div>
</div>
<p>
<button
mat-button
type=
"submit"
color=
"warn"
>
LOGIN
</button>
<!-- <input type="submit" value="Log in">-->
</p>
</form>
</div>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/app/login/login.component.spec.ts
+
16
−
2
View file @
4bd715d1
...
...
@@ -2,15 +2,29 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import
{
LoginComponent
}
from
'
./login.component
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
FormsModule
}
from
'
@angular/forms
'
import
{
ReactiveFormsModule
}
from
'
@angular/forms
'
;
import
{
TranslateModule
,
TranslateService
,
TranslateStore
}
from
"
@ngx-translate/core
"
;
describe
(
'
LoginComponent
'
,
()
=>
{
let
component
:
LoginComponent
;
let
fixture
:
ComponentFixture
<
LoginComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
LoginComponent
]
declarations
:
[
LoginComponent
],
imports
:
[
RouterTestingModule
,
TranslateModule
.
forRoot
(),
ReactiveFormsModule
,
FormsModule
],
//providers: [TranslateService, TranslateStore]
})
.
compileComponents
();
.
compileComponents
();
}));
beforeEach
(()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/app/login/login.component.ts
+
22
−
2
View file @
4bd715d1
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
JwtService
}
from
'
../jwt.service
'
;
@
Component
({
selector
:
'
app-login
'
,
templateUrl
:
'
./login.component.html
'
,
styleUrls
:
[
'
./login.component.css
'
]
styleUrls
:
[
'
./login.component.
s
css
'
]
})
export
class
LoginComponent
implements
OnInit
{
constructor
()
{
}
constructor
(
private
jwtService
:
JwtService
,
private
router
:
Router
,
private
formBuilder
:
FormBuilder
)
{
}
loginForm
:
FormGroup
;
isSubmitted
=
false
;
ngOnInit
():
void
{
this
.
loginForm
=
this
.
formBuilder
.
group
({
email
:
[
''
,
Validators
.
required
],
password
:
[
''
,
Validators
.
required
]
});
}
get
formControls
()
{
return
this
.
loginForm
.
controls
;
}
login
()
{
this
.
isSubmitted
=
true
;
if
(
this
.
loginForm
.
invalid
)
{
return
;
}
this
.
jwtService
.
login
(
this
.
loginForm
.
value
);
this
.
router
.
navigateByUrl
(
'
/admin
'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment