mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-26 02:50:26 +00:00
Feat: confirm dialog for delete playlist #47
This commit is contained in:
parent
bb5bf87dbd
commit
41a46b3656
@ -646,6 +646,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modalDeletePlaylist" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><span class="material-icons title-icon">delete</span>Delete playlist</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="deletePlaylistFrm">
|
||||
<div class="form-group">
|
||||
<label for="deletePlaylist">Playlist</label>
|
||||
<input type="text" class="form-control" id="deletePlaylist" readonly>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-success" data-href='{"cmd": "delPlaylist", "options": []}'>Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modalSaveSmartPlaylist" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
|
@ -92,6 +92,7 @@ var modalAddToPlaylist = new Modal(document.getElementById('modalAddToPlaylist')
|
||||
var modalRenamePlaylist = new Modal(document.getElementById('modalRenamePlaylist'));
|
||||
var modalUpdateDB = new Modal(document.getElementById('modalUpdateDB'));
|
||||
var modalSaveSmartPlaylist = new Modal(document.getElementById('modalSaveSmartPlaylist'));
|
||||
var modalDeletePlaylist = new Modal(document.getElementById('modalDeletePlaylist'));
|
||||
|
||||
function appPrepare(scrollPos) {
|
||||
if (app.current.app != app.last.app || app.current.tab != app.last.tab || app.current.view != app.last.view) {
|
||||
@ -1958,7 +1959,7 @@ function showMenu(el, event) {
|
||||
(type == 'smartpls' ? addMenuItem({"cmd": "showSmartPlaylist", "options": [uri]}, 'Edit smart playlist') : '') +
|
||||
(uri.indexOf('myMPDsmart') != 0 ?
|
||||
addMenuItem({"cmd": "showRenamePlaylist", "options": [uri]}, 'Rename playlist') +
|
||||
addMenuItem({"cmd": "delPlaylist", "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') {
|
||||
var x = document.getElementById('BrowsePlaylistsDetailList');
|
||||
@ -2118,9 +2119,15 @@ function delQueueSong(mode, start, end) {
|
||||
sendAPI({"cmd": "MPD_API_QUEUE_RM_TRACK", "data": { "track": start}});
|
||||
}
|
||||
|
||||
function delPlaylist(uri) {
|
||||
sendAPI({"cmd": "MPD_API_PLAYLIST_RM", "data": {"uri": uri}});
|
||||
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST","data": {"offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
||||
function showDelPlaylist(uri) {
|
||||
document.getElementById('deletePlaylist').value = uri;
|
||||
modalDeletePlaylist.show();
|
||||
}
|
||||
|
||||
function delPlaylist() {
|
||||
var uri = document.getElementById('deletePlaylist').value;
|
||||
sendAPI({"cmd": "MPD_API_PLAYLIST_RM_AND_LIST", "data": {"uri": uri, "offset": app.current.page, "filter": app.current.filter}}, parsePlaylists);
|
||||
modalDeletePlaylist.hide();
|
||||
}
|
||||
|
||||
function confirmSettings() {
|
||||
|
@ -546,6 +546,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
break;
|
||||
case MPD_API_PLAYLIST_RM_AND_LIST:
|
||||
case MPD_API_PLAYLIST_RM:
|
||||
je = json_scanf(msg.p, msg.len, "{data: {uri:%Q}}", &p_charbuf1);
|
||||
if (je == 1) {
|
||||
@ -559,6 +560,12 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) {
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
}
|
||||
//AND_LIST
|
||||
je = json_scanf(msg.p, msg.len, "{data: {offset:%u, filter:%Q}}", &uint_buf1, &p_charbuf1);
|
||||
if (je == 2) {
|
||||
n = mympd_put_playlists(mpd.buf, uint_buf1, p_charbuf1);
|
||||
free(p_charbuf1);
|
||||
}
|
||||
break;
|
||||
case MPD_API_SETTINGS_GET:
|
||||
n = mympd_put_settings(mpd.buf);
|
||||
|
@ -65,6 +65,7 @@
|
||||
X(MPD_API_QUEUE_ADD_PLAYLIST) \
|
||||
X(MPD_API_QUEUE_REPLACE_PLAYLIST) \
|
||||
X(MPD_API_QUEUE_SHUFFLE) \
|
||||
X(MPD_API_PLAYLIST_RM_AND_LIST) \
|
||||
X(MPD_API_PLAYLIST_RM) \
|
||||
X(MPD_API_PLAYLIST_CLEAR) \
|
||||
X(MPD_API_PLAYLIST_RENAME) \
|
||||
|
Loading…
Reference in New Issue
Block a user