mirror of
				https://github.com/SuperBFG7/ympd
				synced 2025-10-31 05:43:01 +00:00 
			
		
		
		
	Feat: add rescan database command
This commit is contained in:
		| @@ -128,6 +128,12 @@ small { | |||||||
|   font-feature-settings: 'liga'; |   font-feature-settings: 'liga'; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .material-icons-left { | ||||||
|  |   font-size: 1rem; | ||||||
|  |   margin-left: -1em; | ||||||
|  |   vertical-align:middle; | ||||||
|  | } | ||||||
|  |  | ||||||
| .material-icons-small { | .material-icons-small { | ||||||
|   font-size: 16px; |   font-size: 16px; | ||||||
| } | } | ||||||
| @@ -281,3 +287,7 @@ caption { | |||||||
|   width:100%; |   width:100%; | ||||||
|   margin-left: 15px; |   margin-left: 15px; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #menu-dbupdate { | ||||||
|  |   padding-left:1rem; | ||||||
|  | } | ||||||
| @@ -24,7 +24,11 @@ | |||||||
|           </a> |           </a> | ||||||
|           <div class="dropdown-menu bg-dark"> |           <div class="dropdown-menu bg-dark"> | ||||||
|             <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "showAddToPlaylist", "options": ["stream"]}'>Add Stream</a> |             <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "showAddToPlaylist", "options": ["stream"]}'>Add Stream</a> | ||||||
|             <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "updateDB", "options": []}'>Update Database</a> |             <a id="navDBupdate" class="dropdown-item text-light bg-dark" data-toggle="collapse" href="#menu-dbupdate"><span class="material-icons material-icons-left">keyboard_arrow_right</span>Database</a> | ||||||
|  |               <div class="collapse" id="menu-dbupdate"> | ||||||
|  |                 <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "updateDB", "options": []}'>Update</a> | ||||||
|  |                 <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "rescanDB", "options": []}'>Rescan</a> | ||||||
|  |               </div> | ||||||
|             <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "openLocalPlayer", "options": []}'>Local Player</a> |             <a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "openLocalPlayer", "options": []}'>Local Player</a> | ||||||
|             <a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalSettings">Settings</a> |             <a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalSettings">Settings</a> | ||||||
|             <a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalAbout">About</a> |             <a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalAbout">About</a> | ||||||
|   | |||||||
| @@ -310,6 +310,16 @@ function appInit() { | |||||||
|         } |         } | ||||||
|     }, false); |     }, false); | ||||||
|  |  | ||||||
|  |     document.getElementById('navDBupdate').addEventListener('click', function(event) { | ||||||
|  |         event.stopPropagation(); | ||||||
|  |         event.preventDefault(); | ||||||
|  |         var icon = this.getElementsByTagName('span')[0]; | ||||||
|  |         if (icon.innerText == 'keyboard_arrow_right') | ||||||
|  |             icon.innerText = 'keyboard_arrow_down'; | ||||||
|  |         else | ||||||
|  |             icon.innerText = 'keyboard_arrow_right';         | ||||||
|  |     }, false); | ||||||
|  |    | ||||||
|     document.getElementById('volumeIcon').parentNode.addEventListener('show.bs.dropdown', function () { |     document.getElementById('volumeIcon').parentNode.addEventListener('show.bs.dropdown', function () { | ||||||
|         sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs); |         sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs); | ||||||
|     });     |     });     | ||||||
| @@ -1840,6 +1850,11 @@ function updateDB() { | |||||||
|     updateDBstarted(true); |     updateDBstarted(true); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function rescanDB() { | ||||||
|  |     sendAPI({"cmd": "MPD_API_DATABASE_RESCAN"}); | ||||||
|  |     updateDBstarted(true); | ||||||
|  | } | ||||||
|  |  | ||||||
| function updateDBstarted(showModal) { | function updateDBstarted(showModal) { | ||||||
|     if (showModal == true) { |     if (showModal == true) { | ||||||
|         document.getElementById('updateDBfinished').innerText = ''; |         document.getElementById('updateDBfinished').innerText = ''; | ||||||
|   | |||||||
| @@ -179,6 +179,11 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) { | |||||||
|             if (uint_rc > 0) |             if (uint_rc > 0) | ||||||
|                 n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); |                 n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); | ||||||
|             break; |             break; | ||||||
|  |         case MPD_API_DATABASE_RESCAN: | ||||||
|  |             uint_rc = mpd_run_rescan(mpd.conn, NULL); | ||||||
|  |             if (uint_rc > 0) | ||||||
|  |                 n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); | ||||||
|  |             break;             | ||||||
|         case MPD_API_PLAYER_PAUSE: |         case MPD_API_PLAYER_PAUSE: | ||||||
|             mpd_run_toggle_pause(mpd.conn); |             mpd_run_toggle_pause(mpd.conn); | ||||||
|             n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); |             n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); | ||||||
|   | |||||||
| @@ -74,6 +74,7 @@ | |||||||
|     X(MPD_API_PLAYLIST_CONTENT_LIST) \ |     X(MPD_API_PLAYLIST_CONTENT_LIST) \ | ||||||
|     X(MPD_API_DATABASE_SEARCH) \ |     X(MPD_API_DATABASE_SEARCH) \ | ||||||
|     X(MPD_API_DATABASE_UPDATE) \ |     X(MPD_API_DATABASE_UPDATE) \ | ||||||
|  |     X(MPD_API_DATABASE_RESCAN) \ | ||||||
|     X(MPD_API_DATABASE_FILESYSTEM_LIST) \ |     X(MPD_API_DATABASE_FILESYSTEM_LIST) \ | ||||||
|     X(MPD_API_DATABASE_TAG_LIST) \ |     X(MPD_API_DATABASE_TAG_LIST) \ | ||||||
|     X(MPD_API_DATABASE_TAG_ALBUM_LIST) \ |     X(MPD_API_DATABASE_TAG_ALBUM_LIST) \ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jcorporation
					jcorporation