diff options
Diffstat (limited to 'client/src/app/+admin/jobs')
-rw-r--r-- | client/src/app/+admin/jobs/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/job.component.ts | 6 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/job.routes.ts | 35 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/jobs-list/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/jobs-list/jobs-list.component.html | 18 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts | 50 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/shared/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/shared/job.service.ts | 30 |
8 files changed, 142 insertions, 0 deletions
diff --git a/client/src/app/+admin/jobs/index.ts b/client/src/app/+admin/jobs/index.ts new file mode 100644 index 000000000..7b5271956 --- /dev/null +++ b/client/src/app/+admin/jobs/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './' | |||
diff --git a/client/src/app/+admin/jobs/job.component.ts b/client/src/app/+admin/jobs/job.component.ts new file mode 100644 index 000000000..bc80c9a6a --- /dev/null +++ b/client/src/app/+admin/jobs/job.component.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | template: '<router-outlet></router-outlet>' | ||
5 | }) | ||
6 | export class JobsComponent {} | ||
diff --git a/client/src/app/+admin/jobs/job.routes.ts b/client/src/app/+admin/jobs/job.routes.ts new file mode 100644 index 000000000..a7bf2b221 --- /dev/null +++ b/client/src/app/+admin/jobs/job.routes.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | import { Routes } from '@angular/router' | ||
2 | |||
3 | import { UserRightGuard } from '../../core' | ||
4 | import { FollowingAddComponent } from './following-add' | ||
5 | import { UserRight } from '../../../../../shared' | ||
6 | import { FollowingListComponent } from './following-list/following-list.component' | ||
7 | import { JobsComponent } from './job.component' | ||
8 | import { JobsListComponent } from './jobs-list/jobs-list.component' | ||
9 | |||
10 | export const JobsRoutes: Routes = [ | ||
11 | { | ||
12 | path: 'jobs', | ||
13 | component: JobsComponent, | ||
14 | canActivate: [ UserRightGuard ], | ||
15 | data: { | ||
16 | userRight: UserRight.MANAGE_JOBS | ||
17 | }, | ||
18 | children: [ | ||
19 | { | ||
20 | path: '', | ||
21 | redirectTo: 'list', | ||
22 | pathMatch: 'full' | ||
23 | }, | ||
24 | { | ||
25 | path: 'list', | ||
26 | component: JobsListComponent, | ||
27 | data: { | ||
28 | meta: { | ||
29 | title: 'Jobs list' | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | ] | ||
34 | } | ||
35 | ] | ||
diff --git a/client/src/app/+admin/jobs/jobs-list/index.ts b/client/src/app/+admin/jobs/jobs-list/index.ts new file mode 100644 index 000000000..cf590a6f8 --- /dev/null +++ b/client/src/app/+admin/jobs/jobs-list/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './jobs-list.component' | |||
diff --git a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html new file mode 100644 index 000000000..a90267172 --- /dev/null +++ b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html | |||
@@ -0,0 +1,18 @@ | |||
1 | <div class="row"> | ||
2 | <div class="content-padding"> | ||
3 | <h3>Jobs list</h3> | ||
4 | |||
5 | <p-dataTable | ||
6 | [value]="jobs" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" | ||
8 | > | ||
9 | <p-column field="id" header="ID"></p-column> | ||
10 | <p-column field="category" header="Category"></p-column> | ||
11 | <p-column field="handlerName" header="Handler name"></p-column> | ||
12 | <p-column field="handlerInputData" header="Input data"></p-column> | ||
13 | <p-column field="state" header="State"></p-column> | ||
14 | <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> | ||
15 | <p-column field="updatedAt" header="Updated date"></p-column> | ||
16 | </p-dataTable> | ||
17 | </div> | ||
18 | </div> | ||
diff --git a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts new file mode 100644 index 000000000..88fe259fb --- /dev/null +++ b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts | |||
@@ -0,0 +1,50 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { SortMeta } from 'primeng/primeng' | ||
4 | import { Job } from '../../../../../../shared/index' | ||
5 | import { RestPagination, RestTable } from '../../../shared' | ||
6 | import { JobService } from '../shared' | ||
7 | import { RestExtractor } from '../../../shared/rest/rest-extractor.service' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-jobs-list', | ||
11 | templateUrl: './jobs-list.component.html', | ||
12 | styleUrls: [ ] | ||
13 | }) | ||
14 | export class JobsListComponent extends RestTable { | ||
15 | jobs: Job[] = [] | ||
16 | totalRecords = 0 | ||
17 | rowsPerPage = 10 | ||
18 | sort: SortMeta = { field: 'createdAt', order: 1 } | ||
19 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
20 | |||
21 | constructor ( | ||
22 | private notificationsService: NotificationsService, | ||
23 | private restExtractor: RestExtractor, | ||
24 | private jobsService: JobService | ||
25 | ) { | ||
26 | super() | ||
27 | } | ||
28 | |||
29 | protected loadData () { | ||
30 | this.jobsService | ||
31 | .getJobs(this.pagination, this.sort) | ||
32 | .map(res => this.restExtractor.applyToResultListData(res, this.formatJob.bind(this))) | ||
33 | .subscribe( | ||
34 | resultList => { | ||
35 | this.jobs = resultList.data | ||
36 | this.totalRecords = resultList.total | ||
37 | }, | ||
38 | |||
39 | err => this.notificationsService.error('Error', err.message) | ||
40 | ) | ||
41 | } | ||
42 | |||
43 | private formatJob (job: Job) { | ||
44 | const handlerInputData = JSON.stringify(job.handlerInputData) | ||
45 | |||
46 | return Object.assign(job, { | ||
47 | handlerInputData | ||
48 | }) | ||
49 | } | ||
50 | } | ||
diff --git a/client/src/app/+admin/jobs/shared/index.ts b/client/src/app/+admin/jobs/shared/index.ts new file mode 100644 index 000000000..609439e5c --- /dev/null +++ b/client/src/app/+admin/jobs/shared/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './job.service' | |||
diff --git a/client/src/app/+admin/jobs/shared/job.service.ts b/client/src/app/+admin/jobs/shared/job.service.ts new file mode 100644 index 000000000..49f1ab6f5 --- /dev/null +++ b/client/src/app/+admin/jobs/shared/job.service.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
2 | import { Injectable } from '@angular/core' | ||
3 | import { SortMeta } from 'primeng/primeng' | ||
4 | import 'rxjs/add/operator/catch' | ||
5 | import 'rxjs/add/operator/map' | ||
6 | import { Observable } from 'rxjs/Observable' | ||
7 | import { ResultList } from '../../../../../../shared' | ||
8 | import { Job } from '../../../../../../shared/models/job.model' | ||
9 | |||
10 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | ||
11 | |||
12 | @Injectable() | ||
13 | export class JobService { | ||
14 | private static BASE_JOB_URL = API_URL + '/api/v1/jobs' | ||
15 | |||
16 | constructor ( | ||
17 | private authHttp: HttpClient, | ||
18 | private restService: RestService, | ||
19 | private restExtractor: RestExtractor | ||
20 | ) {} | ||
21 | |||
22 | getJobs (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> { | ||
23 | let params = new HttpParams() | ||
24 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
25 | |||
26 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL, { params }) | ||
27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
28 | .catch(err => this.restExtractor.handleError(err)) | ||
29 | } | ||
30 | } | ||