Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Meu-Template-Angular-CSR
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Trần Anh Phú
Meu-Template-Angular-CSR
Commits
d382ce2b
Commit
d382ce2b
authored
Dec 04, 2024
by
tinhbe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
945c4ad3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
38 deletions
+55
-38
Job.component.ts
src/app/+admin/Management/Job/Job.component.ts
+29
-26
JobService.service.ts
src/app/+admin/data-access/services/JobService.service.ts
+16
-11
login.component.html
src/app/+login/feature/login.component.html
+1
-1
login.component.ts
src/app/+login/feature/login.component.ts
+9
-0
No files found.
src/app/+admin/Management/Job/Job.component.ts
View file @
d382ce2b
...
...
@@ -34,7 +34,7 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
//#endregion
export
class
JobComponent
implements
OnInit
{
//#region Variable
//#region Variable
selectedJob
?:
JobModel
;
listOfJob
:
JobModel
[]
=
[];
loading
=
true
;
...
...
@@ -52,40 +52,41 @@ export class JobComponent implements OnInit {
title
:
this
.
fb
.
control
(
''
,
[
Validators
.
required
]),
description
:
this
.
fb
.
control
(
''
,
[
Validators
.
required
]),
});
//#endregion
//#region LoadData
constructor
(
private
fb
:
FormBuilder
,
private
jobService
:
JobService
,
private
modal
:
NzModalService
)
{
}
//#endregion
//#region LoadData
constructor
(
private
fb
:
FormBuilder
,
private
jobService
:
JobService
,
private
modal
:
NzModalService
)
{
}
loadDataFromServer
():
void
{
console
.
log
(
"hello"
);
this
.
loading
=
true
;
this
.
jobService
.
jobsGet
().
pipe
(
tap
((
res
)
=>
{
this
.
listOfJob
=
res
.
responseData
.
items
;
console
.
log
(
res
);
if
(
res
.
responseData
)
this
.
listOfJob
=
res
.
responseData
.
rows
;
}),
catchError
((
err
)
=>
{
console
.
log
(
err
)
;
this
.
listOfJob
=
[]
;
return
of
(
null
);
}),
finalize
(()
=>
(
this
.
loading
=
false
))
).
subscribe
();
}
ngOnInit
():
void
{
this
.
loadDataFromServer
();
}
//#endregion
//#endregion
//#region Handler
resetForm
()
{
//#region Handler
resetForm
()
{
this
.
validateJobForm
.
reset
();
this
.
selectedJob
=
{}
as
JobModel
;
}
EnableForm
()
{
EnableForm
()
{
this
.
validateJobForm
.
enable
();
}
DisableForm
()
{
DisableForm
()
{
this
.
validateJobForm
.
disable
();
}
onOk
():
void
{
...
...
@@ -113,8 +114,7 @@ export class JobComponent implements OnInit {
return
of
(
null
);
})
).
subscribe
();
}
else
if
(
this
.
isOnAdd
&&
this
.
selectedJob
)
{
}
else
if
(
this
.
isOnAdd
&&
this
.
selectedJob
)
{
const
newJob
:
JobModel
=
{
id
:
this
.
selectedJob
.
id
,
type
:
this
.
validateJobForm
.
value
.
type
??
undefined
,
...
...
@@ -146,10 +146,10 @@ export class JobComponent implements OnInit {
this
.
isOpenModal
=
false
;
this
.
isOnEdit
=
false
;
}
//#endregion
//#endregion
//#region Action
//#region Action
JobDetail
(
id
:
string
)
{
this
.
DisableForm
();
this
.
isOnEdit
=
false
;
...
...
@@ -157,13 +157,16 @@ export class JobComponent implements OnInit {
this
.
isOnAdd
=
false
;
this
.
jobService
.
getJob
(
id
).
pipe
(
tap
((
res
)
=>
{
this
.
selectedJob
=
res
.
responseData
;
console
.
log
(
res
);
this
.
selectedJob
=
res
.
responseData
as
JobModel
;
}),
catchError
((
err
)
=>
{
console
.
log
(
err
);
return
of
(
null
);
}),
finalize
(()
=>
this
.
loading
=
false
)
finalize
(()
=>
(
this
.
loadDataFromServer
(),
this
.
loading
=
false
))
).
subscribe
();
}
onDelete
(
id
:
string
)
{
...
...
@@ -188,14 +191,14 @@ export class JobComponent implements OnInit {
this
.
isOnAdd
=
false
;
this
.
selectedJob
=
data
;
}
addJob
(){
addJob
()
{
this
.
EnableForm
();
this
.
resetForm
();
this
.
isOpenModal
=
true
;
this
.
isOnEdit
=
false
;
this
.
isOnAdd
=
true
;
}
showDeleteConfirm
(
id
:
string
):
void
{
showDeleteConfirm
(
id
:
string
):
void
{
this
.
modal
.
confirm
({
nzTitle
:
'Bạn có chắc rằng xóa công việc này không?'
,
nzOkText
:
'Xóa'
,
...
...
@@ -205,5 +208,5 @@ export class JobComponent implements OnInit {
nzCancelText
:
'trở về'
,
});
}
//#endregion
//#endregion
}
src/app/+admin/data-access/services/JobService.service.ts
View file @
d382ce2b
...
...
@@ -3,6 +3,7 @@ import { HttpClient, HttpHeaders, HttpParams, HttpRequest } from '@angular/commo
import
{
Observable
}
from
'rxjs'
;
import
{
environment
}
from
'../../../../environments/environment.development'
;
import
{
JobModel
}
from
'../model/jobModel.model'
;
import
{
ResponseResult
,
Rows
}
from
'../../../shared/data-access/interface/response.type'
;
@
Injectable
({
...
...
@@ -13,37 +14,41 @@ export class JobService {
apiUrlById
=
environment
.
API_DOMAIN
+
'/jobById'
;
constructor
(
private
http
:
HttpClient
)
{}
jobsGet
():
Observable
<
any
>
{
// jobsGet(): Observable<ResponseResult<JobModel[]>> {
// return this.http.get<ResponseResult<JobModel[]>>(this.apiUrl);
// }
jobsGet
():
Observable
<
ResponseResult
<
Rows
<
JobModel
>>>
{
const
params
=
new
HttpParams
()
return
this
.
http
.
get
<
any
>
(
this
.
apiUrl
,
{
params
}
);
return
this
.
http
.
get
<
ResponseResult
<
Rows
<
JobModel
>>>
(
this
.
apiUrl
);
}
addingNewJob
(
data
:
JobModel
):
Observable
<
any
>
{
addingNewJob
(
data
:
JobModel
):
Observable
<
ResponseResult
<
JobModel
>>
{
const
headers
=
new
HttpHeaders
()
.
set
(
'Content-Type'
,
'application/json'
)
.
set
(
'
a
uthorization'
,
`Bearer
${
localStorage
.
getItem
(
'token'
)}
`
);
return
this
.
http
.
post
<
any
>
(
this
.
apiUrl
,
data
,
{
headers
});
.
set
(
'
A
uthorization'
,
`Bearer
${
localStorage
.
getItem
(
'token'
)}
`
);
return
this
.
http
.
post
<
ResponseResult
<
JobModel
>
>
(
this
.
apiUrl
,
data
,
{
headers
});
}
deleteJob
(
id
:
string
):
Observable
<
any
>
{
deleteJob
(
id
:
string
):
Observable
<
ResponseResult
<
JobModel
>
>
{
const
headers
=
new
HttpHeaders
()
.
set
(
'Content-Type'
,
'application/json'
)
.
set
(
'Authorization'
,
`Bearer
${
localStorage
.
getItem
(
'token'
)}
`
);
const
url
=
`
${
this
.
apiUrl
}
/
${
id
}
`
;
return
this
.
http
.
delete
<
any
>
(
url
,
{
headers
});
return
this
.
http
.
delete
<
ResponseResult
<
JobModel
>
>
(
url
,
{
headers
});
}
editJob
(
data
:
JobModel
):
Observable
<
any
>
{
editJob
(
data
:
JobModel
):
Observable
<
ResponseResult
<
JobModel
>
>
{
const
headers
=
new
HttpHeaders
()
.
set
(
'Content-Type'
,
'application/json'
)
.
set
(
'Authorization'
,
`Bearer
${
localStorage
.
getItem
(
'token'
)}
`
);
const
url
=
`
${
this
.
apiUrl
}
/
${
data
.
id
}
`
;
return
this
.
http
.
put
<
any
>
(
url
,
data
,
{
headers
});
return
this
.
http
.
put
<
ResponseResult
<
JobModel
>
>
(
url
,
data
,
{
headers
});
}
getJob
(
id
:
string
):
Observable
<
any
>
{
getJob
(
id
:
string
):
Observable
<
ResponseResult
<
JobModel
>
>
{
const
headers
=
new
HttpHeaders
()
.
set
(
'Content-Type'
,
'application/json'
)
.
set
(
'Authorization'
,
`Bearer
${
localStorage
.
getItem
(
'token'
)}
`
);
const
url
=
`
${
this
.
apiUrlById
}
/
${
id
}
`
;
console
.
log
(
id
,
url
);
return
this
.
http
.
get
<
any
>
(
url
,
{
headers
});
return
this
.
http
.
get
<
ResponseResult
<
JobModel
>
>
(
url
,
{
headers
});
}
}
src/app/+login/feature/login.component.html
View file @
d382ce2b
...
...
@@ -11,7 +11,7 @@
<nz-form-item>
<nz-form-control
nzErrorTip=
"Please input your Password!"
>
<nz-input-group
nzPrefixIcon=
"lock"
>
<input
type=
"password"
nz-input
formControlName=
"password"
placeholder=
"Password"
/>
<input
type=
"password"
nz-input
formControlName=
"password"
placeholder=
"Password"
minlength=
"6"
/>
</nz-input-group>
</nz-form-control>
</nz-form-item>
...
...
src/app/+login/feature/login.component.ts
View file @
d382ce2b
...
...
@@ -13,6 +13,7 @@ import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators }
import
{
catchError
,
finalize
,
Observable
,
of
,
tap
}
from
'rxjs'
;
import
{
response
}
from
'express'
;
import
{
AuthService
}
from
'../data-access/Services/Auth.Service'
;
import
{
userNameRegex
}
from
'../../shared/data-access/const/user-name-regex.const'
;
@
Component
({
selector
:
'meu-login'
,
standalone
:
true
,
...
...
@@ -44,11 +45,19 @@ export class LoginComponent implements OnInit {
});
}
ngOnInit
()
{}
validateUserName
(
userName
:
string
):
boolean
{
const
regex
=
new
RegExp
(
userNameRegex
);
return
regex
.
test
(
userName
);
}
onSubmit
()
{
if
(
!
this
.
loginForm
.
valid
)
{
this
.
MgsError
=
"Vui lòng nhập thông tin đăng nhập"
;
return
;
}
if
(
!
this
.
validateUserName
(
this
.
loginForm
.
value
.
userName
))
{
this
.
MgsError
=
"tài khoản không được thêm các kí tự đặc biệt"
;
return
;
}
this
.
authService
.
login
(
this
.
loginForm
.
value
.
userName
,
this
.
loginForm
.
value
.
password
).
pipe
(
catchError
((
err
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment