mirror of
				https://github.com/SuperBFG7/ympd
				synced 2025-10-31 05:43:01 +00:00 
			
		
		
		
	Feat: support search actions for advanced search
Fix: add all to queue button in search card
This commit is contained in:
		| @@ -373,7 +373,7 @@ | |||||||
|           </div> |           </div> | ||||||
|           <div class="input-group mr-2 hide"> |           <div class="input-group mr-2 hide"> | ||||||
|             <div class="input-group-prepend"> |             <div class="input-group-prepend"> | ||||||
|               <button data-href='{"cmd": "addAllFromBrowseDatabase", "options": []}' id="BrowseDatabaseAddAllSongs" class="btn btn-secondary">Add all</button> |               <button data-href='{"cmd": "addAllFromBrowseDatabase", "options": []}' id="BrowseDatabaseAddAllSongs" class="btn btn-secondary material-icons">library_add</button> | ||||||
|               <button id="BrowseDatabaseAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> |               <button id="BrowseDatabaseAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> | ||||||
|               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseDatabaseAddAllSongsDropdown"> |               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseDatabaseAddAllSongsDropdown"> | ||||||
|                 <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> |                 <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> | ||||||
| @@ -445,7 +445,7 @@ | |||||||
|           </div>           |           </div>           | ||||||
|           <div class="input-group mr-2"> |           <div class="input-group mr-2"> | ||||||
|             <div class="input-group-prepend"> |             <div class="input-group-prepend"> | ||||||
|               <button data-href='{"cmd": "addAllFromBrowseFilesystem", "options": []}' id="BrowseFilesystemAddAllSongs" class="btn btn-secondary">Add all</button> |               <button data-href='{"cmd": "addAllFromBrowseFilesystem", "options": []}' id="BrowseFilesystemAddAllSongs" class="btn btn-secondary material-icons">library_add</button> | ||||||
|               <button id="BrowseFilesystemAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> |               <button id="BrowseFilesystemAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> | ||||||
|               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseFilesystemAddAllSongsDropdown"> |               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseFilesystemAddAllSongsDropdown"> | ||||||
|                 <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> |                 <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> | ||||||
| @@ -541,7 +541,7 @@ | |||||||
|           </form> |           </form> | ||||||
|           <div class="input-group mr-2"> |           <div class="input-group mr-2"> | ||||||
|             <div class="input-group-prepend"> |             <div class="input-group-prepend"> | ||||||
|               <button id="searchAddAllSongs" class="btn btn-secondary" data-href='{"cmd": "addAllFromSearch", "options": []}'>Add all</button> |               <button id="searchAddAllSongs" class="btn btn-secondary material-icons" data-href='{"cmd": "addAllFromSearchPlist", "options": ["queue"]}'>library_add</button> | ||||||
|               <button id="searchAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> |               <button id="searchAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button> | ||||||
|               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="searchAddAllSongsDropdown"> |               <div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="searchAddAllSongsDropdown"> | ||||||
|                   <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> |                   <button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button> | ||||||
|   | |||||||
| @@ -2354,6 +2354,14 @@ function parseSmartPlaylist(obj) { | |||||||
|         document.getElementById('saveSmartPlaylistSearch').classList.remove('hide'); |         document.getElementById('saveSmartPlaylistSearch').classList.remove('hide'); | ||||||
|         document.getElementById('selectSaveSmartPlaylistTag').value = obj.data.tag; |         document.getElementById('selectSaveSmartPlaylistTag').value = obj.data.tag; | ||||||
|         document.getElementById('inputSaveSmartPlaylistSearchstr').value = obj.data.searchstr; |         document.getElementById('inputSaveSmartPlaylistSearchstr').value = obj.data.searchstr; | ||||||
|  |         if (settings.featAdvsearch) { | ||||||
|  |             document.getElementById('selectSaveSmartPlaylistTag').parentNode.classList.add('hide'); | ||||||
|  |             document.getElementById('inputSaveSmartPlaylistSearchstr').parentNode.classList.replace('col-md-6','col-md-12'); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             document.getElementById('selectSaveSmartPlaylistTag').parentNode.classList.remove('hide'); | ||||||
|  |             document.getElementById('inputSaveSmartPlaylistSearchstr').parentNode.classList.replace('col-md-12','col-md-6'); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     else if (obj.data.type == 'sticker') { |     else if (obj.data.type == 'sticker') { | ||||||
|         document.getElementById('saveSmartPlaylistSticker').classList.remove('hide'); |         document.getElementById('saveSmartPlaylistSticker').classList.remove('hide'); | ||||||
| @@ -2390,6 +2398,8 @@ function saveSmartPlaylist() { | |||||||
|         if (type == 'search') { |         if (type == 'search') { | ||||||
|             var tagEl = document.getElementById('selectSaveSmartPlaylistTag'); |             var tagEl = document.getElementById('selectSaveSmartPlaylistTag'); | ||||||
|             var tag = tagEl.options[tagEl.selectedIndex].value; |             var tag = tagEl.options[tagEl.selectedIndex].value; | ||||||
|  |             if (settings.featAdvsearch) | ||||||
|  |                 tag = 'expression'; | ||||||
|             var searchstr = document.getElementById('inputSaveSmartPlaylistSearchstr').value; |             var searchstr = document.getElementById('inputSaveSmartPlaylistSearchstr').value; | ||||||
|             sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"type": type, "playlist": name, "tag": tag, "searchstr": searchstr}}); |             sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"type": type, "playlist": name, "tag": tag, "searchstr": searchstr}}); | ||||||
|         } else if (type == 'sticker') { |         } else if (type == 'sticker') { | ||||||
| @@ -2606,9 +2616,8 @@ function showMenu(el, event) { | |||||||
|             addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]},'Replace queue') + |             addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]},'Replace queue') + | ||||||
|             (type == 'smartpls' ? addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'View playlist') : addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'Edit playlist'))+ |             (type == 'smartpls' ? addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'View playlist') : addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'Edit playlist'))+ | ||||||
|             (type == 'smartpls' ? addMenuItem({"cmd": "showSmartPlaylist", "options": [uri]}, 'Edit smart playlist') : '') + |             (type == 'smartpls' ? addMenuItem({"cmd": "showSmartPlaylist", "options": [uri]}, 'Edit smart playlist') : '') + | ||||||
|             (type != 'smartpls' ? |  | ||||||
|             addMenuItem({"cmd": "showRenamePlaylist", "options": [uri]}, 'Rename playlist') +  |             addMenuItem({"cmd": "showRenamePlaylist", "options": [uri]}, 'Rename playlist') +  | ||||||
|                 addMenuItem({"cmd": "showDelPlaylist", "options": [uri]}, 'Delete playlist') : ''); |             addMenuItem({"cmd": "showDelPlaylist", "options": [uri]}, 'Delete playlist'); | ||||||
|     } |     } | ||||||
|     else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') { |     else if (app.current.app == 'Browse' && app.current.tab == 'Playlists' && app.current.view == 'Detail') { | ||||||
|         var x = document.getElementById('BrowsePlaylistsDetailList'); |         var x = document.getElementById('BrowsePlaylistsDetailList'); | ||||||
| @@ -2858,9 +2867,13 @@ function addAllFromBrowseFilesystem() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function addAllFromSearchPlist(plist) { | function addAllFromSearchPlist(plist) { | ||||||
|     if (app.current.search.length >= 2) { |     var nr = parseInt(document.getElementById('panel-heading-search').innerText); | ||||||
|  |     if (nr != NaN && nr > 0) { | ||||||
|  |         if (settings.featAdvsearch) | ||||||
|  |             sendAPI({"cmd": "MPD_API_DATABASE_SEARCH_ADV", "data": {"plist": plist, "sort": "", "sortdesc": false, "expression": app.current.search, "offset": 0}}); | ||||||
|  |         else | ||||||
|             sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.filter, "searchstr": app.current.search, "offset": 0}}); |             sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.filter, "searchstr": app.current.search, "offset": 0}}); | ||||||
|         showNotification('Added '+ parseInt(document.getElementById('panel-heading-search').innerText) +' songs from search to ' + plist, '', '', 'success'); |         showNotification('Added ' + nr  +' songs from search to ' + plist, '', '', 'success'); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2546,6 +2546,9 @@ int mympd_smartpls_clear(char *playlist) { | |||||||
|  |  | ||||||
| int mympd_smartpls_update_search(char *playlist, char *tag, char *searchstr) { | int mympd_smartpls_update_search(char *playlist, char *tag, char *searchstr) { | ||||||
|     mympd_smartpls_clear(playlist); |     mympd_smartpls_clear(playlist); | ||||||
|  |     if (mpd.feat_advsearch == true && strcmp(tag, "expression") == 0) | ||||||
|  |         mympd_search_adv(mpd.buf, searchstr, NULL, true, NULL, playlist, 0); | ||||||
|  |     else | ||||||
|         mympd_search(mpd.buf, searchstr, tag, playlist, 0); |         mympd_search(mpd.buf, searchstr, tag, playlist, 0); | ||||||
|     printf("Updated %s\n", playlist); |     printf("Updated %s\n", playlist); | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jcorporation
					jcorporation