- {albumListKeys !== undefined && albumListKeys.length > 0 && albumListKeys.map((lKey, index) =>
+ {albumListKeys && albumListKeys.length > 0 && albumListKeys.map((lKey, index) =>
<>
- {!isFilterActive && albumListInp.showLKey &&
}
+ {!isFilterActive && albumListInp.showLKey &&
}
{filteredAlbums[lKey] !== undefined && filteredAlbums[lKey].length > 0 && filteredAlbums[lKey].map((album, albumIndex) =>
)}
diff --git a/src/g-player-react/src/Components/screen/album/Albums.js b/src/g-player-react/src/Components/screen/album/Albums.js
index 93d1c10..6ad351f 100644
--- a/src/g-player-react/src/Components/screen/album/Albums.js
+++ b/src/g-player-react/src/Components/screen/album/Albums.js
@@ -1,10 +1,8 @@
import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
-import { A_TO_Z, A_TO_Z_DESC, CURRENT_PAGE, GP_ALBUMS_SORT_FIELD_MAPPING, LANGUAGE, MULTI_LINGUAL, SOME_PAGE, SORT_ARTIST, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_LANGUAGE, SORT_MULTI_LINGUAL, SORT_YEAR } from "../../redux/GPActionTypes";
+import { CURRENT_PAGE, SOME_PAGE, SORT_ARTIST, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_LANGUAGE, SORT_MULTI_LINGUAL, SORT_YEAR } from "../../redux/GPActionTypes";
import { fetchAllAlbums } from "../../redux/library/LibraryActions";
-import { camelize, replace_AndCamelize, setCookies, sortGroupByField } from "../../utilities/util";
-import { AlbumThumb } from "./AlbumThumb";
-import { SortingContainer } from "../SortingContainer";
+import { setCookies } from "../../utilities/util";
import { Spinner } from "../../utilities/Spinner";
import { AlbumList } from "./AlbumList";
diff --git a/src/g-player-react/src/Components/screen/album/albumUtil.js b/src/g-player-react/src/Components/screen/album/albumUtil.js
new file mode 100644
index 0000000..324cdff
--- /dev/null
+++ b/src/g-player-react/src/Components/screen/album/albumUtil.js
@@ -0,0 +1,28 @@
+import { A_TO_Z_DESC, SORT_ARTIST, SORT_YEAR } from "../../redux/GPActionTypes";
+
+export const filterAlbums = (globalFilterText, sortedAlbums, albumListKeys) => {
+ let tempFilteredAlbums = [];
+ let filteredAlbums = {};
+ albumListKeys.forEach(lKey =>{
+ tempFilteredAlbums = sortedAlbums[lKey];
+ tempFilteredAlbums = tempFilteredAlbums.filter(album => {
+ return album.albumName.toLowerCase().includes(globalFilterText)
+ || album.year === globalFilterText
+ || album.genre.toLowerCase().includes(globalFilterText)
+ || album.albumArtist.toLowerCase().includes(globalFilterText)
+ });
+ filteredAlbums[lKey] = tempFilteredAlbums;
+ })
+ return filteredAlbums;
+}
+
+export const sortAlbumKeys = (sortBy, sortedAlbums) => {
+ let tempAlbumListKeys = Object.keys(sortedAlbums);
+ if (sortBy === SORT_YEAR || sortBy === A_TO_Z_DESC) {
+ tempAlbumListKeys = tempAlbumListKeys.sort((a, b) => { return a > b ? -1 : 1 });
+ }
+ if (sortBy === SORT_ARTIST) {
+ tempAlbumListKeys = tempAlbumListKeys.sort((a, b) => { return a > b ? 1 : -1 });
+ }
+ return tempAlbumListKeys;
+}
\ No newline at end of file
diff --git a/src/g-player-react/src/Components/screen/artist/ArtistsList.js b/src/g-player-react/src/Components/screen/artist/ArtistsList.js
index 3cee12c..795f054 100644
--- a/src/g-player-react/src/Components/screen/artist/ArtistsList.js
+++ b/src/g-player-react/src/Components/screen/artist/ArtistsList.js
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
-import { ARTIST, ARTISTS, A_TO_Z, A_TO_Z_DESC, CURRENT_PAGE, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_COUNT_TRACKS } from "../../redux/GPActionTypes";
+import { ARTIST, ARTISTS, CURRENT_PAGE, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_COUNT_TRACKS } from "../../redux/GPActionTypes";
import { fetchAllArtistsDtls } from "../../redux/library/LibraryActions";
import { setCookies, sortGroupByField } from "../../utilities/util";
import { SortingContainer } from "../SortingContainer";
@@ -27,8 +27,6 @@ export const ArtistsList = () => {
if(sortBy===SORT_COUNT_TRACKS){
let tempArtistsDetails = [...artistsDetailsFS];
tempArtistsDetails = tempArtistsDetails.sort((a, b)=>a.count > b.count?-1:1);
- //tempArtistsDetails = tempArtistsDetails.sort((a, b)=>b.imgAvl?1:-1);
- //tempArtistsDetails = tempArtistsDetails.filter(artist => {return artist.imgAvl || artist.count>1})
setAlbumArtistsDetails(tempArtistsDetails);
}
}
@@ -48,13 +46,13 @@ export const ArtistsList = () => {
<>
- {sortBy === SORT_COUNT_TRACKS && artistsDetails!==null && artistsDetails!==undefined && artistsDetails.length>0 && artistsDetails.map((artist, index) =>
+ {sortBy === SORT_COUNT_TRACKS && artistsDetails?.map((artist, index) =>
)}
- {sortBy!==SORT_COUNT_TRACKS && artistsDetailsListKeys !== undefined && artistsDetailsListKeys.length > 0 && artistsDetailsListKeys.map((lKey, index) =>
+ {sortBy!==SORT_COUNT_TRACKS && artistsDetailsListKeys?.map((lKey, index) =>
<>
-
- {artistsDetailsList[lKey] !== undefined && artistsDetailsList[lKey].length > 0 && artistsDetailsList[lKey].map((artist, artistIndex) =>
+
+ {artistsDetailsList[lKey]?.map((artist, artistIndex) =>
)}
>
diff --git a/src/g-player-react/src/Components/screen/genre/Genres.js b/src/g-player-react/src/Components/screen/genre/Genres.js
index d589ffb..1a48890 100644
--- a/src/g-player-react/src/Components/screen/genre/Genres.js
+++ b/src/g-player-react/src/Components/screen/genre/Genres.js
@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from "react-redux";
import { fetchGenreDetails } from "../../redux/library/LibraryActions";
import { Link } from "react-router-dom";
import { GroupedThumbImg4 } from "../../GroupedThumbImg4";
-import { CURRENT_PAGE, GENRE, GENRES, GENRE_LABEL, SORT_ARTIST, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_COUNT_TRACKS, TRACKS_LABEL } from "../../redux/GPActionTypes";
+import { CURRENT_PAGE, GENRE, GENRES, GENRE_LABEL, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_COUNT_TRACKS, TRACKS_LABEL } from "../../redux/GPActionTypes";
import { ThumbnailActionBtn } from "../../ThumbnailActionBtn";
import { camelize, setCookies } from "../../utilities/util";
import { SortingContainer } from "../SortingContainer";
diff --git a/src/g-player-react/src/Components/screen/language/Languages.js b/src/g-player-react/src/Components/screen/language/Languages.js
index 280d6b0..ebd31e2 100644
--- a/src/g-player-react/src/Components/screen/language/Languages.js
+++ b/src/g-player-react/src/Components/screen/language/Languages.js
@@ -3,9 +3,10 @@ import { useDispatch, useSelector } from "react-redux";
import { fetchLanguageDetails } from "../../redux/library/LibraryActions";
import { Link } from "react-router-dom";
import { GroupedThumbImg4 } from "../../GroupedThumbImg4";
-import { CURRENT_PAGE, LANGUAGE, LANGUAGES, LANGUAGE_LABEL, TRACKS_LABEL } from "../../redux/GPActionTypes";
+import { CURRENT_PAGE, LANGUAGE, LANGUAGES, LANGUAGE_LABEL, SORT_A_TO_Z, SORT_A_TO_Z_DESC, SORT_COUNT_TRACKS, TRACKS_LABEL } from "../../redux/GPActionTypes";
import { ThumbnailActionBtn } from "../../ThumbnailActionBtn";
-import { camelize, setCookies } from "../../utilities/util";
+import { camelize, setCookies, sortByKey } from "../../utilities/util";
+import { SortingContainer } from "../SortingContainer";
export const Languages = () => {
const dispatch = useDispatch();
@@ -15,6 +16,7 @@ export const Languages = () => {
const [languageAlbums, setLanguageAlbums] = useState({});
const [languages, setLanguages] = useState([]);
const [languageSongCount, setLanguageSongCount] = useState({});
+ const [sortBy, setSortBy] = useState(SORT_A_TO_Z);
useEffect(()=>{
if(!languageDetails || (languageDetails && !languageDetails.LANGUAGE_SONG_COUNT)){
@@ -37,8 +39,36 @@ export const Languages = () => {
}
},[languageDetails]);
+ useEffect(()=>{
+ if(languages && languages.length>0){
+ let sortedLanguages = [...languages];
+ if(sortBy === SORT_A_TO_Z){
+ sortedLanguages = sortedLanguages.sort((a,b)=>{return a>b?1:-1});
+ }
+ if(sortBy === SORT_A_TO_Z_DESC){
+ sortedLanguages = sortedLanguages.sort((a,b)=>{return a>b?-1:1});
+ }
+ if(sortBy === SORT_COUNT_TRACKS){
+ sortedLanguages = sortedLanguages.sort((a,b)=>{return languageSongCount[a]>languageSongCount[b]?-1:1});
+ }
+ setLanguages(sortedLanguages);
+ }
+ },[sortBy, languages])
+
return(
+
{languages.length > 0 && languages.map(language =>
diff --git a/src/g-player-react/src/Components/screen/lyrics/Lyrics.js b/src/g-player-react/src/Components/screen/lyrics/Lyrics.js
index 1a44b72..c1fc347 100644
--- a/src/g-player-react/src/Components/screen/lyrics/Lyrics.js
+++ b/src/g-player-react/src/Components/screen/lyrics/Lyrics.js
@@ -16,6 +16,7 @@ import { MdOutlineCancelPresentation } from "react-icons/md";
import { FaHourglassStart } from "react-icons/fa6";
import { IoMdDownload } from "react-icons/io";
import { RiDeleteBin6Line } from "react-icons/ri";
+import { TbWriting } from "react-icons/tb";
export const Lyrics = () => {
const dispatch = useDispatch();
@@ -253,7 +254,7 @@ export const Lyrics = () => {
{songPlaying!==null && songPlaying.lyricist!==null &&
- Lyricist: {songPlaying.lyricist}
+ : {songPlaying.lyricist}
}
}
diff --git a/src/g-player-react/src/Components/screen/metadata/EditAlbumInfo.js b/src/g-player-react/src/Components/screen/metadata/EditAlbumInfo.js
index 0d5822f..61aa2ca 100644
--- a/src/g-player-react/src/Components/screen/metadata/EditAlbumInfo.js
+++ b/src/g-player-react/src/Components/screen/metadata/EditAlbumInfo.js
@@ -29,24 +29,25 @@ export const EditAlbumInfo = () => {
const updateModifiedAlbum = async (event, field, type, songId) => {
const target = event.target;
+ let targetValue = "";
if(target.type !== "file"){
- target.value = target.value.trim();
+ targetValue = target.value.trim();
}
const tempModifiedAlbum = {...modifiedAlbum};
if(type === ALBUM){
- tempModifiedAlbum[field] = target.value;
+ tempModifiedAlbum[field] = targetValue;
}else if(type === TRACK){
let tempAlbumTracks = tempModifiedAlbum.albumTracks;
let track = {};
if(!tempAlbumTracks){
tempAlbumTracks = [];
- track[field] = target.value;
+ track[field] = targetValue;
track['songId'] = songId;
tempAlbumTracks.push(track);
}else{
track = tempAlbumTracks.find(elem => {return elem.songId === songId});
if(track){
- track[field] = target.value;
+ track[field] = targetValue;
tempAlbumTracks.forEach((element,i) => {
if(element.songId === songId){
tempAlbumTracks[i] = track;
@@ -54,7 +55,7 @@ export const EditAlbumInfo = () => {
});
}else{
track = {};
- track[field] = target.value;
+ track[field] = targetValue;
track['songId'] = songId;
tempAlbumTracks.push(track);
}
@@ -74,13 +75,13 @@ export const EditAlbumInfo = () => {
}
if(track){
trackIndex = tempAlbumTracks.findIndex(elem1=> elem1.songId === track.songId);
- track[field] = target.value;
+ track[field] = targetValue;
tempAlbumTracks[trackIndex] = track;
}else{
track = {
songId : elem.songId,
}
- track[field] = target.value;
+ track[field] = targetValue;
tempAlbumTracks.push(track);
}
});
diff --git a/src/g-player-react/src/Components/utilities/util.js b/src/g-player-react/src/Components/utilities/util.js
index d13094c..1c0c1e4 100644
--- a/src/g-player-react/src/Components/utilities/util.js
+++ b/src/g-player-react/src/Components/utilities/util.js
@@ -1,4 +1,4 @@
-import { SORT_NONE, SORT_PLAY_COUNT, WIKI_SUMMARY_URL } from "../redux/GPActionTypes";
+import { GP_SORTING_KEY_MAPPING, SORT_NONE, SORT_PLAY_COUNT, WIKI_SUMMARY_URL } from "../redux/GPActionTypes";
export const getMins = (seconds) =>{
@@ -182,6 +182,20 @@ export const sortGroupByField = (entArr, field, histArr) => {
return entListObj;
}
+export const sortByKey = (key,arr,obj) => {
+ console.log("sortByKey key: ",key)
+ console.log("sortByKey arr: ",arr)
+ console.log("sortByKey obj: ",obj)
+ let sarr = [...arr];
+ if(obj && Object.keys(obj).length>0){
+ sarr = arr.sort((a,b)=>obj[a]>obj[b]?GP_SORTING_KEY_MAPPING[key]:GP_SORTING_KEY_MAPPING[key]*-1);
+ }else{
+ sarr = arr.sort((a,b)=>a>b?GP_SORTING_KEY_MAPPING[key]:GP_SORTING_KEY_MAPPING[key]*-1);
+ }
+ console.log("sarr: ",sarr)
+ return sarr;
+}
+
export const getCountArr = (maxCount, countArr) => {
for(let i=5;i
songs = null;
try {
+ Playlist playlist = playlistRepository.getByName(reqPlaylist.getPlaylist());
if (reqPlaylist.getSongId() != 0) {
Library library = libraryService.getSongBySongId(reqPlaylist.getSongId());
playlistItem = createPlaylistItemBySong(library, reqPlaylist);
@@ -82,6 +83,11 @@ public GPResponse addToPlaList(PlaylistItem reqPlaylist) {
playlistItems.add(playlistItem);
resp.setStatus(GP_CONSTANTS.SUCCESS);
resp.setPlaylistItems(playlistItems);
+ if(null != playlist){
+ playlist.setLastUpdated(LocalDateTime.now());
+ playlistRepository.save(playlist);
+ }
+
} else {
resp.setStatus(GP_CONSTANTS.FAILED);
resp.setPlaylistItems(playlistItems);
@@ -112,6 +118,7 @@ public GPResponse addToPlaList(PlaylistItem reqPlaylist) {
resp.setStatus(GP_CONSTANTS.SUCCESS);
resp.setPlaylistItems(playlistItems);
}
+
} catch (Exception e) {
resp.setStatus(GP_CONSTANTS.FAILED);
resp.setStatus1(null);
@@ -439,7 +446,7 @@ public GPResponse importPlaylists(String payload, String fileType) {
for (String reqPlName : reqPlaylistObjKeys) {
playlist = playlistRepository.getByName(reqPlName);
if (playlist == null) {
- playlist = new Playlist(reqPlName, LocalDateTime.now(), null);
+ playlist = new Playlist(reqPlName, LocalDateTime.now(), LocalDateTime.now());
playlist = playlistRepository.save(playlist);
}
reqPlaylistArr = (JSONArray) reqPlaylistsObj.get(reqPlName);
@@ -463,6 +470,8 @@ public GPResponse importPlaylists(String payload, String fileType) {
}
addSongsToPlaylist(songs, playlist);
+ playlist.setLastUpdated(LocalDateTime.now());
+ playlistRepository.save(playlist);
}
resp.setResponse(getPlaylists());
resp.setStatus1(String.valueOf(reqPlaylistObjKeys.size()));
@@ -507,7 +516,7 @@ public GPResponse createPlalist(String name) {
resp.setError(GP_ERRORS.ERR_PLAYLIST_ALREADY_EXISTS);
return resp;
}
- temPlaylist = playlistRepository.save(new Playlist(name, LocalDateTime.now(), null));
+ temPlaylist = playlistRepository.save(new Playlist(name, LocalDateTime.now(), LocalDateTime.now()));
resp.setStatus(GP_CONSTANTS.SUCCESS);
resp.setResponse(temPlaylist);
return resp;