Skip to content
Snippets Groups Projects
Verified Commit 903f8aa2 authored by Jonas Leder's avatar Jonas Leder
Browse files

add s3img component

parent 07196008
No related branches found
No related tags found
No related merge requests found
......@@ -7,12 +7,14 @@ import { HeaderComponent } from './header/header.component';
import {HttpClientModule} from "@angular/common/http";
import { ContentComponent } from './content/content.component';
import {MarkdownModule} from "ngx-markdown";
import { S3imgComponent } from './s3img/s3img.component';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
ContentComponent,
S3imgComponent,
],
imports: [
BrowserModule,
......
<p>Test</p>
<img *ngIf="imgPreview" [src]="imgPreview">
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { S3imgComponent } from './s3img.component';
describe('S3imgComponent', () => {
let component: S3imgComponent;
let fixture: ComponentFixture<S3imgComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ S3imgComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(S3imgComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { HttpClient } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 's3img',
templateUrl: './s3img.component.html',
styleUrls: ['./s3img.component.scss']
})
export class S3imgComponent implements OnInit {
@Input() src: string | undefined;
imgPreview: string | undefined;
imgOriginal: string | undefined;
constructor(private httpClient: HttpClient) { }
ngOnInit(): void {
this.httpClient.get<any>('/api/images?path=' + this.src).subscribe(data => {
if (data.success) {
this.imgPreview = data.preview;
this.imgOriginal = data.original;
}
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment