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

Merge pull request #400 from dkanada/url

Add base url option to web client
This commit is contained in:
Anthony Lavado 2019-08-26 00:19:45 -04:00 committed by GitHub
commit a6db774318
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 83 additions and 32 deletions

View file

@ -1,20 +1,16 @@
<div data-role="page" class="page standalonePage">
<div class="padded-left padded-right padded-bottom-page">
<form class="manualServerForm" style="margin: 0 auto;">
<h1 style="text-align: left;">${HeaderConnectToServer}</h1>
<form class="addServerForm" style="margin: 0 auto;">
<h1>${HeaderConnectToServer}</h1>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtServerHost" required="required" label="${LabelServerHost}" autocomplete="off" spellcheck="false" autocapitalize="none" autocorrect="off" />
<div class="fieldDescription" style="text-align: left;">${LabelServerHostHelp}</div>
</div>
<br />
<div class="inputContainer">
<input is="emby-input" type="number" id="txtServerPort" step="1" min="0" value="8096" label="${LabelServerPort}" />
<div class="fieldDescription">${LabelServerHostHelp}</div>
</div>
<br />
<button is="emby-button" type="submit" class="raised button-submit block">
<span>${ButtonConnect}</span>
</button>
<button is="emby-button" type="button" class="raised button-cancel block btnCancelManualServer">
<button is="emby-button" type="button" class="raised button-cancel block btnCancel">
<span>${ButtonCancel}</span>
</button>
</form>

View file

@ -242,7 +242,7 @@ define(["events", "appStorage"], function(events, appStorage) {
var url = serverAddress || this._serverAddress;
if (!url) throw new Error("serverAddress is yet not set");
var lowered = url.toLowerCase();
return -1 === lowered.indexOf("/emby") && -1 === lowered.indexOf("/mediabrowser") && (url += "/emby"), "/" !== name.charAt(0) && (url += "/"), url += name, params && (params = paramsToString(params)) && (url += "?" + params), url
return "/" !== name.charAt(0) && (url += "/"), url += name, params && (params = paramsToString(params)) && (url += "?" + params), url
}, ApiClient.prototype.fetchWithFailover = function(request, enableReconnection) {
console.log("Requesting " + request.url), request.timeout = 3e4;
var instance = this;

View file

@ -40,7 +40,7 @@ define(["events", "apiclient", "appStorage"], function(events, apiClientFactory,
}
function getEmbyServerUrl(baseUrl, handler) {
return baseUrl + "/emby/" + handler
return baseUrl + "/" + handler
}
function getFetchPromise(request) {

View file

@ -6,7 +6,8 @@ define(["appSettings", "loading", "browser", "emby-button"], function(appSetting
switch (result.State) {
case "SignedIn":
var apiClient = result.ApiClient;
Dashboard.onServerChanged(apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient), Dashboard.navigate("home.html");
Dashboard.onServerChanged(apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient);
Dashboard.navigate("home.html");
break;
case "ServerSignIn":
Dashboard.navigate("login.html?serverid=" + result.Servers[0].Id, false, "none");
@ -27,14 +28,9 @@ define(["appSettings", "loading", "browser", "emby-button"], function(appSetting
}
}
function submitManualServer(page) {
var host = page.querySelector("#txtServerHost").value;
var port = page.querySelector("#txtServerPort").value;
if (port) {
host += ":" + port;
}
function submitServer(page) {
loading.show();
var host = page.querySelector("#txtServerHost").value;
ConnectionManager.connectToAddress(host, {
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function(result) {
@ -47,11 +43,11 @@ define(["appSettings", "loading", "browser", "emby-button"], function(appSetting
}
return function(view, params) {
view.querySelector(".manualServerForm").addEventListener("submit", onManualServerSubmit);
view.querySelector(".btnCancelManualServer").addEventListener("click", goBack);
view.querySelector(".addServerForm").addEventListener("submit", onServerSubmit);
view.querySelector(".btnCancel").addEventListener("click", goBack);
function onManualServerSubmit(e) {
submitManualServer(view);
function onServerSubmit(e) {
submitServer(view);
e.preventDefault();
return false;
}

View file

@ -2,25 +2,62 @@ define(["loading", "libraryMenu", "globalize", "emby-checkbox", "emby-select"],
"use strict";
function onSubmit(e) {
var form = this,
localAddress = form.querySelector("#txtLocalAddress").value,
enableUpnp = form.querySelector("#chkEnableUpnp").checked;
var form = this;
var localAddress = form.querySelector("#txtLocalAddress").value;
var enableUpnp = form.querySelector("#chkEnableUpnp").checked;
confirmSelections(localAddress, enableUpnp, function() {
var validationResult = getValidationAlert(form);
if (validationResult) return void alertText(validationResult);
validateHttps(form).then(function() {
loading.show(), ApiClient.getServerConfiguration().then(function(config) {
loading.show();
ApiClient.getServerConfiguration().then(function(config) {
config.LocalNetworkSubnets = form.querySelector("#txtLanNetworks").value.split(",").map(function(s) {
return s.trim()
}).filter(function(s) {
return s.length > 0
}), config.RemoteIPFilter = form.querySelector("#txtExternalAddressFilter").value.split(",").map(function(s) {
});
config.RemoteIPFilter = form.querySelector("#txtExternalAddressFilter").value.split(",").map(function(s) {
return s.trim()
}).filter(function(s) {
return s.length > 0
}), config.IsRemoteIPFilterBlacklist = "blacklist" === form.querySelector("#selectExternalAddressFilterMode").value, config.PublicPort = form.querySelector("#txtPublicPort").value, config.PublicHttpsPort = form.querySelector("#txtPublicHttpsPort").value;
});
config.IsRemoteIPFilterBlacklist = "blacklist" === form.querySelector("#selectExternalAddressFilterMode").value;
config.PublicPort = form.querySelector("#txtPublicPort").value;
config.PublicHttpsPort = form.querySelector("#txtPublicHttpsPort").value;
var httpsMode = form.querySelector("#selectHttpsMode").value;
"proxy" === httpsMode ? (config.EnableHttps = !0, config.RequireHttps = !1, config.IsBehindProxy = !0) : "required" === httpsMode ? (config.EnableHttps = !0, config.RequireHttps = !0, config.IsBehindProxy = !1) : "enabled" === httpsMode ? (config.EnableHttps = !0, config.RequireHttps = !1, config.IsBehindProxy = !1) : (config.EnableHttps = !1, config.RequireHttps = !1, config.IsBehindProxy = !1), config.HttpsPortNumber = form.querySelector("#txtHttpsPort").value, config.HttpServerPortNumber = form.querySelector("#txtPortNumber").value, config.EnableUPnP = enableUpnp, config.WanDdns = form.querySelector("#txtDdns").value, config.EnableRemoteAccess = form.querySelector("#chkRemoteAccess").checked, config.CertificatePath = form.querySelector("#txtCertificatePath").value || null, config.CertificatePassword = form.querySelector("#txtCertPassword").value || null, config.LocalNetworkAddresses = localAddress ? [localAddress] : [], ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, Dashboard.processErrorResponse)
switch (httpsMode) {
case "proxy":
config.EnableHttps = true;
config.RequireHttps = false;
config.IsBehindProxy = true;
break;
case "required":
config.EnableHttps = true;
config.RequireHttps = true;
config.IsBehindProxy = false;
break;
case "enabled":
config.EnableHttps = true;
config.RequireHttps = false;
config.IsBehindProxy = false;
break;
default:
config.EnableHttps = false;
config.RequireHttps = false;
config.IsBehindProxy = false;
}
config.HttpsPortNumber = form.querySelector("#txtHttpsPort").value;
config.HttpServerPortNumber = form.querySelector("#txtPortNumber").value;
config.EnableUPnP = enableUpnp;
config.WanDdns = form.querySelector("#txtDdns").value;
config.BaseUrl = form.querySelector("#txtBaseUrl").value;
config.EnableRemoteAccess = form.querySelector("#chkRemoteAccess").checked;
config.CertificatePath = form.querySelector("#txtCertificatePath").value || null;
config.CertificatePassword = form.querySelector("#txtCertPassword").value || null;
config.LocalNetworkAddresses = localAddress ? [localAddress] : [];
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, Dashboard.processErrorResponse);
})
})
}), e.preventDefault()
@ -63,11 +100,26 @@ define(["loading", "libraryMenu", "globalize", "emby-checkbox", "emby-select"],
return function(view, params) {
function loadPage(page, config) {
page.querySelector("#txtPortNumber").value = config.HttpServerPortNumber, page.querySelector("#txtPublicPort").value = config.PublicPort, page.querySelector("#txtPublicHttpsPort").value = config.PublicHttpsPort, page.querySelector("#txtLocalAddress").value = config.LocalNetworkAddresses[0] || "", page.querySelector("#txtLanNetworks").value = (config.LocalNetworkSubnets || []).join(", "), page.querySelector("#txtExternalAddressFilter").value = (config.RemoteIPFilter || []).join(", "), page.querySelector("#selectExternalAddressFilterMode").value = config.IsRemoteIPFilterBlacklist ? "blacklist" : "whitelist", page.querySelector("#chkRemoteAccess").checked = null == config.EnableRemoteAccess || config.EnableRemoteAccess;
page.querySelector("#txtPortNumber").value = config.HttpServerPortNumber;
page.querySelector("#txtPublicPort").value = config.PublicPort;
page.querySelector("#txtPublicHttpsPort").value = config.PublicHttpsPort;
page.querySelector("#txtLocalAddress").value = config.LocalNetworkAddresses[0] || "";
page.querySelector("#txtLanNetworks").value = (config.LocalNetworkSubnets || []).join(", ");
page.querySelector("#txtExternalAddressFilter").value = (config.RemoteIPFilter || []).join(", ");
page.querySelector("#selectExternalAddressFilterMode").value = config.IsRemoteIPFilterBlacklist ? "blacklist" : "whitelist";
page.querySelector("#chkRemoteAccess").checked = null == config.EnableRemoteAccess || config.EnableRemoteAccess;
var selectHttpsMode = page.querySelector("#selectHttpsMode");
config.IsBehindProxy ? selectHttpsMode.value = "proxy" : config.RequireHttps ? selectHttpsMode.value = "required" : config.EnableHttps ? selectHttpsMode.value = "enabled" : selectHttpsMode.value = "disabled", page.querySelector("#txtHttpsPort").value = config.HttpsPortNumber, page.querySelector("#txtDdns").value = config.WanDdns || "";
config.IsBehindProxy ? selectHttpsMode.value = "proxy" : config.RequireHttps ? selectHttpsMode.value = "required" : config.EnableHttps ? selectHttpsMode.value = "enabled" : selectHttpsMode.value = "disabled";
page.querySelector("#txtHttpsPort").value = config.HttpsPortNumber;
page.querySelector("#txtDdns").value = config.WanDdns || "";
page.querySelector("#txtBaseUrl").value = config.BaseUrl || "";
var txtCertificatePath = page.querySelector("#txtCertificatePath");
txtCertificatePath.value = config.CertificatePath || "", page.querySelector("#txtCertPassword").value = config.CertificatePassword || "", page.querySelector("#chkEnableUpnp").checked = config.EnableUPnP, onCertPathChange.call(txtCertificatePath), triggerChange(page.querySelector("#chkRemoteAccess")), loading.hide()
txtCertificatePath.value = config.CertificatePath || "";
page.querySelector("#txtCertPassword").value = config.CertificatePassword || "";
page.querySelector("#chkEnableUpnp").checked = config.EnableUPnP;
onCertPathChange.call(txtCertificatePath);
triggerChange(page.querySelector("#chkRemoteAccess"));
loading.hide();
}
function onCertPathChange() {

View file

@ -56,6 +56,11 @@
<div class="fieldDescription">${LabelExternalDDNSHelp}</div>
</div>
<div class="inputContainer fldBaseUrl">
<input is="emby-input" id="txtBaseUrl" type="text" label="${LabelBaseUrl}" />
<div class="fieldDescription">${LabelBaseUrlHelp}</div>
</div>
<div class="inputContainer fldCertificatePath hide">
<div style="display: flex; align-items: center;">
<div style="flex-grow:1;">

View file

@ -632,6 +632,8 @@
"LabelEveryXMinutes": "Every:",
"LabelExternalDDNS": "External domain:",
"LabelExternalDDNSHelp": "If you have a dynamic DNS enter it here for clients to use when connecting remotely. This field is required when used with a custom SSL certificate. Example: mydomain.com.",
"LabelBaseUrl": "Base URL:",
"LabelBaseUrlHelp": "You can add a custom subdirectory here to access the server from a more unique URL.",
"LabelExtractChaptersDuringLibraryScan": "Extract chapter images during the library scan",
"LabelExtractChaptersDuringLibraryScanHelp": "If enabled, chapter images will be extracted when videos are imported during the library scan. If disabled they will be extracted during the chapter images scheduled task, allowing the regular library scan to complete faster.",
"LabelFailed": "Failed",