mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-03 03:26:42 +00:00
Fix for symbol dialog
This commit is contained in:
parent
c8f1a4d428
commit
ca7b43a5c2
@ -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<image height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\" xlink:href=\"${image}\"/>\n</svg>`;
|
||||
}
|
||||
|
||||
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`;
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user