/** @file * @author Edouard DUPIN * @copyright 2018, Edouard DUPIN, all right reserved * @license PROPRIETARY (see license file) */ import { Component, OnInit } from '@angular/core'; import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service'; import { NodeData } from 'common/model'; @Component({ selector: 'app-artists', templateUrl: './artists.html', }) 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; constructor( private artistService: ArtistService, private albumService: AlbumService, private trackService: TrackService, private playerService: PlayerService, private arianeService: ArianeService) { } ngOnInit() { let self = this; this.countTrack = (id:number) => {return self.countTrackCallback(id);}; this.countAlbum = (id:number) => {return self.countAlbumCallback(id);}; // this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId')); this.artistService.getOrder() .then((response: NodeData[]) => { self.artists = response; //console.log("get artists: " + JSON.stringify(self.artists)); }).catch((response) => { self.artists = undefined; }); } onSelectArtist(event: any, idSelected: number):void { if (event.ctrlKey) { this.arianeService.navigateArtistEdit({id: idSelected, newWindows:event.which === 2} ); } else { this.arianeService.navigateArtist({artistId: idSelected, newWindows:event.which === 2} ); } } countTrackCallback(artistId: number) : Promise { return this.artistService.countTrack(artistId); } 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 ...`) }); } }