Skip to content

Commit

Permalink
Feat: Work actions in album detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Sep 17, 2024
1 parent 09e84d5 commit 2926881
Show file tree
Hide file tree
Showing 26 changed files with 227 additions and 153 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ All scripts in the mympd-scripts repository are updated accordingly, do not forg
- MYMPD_API_QUEUE_INSERT_ALBUM_RANGE: new
- MYMPD_API_QUEUE_REPLACE_ALBUM_RANGE: new
- MYMPD_API_SETTINGS_GET: returns now available sticker types
- MYMPD_API_QUEUE_APPEND_ALBUM_DISC renamed to MYMPD_API_QUEUE_APPEND_ALBUM_TAG
- MYMPD_API_QUEUE_INSERT_ALBUM_DISC renamed to MYMPD_API_QUEUE_INSERT_ALBUM_TAG
- MYMPD_API_QUEUE_REPLACE_ALBUM_DISC renamed to MYMPD_API_QUEUE_REPLACE_ALBUM_TAG
- MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_DISC renamed to MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_TAG
- MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_DISC renamed to MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_TAG
- MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_DISC renamed to MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_TAG

### Changelog

Expand All @@ -52,6 +58,7 @@ All scripts in the mympd-scripts repository are updated accordingly, do not forg
- Feat: Add list view
- Feat: Add widgets for home screen
- Feat: Sort list of playlists by name or last-modified
- Feat: Work actions in album detail view
- Upd: Playlist pictures are moved in a separate folder `/var/lib/mympd/pics/playlists`
- Upd: Latest libmympdclient based on libmpdclient master
- Upd: Hide advanced search by default
Expand Down
19 changes: 10 additions & 9 deletions htdocs/js/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,33 @@
/** @module album_js */

/**
* Handles single disc actions
* Handles album filtered by tag
* @param {string} action action to perform
* @param {string} albumId the album id
* @param {string} disc disc number as string
* @param {string} tag MPD tag
* @param {string} value MPD tag value
* @returns {void}
*/
//eslint-disable-next-line no-unused-vars
function addAlbumDisc(action, albumId, disc) {
function addAlbumTag(action, albumId, tag, value) {
switch(action) {
case 'appendQueue':
appendQueue('disc', [albumId, disc]);
appendQueue(tag, [albumId, value]);
break;
case 'appendPlayQueue':
appendPlayQueue('disc', [albumId, disc]);
appendPlayQueue(tag, [albumId, value]);
break;
case 'insertAfterCurrentQueue':
insertAfterCurrentQueue('disc', [albumId, disc]);
insertAfterCurrentQueue(tag, [albumId, value]);
break;
case 'replaceQueue':
replaceQueue('disc', [albumId, disc]);
replaceQueue(tag, [albumId, value]);
break;
case 'replacePlayQueue':
replacePlayQueue('disc', [albumId, disc]);
replacePlayQueue(tag, [albumId, value]);
break;
case 'addPlaylist':
showAddToPlaylist('disc', [albumId, disc]);
showAddToPlaylist(tag, [albumId, value]);
break;
default:
logError('Invalid action: ' + action);
Expand Down
46 changes: 31 additions & 15 deletions htdocs/js/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ const APIparams = {
"type": APItypes.int,
"example": 1,
"desc": "End position (excluding), use -1 for open end"
},
"tag": {
"type": APItypes.string,
"example": "Disc",
"desc": "MPD tag"
},
"tagValue": {
"type": APItypes.string,
"example": "1",
"desc": "MPD tag value"
}
};

Expand Down Expand Up @@ -510,11 +520,12 @@ const APImethods = {
"play": APIparams.play
}
},
"MYMPD_API_QUEUE_INSERT_ALBUM_DISC": {
"desc": "Inserts one discs from an album to distinct position in the queue.",
"MYMPD_API_QUEUE_INSERT_ALBUM_TAG": {
"desc": "Inserts songs from an album with specified tag value to distinct position in the queue.",
"params": {
"albumid": APIparams.albumid,
"disc": APIparams.disc,
"tag": APIparams.tag,
"value": APIparams.tagValue,
"to": APIparams.to,
"whence": APIparams.whence,
"play": APIparams.play
Expand Down Expand Up @@ -584,11 +595,12 @@ const APImethods = {
"play": APIparams.play
}
},
"MYMPD_API_QUEUE_APPEND_ALBUM_DISC": {
"desc": "Appends on disc from an album to the queue.",
"MYMPD_API_QUEUE_APPEND_ALBUM_TAG": {
"desc": "Appends songs from an album to the queue with specified tag value.",
"params": {
"albumid": APIparams.albumid,
"disc": APIparams.disc,
"tag": APIparams.tag,
"value": APIparams.tagValue,
"play": APIparams.play
}
},
Expand Down Expand Up @@ -654,11 +666,12 @@ const APImethods = {
"play": APIparams.play
}
},
"MYMPD_API_QUEUE_REPLACE_ALBUM_DISC": {
"desc": "Replaces the queue with one disc from an album.",
"MYMPD_API_QUEUE_REPLACE_ALBUM_TAG": {
"desc": "Replaces the queue with songs from an album with specified tag value.",
"params": {
"albumid": APIparams.albumid,
"disc": APIparams.disc,
"tag": APIparams.tag,
"value": APIparams.tagValue,
"play": APIparams.play
}
},
Expand Down Expand Up @@ -791,12 +804,13 @@ const APImethods = {
"albumids": APIparams.albumids
}
},
"MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_DISC": {
"MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_TAG": {
"desc": "Appends one disc from an album to the playlist.",
"params": {
"plist": APIparams.plist,
"albumid": APIparams.albumid,
"disc": APIparams.disc
"tag": APIparams.tag,
"value": APIparams.tagValue
}
},
"MYMPD_API_PLAYLIST_CONTENT_INSERT_URIS": {
Expand All @@ -815,12 +829,13 @@ const APImethods = {
"to": APIparams.to
}
},
"MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_DISC": {
"MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_TAG": {
"desc": "Inserts one disc from an album to the playlist.",
"params": {
"plist": APIparams.plist,
"albumid": APIparams.albumid,
"disc": APIparams.disc,
"tag": APIparams.tag,
"value": APIparams.tagValue,
"to": APIparams.to
}
},
Expand All @@ -838,12 +853,13 @@ const APImethods = {
"albumids": APIparams.albumids
}
},
"MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_DISC": {
"MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_TAG": {
"desc": "Replaces the playlist content with one disc from an album.",
"params": {
"plist": APIparams.plist,
"albumid": APIparams.albumid,
"disc": APIparams.disc
"tag": APIparams.tag,
"value": APIparams.tagValue
}
},
"MYMPD_API_PLAYLIST_CONTENT_INSERT_SEARCH": {
Expand Down
3 changes: 3 additions & 0 deletions htdocs/js/clickActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ function clickQuickPlay(target) {
case 'disc':
uri.push(getData(dataNode, 'AlbumId'), getData(dataNode, 'Disc'));
break;
case 'work':
uri.push(getData(dataNode, 'AlbumId'), getData(dataNode, 'Work'));
break;
default:
uri.push(getData(dataNode, 'uri'));
}
Expand Down
17 changes: 9 additions & 8 deletions htdocs/js/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,24 @@ function addMenuItemsNavbarActions(target, popoverBody) {
* @param {HTMLElement} contextMenuBody element to append the menu items
* @returns {void}
*/
function addMenuItemsDiscActions(target, contextMenuTitle, contextMenuBody) {
function addMenuItemsAlbumTagActions(target, contextMenuTitle, contextMenuBody) {
const dataNode = target.parentNode.parentNode;
const disc = getData(dataNode, 'Disc');
const type = getData(dataNode, 'type');
const value = getData(dataNode, ucFirst(type));
const albumId = getData(dataNode, 'AlbumId');

addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["appendQueue", albumId, disc]}, 'Append to queue');
addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["appendPlayQueue", albumId, disc]}, 'Append to queue and play');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["appendQueue", albumId, type, value]}, 'Append to queue');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["appendPlayQueue", albumId, type, value]}, 'Append to queue and play');
if (features.featWhence === true &&
currentState.currentSongId !== -1)
{
addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["insertAfterCurrentQueue", albumId, disc]}, 'Insert after current playing song');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["insertAfterCurrentQueue", albumId, type, value]}, 'Insert after current playing song');
}
addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["replaceQueue", albumId, disc]}, 'Replace queue');
addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["replacePlayQueue", albumId, disc]}, 'Replace queue and play');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["replaceQueue", albumId, type, value]}, 'Replace queue');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["replacePlayQueue", albumId, type, value]}, 'Replace queue and play');
if (features.featPlaylists === true) {
addDivider(contextMenuBody);
addMenuItem(contextMenuBody, {"cmd": "addAlbumDisc", "options": ["addPlaylist", albumId, disc]}, 'Add to playlist');
addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["addPlaylist", albumId, type, value]}, 'Add to playlist');
}
}

Expand Down
5 changes: 3 additions & 2 deletions htdocs/js/contextMenuOffcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ function showContextMenuOffcanvas(target, contextMenuType) {
createContextMenuOffcanvas(target, contextMenuEl, contextMenuType, createMenuViewSettings, undefined);
break;
case 'disc':
//disc actions in album details view
createContextMenuOffcanvas(target, contextMenuEl, contextMenuType, addMenuItemsDiscActions, undefined);
case 'work':
//disc and work actions in album details view
createContextMenuOffcanvas(target, contextMenuEl, contextMenuType, addMenuItemsAlbumTagActions, undefined);
break;
case 'homeIcon':
//home card icon actions
Expand Down
9 changes: 9 additions & 0 deletions htdocs/js/customElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function createPreGeneratedElements() {
pEl.selectAllBtn = elCreateText('button', {"type": "button", "href": "#", "class": ["btn", "mi", "border-0"], "data-title-phrase": "Select all"}, 'radio_button_unchecked');
pEl.actionsBtn = elCreateText('a', {"data-action": "popover", "href": "#", "class": ["mi", "color-darkgrey"], "data-title-phrase": "Actions"}, ligatures['more']);
pEl.actionsDiscBtn = elCreateText('a', {"data-action": "popover", "data-contextmenu": "disc", "href": "#", "class": ["mi", "color-darkgrey"], "data-title-phrase": "Actions"}, ligatures['more']);
pEl.actionsWorkBtn = elCreateText('a', {"data-action": "popover", "data-contextmenu": "work", "href": "#", "class": ["mi", "color-darkgrey"], "data-title-phrase": "Actions"}, ligatures['more']);
pEl.removeBtn = elCreateText('a', {"data-action": "quickRemove", "href": "#", "class": ["mi", "color-darkgrey", "me-1"], "data-title-phrase": "Remove"}, 'clear');
pEl.playBtn = elCreateText('a', {"data-action": "quickPlay", "href": "#", "class": ["mi", "color-darkgrey", "me-1"], "data-title-phrase": "Quick play"}, 'play_arrow');
pEl.showSongsBtn = elCreateText('a', {"data-action": "showSongsByTag", "class": ["mi", "color-darkgrey", "me-1"], "href": "#", "data-title-phrase": "Show songs"}, 'music_note');
Expand Down Expand Up @@ -59,13 +60,21 @@ function createPreGeneratedElements() {
pEl.actionMenuDisc = [
pEl.actionsDiscBtn
];
pEl.actionMenuWork = [
pEl.actionsWorkBtn
];
pEl.actionMenuDiscPlay = [
pEl.playBtn,
pEl.actionsDiscBtn
];
pEl.actionMenuWorkPlay = [
pEl.playBtn,
pEl.actionsWorkBtn
];

pEl.actionIcons = pEl.actionMenu;
pEl.actionDiscIcons = pEl.actionMenuDisc;
pEl.actionWorkIcons = pEl.actionMenuWork;
pEl.actionQueueIcons = pEl.actionMenu;
pEl.actionJukeboxIcons = pEl.actionMenu;
pEl.actionPlaylistDetailIcons = pEl.actionMenu;
Expand Down
17 changes: 9 additions & 8 deletions htdocs/js/globales.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,6 @@ const settingsFields = {
"title": "Enforce disc tag",
"form": "modalSettingsTagsFrm",
"help": "helpSettingsTagDiscEmptyIsFirst"
},
"showWorkTagAlbumDetail": {
"defaultValue": defaults["MYMPD_SHOW_WORK_TAG_ALBUM_DETAIL"],
"inputType": "checkbox",
"title": "Show work in album detail",
"form": "modalSettingsTagsFrm",
"help": "helpSettingsShowWorkTagAlbumDetail"
}
};

Expand Down Expand Up @@ -893,6 +886,13 @@ const settingsWebuiFields = {
"title": "Album list sort",
"form": "modalSettingsSortFrm",
"help": "helpSettingsAlbumListSort"
},
"showWorkTagAlbumDetail": {
"defaultValue": false,
"inputType": "checkbox",
"title": "Show work in album detail",
"form": "modalSettingsTagsFrm",
"help": "helpSettingsShowWorkTagAlbumDetail"
}
};

Expand Down Expand Up @@ -1724,7 +1724,8 @@ const typeFriendly = {
'appGoto': 'View',
'webradio': 'Webradio',
'viewSettings': 'View settings',
'disc': 'Disc'
'disc': 'Disc',
'work': 'Work'
};

const friendlyActions = {
Expand Down
18 changes: 12 additions & 6 deletions htdocs/js/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ function appendPlaylist(type, uris, plist, callback) {
}, callback, true);
break;
case 'disc':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_DISC", {
case 'work':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_APPEND_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"plist": plist
}, callback, true);
break;
Expand Down Expand Up @@ -263,9 +265,11 @@ function insertPlaylist(type, uris, plist, to, callback) {
}, callback, true);
break;
case 'disc':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_DISC", {
case 'work':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_INSERT_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"plist": plist,
"to": to
}, callback, true);
Expand Down Expand Up @@ -316,9 +320,11 @@ function replacePlaylist(type, uris, plist, callback) {
}, callback, true);
break;
case 'disc':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_DISC", {
case 'work':
sendAPI("MYMPD_API_PLAYLIST_CONTENT_REPLACE_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"plist": plist
}, callback, true);
break;
Expand Down
18 changes: 12 additions & 6 deletions htdocs/js/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ function _appendQueue(type, uris, play, callback) {
}, callback, true);
break;
case 'disc':
case 'work':
//disc is limited to one at a time
sendAPI("MYMPD_API_QUEUE_APPEND_ALBUM_DISC", {
sendAPI("MYMPD_API_QUEUE_APPEND_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"play": play
}, callback, true);
break;
Expand Down Expand Up @@ -255,9 +257,11 @@ function insertQueue(type, uris, to, whence, play, callback) {
}, callback, true);
break;
case 'disc':
sendAPI("MYMPD_API_QUEUE_INSERT_ALBUM_DISC", {
case 'work':
sendAPI("MYMPD_API_QUEUE_INSERT_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"to": to,
"whence": whence,
"play": play
Expand Down Expand Up @@ -343,9 +347,11 @@ function _replaceQueue(type, uris, play, callback) {
}, callback, true);
break;
case 'disc':
sendAPI("MYMPD_API_QUEUE_REPLACE_ALBUM_DISC", {
case 'work':
sendAPI("MYMPD_API_QUEUE_REPLACE_ALBUM_TAG", {
"albumid": uris[0],
"disc": uris[1].toString(),
"tag": type,
"value": uris[1].toString(),
"play": play
}, callback, true);
break;
Expand Down
Loading

0 comments on commit 2926881

Please sign in to comment.