diff --git a/frontend/src/app/components/image-upload/image-upload.component.html b/frontend/src/app/components/image-upload/image-upload.component.html index 1452de6..aee82c1 100644 --- a/frontend/src/app/components/image-upload/image-upload.component.html +++ b/frontend/src/app/components/image-upload/image-upload.component.html @@ -37,11 +37,13 @@ Author - + + {{ author?.length || 0 }}/50 Title - + + {{ title?.length || 0 }}/100
diff --git a/frontend/src/app/components/image-upload/image-upload.component.spec.ts b/frontend/src/app/components/image-upload/image-upload.component.spec.ts deleted file mode 100644 index 0edab8d..0000000 --- a/frontend/src/app/components/image-upload/image-upload.component.spec.ts +++ /dev/null @@ -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; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ImageUploadComponent], - }).compileComponents(); - - fixture = TestBed.createComponent(ImageUploadComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/components/image-upload/image-upload.component.ts b/frontend/src/app/components/image-upload/image-upload.component.ts index a5da63c..df0b31b 100644 --- a/frontend/src/app/components/image-upload/image-upload.component.ts +++ b/frontend/src/app/components/image-upload/image-upload.component.ts @@ -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(); 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.');