From d330d623d94778f900e2dd01cec50a7c1cad87ee Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 11 Aug 2022 23:10:19 +0200 Subject: [PATCH] better interface --- .../org/kar/karusic/api/AlbumResource.java | 2 +- .../element-player-audio.html | 22 +- .../element-player-audio.less | 199 ++--------- .../element-player-audio.ts | 120 ++++--- front/src/app/component/top-menu/top-menu.ts | 2 +- front/src/app/model/media.ts | 20 +- .../src/app/scene/album-edit/album-edit.html | 24 +- front/src/app/scene/album-edit/album-edit.ts | 16 +- front/src/app/scene/album/albums.html | 6 + front/src/app/scene/album/albums.ts | 34 +- front/src/app/scene/artist/artist-album.html | 1 + front/src/app/scene/artist/artists.html | 21 ++ front/src/app/scene/artist/artists.ts | 36 +- .../src/app/scene/track-edit/track-edit.html | 101 ++---- .../src/app/scene/track-edit/track-edit.less | 0 front/src/app/scene/track-edit/track-edit.ts | 320 +++++------------- front/src/app/scene/track/track.ts | 12 +- .../app/service/GenericInterfaceModelDB.ts | 6 + front/src/app/service/gender.ts | 1 + front/src/common/service/bdd.ts | 18 + front/src/common/utils/dataInterface.ts | 4 + 21 files changed, 365 insertions(+), 600 deletions(-) delete mode 100644 front/src/app/scene/track-edit/track-edit.less diff --git a/back/src/org/kar/karusic/api/AlbumResource.java b/back/src/org/kar/karusic/api/AlbumResource.java index 1a2487b..e69f920 100644 --- a/back/src/org/kar/karusic/api/AlbumResource.java +++ b/back/src/org/kar/karusic/api/AlbumResource.java @@ -35,7 +35,7 @@ public class AlbumResource { @POST @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) - public Album put(String jsonRequest) throws Exception { + public Album post(String jsonRequest) throws Exception { return SqlWrapper.insertWithJson(Album.class, jsonRequest); } 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 35ccd97..1c6aae2 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 @@ -1,7 +1,7 @@
- +
-
+
+ +
+
{{playMode}} -
- -
-
-
- -
- - -
-
\ No newline at end of file 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 991f9e1..df9f42a 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 @@ -1,32 +1,8 @@ .bottom { - /* - position: fixed; - - bottom:0px; - left:0px; - - display: block; - overflow: visible; - - box-shadow: none; - min-height: 56px; - flex-direction: column; - flex-wrap: nowrap; - justify-content: flex-start; - box-sizing: border-box; - flex-shrink: 0; - width: 100%; - margin: 0; - padding: 0 12px 0 12px; - border: none; - max-height: 1000px; - z-index: 3; - box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.6); - */ .controls { //visibility: hidden; - opacity: 0.5; + opacity: 0.85; width: 96%; height: 150px; border-radius: 10px; @@ -55,60 +31,6 @@ } } - .bigPause { - position: fixed; - top: 120px; - left: 40%; - width: 20%; - height: calc(90% - 120px*2); - border: none; - box-shadow: none; - cursor: pointer; - .material-icons { - color: #FFF; - font-size: 120px; - color: green; - } - &:focus { - outline: none; - } - opacity: 95%; - } - .bigRewind { - position: fixed; - top: 120px; - left: 20%; - width: 20%; - height: calc(90% - 120px*2); - border: none; - .material-icons { - color: #FFF; - font-size: 120px; - color: red; - } - &:focus { - outline: none; - } - opacity: 95%; - } - .bigForward { - position: fixed; - top: 120px; - left: 60%; - width: 20%; - height: calc(90% - 120px*2); - border: none; - .material-icons { - color: #FFF; - font-size: 120px; - color: blue; - } - &:focus { - outline: none; - } - opacity: 95%; - } - .slidecontainer { line-height: 38px; font-size: 10px; @@ -121,7 +43,8 @@ .slider { position: relative; -webkit-appearance: none; - width: 100%; + //width: calc(100% - 60px); + width: 95%; height: 10px; top: 5px; border-radius: 5px; @@ -150,15 +73,30 @@ cursor: pointer; } + .timer-title { + position: absolute; + left: 30px; + width: 100%; + font-size: 20px; + font-weight:bold; + bottom: 104px; + } + .timer-lines { + position: absolute; + left: 30px; + //width: calc(100%-60px); + font-size: 20px; + font-weight:bold; + bottom: 82px; + } .timer-text { position: absolute; - //top: 25px; - left: 30px; - width: 100%; - //line-height: 38px; - font-size: 20px; - font-weight:bold; - } + left: 30px; + width: 100%; + font-size: 20px; + font-weight:bold; + bottom: 40px; + } .timer-control { position: absolute; //top: 25px; @@ -167,7 +105,7 @@ //line-height: 38px; font-size: 30px; font-weight:bold; - bottom: 20px; + bottom: 0px; } .label { //transform: translate(-12px,-12px); @@ -218,89 +156,4 @@ } - .volume-menu { - font-size: 40px; - opacity: 0.5; - width: 300px; - height: 60px; - border-radius: 10px; - position: absolute; - bottom: 90px; - right: 2%; - //margin-left: -200px; - background-color: black; - box-shadow: 3px 3px 5px black; - transition: 1s all; - display: flex; - - .material-icons { - vertical-align: middle; - color: #FFF; - font-size: 40px; - } - /* Create an Arraw on the top ob the box ... */ - &:after, &:before { - bottom: 100%; - right: 13px; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - } - - &:after { - border-color: rgba(136, 183, 213, 0); - border-bottom-color: #263238; - border-width: 15px; - margin-left: -15px; - } - button { - border: none; - background: none; - border-radius: 50%; - } - .slidecontainer { - line-height: 38px; - font-size: 10px; - font-family: monospace; - text-shadow: 1px 1px 0px black; - color: white; - flex: 5; - position: relative; - } - .slider { - position: relative; - -webkit-appearance: none; - width: 98%; - height: 10px; - top: 15px; - border-radius: 5px; - background: #d3d3d3; - outline: none; - opacity: 0.7; - -webkit-transition: .2s; - transition: opacity .2s; - flex: 5; - } - .slider::-webkit-slider-thumb { - -webkit-appearance: none; - appearance: none; - width: 25px; - height: 25px; - border-radius: 50%; - background: #4CAF50; - cursor: pointer; - } - - .slider::-moz-range-thumb { - width: 25px; - height: 25px; - border-radius: 50%; - background: #4CAF50; - cursor: pointer; - } - - } } diff --git a/front/src/app/component/element-player-audio/element-player-audio.ts b/front/src/app/component/element-player-audio/element-player-audio.ts index 7d8cd0f..97b22a6 100644 --- a/front/src/app/component/element-player-audio/element-player-audio.ts +++ b/front/src/app/component/element-player-audio/element-player-audio.ts @@ -4,10 +4,10 @@ * @license PROPRIETARY (see license file) */ import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core'; -import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils'; +import { isArray, isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils'; import { NodeData } from 'common/model'; -import { GenderService, DataService, PlayerService, TrackService } from 'app/service'; +import { GenderService, DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service'; import { PlaylistCurrent } from 'app/service/player'; import { Media } from 'app/model'; import { HttpWrapperService } from 'common/service'; @@ -27,7 +27,7 @@ export enum PlayMode { styleUrls: [ './element-player-audio.less' ] }) export class ElementPlayerAudioComponent implements OnInit { - mediaPlayer: HTMLVideoElement; + mediaPlayer: HTMLAudioElement; duration: number; durationDisplay: string; @ViewChild('mediaPlayer') @@ -48,6 +48,7 @@ export class ElementPlayerAudioComponent implements OnInit { public volume_value: number = 100; public volume_displayMenu: boolean = false; + nameData: string; playStream: boolean; isPlaying: boolean; currentTime: any; @@ -69,12 +70,14 @@ export class ElementPlayerAudioComponent implements OnInit { constructor( private playerService: PlayerService, private trackService: TrackService, + private albumService: AlbumService, + private artistService: ArtistService, private httpService: HttpWrapperService, private dataService: DataService) { // nothing to do... } - private currentLMedia: Media = undefined; - private localIdStreaming: number = undefined; + private currentLMedia: Media; + private localIdStreaming: number; private localListStreaming: number[] = []; ngOnInit() { /* @@ -101,7 +104,22 @@ export class ElementPlayerAudioComponent implements OnInit { this.trackService.get(this.localListStreaming[this.localIdStreaming]) .then((response: Media) => { //console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`); - this.currentLMedia = response; + self.currentLMedia = response; + self.nameData = response.name; + if (!isNullOrUndefined(response.albumId)) { + this.albumService.get(response.albumId) + .then((response2: NodeData) => { + self.nameData = response2.name + " - " + self.nameData; + }) + .catch(() => {}); + } + if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) { + this.artistService.get(response.artists[0]) + .then((response2: NodeData) => { + self.nameData = self.nameData + " (" + response2.name + ")"; + }) + .catch(() => {}); + } if (isNullOrUndefined(self.currentLMedia)) { console.log("Can not retreive the media ...") return; @@ -304,9 +322,6 @@ export class ElementPlayerAudioComponent implements OnInit { this.onNext(); } } - - - } changeStateToPlay() { @@ -355,23 +370,21 @@ export class ElementPlayerAudioComponent implements OnInit { onPlay() { console.log('play'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } + this.lockPlayerEnable(); this.mediaPlayer.play(); } onPause() { console.log('pause'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } + this.unlockPlayerEnable(); this.mediaPlayer.pause(); } @@ -386,12 +399,11 @@ export class ElementPlayerAudioComponent implements OnInit { onStop() { console.log('stop'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } + this.unlockPlayerEnable(); this.mediaPlayer.pause(); this.mediaPlayer.currentTime = 0; } @@ -420,9 +432,7 @@ export class ElementPlayerAudioComponent implements OnInit { seek(newValue:any) { console.log(`seek ${ newValue.value}`); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } @@ -431,9 +441,7 @@ export class ElementPlayerAudioComponent implements OnInit { onRewind() { console.log('rewind'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } @@ -442,9 +450,7 @@ export class ElementPlayerAudioComponent implements OnInit { onForward() { console.log('forward'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } @@ -453,50 +459,38 @@ export class ElementPlayerAudioComponent implements OnInit { onMore() { console.log('more'); - - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { + if(isNullOrUndefined(this.mediaPlayer)) { console.log(`error element: ${ this.mediaPlayer}`); return; } } - onVolumeMenu() { - this.volume_displayMenu = !this.volume_displayMenu; - //this.startHideTimer(); - } - onVolume(newValue:any) { - console.log(`onVolume ${ newValue.value}`); - //this.startHideTimer(); - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { - console.log(`error element: ${ this.mediaPlayer}`); - return; + // these element is to permit to not stop music when sceen is off !! + wakeLock = null; + unlockPlayerEnable() { + let tmppp = this.wakeLock; + this.wakeLock = null; + if (!isNullOrUndefined(tmppp)) { + tmppp.release(); } - this.volume_value = newValue.value; - this.mediaPlayer.volume = this.volume_value / 100; - this.mediaPlayer.muted = false; + try { + let tmp = navigator as any; + this.wakeLock = tmp.wakeLock.request('screen'); + } catch (err) { + // The Wake Lock request has failed - usually system related, such as battery. + console.log(`Can not lock screen element: ${err.name}, ${err.message}`); + } } - - onVolumeMute() { - //this.startHideTimer(); - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { - console.log(`error element: ${ this.mediaPlayer}`); - return; + lockPlayerEnable() { + if ('wakeLock' in navigator) { + try { + let tmp = navigator as any; + this.wakeLock = tmp.wakeLock.request('screen'); + } catch (err) { + // The Wake Lock request has failed - usually system related, such as battery. + console.log(`Can not lock screen element: ${err.name}, ${err.message}`); + } } - this.mediaPlayer.muted = true; } - - onVolumeUnMute() { - //this.startHideTimer(); - if(this.mediaPlayer === null || - this.mediaPlayer === undefined) { - console.log(`error element: ${ this.mediaPlayer}`); - return; - } - this.mediaPlayer.muted = false; - } - } diff --git a/front/src/app/component/top-menu/top-menu.ts b/front/src/app/component/top-menu/top-menu.ts index df05d03..fbf9136 100644 --- a/front/src/app/component/top-menu/top-menu.ts +++ b/front/src/app/component/top-menu/top-menu.ts @@ -157,7 +157,7 @@ export class TopMenuComponent implements OnInit { onArianeArtist(event: any): void { console.log(`onArianeArtist(${ this.arianeArtistId })`); - //this.arianeService.navigateArtist(this.arianeArtistId, event.which === 2); + this.arianeService.navigateArtist( {artistId: this.arianeArtistId, newWindows: event.which === 2 } ); } onArianeAlbum(event: any): void { diff --git a/front/src/app/model/media.ts b/front/src/app/model/media.ts index d3287fe..046ceab 100644 --- a/front/src/app/model/media.ts +++ b/front/src/app/model/media.ts @@ -1,17 +1,16 @@ -import { isNumberFinite, isString, isOptionalOf } from "common/utils"; +import { isNumberFinite, isString, isOptionalOf, isArray } from "common/utils"; import { isNodeData, NodeData } from "common/model/node"; export interface Media extends NodeData { dataId?: number; - typeId?: number; - playlistId?: number; - artistId?: number; + genderId?: number; + artists?: number[]; albumId?: number; episode?: number; + track?: number; date?: number; time?: number; - ageLimit?: string; }; @@ -26,15 +25,15 @@ export function isMedia(data: any): data is Media { if (!isOptionalOf(data.typeId, isNumberFinite)) { return false; } - if (!isOptionalOf(data.playlistId, isNumberFinite)) { - return false; - } - if (!isOptionalOf(data.artistId, isNumberFinite)) { + if (!isOptionalOf(data.artists, isArray)) { return false; } if (!isOptionalOf(data.albumId, isNumberFinite)) { return false; } + if (!isOptionalOf(data.track, isNumberFinite)) { + return false; + } if (!isOptionalOf(data.episode, isNumberFinite)) { return false; } @@ -44,8 +43,5 @@ export function isMedia(data: any): data is Media { if (!isOptionalOf(data.time, isNumberFinite)) { return false; } - if (!isOptionalOf(data.ageLimit, isString)) { - return false; - } return true; } diff --git a/front/src/app/scene/album-edit/album-edit.html b/front/src/app/scene/album-edit/album-edit.html index 3218e87..e9f5587 100644 --- a/front/src/app/scene/album-edit/album-edit.html +++ b/front/src/app/scene/album-edit/album-edit.html @@ -27,16 +27,30 @@
- Number: + name:
-
+
Description: diff --git a/front/src/app/scene/album-edit/album-edit.ts b/front/src/app/scene/album-edit/album-edit.ts index 0eaf14f..615b6c0 100644 --- a/front/src/app/scene/album-edit/album-edit.ts +++ b/front/src/app/scene/album-edit/album-edit.ts @@ -26,14 +26,14 @@ export interface ElementList { }) export class AlbumEditScene implements OnInit { - idAlbum:number = -1; + idAlbum: number = -1; itemIsRemoved:boolean = false; itemIsNotFound:boolean = false; itemIsLoading:boolean = true; error:string = ''; - numberVal: number = null; + nameAlbum:string; description: string = ''; coverFile: File; uploadFileValue: string = ''; @@ -83,15 +83,13 @@ export class AlbumEditScene implements OnInit { this.albumService.get(this.idAlbum) .then((response: NodeData) => { console.log(`get response of album : ${ JSON.stringify(response, null, 2)}`); - if (isNumberFinite(response.name)) { - self.numberVal = response.name; - } + self.nameAlbum = response.name; self.description = response.description; self.updateCoverList(response.covers); self.itemIsLoading = false; }).catch((response) => { self.error = 'Can not get the data'; - self.numberVal = null; + self.nameAlbum = null; self.description = ''; self.coversDisplay = []; self.itemIsNotFound = true; @@ -118,8 +116,8 @@ export class AlbumEditScene implements OnInit { this.coversDisplay = []; } } - onNumber(value:any):void { - this.numberVal = value; + onName(value:any):void { + this.nameAlbum = value; } onDescription(value:any):void { @@ -129,7 +127,7 @@ export class AlbumEditScene implements OnInit { sendValues():void { console.log('send new values....'); let data = { - name: this.numberVal, + name: this.nameAlbum, description: this.description }; if(this.description === undefined) { diff --git a/front/src/app/scene/album/albums.html b/front/src/app/scene/album/albums.html index aac4bd5..dce238c 100644 --- a/front/src/app/scene/album/albums.html +++ b/front/src/app/scene/album/albums.html @@ -12,6 +12,12 @@
{{description}}
+ +
diff --git a/front/src/app/scene/album/albums.ts b/front/src/app/scene/album/albums.ts index f5394f1..dffa33d 100644 --- a/front/src/app/scene/album/albums.ts +++ b/front/src/app/scene/album/albums.ts @@ -7,7 +7,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; - import { ArtistService, DataService, ArianeService, AlbumService } from 'app/service'; + import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service'; import { NodeData } from 'common/model'; import { isNullOrUndefined } from 'common/utils'; @@ -31,6 +31,8 @@ private albumService: AlbumService, private artistService: ArtistService, private arianeService: ArianeService, + private trackService: TrackService, + private playerService: PlayerService, private dataService: DataService) { } @@ -88,6 +90,36 @@ this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} ); } } + playAll(event: any):void { + this.playerService.clear(); + let self = this; + this.trackService.getData() + .then((response: NodeData[]) => { + let ids = []; + response.forEach(element => { + ids.push(element.id); + }); + self.playerService.setNewPlaylist(ids); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } + playShuffe(event: any):void { + this.playerService.clear(); + let self = this; + this.trackService.getData() + .then((response: NodeData[]) => { + let ids = []; + response.forEach(element => { + ids.push(element.id); + }); + self.playerService.setNewPlaylistShuffle(ids); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } } \ No newline at end of file diff --git a/front/src/app/scene/artist/artist-album.html b/front/src/app/scene/artist/artist-album.html index 10e168b..5f43457 100644 --- a/front/src/app/scene/artist/artist-album.html +++ b/front/src/app/scene/artist/artist-album.html @@ -15,6 +15,7 @@
{{albumDescription}}
+
diff --git a/front/src/app/scene/artist/artists.html b/front/src/app/scene/artist/artists.html index 92cc00e..43a6865 100644 --- a/front/src/app/scene/artist/artists.html +++ b/front/src/app/scene/artist/artists.html @@ -1,4 +1,25 @@
+
+
+
+ +
+
+
+
+ {{name}} +
+
+ {{description}} +
+ + +
+
Artists:
diff --git a/front/src/app/scene/artist/artists.ts b/front/src/app/scene/artist/artists.ts index 9fd9526..a27e20e 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, AlbumService } from 'app/service'; +import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; import { NodeData } from 'common/model'; import { isNullOrUndefined } from 'common/utils'; @@ -19,6 +19,8 @@ import { isNullOrUndefined } from 'common/utils'; export class ArtistsScene implements OnInit { cover: string = ''; covers: Array = []; + name: string = "Artists"; + description: string = "All available artists"; artists: NodeData[]; countTrack: (id: number) => Promise; countAlbum: (id: number) => Promise; @@ -27,6 +29,8 @@ export class ArtistsScene implements OnInit { private route: ActivatedRoute, private artistService: ArtistService, private albumService: AlbumService, + private trackService: TrackService, + private playerService: PlayerService, private arianeService: ArianeService) { } @@ -60,5 +64,35 @@ export class ArtistsScene implements OnInit { countAlbumCallback(artistId: number) : Promise { return this.artistService.countAlbum(artistId); } + playAll(event: any):void { + this.playerService.clear(); + let self = this; + this.trackService.getData() + .then((response: NodeData[]) => { + let ids = []; + response.forEach(element => { + ids.push(element.id); + }); + self.playerService.setNewPlaylist(ids); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } + playShuffe(event: any):void { + this.playerService.clear(); + let self = this; + this.trackService.getData() + .then((response: NodeData[]) => { + let ids = []; + response.forEach(element => { + ids.push(element.id); + }); + self.playerService.setNewPlaylistShuffle(ids); + }) + .catch(() => { + console.log(`error to get list o ftrack ...`) + }); + } } diff --git a/front/src/app/scene/track-edit/track-edit.html b/front/src/app/scene/track-edit/track-edit.html index 326beb7..fe69d54 100644 --- a/front/src/app/scene/track-edit/track-edit.html +++ b/front/src/app/scene/track-edit/track-edit.html @@ -52,44 +52,16 @@
- date_range Date: + Gender:
- -
-
-
-
- Type: -
-
- +
- -
-
-
-
- Playlist: -
-
- -
-
-
@@ -128,55 +100,21 @@
- Episode: + Track n°:
+ [value]="data.track" + (input)="onTrack($event.target)"/>
- -
-
-
- -
- Covers -
-
-
- -
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
-
+
@@ -228,7 +166,8 @@ validateTitle="Create" (callback)="eventPopUpAlbum($event[0])">

- Name: + Name:

@@ -240,20 +179,22 @@ validateTitle="Create" (callback)="eventPopUpArtist($event[0])">

- Name: + Name:

- + (callback)="eventPopUpGender($event[0])">

- Name: + Name:

diff --git a/front/src/app/scene/track-edit/track-edit.less b/front/src/app/scene/track-edit/track-edit.less deleted file mode 100644 index e69de29..0000000 diff --git a/front/src/app/scene/track-edit/track-edit.ts b/front/src/app/scene/track-edit/track-edit.ts index faf92de..013d218 100644 --- a/front/src/app/scene/track-edit/track-edit.ts +++ b/front/src/app/scene/track-edit/track-edit.ts @@ -8,11 +8,12 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { DataService, GenderService, PlaylistService, ArtistService, TrackService, ArianeService } from 'app/service'; +import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; import { NodeData } from 'common/model'; import { PopInService } from 'common/service'; import { Media } from 'app/model'; +import { isNullOrUndefined } from 'common/utils'; export interface ElementList { value?: number; @@ -23,27 +24,21 @@ export interface ElementList { class DataToSend { name:string = ''; description:string = ''; - episode?:number; - playlistId:number = null; + track?:number; artistId:number = null; albumId:number = null; dataId:number = -1; - time?:number; - typeId:number = null; - covers:number[] = []; + genderId:number = null; generatedName:string = ''; clone() { let tmp = new DataToSend(); tmp.name = this.name; tmp.description = this.description; - tmp.episode = this.episode; - tmp.playlistId = this.playlistId; + tmp.track = this.track; tmp.artistId = this.artistId; tmp.albumId = this.albumId; tmp.dataId = this.dataId; - tmp.time = this.time; - tmp.typeId = this.typeId; - tmp.covers = this.covers; + tmp.genderId = this.genderId; tmp.generatedName = this.generatedName; return tmp; } @@ -51,8 +46,7 @@ class DataToSend { @Component({ selector: 'app-track-edit', - templateUrl: './track-edit.html', - styleUrls: [ './track-edit.less' ] + templateUrl: './track-edit.html' }) export class TrackEditScene implements OnInit { @@ -65,9 +59,6 @@ export class TrackEditScene implements OnInit { data:DataToSend = new DataToSend(); dataOri:DataToSend = new DataToSend(); - coverFile:File; - uploadFileValue:string = ''; - selectedFiles:FileList; needSend:boolean = false; @@ -78,11 +69,14 @@ export class TrackEditScene implements OnInit { public confirmDeleteImageUrl:string = null; private deleteCoverId:number = null; private deleteMediaId:number = null; + + // to create new album/artist/gender: + private albumInputNew: string; + private artistInputNew: string; + private genderInputNew: string; + + deleteConfirmed() { - if(this.deleteCoverId !== null) { - this.removeCoverAfterConfirm(this.deleteCoverId); - this.cleanConfirm(); - } if(this.deleteMediaId !== null) { this.removeItemAfterConfirm(this.deleteMediaId); this.cleanConfirm(); @@ -95,15 +89,9 @@ export class TrackEditScene implements OnInit { this.deleteMediaId = null; } - coversDisplay:Array = []; - - listType: ElementList[] = [ + listGender: ElementList[] = [ { value: undefined, label: '---' }, ]; - listPlaylist: ElementList[] = [ - { value: undefined, label: '---' }, - { value: null, label: '---' }, - ]; listArtist: ElementList[] = [ { value: undefined, label: '---' }, ]; @@ -112,8 +100,8 @@ export class TrackEditScene implements OnInit { ]; constructor( private route: ActivatedRoute, - private typeService: GenderService, - private playlistService: PlaylistService, + private genderService: GenderService, + private albumService: AlbumService, private artistService: ArtistService, private trackService: TrackService, private arianeService: ArianeService, @@ -130,16 +118,10 @@ export class TrackEditScene implements OnInit { if(this.data.description !== this.dataOri.description) { this.needSend = true; } - if(this.data.episode !== this.dataOri.episode) { + if(this.data.track !== this.dataOri.track) { this.needSend = true; } - if(this.data.time !== this.dataOri.time) { - this.needSend = true; - } - if(this.data.typeId !== this.dataOri.typeId) { - this.needSend = true; - } - if(this.data.playlistId !== this.dataOri.playlistId) { + if(this.data.genderId !== this.dataOri.genderId) { this.needSend = true; } if(this.data.artistId !== this.dataOri.artistId) { @@ -151,47 +133,23 @@ export class TrackEditScene implements OnInit { return this.needSend; } - updateCoverList(covers: any) { - this.coversDisplay = []; - this.data.covers = []; - if(covers !== undefined && covers !== null) { - for(let iii = 0; iii < covers.length; iii++) { - this.data.covers.push(covers[iii]); - this.coversDisplay.push({ - id:covers[iii], - url:this.dataService.getCoverThumbnailUrl(covers[iii]) - }); - } - } else { - this.coversDisplay = []; - } - } ngOnInit() { this.arianeService.updateManual(this.route.snapshot.paramMap); this.idTrack = this.arianeService.getTrackId(); let self = this; - this.listType = [ { value: null, label: '---' } ]; - this.listPlaylist = [ { value: null, label: '---' } ]; + this.listGender = [ { value: null, label: '---' } ]; this.listArtist = [ { value: null, label: '---' } ]; this.listAlbum = [ { value: null, label: '---' } ]; - this.playlistService.getData() + this.genderService.getOrder() .then((response2) => { for(let iii = 0; iii < response2.length; iii++) { - self.listPlaylist.push({ value: response2[iii].id, label: response2[iii].name }); - } - }).catch((response2) => { - console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); - }); - this.typeService.getData() - .then((response2) => { - for(let iii = 0; iii < response2.length; iii++) { - self.listType.push({ value: response2[iii].id, label: response2[iii].name }); + self.listGender.push({ value: response2[iii].id, label: response2[iii].name }); } }).catch((response2) => { console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); }); // this.artistService.getOrder() - this.artistService.getData() + this.artistService.getOrder() .then((response3) => { for(let iii = 0; iii < response3.length; iii++) { self.listArtist.push({ value: response3[iii].id, label: response3[iii].name }); @@ -200,34 +158,37 @@ export class TrackEditScene implements OnInit { }).catch((response3) => { console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`); }); + this.albumService.getOrder() + .then((response3) => { + for(let iii = 0; iii < response3.length; iii++) { + self.listAlbum.push({ value: response3[iii].id, label: response3[iii].name }); + console.log(`[${ self.data.dataId }] Get artist: ${ response3[iii].id }, label:${ response3[iii].name}`); + } + }).catch((response3) => { + console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`); + }); this.trackService.get(this.idTrack) .then((response: Media) => { console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`); self.data.name = response.name; self.data.description = response.description; - self.data.episode = response.episode; - self.data.playlistId = response.playlistId; - if(self.data.playlistId === undefined) { - self.data.playlistId = null; - } + self.data.track = response.track; self.data.dataId = response.dataId; - self.data.time = response.time; self.data.generatedName = "????????? TODO ????????? "; // response.generatedName; - self.onChangeType(response.typeId); - self.onChangeArtist(response.artistId); + self.onChangeGender(response.genderId); + if (response?.artists.length != 0) { + self.onChangeArtist(response.artists[0]); + } self.data.albumId = response.albumId; if(self.data.albumId === undefined) { self.data.albumId = null; } self.dataOri = self.data.clone(); - self.updateCoverList(response.covers); self.updateNeedSend(); - console.log(`coversList : ${ JSON.stringify(self.coversDisplay, null, 2)}`); self.itemIsLoading = false; }).catch((response) => { self.error = 'Can not get the data'; self.data = new DataToSend(); - self.coversDisplay = []; self.dataOri = self.data.clone(); self.updateNeedSend(); self.itemIsNotFound = true; @@ -235,32 +196,12 @@ export class TrackEditScene implements OnInit { }); } - onChangeType(value:any):void { - console.log(`Change requested of type ... ${value}`); - this.data.typeId = value; - if(this.data.typeId === undefined) { - this.data.typeId = null; + onChangeGender(value:any):void { + console.log(`Change requested of gender ... ${value}`); + this.data.genderId = value; + if(this.data.genderId === undefined) { + this.data.genderId = null; } - this.data.artistId = null; - this.data.albumId = null; - this.listArtist = [ { value: undefined, label: '---' } ]; - this.listAlbum = [ { value: undefined, label: '---' } ]; - let self = this; - this.updateNeedSend(); - if(this.data.typeId !== undefined) { - self.typeService.getSubArtist(this.data.typeId) - .then((response2: NodeData[]) => { - for(let iii = 0; iii < response2.length; iii++) { - self.listArtist.push({ value: response2[iii].id, label: response2[iii].name }); - } - }).catch((response2) => { - console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); - }); - } - } - - onChangePlaylist(value:any):void { - this.data.playlistId = value; this.updateNeedSend(); } @@ -269,23 +210,13 @@ export class TrackEditScene implements OnInit { if(this.data.artistId === undefined) { this.data.artistId = null; } - this.data.albumId = null; - this.listAlbum = [ { value: undefined, label: '---' } ]; - let self = this; - if(this.data.artistId !== undefined) { - self.artistService.getAlbum(this.data.artistId) - .then((response3: NodeData[]) => { - for(let iii = 0; iii < response3.length; iii++) { - self.listAlbum.push({ value: response3[iii].id, label: `album ${ response3[iii].name}` }); - } - }).catch((response3) => { - console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`); - }); - } this.updateNeedSend(); } onChangeAlbum(value:any):void { this.data.albumId = value; + if(this.data.albumId === undefined) { + this.data.albumId = null; + } this.updateNeedSend(); } @@ -302,23 +233,12 @@ export class TrackEditScene implements OnInit { } this.updateNeedSend(); } - onDate(value:any):void { - if(value.value.length > 4) { - value.value = this.data.time; - } else { - this.data.time = value.value; - } - if(this.data.time < 10) { - this.data.time = null; - } - this.updateNeedSend(); - } - onEpisode(value:any):void { + onTrack(value:any):void { if(value.value.length > 4) { - value.value = this.data.episode; + value.value = this.data.track; } else { - this.data.episode = parseInt(value.value, 10); + this.data.track = parseInt(value.value, 10); } this.updateNeedSend(); } @@ -336,31 +256,21 @@ export class TrackEditScene implements OnInit { data.description = this.data.description; } } - if(this.data.episode !== this.dataOri.episode) { - data.episode = this.data.episode; + if(this.data.track !== this.dataOri.track) { + data.track = this.data.track; } - if(this.data.time !== this.dataOri.time) { - data.time = this.data.time; - } - if(this.data.typeId !== this.dataOri.typeId) { - if(this.data.typeId === undefined) { - data.typeId = null; + if(this.data.genderId !== this.dataOri.genderId) { + if(this.data.genderId === undefined) { + data.genderId = null; } else { - data.typeId = this.data.typeId; - } - } - if(this.data.playlistId !== this.dataOri.playlistId) { - if(this.data.playlistId === undefined) { - data.playlistId = null; - } else { - data.playlistId = this.data.playlistId; + data.genderId = this.data.genderId; } } if(this.data.artistId !== this.dataOri.artistId) { if(this.data.artistId === undefined) { - data.artistId = null; + data.artists = null; } else { - data.artistId = this.data.artistId; + data.artists = [ this.data.artistId ]; } } if(this.data.albumId !== this.dataOri.albumId) { @@ -381,80 +291,6 @@ export class TrackEditScene implements OnInit { self.updateNeedSend(); }); } - - // At the drag drop area - // (drop)="onDropFile($event)" - onDropFile(event: DragEvent) { - event.preventDefault(); - // this.uploadFile(event.dataTransfer.files[0]); - console.log('error in drag & drop ...'); - } - - // At the drag drop area - // (dragover)="onDragOverFile($event)" - onDragOverFile(event) { - event.stopPropagation(); - event.preventDefault(); - } - - // At the file input element - // (change)="selectFile($event)" - onChangeCover(value:any):void { - this.selectedFiles = value.files; - this.coverFile = this.selectedFiles[0]; - console.log(`select file ${ this.coverFile.name}`); - this.uploadCover(this.coverFile); - this.updateNeedSend(); - } - - uploadCover(file?:File) { - if(file === undefined) { - console.log('No file selected!'); - return; - } - let self = this; - // clean upload labels* - this.upload.clear(); - // display the upload pop-in - this.popInService.open('popin-upload-progress'); - this.trackService.uploadCover(file, this.idTrack, (count, total) => { - self.upload.mediaSendSize = count; - self.upload.mediaSize = total; - }) - .then((response:any) => { - console.log(`get response of cover : ${ JSON.stringify(response, null, 2)}`); - self.upload.result = 'Cover added done'; - // we retrive the whiole media ==> update data ... - self.updateCoverList(response.covers); - }).catch((response:any) => { - // self.error = "Can not get the data"; - console.log('Can not add the cover in the track...'); - self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`; - }); - } - - removeCover(id:number) { - this.cleanConfirm(); - this.confirmDeleteComment = `Delete the cover ID: ${ id}`; - this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); - this.deleteCoverId = id; - this.popInService.open('popin-delete-confirm'); - } - removeCoverAfterConfirm(id:number) { - console.log(`Request remove cover: ${ id}`); - let self = this; - this.trackService.deleteCover(this.idTrack, id) - .then((response:any) => { - console.log(`get response of remove cover : ${ JSON.stringify(response, null, 2)}`); - self.upload.result = 'Cover remove done'; - // we retrive the whiole media ==> update data ... - self.updateCoverList(response.covers); - }).catch((response:any) => { - // self.error = "Can not get the data"; - console.log('Can not remove the cover of the track...'); - self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`; - }); - } removeItem() { console.log('Request remove Media...'); this.cleanConfirm(); @@ -477,18 +313,29 @@ export class TrackEditScene implements OnInit { eventPopUpAlbum(event: string): void { console.log(`GET event: ${ event}`); this.popInService.close('popin-new-album'); + if (event === "validate" && !isNullOrUndefined(this.albumInputNew)) { + this.albumService.insert({ + name:this.albumInputNew, + }); + } } eventPopUpArtist(event: string): void { console.log(`GET event: ${ event}`); this.popInService.close('popin-new-artist'); + if (event === "validate" && !isNullOrUndefined(this.artistInputNew)) { + this.artistService.insert({ + name:this.artistInputNew, + }); + } } - eventPopUpType(event: string): void { + eventPopUpGender(event: string): void { console.log(`GET event: ${ event}`); - this.popInService.close('popin-new-type'); - } - eventPopUpPlaylist(event: string): void { - console.log(`GET event: ${ event}`); - this.popInService.close('popin-new-playlist'); + this.popInService.close('popin-new-gender'); + if (event === "validate" && !isNullOrUndefined(this.genderInputNew)) { + this.genderService.insert({ + name:this.genderInputNew, + }); + } } newAlbum(): void { @@ -499,13 +346,22 @@ export class TrackEditScene implements OnInit { console.log('Request new Artist...'); this.popInService.open('popin-new-artist'); } - newType(): void { - console.log('Request new Type...'); - this.popInService.open('popin-create-type'); + newGender(): void { + console.log('Request new Gender...'); + this.popInService.open('popin-new-gender'); } - newPlaylist() { - console.log('Request new Playlist...'); - this.popInService.open('popin-new-playlist'); + + onNewGenderInput(value) { + console.log(`Request new Gender...${value}`); + this.genderInputNew = value; + } + onNewArtistInput(value) { + console.log(`Request new Gender...${value}`); + this.artistInputNew = value; + } + onNewAlbumInput(value) { + console.log(`Request new Gender...${value}`); + this.albumInputNew = value; } } diff --git a/front/src/app/scene/track/track.ts b/front/src/app/scene/track/track.ts index 32f77a9..4a508d2 100644 --- a/front/src/app/scene/track/track.ts +++ b/front/src/app/scene/track/track.ts @@ -49,7 +49,7 @@ export class TrackScene implements OnInit { name:string = ''; description:string = ''; episode:number = undefined; - artistId:number = undefined; + artists:number[] = undefined; artistName:string = undefined; albumId:number = undefined; albumName:string = undefined; @@ -210,7 +210,7 @@ export class TrackScene implements OnInit { self.name = response.name; self.description = response.description; self.episode = response.episode; - self.artistId = response.artistId; + self.artists = response.artists; self.albumId = response.albumId; self.dataId = response.dataId; self.time = response.time; @@ -226,8 +226,8 @@ export class TrackScene implements OnInit { self.covers = self.dataService.getCoverListUrl(response.covers); self.generateName(); - if(self.artistId !== undefined && self.artistId !== null) { - self.artistService.get(self.artistId) + if(!isNullOrUndefined(self.artists) && self.artists.length !== 0) { + self.artistService.get(self.artists[0]) .then((response2) => { self.artistName = response2.name; self.generateName(); @@ -235,7 +235,7 @@ export class TrackScene implements OnInit { // nothing to do ... }); } - if(self.albumId !== undefined && self.albumId !== null) { + if(!isNullOrUndefined(self.albumId)) { self.albumService.get(self.albumId) .then((response4) => { self.albumName = response4.name; @@ -279,7 +279,7 @@ export class TrackScene implements OnInit { self.name = ''; self.description = ''; self.episode = undefined; - self.artistId = undefined; + self.artists = undefined; self.albumId = undefined; self.dataId = -1; self.time = undefined; diff --git a/front/src/app/service/GenericInterfaceModelDB.ts b/front/src/app/service/GenericInterfaceModelDB.ts index 2eaefbc..0653aa2 100644 --- a/front/src/app/service/GenericInterfaceModelDB.ts +++ b/front/src/app/service/GenericInterfaceModelDB.ts @@ -11,6 +11,7 @@ export class GenericInterfaceModelDB { // nothing to do ... } + gets(): Promise { let self = this; return new Promise((resolve, reject) => { @@ -122,6 +123,11 @@ export class GenericInterfaceModelDB { }); } + insert(data: any): any { + let ret = this.http.postSpecific([this.serviceName], data); + return this.bdd.addAfterPost(this.serviceName, ret); + + } put(id:number, data:any):any { let ret = this.http.putSpecific([this.serviceName, id], data); return this.bdd.setAfterPut(this.serviceName, id, ret); diff --git a/front/src/app/service/gender.ts b/front/src/app/service/gender.ts index 733a6a6..3fdc985 100644 --- a/front/src/app/service/gender.ts +++ b/front/src/app/service/gender.ts @@ -19,6 +19,7 @@ export interface MessageLogIn { @Injectable() export class GenderService extends GenericInterfaceModelDB { + constructor(http: HttpWrapperService, bdd: BddService) { diff --git a/front/src/common/service/bdd.ts b/front/src/common/service/bdd.ts index a608f49..b28add6 100644 --- a/front/src/common/service/bdd.ts +++ b/front/src/common/service/bdd.ts @@ -21,6 +21,24 @@ export class BddService { console.log('Start BddService'); } + addAfterPost(name: string, ret: any) { + let self = this; + return new Promise((resolve, reject) => { + self.get(name) + .then((response:DataInterface) => { + let responseTmp = response; + ret.then((response2) => { + responseTmp.add(response2); + resolve(response2); + }).catch((response2) => { + reject(response2); + }); + }).catch((response) => { + reject(response); + }); + }); + } + setAfterPut(name: string, id: number, ret: any) { let self = this; return new Promise((resolve, reject) => { diff --git a/front/src/common/utils/dataInterface.ts b/front/src/common/utils/dataInterface.ts index b682468..72aaa0d 100644 --- a/front/src/common/utils/dataInterface.ts +++ b/front/src/common/utils/dataInterface.ts @@ -124,6 +124,10 @@ export class DataInterface { } } } + public add(value: NodeData): void { + console.log(`[I] Set ${ this.name }`); + this.bdd.push(value); + } public delete(id: number): void { console.log(`[I] delete ${ this.name } ${ id}`);