import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
-import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
import { ServerService } from '@app/core'
-import { ServerConfig } from '@shared/models'
+import { imageToDataURL } from '@root-helpers/images'
+import { HTMLServerConfig } from '@shared/models'
import { BytesPipe } from '../shared-main'
@Component({
@Input() previewWidth: string
@Input() previewHeight: string
- imageSrc: SafeResourceUrl
+ imageSrc: string
allowedExtensionsMessage = ''
maxSizeText: string
- private serverConfig: ServerConfig
+ private serverConfig: HTMLServerConfig
private bytesPipe: BytesPipe
private file: Blob
constructor (
- private sanitizer: DomSanitizer,
private serverService: ServerService
) {
this.bytesPipe = new BytesPipe()
}
ngOnInit () {
- this.serverConfig = this.serverService.getTmpConfig()
- this.serverService.getConfig()
- .subscribe(config => this.serverConfig = config)
+ this.serverConfig = this.serverService.getHTMLConfig()
this.allowedExtensionsMessage = this.videoImageExtensions.join(', ')
}
private updatePreview () {
if (this.file) {
- const url = URL.createObjectURL(this.file)
- this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url)
+ imageToDataURL(this.file).then(result => this.imageSrc = result)
}
}
}