From 17119e4a546522468878cf115558b17949ab50d0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 12 Nov 2020 15:28:54 +0100 Subject: 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 --- .../modals/video-change-ownership.component.html | 33 +++++++++++ .../modals/video-change-ownership.component.scss | 10 ++++ .../modals/video-change-ownership.component.ts | 69 ++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 client/src/app/+my-library/my-videos/modals/video-change-ownership.component.html create mode 100644 client/src/app/+my-library/my-videos/modals/video-change-ownership.component.scss create mode 100644 client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts (limited to 'client/src/app/+my-library/my-videos/modals') diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.html b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.html new file mode 100644 index 000000000..c7c5a0b69 --- /dev/null +++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.html @@ -0,0 +1,33 @@ + + + + + + + diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.scss b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.scss new file mode 100644 index 000000000..a79fec179 --- /dev/null +++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.scss @@ -0,0 +1,10 @@ +@import '_variables'; +@import '_mixins'; + +p-autocomplete { + display: block; +} + +.form-group { + margin: 20px 0; +} \ No newline at end of file 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 @@ +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' +import { Notifier, UserService } from '@app/core' +import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' +import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' +import { Video, VideoOwnershipService } from '@app/shared/shared-main' +import { NgbModal } from '@ng-bootstrap/ng-bootstrap' + +@Component({ + selector: 'my-video-change-ownership', + templateUrl: './video-change-ownership.component.html', + styleUrls: [ './video-change-ownership.component.scss' ] +}) +export class VideoChangeOwnershipComponent extends FormReactive implements OnInit { + @ViewChild('modal', { static: true }) modal: ElementRef + + usernamePropositions: string[] + + error: string = null + + private video: Video | undefined = undefined + + constructor ( + protected formValidatorService: FormValidatorService, + private videoOwnershipService: VideoOwnershipService, + private notifier: Notifier, + private userService: UserService, + private modalService: NgbModal + ) { + super() + } + + ngOnInit () { + this.buildForm({ + username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR + }) + this.usernamePropositions = [] + } + + show (video: Video) { + this.video = video + this.modalService + .open(this.modal, { centered: true }) + .result + .then(() => this.changeOwnership()) + .catch((_) => _) // Called when closing (cancel) the modal without validating, do nothing + } + + search (event: { query: string }) { + const query = event.query + this.userService.autocomplete(query) + .subscribe( + usernames => this.usernamePropositions = usernames, + + err => this.notifier.error(err.message) + ) + } + + changeOwnership () { + const username = this.form.value['username'] + + this.videoOwnershipService + .changeOwnership(this.video.id, username) + .subscribe( + () => this.notifier.success($localize`Ownership change request sent.`), + + err => this.notifier.error(err.message) + ) + } +} -- cgit v1.2.3