aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-30 10:51:13 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-30 10:55:06 +0100
commit5cd80545422bba855cc9a730a2e13cc9d982c34b (patch)
tree9a60cd7c9218c296a1460938d11e3bce784f7cc0 /client
parent1f3e9feca2caf68024168b0ea9ed39d8438fa235 (diff)
downloadPeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.gz
PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.zst
PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.zip
Add ability to list jobs
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/admin-routing.module.ts4
-rw-r--r--client/src/app/+admin/admin.module.ts11
-rw-r--r--client/src/app/+admin/jobs/index.ts1
-rw-r--r--client/src/app/+admin/jobs/job.component.ts6
-rw-r--r--client/src/app/+admin/jobs/job.routes.ts35
-rw-r--r--client/src/app/+admin/jobs/jobs-list/index.ts1
-rw-r--r--client/src/app/+admin/jobs/jobs-list/jobs-list.component.html18
-rw-r--r--client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts50
-rw-r--r--client/src/app/+admin/jobs/shared/index.ts1
-rw-r--r--client/src/app/+admin/jobs/shared/job.service.ts30
-rw-r--r--client/src/app/core/menu/menu-admin.component.html5
-rw-r--r--client/src/app/core/menu/menu-admin.component.ts4
12 files changed, 163 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'
8import { UsersRoutes } from './users' 8import { UsersRoutes } from './users'
9import { VideoAbusesRoutes } from './video-abuses' 9import { VideoAbusesRoutes } from './video-abuses'
10import { VideoBlacklistRoutes } from './video-blacklist' 10import { VideoBlacklistRoutes } from './video-blacklist'
11import { JobsRoutes } from './jobs/job.routes'
11 12
12const adminRoutes: Routes = [ 13const 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'
5import { AdminComponent } from './admin.component' 5import { AdminComponent } from './admin.component'
6import { FollowersListComponent, FollowingAddComponent, FollowsComponent, FollowService } from './follows' 6import { FollowersListComponent, FollowingAddComponent, FollowsComponent, FollowService } from './follows'
7import { FollowingListComponent } from './follows/following-list/following-list.component' 7import { FollowingListComponent } from './follows/following-list/following-list.component'
8import { JobsComponent } from './jobs/job.component'
9import { JobsListComponent } from './jobs/jobs-list/jobs-list.component'
10import { JobService } from './jobs/shared/job.service'
8import { UserAddComponent, UserListComponent, UsersComponent, UserService, UserUpdateComponent } from './users' 11import { UserAddComponent, UserListComponent, UsersComponent, UserService, UserUpdateComponent } from './users'
9import { VideoAbuseListComponent, VideoAbusesComponent } from './video-abuses' 12import { VideoAbuseListComponent, VideoAbusesComponent } from './video-abuses'
10import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist' 13import { 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})
48export class AdminModule { } 55export 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 @@
1import { Component } from '@angular/core'
2
3@Component({
4 template: '<router-outlet></router-outlet>'
5})
6export 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 @@
1import { Routes } from '@angular/router'
2
3import { UserRightGuard } from '../../core'
4import { FollowingAddComponent } from './following-add'
5import { UserRight } from '../../../../../shared'
6import { FollowingListComponent } from './following-list/following-list.component'
7import { JobsComponent } from './job.component'
8import { JobsListComponent } from './jobs-list/jobs-list.component'
9
10export 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 @@
1import { Component } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications'
3import { SortMeta } from 'primeng/primeng'
4import { Job } from '../../../../../../shared/index'
5import { RestPagination, RestTable } from '../../../shared'
6import { JobService } from '../shared'
7import { RestExtractor } from '../../../shared/rest/rest-extractor.service'
8
9@Component({
10 selector: 'my-jobs-list',
11 templateUrl: './jobs-list.component.html',
12 styleUrls: [ ]
13})
14export 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 @@
1import { HttpClient, HttpParams } from '@angular/common/http'
2import { Injectable } from '@angular/core'
3import { SortMeta } from 'primeng/primeng'
4import 'rxjs/add/operator/catch'
5import 'rxjs/add/operator/map'
6import { Observable } from 'rxjs/Observable'
7import { ResultList } from '../../../../../../shared'
8import { Job } from '../../../../../../shared/models/job.model'
9
10import { RestExtractor, RestPagination, RestService } from '../../../shared'
11
12@Injectable()
13export 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}
diff --git a/client/src/app/core/menu/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html
index eb2d0d69c..9857b2e3e 100644
--- a/client/src/app/core/menu/menu-admin.component.html
+++ b/client/src/app/core/menu/menu-admin.component.html
@@ -19,6 +19,11 @@
19 <span class="hidden-xs glyphicon glyphicon-eye-close"></span> 19 <span class="hidden-xs glyphicon glyphicon-eye-close"></span>
20 Video blacklist 20 Video blacklist
21 </a> 21 </a>
22
23 <a *ngIf="hasJobsRight()" routerLink="/admin/jobs" routerLinkActive="active">
24 <span class="hidden-xs glyphicon glyphicon-tasks"></span>
25 Jobs
26 </a>
22 </div> 27 </div>
23 28
24 <div class="panel-block"> 29 <div class="panel-block">
diff --git a/client/src/app/core/menu/menu-admin.component.ts b/client/src/app/core/menu/menu-admin.component.ts
index 466da1aee..ea8d5f57c 100644
--- a/client/src/app/core/menu/menu-admin.component.ts
+++ b/client/src/app/core/menu/menu-admin.component.ts
@@ -26,4 +26,8 @@ export class MenuAdminComponent {
26 hasVideoBlacklistRight () { 26 hasVideoBlacklistRight () {
27 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) 27 return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
28 } 28 }
29
30 hasJobsRight () {
31 return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS)
32 }
29} 33}