mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
clean up
This commit is contained in:
parent
6cb6e10083
commit
a3c8e11025
4 changed files with 33 additions and 42 deletions
|
@ -62,8 +62,6 @@ function saveUser(page) {
|
||||||
Name: $('#txtUsername', page).val(),
|
Name: $('#txtUsername', page).val(),
|
||||||
Password: $('#txtPassword', page).val()
|
Password: $('#txtPassword', page).val()
|
||||||
};
|
};
|
||||||
//user.Name = $('#txtUsername', page).val();
|
|
||||||
//user.Password = $('#txtPassword', page).val();
|
|
||||||
ApiClient.createUser(_user).then(function (user) {
|
ApiClient.createUser(_user).then(function (user) {
|
||||||
user.Policy.EnableAllFolders = $('#chkEnableAllFolders', page).is(':checked');
|
user.Policy.EnableAllFolders = $('#chkEnableAllFolders', page).is(':checked');
|
||||||
user.Policy.EnabledFolders = [];
|
user.Policy.EnabledFolders = [];
|
||||||
|
|
|
@ -8,8 +8,8 @@ import globalize from '../../scripts/globalize';
|
||||||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
|
|
||||||
export default function (view, params, tabContent) {
|
export default function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData() {
|
||||||
const key = getSavedQueryKey(context);
|
const key = getSavedQueryKey();
|
||||||
let pageData = data[key];
|
let pageData = data[key];
|
||||||
|
|
||||||
if (!pageData) {
|
if (!pageData) {
|
||||||
|
@ -38,16 +38,12 @@ export default function (view, params, tabContent) {
|
||||||
return pageData;
|
return pageData;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuery(context) {
|
function getQuery() {
|
||||||
return getPageData(context).query;
|
return getPageData().query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSavedQueryKey(context) {
|
function getSavedQueryKey() {
|
||||||
if (!context.savedQueryKey) {
|
return params.topParentId + '-' + 'moviecollections';
|
||||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey('moviecollections');
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.savedQueryKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onViewStyleChange = () => {
|
const onViewStyleChange = () => {
|
||||||
|
@ -68,7 +64,7 @@ export default function (view, params, tabContent) {
|
||||||
const reloadItems = (page) => {
|
const reloadItems = (page) => {
|
||||||
loading.show();
|
loading.show();
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const query = getQuery(page);
|
const query = getQuery();
|
||||||
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
|
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
|
||||||
function onNextPageClick() {
|
function onNextPageClick() {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
@ -187,7 +183,7 @@ export default function (view, params, tabContent) {
|
||||||
const itemsContainer = tabContent.querySelector('.itemsContainer');
|
const itemsContainer = tabContent.querySelector('.itemsContainer');
|
||||||
itemsContainer.innerHTML = html;
|
itemsContainer.innerHTML = html;
|
||||||
imageLoader.lazyChildren(itemsContainer);
|
imageLoader.lazyChildren(itemsContainer);
|
||||||
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
|
libraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
|
@ -201,7 +197,7 @@ export default function (view, params, tabContent) {
|
||||||
let isLoading = false;
|
let isLoading = false;
|
||||||
|
|
||||||
this.getCurrentViewStyle = function () {
|
this.getCurrentViewStyle = function () {
|
||||||
return getPageData(tabContent).view;
|
return getPageData().view;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initPage = (tabElement) => {
|
const initPage = (tabElement) => {
|
||||||
|
@ -224,10 +220,10 @@ export default function (view, params, tabContent) {
|
||||||
id: 'PremiereDate,SortName'
|
id: 'PremiereDate,SortName'
|
||||||
}],
|
}],
|
||||||
callback: function () {
|
callback: function () {
|
||||||
getQuery(tabElement).StartIndex = 0;
|
getQuery().StartIndex = 0;
|
||||||
reloadItems(tabElement);
|
reloadItems(tabElement);
|
||||||
},
|
},
|
||||||
query: getQuery(tabElement),
|
query: getQuery(),
|
||||||
button: e.target
|
button: e.target
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -237,16 +233,17 @@ export default function (view, params, tabContent) {
|
||||||
});
|
});
|
||||||
btnSelectView.addEventListener('layoutchange', function (e) {
|
btnSelectView.addEventListener('layoutchange', function (e) {
|
||||||
const viewStyle = e.detail.viewStyle;
|
const viewStyle = e.detail.viewStyle;
|
||||||
getPageData(tabElement).view = viewStyle;
|
getPageData().view = viewStyle;
|
||||||
libraryBrowser.saveViewSetting(getSavedQueryKey(tabElement), viewStyle);
|
libraryBrowser.saveViewSetting(getSavedQueryKey(), viewStyle);
|
||||||
getQuery(tabElement).StartIndex = 0;
|
getQuery().StartIndex = 0;
|
||||||
onViewStyleChange();
|
onViewStyleChange();
|
||||||
reloadItems(tabElement);
|
reloadItems(tabElement);
|
||||||
});
|
});
|
||||||
tabElement.querySelector('.btnNewCollection').addEventListener('click', () => {
|
tabElement.querySelector('.btnNewCollection').addEventListener('click', () => {
|
||||||
import('../../components/collectionEditor/collectionEditor').then(({ default: collectionEditor }) => {
|
import('../../components/collectionEditor/collectionEditor').then(({ default: CollectionEditor }) => {
|
||||||
const serverId = ApiClient.serverInfo().Id;
|
const serverId = ApiClient.serverInfo().Id;
|
||||||
new collectionEditor({
|
const collectionEditor = new CollectionEditor();
|
||||||
|
collectionEditor.show({
|
||||||
items: [],
|
items: [],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default function (view, params, tabContent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSavedQueryKey() {
|
function getSavedQueryKey() {
|
||||||
return libraryBrowser.getSavedQueryKey('moviegenres');
|
return params.topParentId + '-' + 'moviegenres';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPromise() {
|
function getPromise() {
|
||||||
|
|
|
@ -11,8 +11,8 @@ import Events from '../../utils/events.ts';
|
||||||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
|
|
||||||
export default function (view, params, tabContent) {
|
export default function (view, params, tabContent) {
|
||||||
function getPageData(context) {
|
function getPageData() {
|
||||||
const key = getSavedQueryKey(context);
|
const key = getSavedQueryKey();
|
||||||
let pageData = data[key];
|
let pageData = data[key];
|
||||||
|
|
||||||
if (!pageData) {
|
if (!pageData) {
|
||||||
|
@ -40,22 +40,18 @@ export default function (view, params, tabContent) {
|
||||||
return pageData;
|
return pageData;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuery(context) {
|
function getQuery() {
|
||||||
return getPageData(context).query;
|
return getPageData().query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSavedQueryKey(context) {
|
function getSavedQueryKey() {
|
||||||
if (!context.savedQueryKey) {
|
return params.topParentId + '-' + 'trailers';
|
||||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey('trailers');
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.savedQueryKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const reloadItems = () => {
|
const reloadItems = () => {
|
||||||
loading.show();
|
loading.show();
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const query = getQuery(tabContent);
|
const query = getQuery();
|
||||||
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
|
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
|
||||||
function onNextPageClick() {
|
function onNextPageClick() {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
@ -176,7 +172,7 @@ export default function (view, params, tabContent) {
|
||||||
const itemsContainer = tabContent.querySelector('.itemsContainer');
|
const itemsContainer = tabContent.querySelector('.itemsContainer');
|
||||||
itemsContainer.innerHTML = html;
|
itemsContainer.innerHTML = html;
|
||||||
imageLoader.lazyChildren(itemsContainer);
|
imageLoader.lazyChildren(itemsContainer);
|
||||||
libraryBrowser.saveQueryValues(getSavedQueryKey(tabContent), query);
|
libraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
|
@ -188,12 +184,12 @@ export default function (view, params, tabContent) {
|
||||||
this.showFilterMenu = function () {
|
this.showFilterMenu = function () {
|
||||||
import('../../components/filterdialog/filterdialog').then(({ default: filterDialogFactory }) => {
|
import('../../components/filterdialog/filterdialog').then(({ default: filterDialogFactory }) => {
|
||||||
const filterDialog = new filterDialogFactory({
|
const filterDialog = new filterDialogFactory({
|
||||||
query: getQuery(tabContent),
|
query: getQuery(),
|
||||||
mode: 'movies',
|
mode: 'movies',
|
||||||
serverId: ApiClient.serverId()
|
serverId: ApiClient.serverId()
|
||||||
});
|
});
|
||||||
Events.on(filterDialog, 'filterchange', function () {
|
Events.on(filterDialog, 'filterchange', function () {
|
||||||
getQuery(tabContent).StartIndex = 0;
|
getQuery().StartIndex = 0;
|
||||||
reloadItems();
|
reloadItems();
|
||||||
});
|
});
|
||||||
filterDialog.show();
|
filterDialog.show();
|
||||||
|
@ -201,7 +197,7 @@ export default function (view, params, tabContent) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getCurrentViewStyle = function () {
|
this.getCurrentViewStyle = function () {
|
||||||
return getPageData(tabContent).view;
|
return getPageData().view;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initPage = (tabElement) => {
|
const initPage = (tabElement) => {
|
||||||
|
@ -209,7 +205,7 @@ export default function (view, params, tabContent) {
|
||||||
const itemsContainer = tabElement.querySelector('.itemsContainer');
|
const itemsContainer = tabElement.querySelector('.itemsContainer');
|
||||||
alphaPickerElement.addEventListener('alphavaluechanged', function (e) {
|
alphaPickerElement.addEventListener('alphavaluechanged', function (e) {
|
||||||
const newValue = e.detail.value;
|
const newValue = e.detail.value;
|
||||||
const query = getQuery(tabElement);
|
const query = getQuery();
|
||||||
if (newValue === '#') {
|
if (newValue === '#') {
|
||||||
query.NameLessThan = 'A';
|
query.NameLessThan = 'A';
|
||||||
delete query.NameStartsWith;
|
delete query.NameStartsWith;
|
||||||
|
@ -257,10 +253,10 @@ export default function (view, params, tabContent) {
|
||||||
id: 'PremiereDate,SortName'
|
id: 'PremiereDate,SortName'
|
||||||
}],
|
}],
|
||||||
callback: function () {
|
callback: function () {
|
||||||
getQuery(tabElement).StartIndex = 0;
|
getQuery().StartIndex = 0;
|
||||||
reloadItems();
|
reloadItems();
|
||||||
},
|
},
|
||||||
query: getQuery(tabElement),
|
query: getQuery(),
|
||||||
button: e.target
|
button: e.target
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -270,7 +266,7 @@ export default function (view, params, tabContent) {
|
||||||
|
|
||||||
this.renderTab = () => {
|
this.renderTab = () => {
|
||||||
reloadItems();
|
reloadItems();
|
||||||
this.alphaPicker?.updateControls(getQuery(tabContent));
|
this.alphaPicker?.updateControls(getQuery());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue