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
41d4ff00
Commit
41d4ff00
authored
Nov 14, 2024
by
vtduong0912
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form
parent
8b23d2da
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
285 additions
and
41 deletions
+285
-41
job-manager.service.ts
...management/job/data-access/service/job-manager.service.ts
+8
-4
job-form.component.ts
src/app/+admin/management/job/feature/job-form.component.ts
+100
-7
job-list.component.ts
src/app/+admin/management/job/feature/job-list.component.ts
+174
-20
job.component.ts
src/app/+admin/management/job/feature/job.component.ts
+0
-5
job.component.ts
src/app/+job/feature/job.component.ts
+1
-2
login.component.ts
src/app/+login/feature/login.component.ts
+2
-3
No files found.
src/app/+admin/management/job/data-access/service/job-manager.service.ts
View file @
41d4ff00
...
@@ -18,15 +18,19 @@ export class JobManagerService {
...
@@ -18,15 +18,19 @@ export class JobManagerService {
});
});
}
}
jobsGetOne
(
id
:
string
)
{
return
this
.
_http
.
get
<
ResponseResult
<
JobApi
.
Response
>>
(
'jobs/'
+
id
);
}
jobsPost
(
request
:
JobApi
.
Request
)
{
jobsPost
(
request
:
JobApi
.
Request
)
{
return
this
.
_http
.
post
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs'
,
request
);
return
this
.
_http
.
post
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs'
,
request
);
}
}
jobsPut
(
request
:
JobApi
.
Request
)
{
jobsPut
(
id
:
string
,
request
:
JobApi
.
Request
)
{
return
this
.
_http
.
put
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs
'
,
request
);
return
this
.
_http
.
put
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs
/'
+
id
,
request
);
}
}
jobsDelete
(
id
:
number
)
{
jobsDelete
(
id
:
string
)
{
return
this
.
_http
.
delete
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs
'
);
return
this
.
_http
.
delete
<
ResponseResult
<
JobApi
.
Request
>>
(
'jobs
/'
+
id
);
}
}
}
}
\ No newline at end of file
src/app/+admin/management/job/feature/job-form.component.ts
View file @
41d4ff00
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnInit
,
Output
}
from
'@angular/core'
;
import
{
FormBuilder
,
FormGroup
,
Validators
,
ReactiveFormsModule
}
from
'@angular/forms'
;
import
{
NzButtonModule
}
from
'ng-zorro-antd/button'
;
import
{
NzModalModule
}
from
'ng-zorro-antd/modal'
;
import
{
JobManagerService
}
from
'../data-access/service/job-manager.service'
;
import
{
ResponseResult
}
from
'../../../../shared/data-access/interface/response.type'
;
import
{
JobApi
}
from
'../data-access/model/job-manager.model'
;
import
{
catchError
,
of
,
tap
}
from
'rxjs'
;
@
Component
({
@
Component
({
selector
:
'job-form'
,
selector
:
'job-form'
,
standalone
:
true
,
standalone
:
true
,
imports
:
[
NzButtonModule
,
NzModalModule
,
ReactiveFormsModule
],
template
:
`
template
:
`
<div
[class]="{'tw-hidden': isHidden}
">
<div
class="tw-w-full tw-grid tw-justify-items-end
">
<button nz-button nzType="primary" (click)="isCreate = true">Create new job</button>
</div>
</div>
<nz-modal [(nzVisible)]="isCreate" nzTitle="Create new job" nzCancelText="Cancel" nzOkText="Create" (nzOnCancel)="isCreate = false" (nzOnOk)="isCreate = false; onCreateSubmit()">
<ng-container *nzModalContent>
<form [formGroup]="jobCreatingFormGroup">
<div class="tw-flex tw-flex-col tw-flex-wrap tw-gap-y-1">
<label>Type</label>
<select class="tw-border tw-rounded-lg tw-h-8" formControlName="type">
<option value="Full Time">Full Time</option>
<option value="Part Time">Part Time</option>
</select>
<label>Company</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="company">
<label>Company Url</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="company_url">
<label>Location</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="location">
<label>Tilte</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="title">
<label>Description</label>
<textarea class="tw-border tw-rounded-lg tw-h-20" type="text" formControlName="description"></textarea>
<label>How to Apply</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="how_to_apply">
<label>Company Logo</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="company_logo">
<label>Url</label>
<input class="tw-border tw-rounded-lg tw-h-8" type="text" formControlName="url">
</div>
</form>
</ng-container>
</nz-modal>
`
`
})
})
export
class
JobFormComponent
implements
OnInit
{
export
class
JobFormComponent
implements
OnInit
,
OnDestroy
{
isHidden
:
boolean
=
true
;
constructor
()
{
}
ngOnInit
()
{
}
isCreate
:
boolean
=
false
;
jobCreatingFormGroup
:
FormGroup
;
constructor
(
private
_fb
:
FormBuilder
,
private
_service
:
JobManagerService
)
{
this
.
jobCreatingFormGroup
=
this
.
_fb
.
group
({
type
:
[
'Full Time'
,
Validators
.
required
],
company
:
[
''
,
Validators
.
required
],
company_url
:
[
''
,
Validators
.
required
],
location
:
[
''
,
Validators
.
required
],
title
:
[
''
,
Validators
.
required
],
description
:
[
''
,
Validators
.
required
],
how_to_apply
:
[
''
,
Validators
.
required
],
company_logo
:
[
''
,
Validators
.
required
],
url
:
[
''
,
Validators
.
required
],
});
}
ngOnInit
()
{
}
ngOnDestroy
()
{
}
onCreateSubmit
()
{
const
data
=
this
.
jobCreatingFormGroup
.
value
;
if
(
!
this
.
jobCreatingFormGroup
.
valid
)
{
Object
.
values
(
this
.
jobCreatingFormGroup
.
controls
).
forEach
(
control
=>
{
if
(
control
.
invalid
)
{
control
.
markAsDirty
();
control
.
updateValueAndValidity
({
onlySelf
:
true
});
}
});
return
;
}
this
.
jobCreatingFormGroup
.
markAllAsTouched
();
this
.
_service
.
jobsPost
(
data
)
.
pipe
(
tap
((
response
:
ResponseResult
<
JobApi
.
Request
>
)
=>
{
console
.
log
(
response
);
}),
catchError
((
err
)
=>
{
return
of
(
null
);
})
)
.
subscribe
();
}
onEditSubmit
()
{
}
}
}
\ No newline at end of file
src/app/+admin/management/job/feature/job-list.component.ts
View file @
41d4ff00
This diff is collapsed.
Click to expand it.
src/app/+admin/management/job/feature/job.component.ts
View file @
41d4ff00
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
JobListComponent
}
from
'./job-list.component'
;
import
{
JobListComponent
}
from
'./job-list.component'
;
import
{
NzButtonModule
}
from
'ng-zorro-antd/button'
;
import
{
JobFormComponent
}
from
'./job-form.component'
;
import
{
JobFormComponent
}
from
'./job-form.component'
;
@
Component
({
@
Component
({
...
@@ -9,13 +8,9 @@ import { JobFormComponent } from './job-form.component';
...
@@ -9,13 +8,9 @@ import { JobFormComponent } from './job-form.component';
imports
:
[
imports
:
[
JobListComponent
,
JobListComponent
,
JobFormComponent
,
JobFormComponent
,
NzButtonModule
],
],
template
:
`
template
:
`
<h1 class="tw-text-center tw-text-3xl tw-font-semibold tw-my-3">Jobs</h1>
<h1 class="tw-text-center tw-text-3xl tw-font-semibold tw-my-3">Jobs</h1>
<div class="tw-w-full tw-grid tw-justify-items-end">
<button nz-button nzType="primary">Create new job</button>
</div>
<job-form></job-form>
<job-form></job-form>
<job-list></job-list>
<job-list></job-list>
`
`
...
...
src/app/+job/feature/job.component.ts
View file @
41d4ff00
...
@@ -4,7 +4,7 @@ import { CommonModule, DatePipe, JsonPipe, NgFor } from '@angular/common';
...
@@ -4,7 +4,7 @@ import { CommonModule, DatePipe, JsonPipe, NgFor } from '@angular/common';
import
{
JobService
}
from
'../data-access/service/job.service'
import
{
JobService
}
from
'../data-access/service/job.service'
import
{
ResponseResult
,
Rows
}
from
'../../shared/data-access/interface/response.type'
;
import
{
ResponseResult
,
Rows
}
from
'../../shared/data-access/interface/response.type'
;
import
{
Jobs
}
from
'../data-access/model/job.model'
;
import
{
Jobs
}
from
'../data-access/model/job.model'
;
import
{
catchError
,
map
,
of
,
tap
}
from
'rxjs'
;
import
{
catchError
,
of
,
tap
}
from
'rxjs'
;
import
{
NzCardModule
}
from
'ng-zorro-antd/card'
;
import
{
NzCardModule
}
from
'ng-zorro-antd/card'
;
import
{
NzAvatarModule
}
from
'ng-zorro-antd/avatar'
;
import
{
NzAvatarModule
}
from
'ng-zorro-antd/avatar'
;
import
{
NzPaginationModule
}
from
'ng-zorro-antd/pagination'
;
import
{
NzPaginationModule
}
from
'ng-zorro-antd/pagination'
;
...
@@ -17,7 +17,6 @@ import { NzPaginationModule } from 'ng-zorro-antd/pagination';
...
@@ -17,7 +17,6 @@ import { NzPaginationModule } from 'ng-zorro-antd/pagination';
imports
:
[
imports
:
[
CommonModule
,
CommonModule
,
NgFor
,
NgFor
,
JsonPipe
,
NzCardModule
,
NzCardModule
,
NzAvatarModule
,
NzAvatarModule
,
NzPaginationModule
,
NzPaginationModule
,
...
...
src/app/+login/feature/login.component.ts
View file @
41d4ff00
...
@@ -11,7 +11,7 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';
...
@@ -11,7 +11,7 @@ import { NzAlertModule } from 'ng-zorro-antd/alert';
import
{
FormBuilder
,
FormGroup
,
ReactiveFormsModule
,
Validators
}
from
'@angular/forms'
;
import
{
FormBuilder
,
FormGroup
,
ReactiveFormsModule
,
Validators
}
from
'@angular/forms'
;
import
{
AuthService
}
from
'../data-access/service/auth.service'
;
import
{
AuthService
}
from
'../data-access/service/auth.service'
;
import
{
validateUsername
}
from
'../../shared/utils/form-validator/username.validator'
;
import
{
validateUsername
}
from
'../../shared/utils/form-validator/username.validator'
;
import
{
catchError
,
map
,
of
,
tap
}
from
'rxjs'
;
import
{
catchError
,
of
,
tap
}
from
'rxjs'
;
import
{
ResponseResult
}
from
'../../shared/data-access/interface/response.type'
;
import
{
ResponseResult
}
from
'../../shared/data-access/interface/response.type'
;
import
{
Login
}
from
'../data-access/model/login.model'
;
import
{
Login
}
from
'../data-access/model/login.model'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Router
}
from
'@angular/router'
;
...
@@ -31,7 +31,6 @@ import { Router } from '@angular/router';
...
@@ -31,7 +31,6 @@ import { Router } from '@angular/router';
NzAlertModule
,
NzAlertModule
,
NzFormModule
,
NzFormModule
,
ReactiveFormsModule
,
ReactiveFormsModule
,
JsonPipe
],
],
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
})
})
...
@@ -43,7 +42,6 @@ export class LoginComponent implements OnInit {
...
@@ -43,7 +42,6 @@ export class LoginComponent implements OnInit {
constructor
(
constructor
(
private
_fb
:
FormBuilder
,
private
_fb
:
FormBuilder
,
private
_authService
:
AuthService
,
private
_authService
:
AuthService
,
private
_changeDetectorRef
:
ChangeDetectorRef
,
private
_router
:
Router
private
_router
:
Router
)
{
)
{
this
.
signInFormGroup
=
this
.
_fb
.
group
({
this
.
signInFormGroup
=
this
.
_fb
.
group
({
...
@@ -82,6 +80,7 @@ export class LoginComponent implements OnInit {
...
@@ -82,6 +80,7 @@ export class LoginComponent implements OnInit {
}
}
onSuccess
(
response
:
ResponseResult
<
Login
.
Response
>
)
{
onSuccess
(
response
:
ResponseResult
<
Login
.
Response
>
)
{
console
.
log
(
response
.
responseData
?.
token
);
localStorage
.
setItem
(
"token"
,
response
.
responseData
?.
token
??
""
);
localStorage
.
setItem
(
"token"
,
response
.
responseData
?.
token
??
""
);
localStorage
.
setItem
(
"role"
,
response
.
responseData
?.
role
??
""
);
localStorage
.
setItem
(
"role"
,
response
.
responseData
?.
role
??
""
);
this
.
_router
.
navigate
([
'/home'
]);
this
.
_router
.
navigate
([
'/home'
]);
...
...
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