mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Add/update/delete/list my playlists
This commit is contained in:
parent
d4c9f45b31
commit
830b4faff1
48 changed files with 1076 additions and 153 deletions
69
client/src/app/shared/images/image-upload.component.ts
Normal file
69
client/src/app/shared/images/image-upload.component.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { Component, forwardRef, Input } from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
|
||||
import { ServerService } from '@app/core'
|
||||
|
||||
@Component({
|
||||
selector: 'my-image-upload',
|
||||
styleUrls: [ './image-upload.component.scss' ],
|
||||
templateUrl: './image-upload.component.html',
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => ImageUploadComponent),
|
||||
multi: true
|
||||
}
|
||||
]
|
||||
})
|
||||
export class ImageUploadComponent implements ControlValueAccessor {
|
||||
@Input() inputLabel: string
|
||||
@Input() inputName: string
|
||||
@Input() previewWidth: string
|
||||
@Input() previewHeight: string
|
||||
|
||||
imageSrc: SafeResourceUrl
|
||||
|
||||
private file: File
|
||||
|
||||
constructor (
|
||||
private sanitizer: DomSanitizer,
|
||||
private serverService: ServerService
|
||||
) {}
|
||||
|
||||
get videoImageExtensions () {
|
||||
return this.serverService.getConfig().video.image.extensions
|
||||
}
|
||||
|
||||
get maxVideoImageSize () {
|
||||
return this.serverService.getConfig().video.image.size.max
|
||||
}
|
||||
|
||||
onFileChanged (file: File) {
|
||||
this.file = file
|
||||
|
||||
this.propagateChange(this.file)
|
||||
this.updatePreview()
|
||||
}
|
||||
|
||||
propagateChange = (_: any) => { /* empty */ }
|
||||
|
||||
writeValue (file: any) {
|
||||
this.file = file
|
||||
this.updatePreview()
|
||||
}
|
||||
|
||||
registerOnChange (fn: (_: any) => void) {
|
||||
this.propagateChange = fn
|
||||
}
|
||||
|
||||
registerOnTouched () {
|
||||
// Unused
|
||||
}
|
||||
|
||||
private updatePreview () {
|
||||
if (this.file) {
|
||||
const url = URL.createObjectURL(this.file)
|
||||
this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue