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 { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
import { Song } from '../song/song.entity';
|
import { Song } from '../song/song.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@ -7,12 +8,18 @@ export class Album {
|
|||||||
id: number
|
id: number
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
title: string
|
title: string
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
artist: string
|
artist: string
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty
|
||||||
genre: string
|
genre: string
|
||||||
|
|
||||||
@OneToMany(() => Song, (song) => song.album, { eager: true, onDelete: 'CASCADE' })
|
@OneToMany(() => Song, (song) => song.album, { eager: true, onDelete: 'CASCADE' })
|
||||||
|
@ -50,11 +50,11 @@ export class AlbumService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
albumToUpdate.title = updateAlbumDto.title;
|
const savedAlbum = await this.albumRepository.update({ id: updateAlbumDto.id }, {
|
||||||
albumToUpdate.artist = updateAlbumDto.artist;
|
title: updateAlbumDto.title,
|
||||||
albumToUpdate.genre = updateAlbumDto.genre;
|
artist: updateAlbumDto.artist,
|
||||||
const savedAlbum = await this.albumRepository.save(albumToUpdate);
|
genre: updateAlbumDto.genre
|
||||||
return savedAlbum;
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error("AlbumService: update: IDs do not match", id, updateAlbumDto);
|
console.error("AlbumService: update: IDs do not match", id, updateAlbumDto);
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
|
||||||
import { Album } from '../album/album.entity';
|
import { Album } from '../album/album.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@ -7,12 +8,16 @@ export class Song {
|
|||||||
id: number
|
id: number
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
title: string
|
title: string
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsNumber()
|
||||||
duration: number
|
duration: number
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
@IsNumber()
|
||||||
trackNumber: number
|
trackNumber: number
|
||||||
|
|
||||||
@ManyToOne(() => Album, (album) => album.songs, { cascade: true })
|
@ManyToOne(() => Album, (album) => album.songs, { cascade: true })
|
||||||
|
@ -51,12 +51,12 @@ export class SongService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
songToUpdate.id = updateSongDto.id;
|
const song = await this.songRepository.update({ id: updateSongDto.id }, {
|
||||||
songToUpdate.title = updateSongDto.title;
|
title: updateSongDto.title,
|
||||||
songToUpdate.duration = updateSongDto.duration;
|
duration: updateSongDto.duration,
|
||||||
songToUpdate.trackNumber = updateSongDto.trackNumber;
|
trackNumber: updateSongDto.trackNumber,
|
||||||
songToUpdate.album = album;
|
album: album,
|
||||||
const song = await this.songRepository.save(songToUpdate);
|
});
|
||||||
return song;
|
return song;
|
||||||
} else {
|
} else {
|
||||||
console.error("SongService: update: IDs do not match");
|
console.error("SongService: update: IDs do not match");
|
||||||
|
@ -44,13 +44,10 @@ export default function Page() {
|
|||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
try {
|
try {
|
||||||
console.log(formData);
|
|
||||||
if (formData.get('id') == "") {
|
if (formData.get('id') == "") {
|
||||||
const data = await createSong(formData);
|
await createSong(formData);
|
||||||
console.log(data);
|
|
||||||
} else {
|
} else {
|
||||||
const data = await updateSong(formData);
|
await updateSong(formData);
|
||||||
console.log(data);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating Song: ", error);
|
console.error("Error creating Song: ", error);
|
||||||
@ -75,7 +72,7 @@ export default function Page() {
|
|||||||
const data = await getSong(parseInt(songId));
|
const data = await getSong(parseInt(songId));
|
||||||
setFormModalTitle("Edit Song");
|
setFormModalTitle("Edit Song");
|
||||||
setFormModalButtonLabel("Save");
|
setFormModalButtonLabel("Save");
|
||||||
setFormSongId(songId)
|
setFormSongId(songId);
|
||||||
setFormAlbumId(albumId);
|
setFormAlbumId(albumId);
|
||||||
setFormSongTitle(data.title);
|
setFormSongTitle(data.title);
|
||||||
setFormSongDuration(data.duration);
|
setFormSongDuration(data.duration);
|
||||||
|
@ -39,7 +39,6 @@ export default function Page() {
|
|||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
try {
|
try {
|
||||||
console.log(formData);
|
|
||||||
if (formData.get('id') == "") {
|
if (formData.get('id') == "") {
|
||||||
await createAlbum(formData);
|
await createAlbum(formData);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user