diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-12 15:28:54 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-13 12:02:21 +0100 |
commit | 17119e4a546522468878cf115558b17949ab50d0 (patch) | |
tree | 3f130cfd7fdccf5aeeac9beee941750590239047 /client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts | |
parent | b4bc269e5517849b5b89052f0c1a2c01b6f65089 (diff) | |
download | PeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.gz PeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.zst PeerTube-17119e4a546522468878cf115558b17949ab50d0.zip |
Reorganize left menu and account menu
Add my-settings and my-library in left menu
Move administration below my-library
Split account menu: my-setting and my library
Diffstat (limited to 'client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts')
-rw-r--r-- | client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts new file mode 100644 index 000000000..84237dee1 --- /dev/null +++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts | |||
@@ -0,0 +1,69 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | ||
2 | import { Notifier, UserService } from '@app/core' | ||
3 | import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' | ||
4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | ||
5 | import { Video, VideoOwnershipService } from '@app/shared/shared-main' | ||
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-video-change-ownership', | ||
10 | templateUrl: './video-change-ownership.component.html', | ||
11 | styleUrls: [ './video-change-ownership.component.scss' ] | ||
12 | }) | ||
13 | export class VideoChangeOwnershipComponent extends FormReactive implements OnInit { | ||
14 | @ViewChild('modal', { static: true }) modal: ElementRef | ||
15 | |||
16 | usernamePropositions: string[] | ||
17 | |||
18 | error: string = null | ||
19 | |||
20 | private video: Video | undefined = undefined | ||
21 | |||
22 | constructor ( | ||
23 | protected formValidatorService: FormValidatorService, | ||
24 | private videoOwnershipService: VideoOwnershipService, | ||
25 | private notifier: Notifier, | ||
26 | private userService: UserService, | ||
27 | private modalService: NgbModal | ||
28 | ) { | ||
29 | super() | ||
30 | } | ||
31 | |||
32 | ngOnInit () { | ||
33 | this.buildForm({ | ||
34 | username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR | ||
35 | }) | ||
36 | this.usernamePropositions = [] | ||
37 | } | ||
38 | |||
39 | show (video: Video) { | ||
40 | this.video = video | ||
41 | this.modalService | ||
42 | .open(this.modal, { centered: true }) | ||
43 | .result | ||
44 | .then(() => this.changeOwnership()) | ||
45 | .catch((_) => _) // Called when closing (cancel) the modal without validating, do nothing | ||
46 | } | ||
47 | |||
48 | search (event: { query: string }) { | ||
49 | const query = event.query | ||
50 | this.userService.autocomplete(query) | ||
51 | .subscribe( | ||
52 | usernames => this.usernamePropositions = usernames, | ||
53 | |||
54 | err => this.notifier.error(err.message) | ||
55 | ) | ||
56 | } | ||
57 | |||
58 | changeOwnership () { | ||
59 | const username = this.form.value['username'] | ||
60 | |||
61 | this.videoOwnershipService | ||
62 | .changeOwnership(this.video.id, username) | ||
63 | .subscribe( | ||
64 | () => this.notifier.success($localize`Ownership change request sent.`), | ||
65 | |||
66 | err => this.notifier.error(err.message) | ||
67 | ) | ||
68 | } | ||
69 | } | ||