1
0
Fork 0
peertube/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts
kontrollanten d0800f7661
Implement avatar miniatures (#4639)
* client: remove unused file

* refactor(client/my-actor-avatar): size from input

Read size from component input instead of scss, to make it possible to
use smaller avatar images when implemented.

* implement avatar miniatures

close #4560

* fix(test): max file size

* fix(search-index): normalize res acc to avatarMini

* refactor avatars to an array

* client/search: resize channel avatar to 120

* refactor(client/videos): remove unused function

* client(actor-avatar): set default size

* fix tests and avatars full result

When findOne is used only an array containting one avatar is returned.

* update migration version and version notations

* server/search: harmonize normalizing

* Cleanup avatar miniature PR

Co-authored-by: Chocobozzz <me@florianbigard.com>
2022-02-28 08:34:43 +01:00

77 lines
2.5 KiB
TypeScript

import { SelectChannelItem } from 'src/types/select-options-item.model'
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, Notifier } from '@app/core'
import { listUserChannelsForSelect } from '@app/helpers'
import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { VideoChangeOwnership } from '@shared/models'
@Component({
selector: 'my-accept-ownership',
templateUrl: './my-accept-ownership.component.html',
styleUrls: [ './my-accept-ownership.component.scss' ]
})
export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
@Output() accepted = new EventEmitter<void>()
@ViewChild('modal', { static: true }) modal: ElementRef
videoChangeOwnership: VideoChangeOwnership | undefined = undefined
videoChannels: SelectChannelItem[]
error: string = null
constructor (
protected formValidatorService: FormValidatorService,
private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier,
private authService: AuthService,
private modalService: NgbModal
) {
super()
}
ngOnInit () {
this.videoChannels = []
listUserChannelsForSelect(this.authService)
.subscribe(channels => this.videoChannels = channels)
this.buildForm({
channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
})
}
show (videoChangeOwnership: VideoChangeOwnership) {
// Select the first available channel by default
this.form.patchValue({
channel: this.videoChannels[0].id
})
this.videoChangeOwnership = videoChangeOwnership
this.modalService
.open(this.modal, { centered: true })
.result
.then(() => this.acceptOwnership())
.catch(() => this.videoChangeOwnership = undefined)
}
acceptOwnership () {
const channel = this.form.value['channel']
const videoChangeOwnership = this.videoChangeOwnership
this.videoOwnershipService
.acceptOwnership(videoChangeOwnership.id, { channelId: channel })
.subscribe({
next: () => {
this.notifier.success($localize`Ownership accepted`)
if (this.accepted) this.accepted.emit()
this.videoChangeOwnership = undefined
},
error: err => this.notifier.error(err.message)
})
}
}