mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #2705 from thornbill/custom-menu-links
Add support for custom menu links in config.json
This commit is contained in:
commit
c6862bcebe
3 changed files with 44 additions and 2 deletions
|
@ -23,6 +23,7 @@
|
||||||
"id": "wmc"
|
"id": "wmc"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"menuLinks": [],
|
||||||
"servers": [],
|
"servers": [],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"playAccessValidation/plugin",
|
"playAccessValidation/plugin",
|
||||||
|
|
|
@ -10,6 +10,7 @@ import groupSelectionMenu from '../components/syncPlay/ui/groupSelectionMenu';
|
||||||
import browser from './browser';
|
import browser from './browser';
|
||||||
import globalize from './globalize';
|
import globalize from './globalize';
|
||||||
import imageHelper from './imagehelper';
|
import imageHelper from './imagehelper';
|
||||||
|
import { getMenuLinks } from '../scripts/settings/webSettings';
|
||||||
import '../elements/emby-button/paper-icon-button-light';
|
import '../elements/emby-button/paper-icon-button-light';
|
||||||
import 'material-design-icons-iconfont';
|
import 'material-design-icons-iconfont';
|
||||||
import '../assets/css/scrollstyles.scss';
|
import '../assets/css/scrollstyles.scss';
|
||||||
|
@ -273,9 +274,11 @@ import Headroom from 'headroom.js';
|
||||||
html += '<div style="height:.5em;"></div>';
|
html += '<div style="height:.5em;"></div>';
|
||||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" href="#!/home.html"><span class="material-icons navMenuOptionIcon home"></span><span class="navMenuOptionText">' + globalize.translate('Home') + '</span></a>';
|
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" href="#!/home.html"><span class="material-icons navMenuOptionIcon home"></span><span class="navMenuOptionText">' + globalize.translate('Home') + '</span></a>';
|
||||||
|
|
||||||
|
// placeholder for custom menu links
|
||||||
|
html += '<div class="customMenuOptions"></div>';
|
||||||
|
|
||||||
// libraries are added here
|
// libraries are added here
|
||||||
html += '<div class="libraryMenuOptions">';
|
html += '<div class="libraryMenuOptions"></div>';
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
if (user.localUser && user.localUser.Policy.IsAdministrator) {
|
if (user.localUser && user.localUser.Policy.IsAdministrator) {
|
||||||
html += '<div class="adminMenuOptions">';
|
html += '<div class="adminMenuOptions">';
|
||||||
|
@ -638,6 +641,32 @@ import Headroom from 'headroom.js';
|
||||||
|
|
||||||
const userId = Dashboard.getCurrentUserId();
|
const userId = Dashboard.getCurrentUserId();
|
||||||
const apiClient = getCurrentApiClient();
|
const apiClient = getCurrentApiClient();
|
||||||
|
|
||||||
|
const customMenuOptions = document.querySelector('.customMenuOptions');
|
||||||
|
if (customMenuOptions) {
|
||||||
|
getMenuLinks().then(links => {
|
||||||
|
links.forEach(link => {
|
||||||
|
const option = document.createElement('a');
|
||||||
|
option.setAttribute('is', 'emby-linkbutton');
|
||||||
|
option.className = 'navMenuOption lnkMediaFolder';
|
||||||
|
option.rel = 'noopener noreferrer';
|
||||||
|
option.target = '_blank';
|
||||||
|
option.href = link.url;
|
||||||
|
|
||||||
|
const icon = document.createElement('span');
|
||||||
|
icon.className = `material-icons navMenuOptionIcon ${link.icon || 'link'}`;
|
||||||
|
option.appendChild(icon);
|
||||||
|
|
||||||
|
const label = document.createElement('span');
|
||||||
|
label.className = 'navMenuOptionText';
|
||||||
|
label.textContent = link.name;
|
||||||
|
option.appendChild(label);
|
||||||
|
|
||||||
|
customMenuOptions.appendChild(option);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
const libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
||||||
|
|
||||||
if (libraryMenuOptions) {
|
if (libraryMenuOptions) {
|
||||||
|
|
|
@ -126,6 +126,18 @@ export function getThemes() {
|
||||||
|
|
||||||
export const getDefaultTheme = () => internalDefaultTheme;
|
export const getDefaultTheme = () => internalDefaultTheme;
|
||||||
|
|
||||||
|
export function getMenuLinks() {
|
||||||
|
return getConfig().then(config => {
|
||||||
|
if (!config.menuLinks) {
|
||||||
|
console.error('web config is invalid, missing menuLinks:', config);
|
||||||
|
}
|
||||||
|
return config.menuLinks || [];
|
||||||
|
}).catch(error => {
|
||||||
|
console.log('cannot get web config:', error);
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getPlugins() {
|
export function getPlugins() {
|
||||||
return getConfig().then(config => {
|
return getConfig().then(config => {
|
||||||
if (!config.plugins) {
|
if (!config.plugins) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue