mirror of
https://codeberg.org/beerbrawl/beerbrawl.git
synced 2024-09-23 01:30:52 +02:00
feat(#33): tweaks and test fix
This commit is contained in:
parent
3816f67b66
commit
365a213642
|
@ -37,11 +37,13 @@
|
|||
|
||||
<mat-form-field class="full-width">
|
||||
<mat-label>Author</mat-label>
|
||||
<input matInput [(ngModel)]="author" />
|
||||
<input matInput [(ngModel)]="author" maxlength="50" />
|
||||
<mat-hint align="end">{{ author?.length || 0 }}/50</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="full-width">
|
||||
<mat-label>Title</mat-label>
|
||||
<input matInput [(ngModel)]="title" />
|
||||
<input matInput [(ngModel)]="title" maxlength="100" />
|
||||
<mat-hint align="end">{{ title?.length || 0 }}/100</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="buttons">
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ImageUploadComponent } from './image-upload.component';
|
||||
|
||||
describe('ImageUploadComponent', () => {
|
||||
let component: ImageUploadComponent;
|
||||
let fixture: ComponentFixture<ImageUploadComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ImageUploadComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ImageUploadComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -5,6 +5,7 @@ import { MatCardModule } from '@angular/material/card';
|
|||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { SharedMediaEndpointService } from '@api';
|
||||
|
||||
@Component({
|
||||
|
@ -33,26 +34,24 @@ export class ImageUploadComponent {
|
|||
token = input.required<string>();
|
||||
|
||||
sharedMediaService = inject(SharedMediaEndpointService);
|
||||
snackBar = inject(MatSnackBar);
|
||||
|
||||
uploadImage() {
|
||||
// console.log(this.token());
|
||||
// if (!this.token()) {
|
||||
// this.errorMessage = 'No tournament token supplied!';
|
||||
// return;
|
||||
// }
|
||||
console.log(this.author === '' ? 'PartyGuest' : this.author);
|
||||
if (this.providedImage && this.tournamentId) {
|
||||
const createDto = {
|
||||
author: this.author === '' ? 'PartyGuest' : this.author,
|
||||
title:
|
||||
this.title === ''
|
||||
? `t-${this.tournamentId()}_${Date.now().toLocaleString()}_submission.jpg`
|
||||
? `t-${this.tournamentId()}_${Date.now().toString()}_submission.jpg`
|
||||
: this.title,
|
||||
tournamentId: this.tournamentId()!,
|
||||
};
|
||||
this.sharedMediaService.createSharedMedia(createDto, this.providedImage).subscribe({
|
||||
next: () => {
|
||||
console.log('Succesfully created');
|
||||
this.snackBar.open('Succesfully uploaded image.', 'OK', { duration: 2500 });
|
||||
this.clear();
|
||||
},
|
||||
error: () => {
|
||||
console.error('Error when uplaoding image.');
|
||||
|
|
Loading…
Reference in a new issue