diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-08 12:09:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-08 13:38:04 +0200 |
commit | 27ec473f5306621643fcb169be7cfe6b15136265 (patch) | |
tree | bc4a8d81c5baa58ae1af6434731644da7c2df109 /client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts | |
parent | 84531547bc0934a2abda586d539f7455b455d488 (diff) | |
download | PeerTube-27ec473f5306621643fcb169be7cfe6b15136265.tar.gz PeerTube-27ec473f5306621643fcb169be7cfe6b15136265.tar.zst PeerTube-27ec473f5306621643fcb169be7cfe6b15136265.zip |
Set channel banner/avatar in creation form
Diffstat (limited to 'client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts')
-rw-r--r-- | client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts b/client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts index 48451744c..8c12d3c4c 100644 --- a/client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts +++ b/client/src/app/shared/shared-actor-image/actor-banner-edit.component.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' |
2 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | ||
2 | import { Notifier, ServerService } from '@app/core' | 3 | import { Notifier, ServerService } from '@app/core' |
3 | import { VideoChannel } from '@app/shared/shared-main' | 4 | import { VideoChannel } from '@app/shared/shared-main' |
4 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 5 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' |
@@ -17,6 +18,7 @@ export class ActorBannerEditComponent implements OnInit { | |||
17 | @ViewChild('bannerPopover') bannerPopover: NgbPopover | 18 | @ViewChild('bannerPopover') bannerPopover: NgbPopover |
18 | 19 | ||
19 | @Input() actor: VideoChannel | 20 | @Input() actor: VideoChannel |
21 | @Input() previewImage = false | ||
20 | 22 | ||
21 | @Output() bannerChange = new EventEmitter<FormData>() | 23 | @Output() bannerChange = new EventEmitter<FormData>() |
22 | @Output() bannerDelete = new EventEmitter<void>() | 24 | @Output() bannerDelete = new EventEmitter<void>() |
@@ -25,7 +27,10 @@ export class ActorBannerEditComponent implements OnInit { | |||
25 | maxBannerSize = 0 | 27 | maxBannerSize = 0 |
26 | bannerExtensions = '' | 28 | bannerExtensions = '' |
27 | 29 | ||
30 | preview: SafeResourceUrl | ||
31 | |||
28 | constructor ( | 32 | constructor ( |
33 | private sanitizer: DomSanitizer, | ||
29 | private serverService: ServerService, | 34 | private serverService: ServerService, |
30 | private notifier: Notifier | 35 | private notifier: Notifier |
31 | ) { } | 36 | ) { } |
@@ -54,13 +59,18 @@ export class ActorBannerEditComponent implements OnInit { | |||
54 | formData.append('bannerfile', bannerfile) | 59 | formData.append('bannerfile', bannerfile) |
55 | this.bannerPopover?.close() | 60 | this.bannerPopover?.close() |
56 | this.bannerChange.emit(formData) | 61 | this.bannerChange.emit(formData) |
62 | |||
63 | if (this.previewImage) { | ||
64 | this.preview = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(bannerfile)) | ||
65 | } | ||
57 | } | 66 | } |
58 | 67 | ||
59 | deleteBanner () { | 68 | deleteBanner () { |
69 | this.preview = undefined | ||
60 | this.bannerDelete.emit() | 70 | this.bannerDelete.emit() |
61 | } | 71 | } |
62 | 72 | ||
63 | hasBanner () { | 73 | hasBanner () { |
64 | return !!this.actor.bannerUrl | 74 | return !!this.preview || !!this.actor.bannerUrl |
65 | } | 75 | } |
66 | } | 76 | } |