diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:51:13 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:55:06 +0100 |
commit | 5cd80545422bba855cc9a730a2e13cc9d982c34b (patch) | |
tree | 9a60cd7c9218c296a1460938d11e3bce784f7cc0 /client/src/app/+admin/jobs/jobs-list | |
parent | 1f3e9feca2caf68024168b0ea9ed39d8438fa235 (diff) | |
download | PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.gz PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.zst PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.zip |
Add ability to list jobs
Diffstat (limited to 'client/src/app/+admin/jobs/jobs-list')
3 files changed, 69 insertions, 0 deletions
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 | } | ||