diff --git a/back/src/org/kar/karusic/api/Front.java b/back/src/org/kar/karusic/api/Front.java index 2095637..f533d90 100644 --- a/back/src/org/kar/karusic/api/Front.java +++ b/back/src/org/kar/karusic/api/Front.java @@ -69,8 +69,8 @@ public class Front { // use this if I want to download the file: //response.header("Content-Disposition", "attachment; filename=" + fileName); CacheControl cc = new CacheControl(); - cc.setMaxAge(60); - cc.setNoCache(false); + cc.setMaxAge(1); + cc.setNoCache(true); response.cacheControl(cc); response.type(mineType); diff --git a/back/src/org/kar/karusic/api/TrackResource.java b/back/src/org/kar/karusic/api/TrackResource.java index 344817a..4d5a2a8 100644 --- a/back/src/org/kar/karusic/api/TrackResource.java +++ b/back/src/org/kar/karusic/api/TrackResource.java @@ -23,6 +23,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; +import java.util.ArrayList; import java.util.List; @Path("/track") @@ -228,7 +229,8 @@ public class TrackResource { trackElem.dataId = data.id; // Now list of artis has an internal management: if (artistElem != null) { - trackElem.artists = List.of(artistElem.id); + trackElem.artists = new ArrayList<>(); + trackElem.artists.add(artistElem.id); } trackElem = SqlWrapper.insert(trackElem); /* diff --git a/front/src/app/app-routing.module.ts b/front/src/app/app-routing.module.ts index 0578695..d35b749 100644 --- a/front/src/app/app-routing.module.ts +++ b/front/src/app/app-routing.module.ts @@ -8,8 +8,8 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; // CLI imports router import { SsoScene } from 'common/scene'; -import { HelpScene, HomeScene, AlbumEditScene, AlbumScene, ArtistEditScene, ArtistScene, SettingsScene, - GenderScene, PlaylistScene, TrackEditScene, TrackScene, UploadScene, ArtistsScene, ArtistAlbumScene } from './scene'; +import { HelpScene, HomeScene, AlbumEditScene, AlbumsScene, ArtistEditScene, ArtistScene, SettingsScene, + GenderScene, PlaylistScene, TrackEditScene, TrackScene, UploadScene, ArtistsScene, ArtistAlbumScene, AlbumScene } from './scene'; // import { HelpComponent } from './help/help.component'; @@ -64,10 +64,8 @@ const routes: Routes = [ // -- Album: // ------------------------------------ // display all Album - { path: 'album', component: AlbumScene }, - // display all album for a specific artist - // display all album for a specific gender - { path: 'album/:genderId/:artistId', component: AlbumScene }, + { path: 'album', component: AlbumsScene }, + { path: 'album/:albumId', component: AlbumScene }, { path: 'album-edit/:albumId', component: AlbumEditScene }, diff --git a/front/src/app/app.module.ts b/front/src/app/app.module.ts index 9a3eae4..47ce997 100644 --- a/front/src/app/app.module.ts +++ b/front/src/app/app.module.ts @@ -23,7 +23,7 @@ import { PopInDeleteConfirm } from '../common/popin/delete-confirm/delete-confir import { AppComponent } from './app.component'; import { ErrorComponent } from '../common/error/error'; -import { HomeScene, HelpScene, GenderScene, PlaylistScene, ArtistScene, AlbumScene, TrackScene, SettingsScene, +import { HomeScene, HelpScene, GenderScene, PlaylistScene, ArtistScene, AlbumScene, AlbumsScene, TrackScene, SettingsScene, TrackEditScene, AlbumEditScene, ArtistEditScene, ArtistsScene, ArtistAlbumScene } from './scene'; import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service'; import { BddService, CookiesService, HttpWrapperService, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service'; @@ -60,6 +60,7 @@ import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ArtistsScene, ArtistScene, AlbumScene, + AlbumsScene, TrackScene, SettingsScene, TrackEditScene, diff --git a/front/src/app/component/element-player-audio/element-player-audio.html b/front/src/app/component/element-player-audio/element-player-audio.html index ee4a79f..35ccd97 100644 --- a/front/src/app/component/element-player-audio/element-player-audio.html +++ b/front/src/app/component/element-player-audio/element-player-audio.html @@ -16,9 +16,6 @@
- - -
- + +
+
+ + + + + + + + + + +
- - - - - - - -
diff --git a/front/src/app/component/element-player-audio/element-player-audio.less b/front/src/app/component/element-player-audio/element-player-audio.less index 98bbcb9..991f9e1 100644 --- a/front/src/app/component/element-player-audio/element-player-audio.less +++ b/front/src/app/component/element-player-audio/element-player-audio.less @@ -28,7 +28,7 @@ //visibility: hidden; opacity: 0.5; width: 96%; - height: 60px; + height: 150px; border-radius: 10px; position: absolute; bottom: 20px; @@ -121,7 +121,7 @@ .slider { position: relative; -webkit-appearance: none; - width: 98%; + width: 100%; height: 10px; top: 5px; border-radius: 5px; @@ -149,14 +149,32 @@ background: #4CAF50; cursor: pointer; } + .timer-text { - position: absolute; - top: 25px; - left: 0px; - width: 100%; - line-height: 38px; - font-size: 30px; - font-weight:bold; + position: absolute; + //top: 25px; + left: 30px; + width: 100%; + //line-height: 38px; + font-size: 20px; + font-weight:bold; + } + .timer-control { + position: absolute; + //top: 25px; + left: 0px; + width: 100%; + //line-height: 38px; + font-size: 30px; + font-weight:bold; + bottom: 20px; + } + .label { + //transform: translate(-12px,-12px); + vertical-align: text-top; + line-height: 18px; + min-width: 50%; + //display: block, } } /* diff --git a/front/src/app/component/element-season/element-season.html b/front/src/app/component/element-season/element-season.html index b8bda5a..2ea5831 100644 --- a/front/src/app/component/element-season/element-season.html +++ b/front/src/app/component/element-season/element-season.html @@ -11,9 +11,31 @@
{{prefixName}} {{numberAlbum}}
-
- {{count}} Episodes +
+ No {{countSubType}}
-
- {{count}} Episode +
+ {{count}} {{countSubType}}s +
+
+ {{count}} {{countSubType}} +
+ +
+ No {{countSubType2}} +
+
+ {{count2}} {{countSubType2}}s +
+
+ {{count2}} {{countSubType2}} +
+ +
+ {{subValues}}: {{subValueData}} +
+ + +
+ {{description}}
diff --git a/front/src/app/component/element-season/element-season.ts b/front/src/app/component/element-season/element-season.ts index 10e6d67..e82df7a 100644 --- a/front/src/app/component/element-season/element-season.ts +++ b/front/src/app/component/element-season/element-season.ts @@ -18,10 +18,18 @@ export class ElementSeasonComponent implements OnInit { // input parameters @Input() element:NodeData; @Input() prefix:String; + @Input() countSubTypeCallBack: (arg0: number) => Promise; + @Input() countSubType: String; + @Input() countSubType2CallBack: (arg0: number) => Promise; + @Input() countSubType2: String; + @Input() subValuesCallBack: (arg0: number) => Promise; + @Input() subValues: String; prefixName: string = ""; numberAlbum: string; count: number; + count2: number; + subValueData: String; covers: string[]; description: string; @@ -32,6 +40,9 @@ export class ElementSeasonComponent implements OnInit { } ngOnInit() { this.prefix = this.prefixName??""; + this.count = undefined; + this.count2 = undefined; + if (isNullOrUndefined(this.element)) { this.numberAlbum = undefined; this.covers = undefined; @@ -41,11 +52,39 @@ export class ElementSeasonComponent implements OnInit { this.description = this.element.description; this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers); let self = this; - this.albumService.countTrack(this.element.id) - .then((response) => { - self.count = response; - }).catch((response) => { - self.count = null; - }); + if (!isNullOrUndefined(this.countSubTypeCallBack)) { + this.countSubTypeCallBack(this.element.id) + .then((response) => { + self.count = response; + //console.log(`get values: ${this.element.id} ==> ${self.count}`) + }).catch((response) => { + self.count = undefined; + }); + } + if (!isNullOrUndefined(this.countSubType2CallBack)) { + this.countSubType2CallBack(this.element.id) + .then((response) => { + self.count2 = response; + //console.log(`get values: ${this.element.id} ==> ${self.count}`) + }).catch((response) => { + self.count2 = undefined; + }); + } + if (!isNullOrUndefined(this.subValuesCallBack)) { + //console.log(`Value call back define ==> call values`) + this.subValuesCallBack(this.element.id) + .then((response: string[]) => { + this.subValueData = ""; + for (let kkk=0; kkk ${self.subValueData}`) + }).catch((response) => { + self.count2 = undefined; + }); + } } } \ No newline at end of file diff --git a/front/src/app/component/element-track/element-track.html b/front/src/app/component/element-track/element-track.html index fd5d845..da7dc1a 100644 --- a/front/src/app/component/element-track/element-track.html +++ b/front/src/app/component/element-track/element-track.html @@ -1,11 +1,8 @@
- {{prefixName}} {{numberAlbum}} + {{name}}
-
- {{count}} Episodes -
-
- {{count}} Episode +
+ n° {{track}}
\ No newline at end of file diff --git a/front/src/app/component/element-track/element-track.ts b/front/src/app/component/element-track/element-track.ts index 5585376..8ee6ac2 100644 --- a/front/src/app/component/element-track/element-track.ts +++ b/front/src/app/component/element-track/element-track.ts @@ -20,8 +20,8 @@ export class ElementTrackComponent implements OnInit { @Input() prefix:String; prefixName: string = ""; - numberAlbum: string; - count: number; + name: string; + track: number; covers: string[]; description: string; @@ -33,19 +33,14 @@ export class ElementTrackComponent implements OnInit { ngOnInit() { this.prefix = this.prefixName??""; if (isNullOrUndefined(this.element)) { - this.numberAlbum = undefined; + this.name = undefined; this.covers = undefined; this.description = undefined; } - this.numberAlbum = this.element.name; + this.name = this.element.name; this.description = this.element.description; + this.track = this.element["track"]; this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers); let self = this; - this.albumService.countTrack(this.element.id) - .then((response) => { - self.count = response; - }).catch((response) => { - self.count = null; - }); } } \ No newline at end of file diff --git a/front/src/app/scene/album/album.html b/front/src/app/scene/album/album.html index 1e5e5a5..bf5985e 100644 --- a/front/src/app/scene/album/album.html +++ b/front/src/app/scene/album/album.html @@ -1,29 +1,40 @@
-
- +
+
-
-
- {{artistName}} +
+
+ {{name}}
-
- Album {{name}} +
+ {{albumName}}
-
- {{description}} +
+ {{albumDescription}}
+
+ {{albumDescription}} +
+ +
-
+
Tracks:
Track:
-
- -
-
+
+
\ No newline at end of file diff --git a/front/src/app/scene/album/album.less b/front/src/app/scene/album/album.less deleted file mode 100644 index 8b13789..0000000 --- a/front/src/app/scene/album/album.less +++ /dev/null @@ -1 +0,0 @@ - diff --git a/front/src/app/scene/album/album.ts b/front/src/app/scene/album/album.ts index 0c3ab5d..36532c7 100644 --- a/front/src/app/scene/album/album.ts +++ b/front/src/app/scene/album/album.ts @@ -4,86 +4,122 @@ * @license PROPRIETARY (see license file) */ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -import { AlbumService, DataService, ArtistService, ArianeService } from 'app/service'; - -@Component({ - selector: 'app-album', - templateUrl: './album.html', - styleUrls: [ './album.less' ] -}) -export class AlbumScene implements OnInit { - name: string = ''; - artistName: string = ''; - description: string = ''; - artistId: number = null; - cover: string = ''; - covers: Array = []; - idAlbum = -1; - tracksError = ''; - tracks = []; - constructor( - private route: ActivatedRoute, - private albumService: AlbumService, - private artistService: ArtistService, - private arianeService: ArianeService, - private dataService: DataService) { - - } - - ngOnInit() { - console.log('ngOnInit(AlbumComponent)'); - this.arianeService.updateManual(this.route.snapshot.paramMap); - this.idAlbum = this.arianeService.getAlbumId(); - - let self = this; - this.albumService.get(this.idAlbum) - .then((response:any) => { - console.log("Get element ! " + JSON.stringify(response)); - self.name = response.name; - self.artistId = response.parentId; - self.description = response.description; - if(response.covers === undefined || response.covers === null || response.covers.length === 0) { - self.cover = null; - self.covers = []; - } else { - self.cover = self.dataService.getCoverUrl(response.covers[0]); - for(let iii = 0; iii < response.covers.length; iii++) { - self.covers.push(self.dataService.getCoverUrl(response.covers[iii])); - } - } - self.artistService.get(self.artistId) - .then((response2:any) => { - self.artistName = response2.name; - }).catch((response2:any) => { - self.artistName = ''; - }); - }).catch((response3:any) => { - self.description = ''; - self.name = '???'; - self.artistName = ''; - self.artistId = null; - self.cover = null; - self.covers = []; - }); - console.log(`get parameter id: ${ this.idAlbum}`); - this.albumService.getTrack(this.idAlbum) - .then((response4:any) => { - self.tracksError = ''; - self.tracks = response4; - }).catch((response5:any) => { - self.tracksError = 'Can not get the List of track without album'; - self.tracks = []; - }); - } - - onSelectTrack(event: any, idSelected: number):void { - if (event.ctrlKey === false) { - this.arianeService.navigateTrack({ trackId: idSelected, newWindows:event.which === 2} ); - } else { - this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} ); + import { Component, OnInit } from '@angular/core'; + import { ActivatedRoute } from '@angular/router'; + import { Media } from 'app/model'; + import { AlbumModel, isAlbumModel } from 'app/model/album'; + + import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; + import { NodeData } from 'common/model'; + + @Component({ + selector: 'app-album', + templateUrl: './album.html' + }) + + export class AlbumScene implements OnInit { + public idArtist = -1; + public idAlbum = -1; + public name: string = ''; + public description: string = undefined; + public covers: Array = undefined; + public albumName: string = ''; + public albumDescription: string = undefined; + public albumCovers: string[] = undefined; + + public tracksIds: number[] = undefined; + public tracks: Media[] = undefined; + + constructor( + private route: ActivatedRoute, + private artistService: ArtistService, + private albumService: AlbumService, + private trackService: TrackService, + private arianeService: ArianeService, + private playerService: PlayerService, + private dataService: DataService) { + + } + + ngOnInit() { + this.arianeService.updateManual(this.route.snapshot.paramMap); + // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); + // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); + this.idArtist = this.arianeService.getArtistId(); + this.idAlbum = this.arianeService.getAlbumId(); + let self = this; + this.artistService.get(this.idArtist) + .then((response) => { + self.name = response.name; + self.description = response.description; + self.covers = this.dataService.getCoverListUrl(response.covers); + }).catch((response) => { + self.description = undefined; + self.name = '???'; + self.covers = undefined; + // no check just ==> an error occured on album + }); + this.albumService.get(this.idAlbum) + .then((response) => { + self.albumName = response.name; + self.albumDescription = response.description; + self.albumCovers = this.dataService.getCoverListUrl(response.covers); + }).catch((response) => { + self.albumDescription = undefined; + self.albumName = '???'; + self.albumCovers = undefined; + // no check just ==> an error occured on album + }); + + //console.log("all the tracks: " + self.tracksIds); + this.trackService.getWithAlbum(self.idAlbum) + .then((response2: Media[]) => { + self.tracks = response2; + console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`); + }).catch((response) => { + //console.log(`>>>>BBB plop`); + self.tracks = undefined; + }); + } + + onSelectTrack(event: any, idSelected: number):void { + if (event.ctrlKey === false) { + //this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} ); + // TODO: add on global player ... + //this.playerService.play(idSelected); + + let elements: number[] = []; + let valuePlayed: number = undefined; + for (let iii=0; iii< this.tracks.length; iii++) { + elements.push(this.tracks[iii].id); + console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`); + if (this.tracks[iii].id == idSelected) { + console.log(` ==> find`); + valuePlayed = iii; + } + } + this.playerService.playInList(valuePlayed, elements); + + } else { + this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} ); + } + } + playAll(event: any):void { + let elements: number[] = []; + for (let iii=0; iii< this.tracks.length; iii++) { + elements.push(this.tracks[iii].id); } - } -} + this.playerService.clear(); + this.playerService.setNewPlaylist(elements); + } + playShuffe(event: any):void { + let elements: number[] = []; + for (let iii=0; iii< this.tracks.length; iii++) { + elements.push(this.tracks[iii].id); + } + this.playerService.clear(); + this.playerService.setNewPlaylistShuffle(elements); + } + } + + \ No newline at end of file diff --git a/front/src/app/scene/album/albums.html b/front/src/app/scene/album/albums.html new file mode 100644 index 0000000..aac4bd5 --- /dev/null +++ b/front/src/app/scene/album/albums.html @@ -0,0 +1,42 @@ +
+
+
+
+ +
+
+
+
+ {{name}} +
+
+ {{description}} +
+
+
+
+
+
Albums:
+
Album:
+
+ +
+
+
+
+
Tracks:
+
Track:
+
+ +
+
+
+
\ No newline at end of file diff --git a/front/src/app/scene/album/albums.ts b/front/src/app/scene/album/albums.ts new file mode 100644 index 0000000..f5394f1 --- /dev/null +++ b/front/src/app/scene/album/albums.ts @@ -0,0 +1,93 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2018, Edouard DUPIN, all right reserved + * @license PROPRIETARY (see license file) + */ + + import { Component, OnInit } from '@angular/core'; + import { ActivatedRoute } from '@angular/router'; + + import { ArtistService, DataService, ArianeService, AlbumService } from 'app/service'; + import { NodeData } from 'common/model'; + import { isNullOrUndefined } from 'common/utils'; + + @Component({ + selector: 'app-albums', + templateUrl: './albums.html' + }) + + export class AlbumsScene implements OnInit { + public name: string = ''; + public description: string = undefined; + public covers: string[] = undefined; + public albums: NodeData[] = undefined; + public tracks: any[] = undefined; + public countSubElement: number = undefined; + countTrack: (id: number) => Promise; + getArtistsString: (id: number) => Promise; + + constructor( + private route: ActivatedRoute, + private albumService: AlbumService, + private artistService: ArtistService, + private arianeService: ArianeService, + private dataService: DataService) { + + } + + countTrackCallback(albumId: number) : Promise { + return this.albumService.countTrack(albumId); + } + + getArtistsStringCallback(albumId: number) : Promise { + console.log(`request all artist for album: {albumId}`) + return this.albumService.getArtists(albumId); + } + ngOnInit() { + this.getArtistsString = (id:number) => {return self.getArtistsStringCallback(id);}; + this.countTrack = (id:number) => {return self.countTrackCallback(id);}; + this.arianeService.updateManual(this.route.snapshot.paramMap); + let self = this; + self.name = "All Albums"; + self.description = "View all albums (no specific artist)"; + + //console.log(`get parameter id: ${ this.idArtist}`); + this.albumService.getOrder() + .then((response: NodeData[]) => { + //console.log(`>>>> get album : ${JSON.stringify(response)}`) + self.albums = response; + }).catch((response) => { + self.albums = undefined; + }); + // TODO later: get all orfan tracks ... + /* + this.artistService.getTrack(this.idArtist) + .then((response: NodeData[]) => { + //console.log(`>>>> get track : ${JSON.stringify(response)}`) + self.tracks = response; + }).catch((response) => { + self.tracks = undefined; + }); + */ + } + + + + onSelectAlbum(event: any, idSelected: number):void { + if (event.ctrlKey) { + this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 } ); + } else { + this.arianeService.navigateAlbum({albumId: idSelected, newWindows: event.which === 2 } ); + } + } + + onSelectTrack(event: any, idSelected: number):void { + if (event.ctrlKey) { + this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} ); + } else { + this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} ); + } + } + } + + \ No newline at end of file diff --git a/front/src/app/scene/artist-edit/artist-edit.ts b/front/src/app/scene/artist-edit/artist-edit.ts index afd6108..1566c44 100644 --- a/front/src/app/scene/artist-edit/artist-edit.ts +++ b/front/src/app/scene/artist-edit/artist-edit.ts @@ -122,7 +122,7 @@ export class ArtistEditScene implements OnInit { }).catch((response) => { self.albumsCount = '---'; }); - this.artistService.getTrack(this.idArtist) + this.artistService.getAllTracks(this.idArtist) .then((response) => { self.trackCount = "" + response.length; }).catch((response) => { diff --git a/front/src/app/scene/artist/artist-album.html b/front/src/app/scene/artist/artist-album.html index 62d5ef9..10e168b 100644 --- a/front/src/app/scene/artist/artist-album.html +++ b/front/src/app/scene/artist/artist-album.html @@ -15,6 +15,12 @@
{{albumDescription}}
+ +
@@ -27,5 +33,5 @@ (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
-
+
\ No newline at end of file diff --git a/front/src/app/scene/artist/artist-album.ts b/front/src/app/scene/artist/artist-album.ts index 463d8b8..79a82b5 100644 --- a/front/src/app/scene/artist/artist-album.ts +++ b/front/src/app/scene/artist/artist-album.ts @@ -104,5 +104,20 @@ export class ArtistAlbumScene implements OnInit { this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} ); } } + playAll(event: any):void { + let elements: number[] = []; + for (let iii=0; iii< this.tracks.length; iii++) { + elements.push(this.tracks[iii].id); + } + this.playerService.clear(); + this.playerService.setNewPlaylist(elements); + } + playShuffe(event: any):void { + let elements: number[] = []; + for (let iii=0; iii< this.tracks.length; iii++) { + elements.push(this.tracks[iii].id); + } + this.playerService.clear(); + this.playerService.setNewPlaylistShuffle(elements); + } } - diff --git a/front/src/app/scene/artist/artist.html b/front/src/app/scene/artist/artist.html index 144d983..27774c0 100644 --- a/front/src/app/scene/artist/artist.html +++ b/front/src/app/scene/artist/artist.html @@ -12,6 +12,12 @@
{{description}}
+ +
@@ -19,7 +25,11 @@
Albums:
Album:
- +
@@ -27,8 +37,10 @@
Tracks:
Track:
- +
-
+
\ No newline at end of file diff --git a/front/src/app/scene/artist/artist.ts b/front/src/app/scene/artist/artist.ts index 0ff58c6..8767e30 100644 --- a/front/src/app/scene/artist/artist.ts +++ b/front/src/app/scene/artist/artist.ts @@ -7,7 +7,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ArtistService, DataService, ArianeService } from 'app/service'; +import { ArtistService, DataService, ArianeService, AlbumService, PlayerService } from 'app/service'; import { NodeData } from 'common/model'; import { isNullOrUndefined } from 'common/utils'; @@ -23,16 +23,25 @@ export class ArtistScene implements OnInit { public covers: string[] = undefined; public albums: NodeData[] = undefined; public tracks: any[] = undefined; + public countSubElement: number = undefined; + countTrack: (id: number) => Promise; constructor( private route: ActivatedRoute, + private albumService: AlbumService, private artistService: ArtistService, + private playerService: PlayerService, private arianeService: ArianeService, private dataService: DataService) { } + + countTrackCallback(albumId: number) : Promise { + return this.albumService.countTrack(albumId); + } ngOnInit() { + this.countTrack = (id:number) => {return self.countTrackCallback(id);}; this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); @@ -68,6 +77,9 @@ export class ArtistScene implements OnInit { }); */ } + + + onSelectAlbum(event: any, idSelected: number):void { if (event.ctrlKey) { this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 } ); @@ -83,5 +95,36 @@ export class ArtistScene implements OnInit { this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} ); } } + + getAllTracksIds(): Promise { + let elements: number[] = []; + for (let iii=0; iii< this.albums.length; iii++) { + elements.push(this.albums[iii].id); + } + return this.albumService.getAllTracksForAlbums(elements); + } + + playAll(event: any):void { + this.playerService.clear(); + let self = this; + this.getAllTracksIds() + .then((response: number[]) => { + self.playerService.setNewPlaylist(response); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } + playShuffe(event: any):void { + this.playerService.clear(); + let self = this; + this.getAllTracksIds() + .then((response: number[]) => { + self.playerService.setNewPlaylistShuffle(response); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } } diff --git a/front/src/app/scene/artist/artists.html b/front/src/app/scene/artist/artists.html index d1376fa..92cc00e 100644 --- a/front/src/app/scene/artist/artists.html +++ b/front/src/app/scene/artist/artists.html @@ -1,11 +1,17 @@
-
Artits:
+
Artists:
Artist:
- +
-
+
\ No newline at end of file diff --git a/front/src/app/scene/artist/artists.ts b/front/src/app/scene/artist/artists.ts index 77fa5ca..9fd9526 100644 --- a/front/src/app/scene/artist/artists.ts +++ b/front/src/app/scene/artist/artists.ts @@ -7,7 +7,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ArtistService, DataService, ArianeService } from 'app/service'; +import { ArtistService, DataService, ArianeService, AlbumService } from 'app/service'; import { NodeData } from 'common/model'; import { isNullOrUndefined } from 'common/utils'; @@ -20,19 +20,24 @@ export class ArtistsScene implements OnInit { cover: string = ''; covers: Array = []; artists: NodeData[]; + countTrack: (id: number) => Promise; + countAlbum: (id: number) => Promise; constructor( private route: ActivatedRoute, private artistService: ArtistService, + private albumService: AlbumService, private arianeService: ArianeService) { } ngOnInit() { + let self = this; + this.countTrack = (id:number) => {return self.countTrackCallback(id);}; + this.countAlbum = (id:number) => {return self.countAlbumCallback(id);}; this.arianeService.updateManual(this.route.snapshot.paramMap); // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); - let self = this; this.artistService.getOrder() .then((response: NodeData[]) => { self.artists = response; @@ -49,5 +54,11 @@ export class ArtistsScene implements OnInit { } } + countTrackCallback(artistId: number) : Promise { + return this.artistService.countTrack(artistId); + } + countAlbumCallback(artistId: number) : Promise { + return this.artistService.countAlbum(artistId); + } } diff --git a/front/src/app/scene/index.ts b/front/src/app/scene/index.ts index 1197113..f28fb74 100644 --- a/front/src/app/scene/index.ts +++ b/front/src/app/scene/index.ts @@ -3,6 +3,7 @@ import { HelpScene } from "./help/help"; import { HomeScene } from "./home/home"; import { AlbumEditScene } from "./album-edit/album-edit"; import { AlbumScene } from "./album/album"; +import { AlbumsScene } from "./album/albums"; import { ArtistEditScene } from "./artist-edit/artist-edit"; import { ArtistScene } from "./artist/artist"; import { ArtistsScene } from "./artist/artists"; @@ -19,6 +20,7 @@ export { HomeScene, SettingsScene, AlbumScene, + AlbumsScene, AlbumEditScene, ArtistsScene, ArtistScene, diff --git a/front/src/app/scene/upload/upload.ts b/front/src/app/scene/upload/upload.ts index 3fcc0e2..4c5f653 100644 --- a/front/src/app/scene/upload/upload.ts +++ b/front/src/app/scene/upload/upload.ts @@ -521,7 +521,7 @@ export class UploadScene implements OnInit { // no album check only the artist files. if(isNullOrUndefined(this.globalAlbum)) { console.error(`NO ALBUM ==> check artist ID...`); - self.artistService.getTrack(self.artistId) + self.artistService.getAllTracks(self.artistId) .then((response: any[]) => { self.listFileInBdd = response; console.error(`find track: ${JSON.stringify(response, null, 2)}`); diff --git a/front/src/app/service/album.ts b/front/src/app/service/album.ts index 793d2fc..0620435 100644 --- a/front/src/app/service/album.ts +++ b/front/src/app/service/album.ts @@ -19,13 +19,34 @@ export class AlbumService extends GenericInterfaceModelDB { bdd: BddService) { super('album', http, bdd); } + getAllTracksForAlbums(idAlbums: number[]): Promise { + let self = this; + return new Promise((resolve, reject) => { + self.bdd.get('track') + .then((response: DataInterface) => { + let data = response.getsWhere([ + { + check: TypeCheck.EQUAL, + key: 'albumId', + value: idAlbums, + }, + ], + [ 'name' ]); // tODO : set the Id in the track ... + // filter with artist- ID !!! + const listId = DataInterface.extractLimitOne(data, "id"); + resolve(listId); + }).catch((response) => { + reject(response); + }); + }); + } /** * Get all the track for a specific album * @param idAlbum - Id of the album. * @returns a promise on the list of track elements */ - getTrack(idAlbum:number): Promise { + getTrack(idAlbum:number): Promise { let self = this; return new Promise((resolve, reject) => { self.bdd.get('track') @@ -44,13 +65,12 @@ export class AlbumService extends GenericInterfaceModelDB { }); }); } - /** - * Get the number of track in this saison ID - * @param id - Id of the album. - * @returns The number of element present in this saison + * Get all the artists for a specific album + * @param idAlbum - Id of the album. + * @returns a promise on the list of Artist names for this album */ - countTrack(id:number): Promise { + getArtists(idAlbum:number): Promise { let self = this; return new Promise((resolve, reject) => { self.bdd.get('track') @@ -59,7 +79,49 @@ export class AlbumService extends GenericInterfaceModelDB { { check: TypeCheck.EQUAL, key: 'albumId', - value: id, + value: idAlbum, + }, + ], + [ 'name' ]); + // filter with artist- ID !!! + const listArtistId = DataInterface.extractLimitOneList(data, "artists"); + //console.log(`${idAlbum} ==> List Of ids: ${JSON.stringify(listArtistId, null, 2)} `); + self.bdd.get('artist') + .then((response:DataInterface) => { + let dataArtist = response.getsWhere([ + { + check: TypeCheck.EQUAL, + key: 'id', + value: listArtistId, + }, + ], [ 'name']); + const listArtistNames = DataInterface.extractLimitOne(dataArtist, "name"); + resolve(listArtistNames); + return; + }).catch((response) => { + reject(response); + }); + }).catch((response) => { + reject(response); + }); + }); + } + + /** + * Get the number of track in this saison ID + * @param AlbumId - Id of the album. + * @returns The number of element present in this saison + */ + countTrack(AlbumId:number): Promise { + let self = this; + return new Promise((resolve, reject) => { + self.bdd.get('track') + .then((response: DataInterface) => { + let data = response.getsWhere([ + { + check: TypeCheck.EQUAL, + key: 'albumId', + value: AlbumId, }, ]); resolve(data.length); diff --git a/front/src/app/service/ariane.ts b/front/src/app/service/ariane.ts index 971fa08..5adb07d 100644 --- a/front/src/app/service/ariane.ts +++ b/front/src/app/service/ariane.ts @@ -370,8 +370,8 @@ export class ArianeService { this.genericNavigateEdit('gender', id, newWindows); } - navigateAlbum({ genderId, artistId, newWindows }: { genderId?: number; artistId?: number; newWindows?: boolean; }):void { - this.genericNavigate('album', [ genderId, artistId ], newWindows); + navigateAlbum({ albumId, newWindows }: { albumId?: number; newWindows?: boolean; }):void { + this.genericNavigate('album', [ albumId ], newWindows); } navigateAlbumEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void { this.genericNavigateEdit('album', id, newWindows); diff --git a/front/src/app/service/artist.ts b/front/src/app/service/artist.ts index 4083d1e..2b2ac2e 100644 --- a/front/src/app/service/artist.ts +++ b/front/src/app/service/artist.ts @@ -27,15 +27,15 @@ export class ArtistService extends GenericInterfaceModelDB { * @param idArtist - Id of the artist. * @returns a promise on the list of track elements */ - getTrack(idArtist:number): Promise { + getTrackNoAlbum(idArtist:number): Promise { let self = this; return new Promise((resolve, reject) => { self.bdd.get('track') .then((response: DataInterface) => { let data = response.getsWhere([ { - check: TypeCheck.EQUAL, - key: 'artistId', + check: TypeCheck.CONTAINS, + key: 'artists', value: idArtist, }, { check: TypeCheck.EQUAL, @@ -43,7 +43,31 @@ export class ArtistService extends GenericInterfaceModelDB { value: undefined, }, ], - [ 'episode', 'name' ]); + [ 'track', 'name' ]); + resolve(data); + }).catch((response) => { + reject(response); + }); + }); + } + /** + * Get all the track for a specific artist + * @param idArtist - Id of the artist. + * @returns a promise on the list of track elements + */ + getAllTracks(idArtist:number): Promise { + let self = this; + return new Promise((resolve, reject) => { + self.bdd.get('track') + .then((response: DataInterface) => { + let data = response.getsWhere([ + { + check: TypeCheck.CONTAINS, + key: 'artists', + value: idArtist, + } + ], + [ 'track', 'name' ]); resolve(data); }).catch((response) => { reject(response); @@ -56,16 +80,16 @@ export class ArtistService extends GenericInterfaceModelDB { * @param id - Id of the artist. * @returns The number of track present in this artist */ - countTrack(id:number): Promise { + countTrack(artistId:number): Promise { let self = this; return new Promise((resolve, reject) => { self.bdd.get('track') .then((response:DataInterface) => { let data = response.getsWhere([ { - check: TypeCheck.EQUAL, - key: 'artistId', - value: id, + check: TypeCheck.CONTAINS, + key: 'artists', + value: artistId, }, ]); resolve(data.length); @@ -93,10 +117,10 @@ export class ArtistService extends GenericInterfaceModelDB { value: idArtist, }, ], [ 'id' ]); - console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2)); + //console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2)); // extract a single time all value "id" in an array const listAlbumId = DataInterface.extractLimitOne(data, "albumId"); - console.log("==> List Of ids: " + JSON.stringify(listAlbumId, null, 2)); + //console.log("==> List Of ids: " + JSON.stringify(listAlbumId, null, 2)); self.bdd.get('album') .then((response:DataInterface) => { let dataAlbum = response.getsWhere([ @@ -107,7 +131,7 @@ export class ArtistService extends GenericInterfaceModelDB { }, ], [ 'publication', 'name', 'id' ]); resolve(dataAlbum); - console.log("==> get all albums: " + JSON.stringify(dataAlbum, null, 2)); + //console.log("==> get all albums: " + JSON.stringify(dataAlbum, null, 2)); return; }).catch((response) => { reject(response); @@ -118,6 +142,28 @@ export class ArtistService extends GenericInterfaceModelDB { }); }); } + countAlbum(idArtist:number): Promise { + let self = this; + return new Promise((resolve, reject) => { + self.bdd.get('track') + .then((response:DataInterface) => { + console.log(" <<<========================================>>> " + idArtist); + let data = response.getsWhere([ + { + check: TypeCheck.CONTAINS, //< this is for array containing + key: 'artists', + value: idArtist, + }, + ], [ 'id' ]); + //console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2)); + // extract a single time all value "id" in an array + const listAlbumId = DataInterface.extractLimitOne(data, "albumId"); + resolve(listAlbumId.length); + }).catch((response) => { + reject(response); + }); + }); + } } diff --git a/front/src/common/service/bdd.ts b/front/src/common/service/bdd.ts index 78a3f3f..a608f49 100644 --- a/front/src/common/service/bdd.ts +++ b/front/src/common/service/bdd.ts @@ -68,13 +68,13 @@ export class BddService { get(name: string): Promise { let self = this; - console.log(`Try to get DB '${ name }'`); + //console.log(`Try to get DB '${ name }'`); if( !isNullOrUndefined(this.bdd[name]) ) { return new Promise((resolve, reject) => { resolve(self.bdd[name]); }); } - console.log(`get DB: ?? ${ name } ??`); + //console.log(`get DB: ?? ${ name } ??`); if(isNullOrUndefined(this.bddPomise[name])) { this.bddPomise[name] = []; // Try to load Local Data (storage) @@ -83,31 +83,31 @@ export class BddService { localStorage.getItem(this.baseLocalStorageName + name); } if(retriveBDDString !== null) { - console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`); + //console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`); let retriveBDD = JSON.parse(retriveBDDString); - console.log(`retrive local bdd (${ name })= ${ retriveBDD}`); + //console.log(`retrive local bdd (${ name })= ${ retriveBDD}`); let retriveBDDTmp = new DataInterface(name, retriveBDD); self.bdd[name] = retriveBDDTmp; for(let iii = 0; iii < self.bddPomise[name].length; iii++) { self.bddPomise[name][iii].resolve(self.bdd[name]); } // brut force update of the BDD : TODO optimise it later ... - console.log(`Update BDD (${ name })`); + //console.log(`Update BDD (${ name })`); self.http.getSpecific(name) .then((response) => { - console.log(`end download DB: ==> ${ name } ${ response.length}`); + //console.log(`end download DB: ==> ${ name } ${ response.length}`); self.bdd[name] = new DataInterface(name, response); localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd)); }).catch((response) => { console.log(`[E] ${ self.constructor.name }: cant not get data from remote server: ${ name}`); }); } else { - console.log(`Download BDD (${ name })`); + //console.log(`Download BDD (${ name })`); return new Promise((resolve, reject) => { self.http.getSpecific(name) .then((response) => { - console.log(`end download DB: ==> ${ name } ${ response.length}`);// + " " + JSON.stringify(response).length); + //console.log(`end download DB: ==> ${ name } ${ response.length}`);// + " " + JSON.stringify(response).length); self.bdd[name] = new DataInterface(name, response); if(self.useLocalStorage === true) { localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd)); diff --git a/front/src/common/utils/dataInterface.ts b/front/src/common/utils/dataInterface.ts index 25a3442..b682468 100644 --- a/front/src/common/utils/dataInterface.ts +++ b/front/src/common/utils/dataInterface.ts @@ -41,6 +41,17 @@ export class DataInterface { } return out; } + static extractLimitOneList(data: NodeData[], key: string): any[] { + const out = []; + for (let iii=0; iii