1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #2707 from grafixeyehero/fix-accese

Access module
This commit is contained in:
Bill Thornton 2021-09-08 09:45:18 -04:00 committed by GitHub
commit e33a589a27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 326 additions and 303 deletions

View file

@ -100,6 +100,7 @@ module.exports = {
'jQuery': 'readonly', 'jQuery': 'readonly',
// Jellyfin globals // Jellyfin globals
'ApiClient': 'writable', 'ApiClient': 'writable',
'Events': 'writable',
'chrome': 'writable', 'chrome': 'writable',
'DlnaProfilePage': 'writable', 'DlnaProfilePage': 'writable',
'DashboardPage': 'writable', 'DashboardPage': 'writable',
@ -115,6 +116,8 @@ module.exports = {
'Loading': 'writable', 'Loading': 'writable',
'MetadataEditor': 'writable', 'MetadataEditor': 'writable',
'PlaylistViewer': 'writable', 'PlaylistViewer': 'writable',
'ServerNotifications': 'writable',
'TaskButton': 'writable',
'UserParentalControlPage': 'writable', 'UserParentalControlPage': 'writable',
'Windows': 'readonly' 'Windows': 'readonly'
}, },

View file

@ -10,22 +10,20 @@ import '../formdialog.scss';
import '../../elements/emby-button/emby-button'; import '../../elements/emby-button/emby-button';
import alert from '../alert'; import alert from '../alert';
/* eslint-disable indent */ function getSystemInfo() {
function getSystemInfo() {
return systemInfo ? Promise.resolve(systemInfo) : ApiClient.getPublicSystemInfo().then( return systemInfo ? Promise.resolve(systemInfo) : ApiClient.getPublicSystemInfo().then(
info => { info => {
systemInfo = info; systemInfo = info;
return info; return info;
} }
); );
} }
function onDialogClosed() { function onDialogClosed() {
loading.hide(); loading.hide();
} }
function refreshDirectoryBrowser(page, path, fileOptions, updatePathOnError) { function refreshDirectoryBrowser(page, path, fileOptions, updatePathOnError) {
if (path && typeof path !== 'string') { if (path && typeof path !== 'string') {
throw new Error('invalid path'); throw new Error('invalid path');
} }
@ -77,9 +75,9 @@ import alert from '../alert';
} }
} }
); );
} }
function getItem(cssClass, type, path, name) { function getItem(cssClass, type, path, name) {
let html = ''; let html = '';
html += `<div class="listItem listItem-border ${cssClass}" data-type="${type}" data-path="${path}">`; html += `<div class="listItem listItem-border ${cssClass}" data-type="${type}" data-path="${path}">`;
html += '<div class="listItemBody" style="padding-left:0;padding-top:.5em;padding-bottom:.5em;">'; html += '<div class="listItemBody" style="padding-left:0;padding-top:.5em;padding-bottom:.5em;">';
@ -90,9 +88,9 @@ import alert from '../alert';
html += '<span class="material-icons arrow_forward" style="font-size:inherit;"></span>'; html += '<span class="material-icons arrow_forward" style="font-size:inherit;"></span>';
html += '</div>'; html += '</div>';
return html; return html;
} }
function getEditorHtml(options, systemInfo) { function getEditorHtml(options, systemInfo) {
let html = ''; let html = '';
html += '<div class="formDialogContent scrollY">'; html += '<div class="formDialogContent scrollY">';
html += '<div class="dialogContentInner dialog-content-centered" style="padding-top:2em;">'; html += '<div class="dialogContentInner dialog-content-centered" style="padding-top:2em;">';
@ -149,19 +147,19 @@ import alert from '../alert';
html += '</div>'; html += '</div>';
return html; return html;
} }
function alertText(text) { function alertText(text) {
alertTextWithOptions({ alertTextWithOptions({
text: text text: text
}); });
} }
function alertTextWithOptions(options) { function alertTextWithOptions(options) {
alert(options); alert(options);
} }
function validatePath(path, validateWriteable, apiClient) { function validatePath(path, validateWriteable, apiClient) {
return apiClient.ajax({ return apiClient.ajax({
type: 'POST', type: 'POST',
url: apiClient.getUrl('Environment/ValidatePath'), url: apiClient.getUrl('Environment/ValidatePath'),
@ -187,9 +185,9 @@ import alert from '../alert';
} }
return Promise.resolve(); return Promise.resolve();
}); });
} }
function initEditor(content, options, fileOptions) { function initEditor(content, options, fileOptions) {
content.addEventListener('click', e => { content.addEventListener('click', e => {
const lnkPath = dom.parentWithClass(e.target, 'lnkPath'); const lnkPath = dom.parentWithClass(e.target, 'lnkPath');
if (lnkPath) { if (lnkPath) {
@ -227,9 +225,9 @@ import alert from '../alert';
e.stopPropagation(); e.stopPropagation();
return false; return false;
}); });
} }
function getDefaultPath(options) { function getDefaultPath(options) {
if (options.path) { if (options.path) {
return Promise.resolve(options.path); return Promise.resolve(options.path);
} else { } else {
@ -241,12 +239,13 @@ import alert from '../alert';
} }
); );
} }
} }
class directoryBrowser { let systemInfo;
constructor() { class DirectoryBrowser {
let currentDialog; currentDialog;
this.show = options => {
show = options => {
options = options || {}; options = options || {};
const fileOptions = { const fileOptions = {
includeDirectories: true includeDirectories: true
@ -286,7 +285,7 @@ import alert from '../alert';
dlg.querySelector('.btnCloseDialog').addEventListener('click', () => { dlg.querySelector('.btnCloseDialog').addEventListener('click', () => {
dialogHelper.close(dlg); dialogHelper.close(dlg);
}); });
currentDialog = dlg; this.currentDialog = dlg;
dlg.querySelector('#txtDirectoryPickerPath').value = initialPath; dlg.querySelector('#txtDirectoryPickerPath').value = initialPath;
const txtNetworkPath = dlg.querySelector('#txtNetworkPath'); const txtNetworkPath = dlg.querySelector('#txtNetworkPath');
if (txtNetworkPath) { if (txtNetworkPath) {
@ -298,15 +297,12 @@ import alert from '../alert';
} }
); );
}; };
this.close = () => {
if (currentDialog) { close = () => {
dialogHelper.close(currentDialog); if (this.currentDialog) {
dialogHelper.close(this.currentDialog);
} }
}; };
} }
}
let systemInfo; export default DirectoryBrowser;
/* eslint-enable indent */
export default directoryBrowser;

View file

@ -102,8 +102,8 @@ import template from './mediaLibraryCreator.template.html';
function onAddButtonClick() { function onAddButtonClick() {
const page = dom.parentWithClass(this, 'dlg-librarycreator'); const page = dom.parentWithClass(this, 'dlg-librarycreator');
import('../directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
enableNetworkSharePath: true, enableNetworkSharePath: true,
callback: function (path, networkSharePath) { callback: function (path, networkSharePath) {

View file

@ -162,8 +162,8 @@ import template from './mediaLibraryEditor.template.html';
} }
function showDirectoryBrowser(context, originalPath, networkPath) { function showDirectoryBrowser(context, originalPath, networkPath) {
import('../directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
enableNetworkSharePath: true, enableNetworkSharePath: true,
pathReadOnly: originalPath != null, pathReadOnly: originalPath != null,

View file

@ -145,8 +145,8 @@ export default function (page, providerId, options) {
function onSelectPathClick(e) { function onSelectPathClick(e) {
const page = $(e.target).parents('.xmltvForm')[0]; const page = $(e.target).parents('.xmltvForm')[0];
import('../directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeFiles: true, includeFiles: true,
callback: function (path) { callback: function (path) {

View file

@ -217,8 +217,8 @@ import alert from '../../components/alert';
setDecodingCodecsVisible(page, this.value); setDecodingCodecsVisible(page, this.value);
}); });
$('#btnSelectEncoderPath', page).on('click.selectDirectory', function () { $('#btnSelectEncoderPath', page).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeFiles: true, includeFiles: true,
callback: function (path) { callback: function (path) {
@ -232,8 +232,8 @@ import alert from '../../components/alert';
}); });
}); });
$('#btnSelectTranscodingTempPath', page).on('click.selectDirectory', function () { $('#btnSelectTranscodingTempPath', page).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
callback: function (path) { callback: function (path) {
if (path) { if (path) {
@ -249,8 +249,8 @@ import alert from '../../components/alert';
}); });
}); });
$('#btnSelectFallbackFontPath', page).on('click.selectDirectory', function () { $('#btnSelectFallbackFontPath', page).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeDirectories: true, includeDirectories: true,
callback: function (path) { callback: function (path) {

View file

@ -55,8 +55,8 @@ import alert from '../../components/alert';
const brandingConfigKey = 'branding'; const brandingConfigKey = 'branding';
export default function (view) { export default function (view) {
$('#btnSelectCachePath', view).on('click.selectDirectory', function () { $('#btnSelectCachePath', view).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
callback: function (path) { callback: function (path) {
if (path) { if (path) {
@ -72,8 +72,8 @@ import alert from '../../components/alert';
}); });
}); });
$('#btnSelectMetadataPath', view).on('click.selectDirectory', function () { $('#btnSelectMetadataPath', view).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
path: $('#txtMetadataPath', view).val(), path: $('#txtMetadataPath', view).val(),
networkSharePath: $('#txtMetadataNetworkPath', view).val(), networkSharePath: $('#txtMetadataNetworkPath', view).val(),

View file

@ -181,8 +181,8 @@ import alert from '../../components/alert';
} }
}); });
view.querySelector('#btnSelectCertPath').addEventListener('click', function () { view.querySelector('#btnSelectCertPath').addEventListener('click', function () {
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeFiles: true, includeFiles: true,
includeDirectories: true, includeDirectories: true,

View file

@ -60,8 +60,8 @@ $(document).on('pageinit', '#liveTvSettingsPage', function () {
const page = this; const page = this;
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit); $('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
$('#btnSelectRecordingPath', page).on('click.selectDirectory', function () { $('#btnSelectRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
callback: function (path) { callback: function (path) {
if (path) { if (path) {
@ -75,8 +75,8 @@ $(document).on('pageinit', '#liveTvSettingsPage', function () {
}); });
}); });
$('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () { $('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
callback: function (path) { callback: function (path) {
if (path) { if (path) {
@ -90,8 +90,8 @@ $(document).on('pageinit', '#liveTvSettingsPage', function () {
}); });
}); });
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () { $('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
callback: function (path) { callback: function (path) {
if (path) { if (path) {
@ -105,8 +105,8 @@ $(document).on('pageinit', '#liveTvSettingsPage', function () {
}); });
}); });
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () { $('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { import('../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directoryBrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeFiles: true, includeFiles: true,
callback: function (path) { callback: function (path) {

View file

@ -212,8 +212,8 @@ export default function (view, params) {
}); });
}); });
view.querySelector('.btnSelectPath').addEventListener('click', function () { view.querySelector('.btnSelectPath').addEventListener('click', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directorybrowser}) => { import('../components/directorybrowser/directorybrowser').then(({default: DirectoryBrowser}) => {
const picker = new directorybrowser(); const picker = new DirectoryBrowser();
picker.show({ picker.show({
includeFiles: true, includeFiles: true,
callback: function (path) { callback: function (path) {

View file

@ -6,6 +6,10 @@ import baseAlert from '../components/alert';
import baseConfirm from '../components/confirm/confirm'; import baseConfirm from '../components/confirm/confirm';
import globalize from '../scripts/globalize'; import globalize from '../scripts/globalize';
import * as webSettings from './settings/webSettings'; import * as webSettings from './settings/webSettings';
import datetime from '../scripts/datetime';
import DirectoryBrowser from '../components/directorybrowser/directorybrowser';
import dialogHelper from '../components/dialogHelper/dialogHelper';
import itemIdentifier from '../components/itemidentifier/itemidentifier';
export function getCurrentUser() { export function getCurrentUser() {
return window.ApiClient.getCurrentUser(false); return window.ApiClient.getCurrentUser(false);
@ -94,6 +98,12 @@ export function getPluginUrl(name) {
return 'configurationpage?name=' + encodeURIComponent(name); return 'configurationpage?name=' + encodeURIComponent(name);
} }
export function getConfigurationResourceUrl(name) {
return ApiClient.getUrl('web/ConfigurationPage', {
name: name
});
}
export function navigate(url, preserveQueryString) { export function navigate(url, preserveQueryString) {
if (!url) { if (!url) {
throw new Error('url cannot be null or empty'); throw new Error('url cannot be null or empty');
@ -204,6 +214,7 @@ const Dashboard = {
capabilities, capabilities,
confirm, confirm,
getPluginUrl, getPluginUrl,
getConfigurationResourceUrl,
getCurrentUser, getCurrentUser,
getCurrentUserId, getCurrentUserId,
hideLoadingMsg, hideLoadingMsg,
@ -215,7 +226,11 @@ const Dashboard = {
processServerConfigurationUpdateResult, processServerConfigurationUpdateResult,
selectServer, selectServer,
serverAddress, serverAddress,
showLoadingMsg showLoadingMsg,
datetime,
DirectoryBrowser,
dialogHelper,
itemIdentifier
}; };
// This is used in plugins and templates, so keep it defined for now. // This is used in plugins and templates, so keep it defined for now.

View file

@ -211,4 +211,6 @@ Events.on(ServerConnections, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient); bindEvents(newApiClient);
}); });
window.ServerNotifications = serverNotifications;
export default serverNotifications; export default serverNotifications;

View file

@ -37,6 +37,7 @@ import SyncPlayNoActivePlayer from '../components/syncPlay/ui/players/NoActivePl
import SyncPlayHtmlVideoPlayer from '../components/syncPlay/ui/players/HtmlVideoPlayer'; import SyncPlayHtmlVideoPlayer from '../components/syncPlay/ui/players/HtmlVideoPlayer';
import SyncPlayHtmlAudioPlayer from '../components/syncPlay/ui/players/HtmlAudioPlayer'; import SyncPlayHtmlAudioPlayer from '../components/syncPlay/ui/players/HtmlAudioPlayer';
import { currentSettings } from './settings/userSettings'; import { currentSettings } from './settings/userSettings';
import taskButton from '../scripts/taskbutton';
// TODO: Move this elsewhere // TODO: Move this elsewhere
window.getWindowLocationSearch = function(win) { window.getWindowLocationSearch = function(win) {
@ -83,6 +84,10 @@ function loadCoreDictionary() {
} }
function init() { function init() {
// This is used in plugins
window.Events = Events;
window.TaskButton = taskButton;
serverAddress().then(server => { serverAddress().then(server => {
if (server) { if (server) {
ServerConnections.initApiClient(server); ServerConnections.initApiClient(server);

View file

@ -5,7 +5,7 @@ import globalize from '../scripts/globalize';
import '../elements/emby-button/emby-button'; import '../elements/emby-button/emby-button';
import ServerConnections from '../components/ServerConnections'; import ServerConnections from '../components/ServerConnections';
export default function (options) { function taskbutton(options) {
function pollTasks() { function pollTasks() {
ServerConnections.getApiClient(serverId).getScheduledTasks({ ServerConnections.getApiClient(serverId).getScheduledTasks({
IsEnabled: true IsEnabled: true
@ -120,3 +120,5 @@ export default function (options) {
Events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate); Events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
} }
} }
export default taskbutton;