diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-02 17:48:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | ed31c059851a30bd5ba9999f8ecb3822d576b9f4 (patch) | |
tree | 7923ef7891ae9fd26965c3004bd75e736f0fedd0 /client | |
parent | 299474e8279675adb6c5ce140e7e39c6f3439453 (diff) | |
download | PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.gz PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.zst PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.zip |
Add ability to list video imports
Diffstat (limited to 'client')
8 files changed, 160 insertions, 5 deletions
diff --git a/client/src/app/+my-account/my-account-routing.module.ts b/client/src/app/+my-account/my-account-routing.module.ts index 91b464f75..6f0806e8a 100644 --- a/client/src/app/+my-account/my-account-routing.module.ts +++ b/client/src/app/+my-account/my-account-routing.module.ts | |||
@@ -8,6 +8,7 @@ import { MyAccountVideosComponent } from './my-account-videos/my-account-videos. | |||
8 | import { MyAccountVideoChannelsComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channels.component' | 8 | import { MyAccountVideoChannelsComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channels.component' |
9 | import { MyAccountVideoChannelCreateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-create.component' | 9 | import { MyAccountVideoChannelCreateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-create.component' |
10 | import { MyAccountVideoChannelUpdateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-update.component' | 10 | import { MyAccountVideoChannelUpdateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-update.component' |
11 | import { MyAccountVideoImportsComponent } from '@app/+my-account/my-account-video-imports/my-account-video-imports.component' | ||
11 | 12 | ||
12 | const myAccountRoutes: Routes = [ | 13 | const myAccountRoutes: Routes = [ |
13 | { | 14 | { |
@@ -64,6 +65,15 @@ const myAccountRoutes: Routes = [ | |||
64 | title: 'Account videos' | 65 | title: 'Account videos' |
65 | } | 66 | } |
66 | } | 67 | } |
68 | }, | ||
69 | { | ||
70 | path: 'video-imports', | ||
71 | component: MyAccountVideoImportsComponent, | ||
72 | data: { | ||
73 | meta: { | ||
74 | title: 'Account video imports' | ||
75 | } | ||
76 | } | ||
67 | } | 77 | } |
68 | ] | 78 | ] |
69 | } | 79 | } |
diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html new file mode 100644 index 000000000..74ca33fa3 --- /dev/null +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html | |||
@@ -0,0 +1,37 @@ | |||
1 | <p-table | ||
2 | [value]="videoImports" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" | ||
3 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" | ||
4 | > | ||
5 | <ng-template pTemplate="header"> | ||
6 | <tr> | ||
7 | <th i18n>URL</th> | ||
8 | <th i18n>Video</th> | ||
9 | <th i18n style="width: 150px">State</th> | ||
10 | <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
11 | <th></th> | ||
12 | </tr> | ||
13 | </ng-template> | ||
14 | |||
15 | <ng-template pTemplate="body" let-videoImport> | ||
16 | <tr> | ||
17 | <td> | ||
18 | <a [href]="videoImport.targetUrl" target="_blank" rel="noopener noreferrer">{{ videoImport.targetUrl }}</a> | ||
19 | </td> | ||
20 | |||
21 | <td *ngIf="isVideoImportPending(videoImport)"> | ||
22 | {{ videoImport.video.name }} | ||
23 | </td> | ||
24 | <td *ngIf="isVideoImportSuccess(videoImport)"> | ||
25 | <a [href]="getVideoUrl(videoImport.video)" target="_blank" rel="noopener noreferrer">{{ videoImport.video.name }}</a> | ||
26 | </td> | ||
27 | <td *ngIf="isVideoImportFailed(videoImport)"></td> | ||
28 | |||
29 | <td>{{ videoImport.state.label }}</td> | ||
30 | <td>{{ videoImport.createdAt }}</td> | ||
31 | |||
32 | <td class="action-cell"> | ||
33 | <my-edit-button *ngIf="isVideoImportSuccess(videoImport)" [routerLink]="getEditVideoUrl(videoImport.video)"></my-edit-button> | ||
34 | </td> | ||
35 | </tr> | ||
36 | </ng-template> | ||
37 | </p-table> | ||
diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.scss b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.scss new file mode 100644 index 000000000..5e6774739 --- /dev/null +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.scss | |||
@@ -0,0 +1,2 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts new file mode 100644 index 000000000..31ccb0bc8 --- /dev/null +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts | |||
@@ -0,0 +1,66 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { RestPagination, RestTable } from '@app/shared' | ||
3 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
4 | import { NotificationsService } from 'angular2-notifications' | ||
5 | import { ConfirmService } from '@app/core' | ||
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | import { VideoImport, VideoImportState } from '../../../../../shared/models/videos' | ||
8 | import { VideoImportService } from '@app/shared/video-import' | ||
9 | |||
10 | @Component({ | ||
11 | selector: 'my-account-video-imports', | ||
12 | templateUrl: './my-account-video-imports.component.html', | ||
13 | styleUrls: [ './my-account-video-imports.component.scss' ] | ||
14 | }) | ||
15 | export class MyAccountVideoImportsComponent extends RestTable implements OnInit { | ||
16 | videoImports: VideoImport[] = [] | ||
17 | totalRecords = 0 | ||
18 | rowsPerPage = 10 | ||
19 | sort: SortMeta = { field: 'createdAt', order: 1 } | ||
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
21 | |||
22 | constructor ( | ||
23 | private notificationsService: NotificationsService, | ||
24 | private confirmService: ConfirmService, | ||
25 | private videoImportService: VideoImportService, | ||
26 | private i18n: I18n | ||
27 | ) { | ||
28 | super() | ||
29 | } | ||
30 | |||
31 | ngOnInit () { | ||
32 | this.loadSort() | ||
33 | } | ||
34 | |||
35 | isVideoImportSuccess (videoImport: VideoImport) { | ||
36 | return videoImport.state.id === VideoImportState.SUCCESS | ||
37 | } | ||
38 | |||
39 | isVideoImportPending (videoImport: VideoImport) { | ||
40 | return videoImport.state.id === VideoImportState.PENDING | ||
41 | } | ||
42 | |||
43 | isVideoImportFailed (videoImport: VideoImport) { | ||
44 | return videoImport.state.id === VideoImportState.FAILED | ||
45 | } | ||
46 | |||
47 | getVideoUrl (video: { uuid: string }) { | ||
48 | return '/videos/watch/' + video.uuid | ||
49 | } | ||
50 | |||
51 | getEditVideoUrl (video: { uuid: string }) { | ||
52 | return '/videos/update/' + video.uuid | ||
53 | } | ||
54 | |||
55 | protected loadData () { | ||
56 | this.videoImportService.getMyVideoImports(this.pagination, this.sort) | ||
57 | .subscribe( | ||
58 | resultList => { | ||
59 | this.videoImports = resultList.data | ||
60 | this.totalRecords = resultList.total | ||
61 | }, | ||
62 | |||
63 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
64 | ) | ||
65 | } | ||
66 | } | ||
diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts index 54830c75e..01e1ef1da 100644 --- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts +++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts | |||
@@ -145,6 +145,8 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni | |||
145 | suffix = this.i18n('Waiting transcoding') | 145 | suffix = this.i18n('Waiting transcoding') |
146 | } else if (video.state.id === VideoState.TO_TRANSCODE) { | 146 | } else if (video.state.id === VideoState.TO_TRANSCODE) { |
147 | suffix = this.i18n('To transcode') | 147 | suffix = this.i18n('To transcode') |
148 | } else if (video.state.id === VideoState.TO_IMPORT) { | ||
149 | suffix = this.i18n('To import') | ||
148 | } else { | 150 | } else { |
149 | return '' | 151 | return '' |
150 | } | 152 | } |
diff --git a/client/src/app/+my-account/my-account.component.html b/client/src/app/+my-account/my-account.component.html index 48db55ad3..f67245d85 100644 --- a/client/src/app/+my-account/my-account.component.html +++ b/client/src/app/+my-account/my-account.component.html | |||
@@ -5,6 +5,8 @@ | |||
5 | <a i18n routerLink="/my-account/video-channels" routerLinkActive="active" class="title-page">My video channels</a> | 5 | <a i18n routerLink="/my-account/video-channels" routerLinkActive="active" class="title-page">My video channels</a> |
6 | 6 | ||
7 | <a i18n routerLink="/my-account/videos" routerLinkActive="active" class="title-page">My videos</a> | 7 | <a i18n routerLink="/my-account/videos" routerLinkActive="active" class="title-page">My videos</a> |
8 | |||
9 | <a i18n routerLink="/my-account/video-imports" routerLinkActive="active" class="title-page">My video imports</a> | ||
8 | </div> | 10 | </div> |
9 | 11 | ||
10 | <div class="margin-content"> | 12 | <div class="margin-content"> |
diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index 2088273e6..5403ab649 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { TableModule } from 'primeng/table' | ||
1 | import { NgModule } from '@angular/core' | 2 | import { NgModule } from '@angular/core' |
2 | import { SharedModule } from '../shared' | 3 | import { SharedModule } from '../shared' |
3 | import { MyAccountRoutingModule } from './my-account-routing.module' | 4 | import { MyAccountRoutingModule } from './my-account-routing.module' |
@@ -11,11 +12,13 @@ import { MyAccountVideoChannelsComponent } from '@app/+my-account/my-account-vid | |||
11 | import { MyAccountVideoChannelCreateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-create.component' | 12 | import { MyAccountVideoChannelCreateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-create.component' |
12 | import { MyAccountVideoChannelUpdateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-update.component' | 13 | import { MyAccountVideoChannelUpdateComponent } from '@app/+my-account/my-account-video-channels/my-account-video-channel-update.component' |
13 | import { ActorAvatarInfoComponent } from '@app/+my-account/shared/actor-avatar-info.component' | 14 | import { ActorAvatarInfoComponent } from '@app/+my-account/shared/actor-avatar-info.component' |
15 | import { MyAccountVideoImportsComponent } from '@app/+my-account/my-account-video-imports/my-account-video-imports.component' | ||
14 | 16 | ||
15 | @NgModule({ | 17 | @NgModule({ |
16 | imports: [ | 18 | imports: [ |
17 | MyAccountRoutingModule, | 19 | MyAccountRoutingModule, |
18 | SharedModule | 20 | SharedModule, |
21 | TableModule | ||
19 | ], | 22 | ], |
20 | 23 | ||
21 | declarations: [ | 24 | declarations: [ |
@@ -28,7 +31,8 @@ import { ActorAvatarInfoComponent } from '@app/+my-account/shared/actor-avatar-i | |||
28 | MyAccountVideoChannelsComponent, | 31 | MyAccountVideoChannelsComponent, |
29 | MyAccountVideoChannelCreateComponent, | 32 | MyAccountVideoChannelCreateComponent, |
30 | MyAccountVideoChannelUpdateComponent, | 33 | MyAccountVideoChannelUpdateComponent, |
31 | ActorAvatarInfoComponent | 34 | ActorAvatarInfoComponent, |
35 | MyAccountVideoImportsComponent | ||
32 | ], | 36 | ], |
33 | 37 | ||
34 | exports: [ | 38 | exports: [ |
diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.ts index b4709866a..59b58ab38 100644 --- a/client/src/app/shared/video-import/video-import.service.ts +++ b/client/src/app/shared/video-import/video-import.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError, map, switchMap } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { Observable } from 'rxjs' | 4 | import { Observable } from 'rxjs' |
5 | import { VideoImport } from '../../../../../shared' | 5 | import { VideoImport } from '../../../../../shared' |
@@ -8,6 +8,12 @@ import { RestExtractor, RestService } from '../rest' | |||
8 | import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' | 8 | import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' |
9 | import { objectToFormData } from '@app/shared/misc/utils' | 9 | import { objectToFormData } from '@app/shared/misc/utils' |
10 | import { VideoUpdate } from '../../../../../shared/models/videos' | 10 | import { VideoUpdate } from '../../../../../shared/models/videos' |
11 | import { ResultList } from '../../../../../shared/models/result-list.model' | ||
12 | import { UserService } from '@app/shared/users/user.service' | ||
13 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
14 | import { RestPagination } from '@app/shared/rest' | ||
15 | import { ServerService } from '@app/core' | ||
16 | import { peertubeTranslate } from '@app/shared/i18n/i18n-utils' | ||
11 | 17 | ||
12 | @Injectable() | 18 | @Injectable() |
13 | export class VideoImportService { | 19 | export class VideoImportService { |
@@ -16,7 +22,8 @@ export class VideoImportService { | |||
16 | constructor ( | 22 | constructor ( |
17 | private authHttp: HttpClient, | 23 | private authHttp: HttpClient, |
18 | private restService: RestService, | 24 | private restService: RestService, |
19 | private restExtractor: RestExtractor | 25 | private restExtractor: RestExtractor, |
26 | private serverService: ServerService | ||
20 | ) {} | 27 | ) {} |
21 | 28 | ||
22 | importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> { | 29 | importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> { |
@@ -53,4 +60,29 @@ export class VideoImportService { | |||
53 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 60 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
54 | } | 61 | } |
55 | 62 | ||
63 | getMyVideoImports (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoImport>> { | ||
64 | let params = new HttpParams() | ||
65 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
66 | |||
67 | return this.authHttp | ||
68 | .get<ResultList<VideoImport>>(UserService.BASE_USERS_URL + '/me/videos/imports', { params }) | ||
69 | .pipe( | ||
70 | switchMap(res => this.extractVideoImports(res)), | ||
71 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
72 | catchError(err => this.restExtractor.handleError(err)) | ||
73 | ) | ||
74 | } | ||
75 | |||
76 | private extractVideoImports (result: ResultList<VideoImport>): Observable<ResultList<VideoImport>> { | ||
77 | return this.serverService.localeObservable | ||
78 | .pipe( | ||
79 | map(translations => { | ||
80 | result.data.forEach(d => | ||
81 | d.state.label = peertubeTranslate(d.state.label, translations) | ||
82 | ) | ||
83 | |||
84 | return result | ||
85 | }) | ||
86 | ) | ||
87 | } | ||
56 | } | 88 | } |