Adding tracknumber, adding sorting
Some checks failed
Music Collection CI Workflow / test (./frontend) (push) Successful in 36s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-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
Music Collection CI Workflow / test (./backend) (push) Failing after 29s
Some checks failed
Music Collection CI Workflow / test (./frontend) (push) Successful in 36s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-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
Music Collection CI Workflow / test (./backend) (push) Failing after 29s
This commit is contained in:
parent
13ec515d97
commit
fa3daa831f
@ -13,7 +13,11 @@ export class AlbumService {
|
||||
) {}
|
||||
|
||||
findAll(): Promise<Album[]> {
|
||||
return this.albumRepository.find();
|
||||
return this.albumRepository.find({
|
||||
order: {
|
||||
artist: "ASC"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
findOneById(id: number): Promise<Album | null> {
|
||||
|
@ -1,5 +1,6 @@
|
||||
export class CreateSongDto {
|
||||
title: string;
|
||||
duration: number;
|
||||
trackNumber: number;
|
||||
albumId: number;
|
||||
}
|
||||
|
@ -2,5 +2,6 @@ export class UpdateSongDto {
|
||||
id: number;
|
||||
title: string;
|
||||
duration: number;
|
||||
trackNumber: number;
|
||||
albumId: number;
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ export class Song {
|
||||
@Column()
|
||||
duration: number
|
||||
|
||||
@Column
|
||||
trackNumber: number
|
||||
|
||||
@ManyToOne(() => Album, (album) => album.songs)
|
||||
album: Album
|
||||
}
|
||||
|
@ -13,7 +13,11 @@ export class SongService {
|
||||
) {}
|
||||
|
||||
findAll(): Promise<Song[]> {
|
||||
return this.songRepository.find();
|
||||
return this.songRepository.find({
|
||||
order: {
|
||||
trackNumber: "ASC"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
findOneById(id: number): Promise<Song | null> {
|
||||
@ -23,7 +27,8 @@ export class SongService {
|
||||
async create(createSongDto: CreateSongDto): Promise<number> {
|
||||
const song = this.songRepository.create({
|
||||
title: createSongDto.title,
|
||||
duration: createSongDto.duration
|
||||
duration: createSongDto.duration,
|
||||
trackNumber: createSongDto.trackNumber
|
||||
});
|
||||
const savedSong = await this.songRepository.save(song);
|
||||
return savedSong.id;
|
||||
@ -37,7 +42,8 @@ export class SongService {
|
||||
|
||||
await this.songRepository.update({ id: updateSongDto.id }, {
|
||||
title: updateSongDto.title,
|
||||
duration: updateSongDto.duration
|
||||
duration: updateSongDto.duration,
|
||||
trackNumber: createSongDto.trackNumber
|
||||
});
|
||||
return "Song updated successfully";
|
||||
} else {
|
||||
|
@ -58,6 +58,7 @@ export default function Page() {
|
||||
<table className="u-full-width">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Title</th>
|
||||
<th>Duration</th>
|
||||
</tr>
|
||||
@ -65,6 +66,7 @@ export default function Page() {
|
||||
<tbody>
|
||||
{album.songs.map((song: Song) => (
|
||||
<tr key={song.id}>
|
||||
<td>{song.trackNumber}</td>
|
||||
<td>{song.title}</td>
|
||||
<td>{TimeUtils.fancyTimeFormat(song.duration)}</td>
|
||||
</tr>
|
||||
|
@ -4,5 +4,6 @@ export interface Song {
|
||||
id: number;
|
||||
title: string;
|
||||
duration: number;
|
||||
trackNumber: number;
|
||||
album: Album;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user