Feature/add logo endpoint (#1506)

* Add logo endpoint

* Update changelog
This commit is contained in:
Thomas Kaul
2022-12-12 20:13:45 +01:00
committed by GitHub
parent 49dcade964
commit e87b93f19c
11 changed files with 148 additions and 8 deletions

View File

@@ -10,9 +10,9 @@
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
<gf-symbol-icon
*ngIf="element.url"
[dataSource]="element.dataSource"
[symbol]="element.symbol"
[tooltip]="element.name"
[url]="element.url"
></gf-symbol-icon>
</td>
</ng-container>

View File

@@ -1,6 +1,7 @@
<img
*ngIf="url"
src="https://www.google.com/s2/favicons?domain={{ url }}&sz=64"
*ngIf="src"
onerror="this.style.display='none'"
[ngClass]="{ large: size === 'large' }"
[src]="src"
[title]="tooltip ? tooltip : ''"
/>

View File

@@ -2,8 +2,9 @@ import {
ChangeDetectionStrategy,
Component,
Input,
OnInit
OnChanges
} from '@angular/core';
import { DataSource } from '@prisma/client';
@Component({
selector: 'gf-symbol-icon',
@@ -11,12 +12,22 @@ import {
templateUrl: './symbol-icon.component.html',
styleUrls: ['./symbol-icon.component.scss']
})
export class SymbolIconComponent implements OnInit {
export class SymbolIconComponent implements OnChanges {
@Input() dataSource: DataSource;
@Input() size: 'large';
@Input() symbol: string;
@Input() tooltip: string;
@Input() url: string;
public src: string;
public constructor() {}
public ngOnInit() {}
public ngOnChanges() {
if (this.dataSource && this.symbol) {
this.src = `../api/v1/logo/${this.dataSource}/${this.symbol}`;
} else if (this.url) {
this.src = `../api/v1/logo?url=${this.url}`;
}
}
}