diff --git a/src/app/components/preferences/common/symbols/symbols.component.html b/src/app/components/preferences/common/symbols/symbols.component.html index 54e9ab29..a182fa8b 100644 --- a/src/app/components/preferences/common/symbols/symbols.component.html +++ b/src/app/components/preferences/common/symbols/symbols.component.html @@ -32,7 +32,7 @@ lazyimg [ngClass]="{ imageSelected: isSelected === symbol.symbol_id }" class="image" - [src]="getImageSourceForTemplate(symbol.symbol_id) | authImage: server | async" + [src]="getImageSourceForTemplate(symbol.symbol_id)| authImage: server | async" /> diff --git a/src/app/components/preferences/common/symbols/symbols.component.ts b/src/app/components/preferences/common/symbols/symbols.component.ts index e7a13d95..4ed42f18 100644 --- a/src/app/components/preferences/common/symbols/symbols.component.ts +++ b/src/app/components/preferences/common/symbols/symbols.component.ts @@ -1,4 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; import { Server } from '../../../../models/server'; import { Symbol } from '../../../../models/symbol'; import { SymbolService } from '../../../../services/symbol.service'; @@ -18,7 +19,7 @@ export class SymbolsComponent implements OnInit { isSelected: string = ''; searchText: string = ''; - constructor(private symbolService: SymbolService) {} + constructor(private symbolService: SymbolService, private domSanitizer: DomSanitizer) {} ngOnInit() { this.isSelected = this.symbol; @@ -76,6 +77,11 @@ export class SymbolsComponent implements OnInit { width=\"${imageToUpload.width}\">\n\n`; } + getImage(symbolFilename: string) { + let symbol = this.symbolService.get(symbolFilename); + return this.domSanitizer.bypassSecurityTrustUrl(`data:image/svg+xml;base64,${btoa(symbol.raw)}`); + } + getImageSourceForTemplate(symbol: string) { return `${this.server.protocol}//${this.server.host}:${this.server.port}/v3/symbols/${symbol}/raw`; } diff --git a/src/app/filters/authImageFilter.ts b/src/app/filters/authImageFilter.ts index 6df02d3c..070b286b 100644 --- a/src/app/filters/authImageFilter.ts +++ b/src/app/filters/authImageFilter.ts @@ -2,6 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core'; import { Console } from 'console'; import { Server } from '../models/server'; import { HttpServer } from '../services/http-server.service'; +import { DomSanitizer } from '@angular/platform-browser'; @Pipe({ name: 'authImage' @@ -9,7 +10,8 @@ import { HttpServer } from '../services/http-server.service'; export class AuthImageFilter implements PipeTransform { constructor( - private httpServer: HttpServer + private httpServer: HttpServer, + private domSanitizer: DomSanitizer ) {} async transform(src: string, server: Server) { @@ -17,7 +19,7 @@ export class AuthImageFilter implements PipeTransform { const imageBlob: Blob = await this.httpServer.getBlob(server, url).toPromise(); const reader = new FileReader(); return new Promise((resolve, reject) => { - reader.onloadend = () => resolve(reader.result as string); + reader.onloadend = () => resolve(this.domSanitizer.bypassSecurityTrustUrl(reader.result as string)); reader.readAsDataURL(imageBlob); }); }