Fixes
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Failing after 29s
Music Collection CI Workflow / test (./frontend) (push) Successful in 35s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
Music Collection CI Workflow / deploy (push) Has been skipped
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Failing after 29s
Music Collection CI Workflow / test (./frontend) (push) Successful in 35s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
Music Collection CI Workflow / deploy (push) Has been skipped
This commit is contained in:
parent
e0d6c68d43
commit
fb67512092
@ -1,4 +1,5 @@
|
||||
import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { Song } from '../song/song.entity';
|
||||
|
||||
@Entity()
|
||||
@ -7,12 +8,18 @@ export class Album {
|
||||
id: number
|
||||
|
||||
@Column()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
title: string
|
||||
|
||||
@Column()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
artist: string
|
||||
|
||||
@Column()
|
||||
@IsString()
|
||||
@IsNotEmpty
|
||||
genre: string
|
||||
|
||||
@OneToMany(() => Song, (song) => song.album, { eager: true, onDelete: 'CASCADE' })
|
||||
|
@ -50,11 +50,11 @@ export class AlbumService {
|
||||
return null;
|
||||
}
|
||||
|
||||
albumToUpdate.title = updateAlbumDto.title;
|
||||
albumToUpdate.artist = updateAlbumDto.artist;
|
||||
albumToUpdate.genre = updateAlbumDto.genre;
|
||||
const savedAlbum = await this.albumRepository.save(albumToUpdate);
|
||||
return savedAlbum;
|
||||
const savedAlbum = await this.albumRepository.update({ id: updateAlbumDto.id }, {
|
||||
title: updateAlbumDto.title,
|
||||
artist: updateAlbumDto.artist,
|
||||
genre: updateAlbumDto.genre
|
||||
});
|
||||
} else {
|
||||
console.error("AlbumService: update: IDs do not match", id, updateAlbumDto);
|
||||
return null;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
|
||||
import { Album } from '../album/album.entity';
|
||||
|
||||
@Entity()
|
||||
@ -7,12 +8,16 @@ export class Song {
|
||||
id: number
|
||||
|
||||
@Column()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
title: string
|
||||
|
||||
@Column()
|
||||
@IsNumber()
|
||||
duration: number
|
||||
|
||||
@Column()
|
||||
@IsNumber()
|
||||
trackNumber: number
|
||||
|
||||
@ManyToOne(() => Album, (album) => album.songs, { cascade: true })
|
||||
|
@ -51,12 +51,12 @@ export class SongService {
|
||||
return null;
|
||||
}
|
||||
|
||||
songToUpdate.id = updateSongDto.id;
|
||||
songToUpdate.title = updateSongDto.title;
|
||||
songToUpdate.duration = updateSongDto.duration;
|
||||
songToUpdate.trackNumber = updateSongDto.trackNumber;
|
||||
songToUpdate.album = album;
|
||||
const song = await this.songRepository.save(songToUpdate);
|
||||
const song = await this.songRepository.update({ id: updateSongDto.id }, {
|
||||
title: updateSongDto.title,
|
||||
duration: updateSongDto.duration,
|
||||
trackNumber: updateSongDto.trackNumber,
|
||||
album: album,
|
||||
});
|
||||
return song;
|
||||
} else {
|
||||
console.error("SongService: update: IDs do not match");
|
||||
|
@ -44,13 +44,10 @@ export default function Page() {
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
try {
|
||||
console.log(formData);
|
||||
if (formData.get('id') == "") {
|
||||
const data = await createSong(formData);
|
||||
console.log(data);
|
||||
await createSong(formData);
|
||||
} else {
|
||||
const data = await updateSong(formData);
|
||||
console.log(data);
|
||||
await updateSong(formData);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error creating Song: ", error);
|
||||
@ -75,7 +72,7 @@ export default function Page() {
|
||||
const data = await getSong(parseInt(songId));
|
||||
setFormModalTitle("Edit Song");
|
||||
setFormModalButtonLabel("Save");
|
||||
setFormSongId(songId)
|
||||
setFormSongId(songId);
|
||||
setFormAlbumId(albumId);
|
||||
setFormSongTitle(data.title);
|
||||
setFormSongDuration(data.duration);
|
||||
|
@ -39,7 +39,6 @@ export default function Page() {
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
try {
|
||||
console.log(formData);
|
||||
if (formData.get('id') == "") {
|
||||
await createAlbum(formData);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user