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 | |
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')
-rw-r--r-- | client/src/app/+admin/admin-routing.module.ts | 4 | ||||
-rw-r--r-- | client/src/app/+admin/admin.module.ts | 11 | ||||
-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 |
10 files changed, 154 insertions, 3 deletions
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts index cd8b9bdef..7ef5c6105 100644 --- a/client/src/app/+admin/admin-routing.module.ts +++ b/client/src/app/+admin/admin-routing.module.ts | |||
@@ -8,6 +8,7 @@ import { FollowsRoutes } from './follows' | |||
8 | import { UsersRoutes } from './users' | 8 | import { UsersRoutes } from './users' |
9 | import { VideoAbusesRoutes } from './video-abuses' | 9 | import { VideoAbusesRoutes } from './video-abuses' |
10 | import { VideoBlacklistRoutes } from './video-blacklist' | 10 | import { VideoBlacklistRoutes } from './video-blacklist' |
11 | import { JobsRoutes } from './jobs/job.routes' | ||
11 | 12 | ||
12 | const adminRoutes: Routes = [ | 13 | const adminRoutes: Routes = [ |
13 | { | 14 | { |
@@ -24,7 +25,8 @@ const adminRoutes: Routes = [ | |||
24 | ...FollowsRoutes, | 25 | ...FollowsRoutes, |
25 | ...UsersRoutes, | 26 | ...UsersRoutes, |
26 | ...VideoAbusesRoutes, | 27 | ...VideoAbusesRoutes, |
27 | ...VideoBlacklistRoutes | 28 | ...VideoBlacklistRoutes, |
29 | ...JobsRoutes | ||
28 | ] | 30 | ] |
29 | } | 31 | } |
30 | ] | 32 | ] |
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index 3c6b7a793..c0b006e73 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts | |||
@@ -5,6 +5,9 @@ import { AdminRoutingModule } from './admin-routing.module' | |||
5 | import { AdminComponent } from './admin.component' | 5 | import { AdminComponent } from './admin.component' |
6 | import { FollowersListComponent, FollowingAddComponent, FollowsComponent, FollowService } from './follows' | 6 | import { FollowersListComponent, FollowingAddComponent, FollowsComponent, FollowService } from './follows' |
7 | import { FollowingListComponent } from './follows/following-list/following-list.component' | 7 | import { FollowingListComponent } from './follows/following-list/following-list.component' |
8 | import { JobsComponent } from './jobs/job.component' | ||
9 | import { JobsListComponent } from './jobs/jobs-list/jobs-list.component' | ||
10 | import { JobService } from './jobs/shared/job.service' | ||
8 | import { UserAddComponent, UserListComponent, UsersComponent, UserService, UserUpdateComponent } from './users' | 11 | import { UserAddComponent, UserListComponent, UsersComponent, UserService, UserUpdateComponent } from './users' |
9 | import { VideoAbuseListComponent, VideoAbusesComponent } from './video-abuses' | 12 | import { VideoAbuseListComponent, VideoAbusesComponent } from './video-abuses' |
10 | import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' | 13 | import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' |
@@ -33,7 +36,10 @@ import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-bl | |||
33 | VideoBlacklistListComponent, | 36 | VideoBlacklistListComponent, |
34 | 37 | ||
35 | VideoAbusesComponent, | 38 | VideoAbusesComponent, |
36 | VideoAbuseListComponent | 39 | VideoAbuseListComponent, |
40 | |||
41 | JobsComponent, | ||
42 | JobsListComponent | ||
37 | ], | 43 | ], |
38 | 44 | ||
39 | exports: [ | 45 | exports: [ |
@@ -42,7 +48,8 @@ import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-bl | |||
42 | 48 | ||
43 | providers: [ | 49 | providers: [ |
44 | FollowService, | 50 | FollowService, |
45 | UserService | 51 | UserService, |
52 | JobService | ||
46 | ] | 53 | ] |
47 | }) | 54 | }) |
48 | export class AdminModule { } | 55 | export class AdminModule { } |
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 | } | ||