diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-ownership')
5 files changed, 245 insertions, 0 deletions
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.html b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.html new file mode 100644 index 000000000..fd7d7d23b --- /dev/null +++ b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.html | |||
@@ -0,0 +1,34 @@ | |||
1 | <ng-template #modal let-close="close" let-dismiss="dismiss"> | ||
2 | <div class="modal-header"> | ||
3 | <h4 i18n class="modal-title">Accept ownership</h4> | ||
4 | <span class="close" aria-label="Close" role="button" (click)="dismiss()"></span> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body" [formGroup]="form"> | ||
8 | <div class="form-group"> | ||
9 | <label i18n for="channel">Select the target channel</label> | ||
10 | <select formControlName="channel" id="channel" class="peertube-select-container"> | ||
11 | <option></option> | ||
12 | <option *ngFor="let channel of videoChannels" [value]="channel.id">{{ channel.displayName }} | ||
13 | </option> | ||
14 | </select> | ||
15 | <div *ngIf="formErrors.channel" class="form-error"> | ||
16 | {{ formErrors.channel }} | ||
17 | </div> | ||
18 | </div> | ||
19 | </div> | ||
20 | |||
21 | <div class="modal-footer inputs"> | ||
22 | <div class="form-group inputs"> | ||
23 | <span i18n class="action-button action-button-cancel" (click)="dismiss()"> | ||
24 | Cancel | ||
25 | </span> | ||
26 | |||
27 | <input | ||
28 | type="submit" i18n-value value="Submit" class="action-button-submit" | ||
29 | [disabled]="!form.valid" | ||
30 | (click)="close()" | ||
31 | > | ||
32 | </div> | ||
33 | </div> | ||
34 | </ng-template> | ||
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.scss b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.scss new file mode 100644 index 000000000..ad6117413 --- /dev/null +++ b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.scss | |||
@@ -0,0 +1,10 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | select { | ||
5 | display: block; | ||
6 | } | ||
7 | |||
8 | .form-group { | ||
9 | margin: 20px 0; | ||
10 | } \ No newline at end of file | ||
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts new file mode 100644 index 000000000..a68b452ec --- /dev/null +++ b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts | |||
@@ -0,0 +1,79 @@ | |||
1 | import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { FormReactive } from '@app/shared' | ||
4 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
5 | import { VideoOwnershipService } from '@app/shared/video-ownership' | ||
6 | import { VideoChangeOwnership } from '../../../../../../shared/models/videos' | ||
7 | import { VideoAcceptOwnershipValidatorsService } from '@app/shared/forms/form-validators' | ||
8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
9 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
11 | import { AuthService } from '@app/core' | ||
12 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
13 | |||
14 | @Component({ | ||
15 | selector: 'my-account-accept-ownership', | ||
16 | templateUrl: './my-account-accept-ownership.component.html', | ||
17 | styleUrls: [ './my-account-accept-ownership.component.scss' ] | ||
18 | }) | ||
19 | export class MyAccountAcceptOwnershipComponent extends FormReactive implements OnInit { | ||
20 | @Output() accepted = new EventEmitter<void>() | ||
21 | |||
22 | @ViewChild('modal') modal: ElementRef | ||
23 | |||
24 | videoChangeOwnership: VideoChangeOwnership | undefined = undefined | ||
25 | |||
26 | videoChannels: VideoChannel[] | ||
27 | |||
28 | error: string = null | ||
29 | |||
30 | constructor ( | ||
31 | protected formValidatorService: FormValidatorService, | ||
32 | private videoChangeOwnershipValidatorsService: VideoAcceptOwnershipValidatorsService, | ||
33 | private videoOwnershipService: VideoOwnershipService, | ||
34 | private notificationsService: NotificationsService, | ||
35 | private authService: AuthService, | ||
36 | private videoChannelService: VideoChannelService, | ||
37 | private modalService: NgbModal, | ||
38 | private i18n: I18n | ||
39 | ) { | ||
40 | super() | ||
41 | } | ||
42 | |||
43 | ngOnInit () { | ||
44 | this.videoChannels = [] | ||
45 | |||
46 | this.videoChannelService.listAccountVideoChannels(this.authService.getUser().account) | ||
47 | .subscribe(videoChannels => this.videoChannels = videoChannels.data) | ||
48 | |||
49 | this.buildForm({ | ||
50 | channel: this.videoChangeOwnershipValidatorsService.CHANNEL | ||
51 | }) | ||
52 | } | ||
53 | |||
54 | show (videoChangeOwnership: VideoChangeOwnership) { | ||
55 | this.videoChangeOwnership = videoChangeOwnership | ||
56 | this.modalService | ||
57 | .open(this.modal) | ||
58 | .result | ||
59 | .then(() => this.acceptOwnership()) | ||
60 | .catch(() => this.videoChangeOwnership = undefined) | ||
61 | } | ||
62 | |||
63 | acceptOwnership () { | ||
64 | const channel = this.form.value['channel'] | ||
65 | |||
66 | const videoChangeOwnership = this.videoChangeOwnership | ||
67 | this.videoOwnershipService | ||
68 | .acceptOwnership(videoChangeOwnership.id, { channelId: channel }) | ||
69 | .subscribe( | ||
70 | () => { | ||
71 | this.notificationsService.success(this.i18n('Success'), this.i18n('Ownership accepted')) | ||
72 | if (this.accepted) this.accepted.emit() | ||
73 | this.videoChangeOwnership = undefined | ||
74 | }, | ||
75 | |||
76 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
77 | ) | ||
78 | } | ||
79 | } | ||
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html new file mode 100644 index 000000000..379fd8bb1 --- /dev/null +++ b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.html | |||
@@ -0,0 +1,54 @@ | |||
1 | <p-table | ||
2 | [value]="videoChangeOwnerships" | ||
3 | [lazy]="true" | ||
4 | [paginator]="true" | ||
5 | [totalRecords]="totalRecords" | ||
6 | [rows]="rowsPerPage" | ||
7 | [sortField]="sort.field" | ||
8 | [sortOrder]="sort.order" | ||
9 | (onLazyLoad)="loadLazy($event)" | ||
10 | > | ||
11 | <ng-template pTemplate="header"> | ||
12 | <tr> | ||
13 | <th i18n>Initiator</th> | ||
14 | <th i18n>Video</th> | ||
15 | <th i18n pSortableColumn="createdAt"> | ||
16 | Created | ||
17 | <p-sortIcon field="createdAt"></p-sortIcon> | ||
18 | </th> | ||
19 | <th i18n>Status</th> | ||
20 | <th i18n>Action</th> | ||
21 | </tr> | ||
22 | </ng-template> | ||
23 | |||
24 | <ng-template pTemplate="body" let-videoChangeOwnership> | ||
25 | <tr> | ||
26 | <td> | ||
27 | <a [href]="videoChangeOwnership.initiatorAccount.url" i18n-title title="Go to the account" | ||
28 | target="_blank" rel="noopener noreferrer"> | ||
29 | {{ createByString(videoChangeOwnership.initiatorAccount) }} | ||
30 | </a> | ||
31 | </td> | ||
32 | <td> | ||
33 | <a [href]="videoChangeOwnership.video.url" i18n-title title="Go to the video" target="_blank" | ||
34 | rel="noopener noreferrer"> | ||
35 | {{ videoChangeOwnership.video.name }} | ||
36 | </a> | ||
37 | </td> | ||
38 | <td>{{ videoChangeOwnership.createdAt }}</td> | ||
39 | <td i18n>{{ videoChangeOwnership.status }}</td> | ||
40 | <td class="action-cell"> | ||
41 | <ng-container *ngIf="videoChangeOwnership.status === 'WAITING'"> | ||
42 | <my-button i18n label="Accept" | ||
43 | icon="icon-tick" | ||
44 | (click)="openAcceptModal(videoChangeOwnership)"></my-button> | ||
45 | <my-button i18n label="Refuse" | ||
46 | icon="icon-cross" | ||
47 | (click)="refuse(videoChangeOwnership)">Refuse</my-button> | ||
48 | </ng-container> | ||
49 | </td> | ||
50 | </tr> | ||
51 | </ng-template> | ||
52 | </p-table> | ||
53 | |||
54 | <my-account-accept-ownership #myAccountAcceptOwnershipComponent (accepted)="accepted()"></my-account-accept-ownership> \ No newline at end of file | ||
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts new file mode 100644 index 000000000..13517b9f4 --- /dev/null +++ b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts | |||
@@ -0,0 +1,68 @@ | |||
1 | import { Component, OnInit, ViewChild } from '@angular/core' | ||
2 | import { NotificationsService } from 'angular2-notifications' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { RestPagination, RestTable } from '@app/shared' | ||
5 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
6 | import { VideoChangeOwnership } from '../../../../../shared' | ||
7 | import { VideoOwnershipService } from '@app/shared/video-ownership' | ||
8 | import { Account } from '@app/shared/account/account.model' | ||
9 | import { MyAccountAcceptOwnershipComponent } | ||
10 | from '@app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component' | ||
11 | |||
12 | @Component({ | ||
13 | selector: 'my-account-ownership', | ||
14 | templateUrl: './my-account-ownership.component.html' | ||
15 | }) | ||
16 | export class MyAccountOwnershipComponent extends RestTable implements OnInit { | ||
17 | videoChangeOwnerships: VideoChangeOwnership[] = [] | ||
18 | totalRecords = 0 | ||
19 | rowsPerPage = 10 | ||
20 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
21 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
22 | |||
23 | @ViewChild('myAccountAcceptOwnershipComponent') myAccountAcceptOwnershipComponent: MyAccountAcceptOwnershipComponent | ||
24 | |||
25 | constructor ( | ||
26 | private notificationsService: NotificationsService, | ||
27 | private videoOwnershipService: VideoOwnershipService, | ||
28 | private i18n: I18n | ||
29 | ) { | ||
30 | super() | ||
31 | } | ||
32 | |||
33 | ngOnInit () { | ||
34 | this.loadSort() | ||
35 | } | ||
36 | |||
37 | protected loadData () { | ||
38 | return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort) | ||
39 | .subscribe( | ||
40 | resultList => { | ||
41 | this.videoChangeOwnerships = resultList.data | ||
42 | this.totalRecords = resultList.total | ||
43 | }, | ||
44 | |||
45 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
46 | ) | ||
47 | } | ||
48 | |||
49 | createByString (account: Account) { | ||
50 | return Account.CREATE_BY_STRING(account.name, account.host) | ||
51 | } | ||
52 | |||
53 | openAcceptModal (videoChangeOwnership: VideoChangeOwnership) { | ||
54 | this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership) | ||
55 | } | ||
56 | |||
57 | accepted () { | ||
58 | this.loadData() | ||
59 | } | ||
60 | |||
61 | refuse (videoChangeOwnership: VideoChangeOwnership) { | ||
62 | this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id) | ||
63 | .subscribe( | ||
64 | () => this.loadData(), | ||
65 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
66 | ) | ||
67 | } | ||
68 | } | ||