mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration of musicrecommended to ES6 module
This commit is contained in:
parent
d7142955f9
commit
29ae08ffb4
2 changed files with 62 additions and 41 deletions
|
@ -116,6 +116,7 @@
|
||||||
"src/components/syncPlay/timeSyncManager.js",
|
"src/components/syncPlay/timeSyncManager.js",
|
||||||
"src/controllers/dashboard/logs.js",
|
"src/controllers/dashboard/logs.js",
|
||||||
"src/controllers/dashboard/plugins/repositories.js",
|
"src/controllers/dashboard/plugins/repositories.js",
|
||||||
|
"src/controllers/music/musicrecommended.js",
|
||||||
"src/controllers/user/display.js",
|
"src/controllers/user/display.js",
|
||||||
"src/controllers/user/home.js",
|
"src/controllers/user/home.js",
|
||||||
"src/controllers/user/playback.js",
|
"src/controllers/user/playback.js",
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', 'cardBuilder', 'dom', 'apphost', 'imageLoader', 'libraryMenu', 'playbackManager', 'mainTabsManager', 'globalize', 'scrollStyles', 'emby-itemscontainer', 'emby-tabs', 'emby-button', 'flexStyles'], function (browser, layoutManager, userSettings, inputManager, loading, cardBuilder, dom, appHost, imageLoader, libraryMenu, playbackManager, mainTabsManager, globalize) {
|
import browser from 'browser';
|
||||||
'use strict';
|
import layoutManager from 'layoutManager';
|
||||||
|
import * as userSettings from 'userSettings';
|
||||||
|
import inputManager from 'inputManager';
|
||||||
|
import loading from 'loading';
|
||||||
|
import cardBuilder from 'cardBuilder';
|
||||||
|
import dom from 'dom';
|
||||||
|
import appHost from 'apphost';
|
||||||
|
import imageLoader from 'imageLoader';
|
||||||
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import mainTabsManager from 'mainTabsManager';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'scrollStyles';
|
||||||
|
import 'emby-itemscontainer';
|
||||||
|
import 'emby-tabs';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function itemsPerRow() {
|
function itemsPerRow() {
|
||||||
var screenWidth = dom.getWindowSize().innerWidth;
|
const screenWidth = dom.getWindowSize().innerWidth;
|
||||||
|
|
||||||
if (screenWidth >= 1920) {
|
if (screenWidth >= 1920) {
|
||||||
return 9;
|
return 9;
|
||||||
|
@ -29,8 +46,8 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
|
|
||||||
function loadLatest(page, parentId) {
|
function loadLatest(page, parentId) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var userId = ApiClient.getCurrentUserId();
|
const userId = ApiClient.getCurrentUserId();
|
||||||
var options = {
|
const options = {
|
||||||
IncludeItemTypes: 'Audio',
|
IncludeItemTypes: 'Audio',
|
||||||
Limit: enableScrollX() ? 3 * itemsPerRow() : 2 * itemsPerRow(),
|
Limit: enableScrollX() ? 3 * itemsPerRow() : 2 * itemsPerRow(),
|
||||||
Fields: 'PrimaryImageAspectRatio,BasicSyncInfo',
|
Fields: 'PrimaryImageAspectRatio,BasicSyncInfo',
|
||||||
|
@ -40,8 +57,8 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
EnableTotalRecordCount: false
|
EnableTotalRecordCount: false
|
||||||
};
|
};
|
||||||
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
|
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
|
||||||
var elem = page.querySelector('#recentlyAddedSongs');
|
const elem = page.querySelector('#recentlyAddedSongs');
|
||||||
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
let supportsImageAnalysis = appHost.supports('imageanalysis');
|
||||||
supportsImageAnalysis = false;
|
supportsImageAnalysis = false;
|
||||||
elem.innerHTML = cardBuilder.getCardsHtml({
|
elem.innerHTML = cardBuilder.getCardsHtml({
|
||||||
items: items,
|
items: items,
|
||||||
|
@ -60,14 +77,14 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
imageLoader.lazyChildren(elem);
|
imageLoader.lazyChildren(elem);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
|
||||||
require(['autoFocuser'], function (autoFocuser) {
|
import('autoFocuser').then(({default: autoFocuser}) => {
|
||||||
autoFocuser.autoFocus(page);
|
autoFocuser.autoFocus(page);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRecentlyPlayed(page, parentId) {
|
function loadRecentlyPlayed(page, parentId) {
|
||||||
var options = {
|
const options = {
|
||||||
SortBy: 'DatePlayed',
|
SortBy: 'DatePlayed',
|
||||||
SortOrder: 'Descending',
|
SortOrder: 'Descending',
|
||||||
IncludeItemTypes: 'Audio',
|
IncludeItemTypes: 'Audio',
|
||||||
|
@ -81,7 +98,7 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
EnableTotalRecordCount: false
|
EnableTotalRecordCount: false
|
||||||
};
|
};
|
||||||
ApiClient.getItems(ApiClient.getCurrentUserId(), options).then(function (result) {
|
ApiClient.getItems(ApiClient.getCurrentUserId(), options).then(function (result) {
|
||||||
var elem = page.querySelector('#recentlyPlayed');
|
const elem = page.querySelector('#recentlyPlayed');
|
||||||
|
|
||||||
if (result.Items.length) {
|
if (result.Items.length) {
|
||||||
elem.classList.remove('hide');
|
elem.classList.remove('hide');
|
||||||
|
@ -89,8 +106,8 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
elem.classList.add('hide');
|
elem.classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemsContainer = elem.querySelector('.itemsContainer');
|
const itemsContainer = elem.querySelector('.itemsContainer');
|
||||||
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
let supportsImageAnalysis = appHost.supports('imageanalysis');
|
||||||
supportsImageAnalysis = false;
|
supportsImageAnalysis = false;
|
||||||
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
||||||
items: result.Items,
|
items: result.Items,
|
||||||
|
@ -111,7 +128,7 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFrequentlyPlayed(page, parentId) {
|
function loadFrequentlyPlayed(page, parentId) {
|
||||||
var options = {
|
const options = {
|
||||||
SortBy: 'PlayCount',
|
SortBy: 'PlayCount',
|
||||||
SortOrder: 'Descending',
|
SortOrder: 'Descending',
|
||||||
IncludeItemTypes: 'Audio',
|
IncludeItemTypes: 'Audio',
|
||||||
|
@ -125,7 +142,7 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
EnableTotalRecordCount: false
|
EnableTotalRecordCount: false
|
||||||
};
|
};
|
||||||
ApiClient.getItems(ApiClient.getCurrentUserId(), options).then(function (result) {
|
ApiClient.getItems(ApiClient.getCurrentUserId(), options).then(function (result) {
|
||||||
var elem = page.querySelector('#topPlayed');
|
const elem = page.querySelector('#topPlayed');
|
||||||
|
|
||||||
if (result.Items.length) {
|
if (result.Items.length) {
|
||||||
elem.classList.remove('hide');
|
elem.classList.remove('hide');
|
||||||
|
@ -133,8 +150,8 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
elem.classList.add('hide');
|
elem.classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemsContainer = elem.querySelector('.itemsContainer');
|
const itemsContainer = elem.querySelector('.itemsContainer');
|
||||||
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
let supportsImageAnalysis = appHost.supports('imageanalysis');
|
||||||
supportsImageAnalysis = false;
|
supportsImageAnalysis = false;
|
||||||
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
||||||
items: result.Items,
|
items: result.Items,
|
||||||
|
@ -160,7 +177,7 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
loadRecentlyPlayed(tabContent, parentId);
|
loadRecentlyPlayed(tabContent, parentId);
|
||||||
loadFrequentlyPlayed(tabContent, parentId);
|
loadFrequentlyPlayed(tabContent, parentId);
|
||||||
|
|
||||||
require(['components/favoriteitems'], function (favoriteItems) {
|
import('components/favoriteitems').then(({default: favoriteItems}) => {
|
||||||
favoriteItems.render(tabContent, ApiClient.getCurrentUserId(), parentId, ['favoriteArtists', 'favoriteAlbums', 'favoriteSongs']);
|
favoriteItems.render(tabContent, ApiClient.getCurrentUserId(), parentId, ['favoriteArtists', 'favoriteAlbums', 'favoriteSongs']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -211,10 +228,10 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view, params) {
|
||||||
function reload() {
|
function reload() {
|
||||||
loading.show();
|
loading.show();
|
||||||
var tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
const tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
||||||
loadSuggestionsTab(view, tabContent, params.topParentId);
|
loadSuggestionsTab(view, tabContent, params.topParentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,46 +274,48 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabController(page, index, callback) {
|
function getTabController(page, index, callback) {
|
||||||
var depends = [];
|
let depends;
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
|
depends = 'controllers/music/musicrecommended';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
depends.push('controllers/music/musicalbums');
|
depends = 'controllers/music/musicalbums';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
depends.push('controllers/music/musicartists');
|
depends = 'controllers/music/musicartists';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
depends.push('controllers/music/musicplaylists');
|
depends = 'controllers/music/musicplaylists';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
depends.push('controllers/music/songs');
|
depends = 'controllers/music/songs';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
depends.push('controllers/music/musicgenres');
|
depends = 'controllers/music/musicgenres';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
depends.push('scripts/searchtab');
|
depends = 'scripts/searchtab';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
require(depends, function (controllerFactory) {
|
import(depends).then(({default: controllerFactory}) => {
|
||||||
var tabContent;
|
let tabContent;
|
||||||
|
|
||||||
if (0 == index) {
|
if (0 == index) {
|
||||||
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
||||||
self.tabContent = tabContent;
|
self.tabContent = tabContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
var controller = tabControllers[index];
|
let controller = tabControllers[index];
|
||||||
|
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
||||||
|
@ -356,16 +375,16 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isViewRestored;
|
let isViewRestored;
|
||||||
var self = this;
|
const self = this;
|
||||||
var currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
|
let currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
|
||||||
var initialTabIndex = currentTabIndex;
|
let initialTabIndex = currentTabIndex;
|
||||||
|
|
||||||
self.initTab = function () {
|
self.initTab = function () {
|
||||||
var tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
const tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
||||||
var containers = tabContent.querySelectorAll('.itemsContainer');
|
const containers = tabContent.querySelectorAll('.itemsContainer');
|
||||||
|
|
||||||
for (var i = 0, length = containers.length; i < length; i++) {
|
for (let i = 0, length = containers.length; i < length; i++) {
|
||||||
setScrollClasses(containers[i], enableScrollX());
|
setScrollClasses(containers[i], enableScrollX());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -374,13 +393,13 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
reload();
|
reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
var tabControllers = [];
|
const tabControllers = [];
|
||||||
var renderedTabs = [];
|
const renderedTabs = [];
|
||||||
view.addEventListener('viewshow', function (e) {
|
view.addEventListener('viewshow', function (e) {
|
||||||
isViewRestored = e.detail.isRestored;
|
isViewRestored = e.detail.isRestored;
|
||||||
initTabs();
|
initTabs();
|
||||||
if (!view.getAttribute('data-title')) {
|
if (!view.getAttribute('data-title')) {
|
||||||
var parentId = params.topParentId;
|
const parentId = params.topParentId;
|
||||||
|
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
ApiClient.getItem(ApiClient.getCurrentUserId(), parentId).then(function (item) {
|
ApiClient.getItem(ApiClient.getCurrentUserId(), parentId).then(function (item) {
|
||||||
|
@ -405,5 +424,6 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', '
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue