diff --git a/src/addserver.html b/src/addserver.html new file mode 100644 index 0000000000..30b5ce7dab --- /dev/null +++ b/src/addserver.html @@ -0,0 +1,22 @@ +
+
+
+

${HeaderConnectToServer}

+
+ +
${LabelServerHostHelp}
+
+
+
+ +
+
+ + +
+
+
\ No newline at end of file diff --git a/src/scripts/addserver.js b/src/scripts/addserver.js new file mode 100644 index 0000000000..ea0999b683 --- /dev/null +++ b/src/scripts/addserver.js @@ -0,0 +1,55 @@ +define(["appSettings", "loading", "browser", "emby-linkbutton"], function(appSettings, loading, browser) { + "use strict"; + + function handleConnectionResult(page, result) { + switch (loading.hide(), result.State) { + case "SignedIn": + var apiClient = result.ApiClient; + Dashboard.onServerChanged(apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient), Dashboard.navigate("home.html"); + break; + case "ServerSignIn": + Dashboard.navigate("login.html?serverid=" + result.Servers[0].Id, !1, "none"); + break; + case "ServerSelection": + Dashboard.navigate("selectserver.html", !1, "none"); + break; + case "ServerUpdateNeeded": + Dashboard.alert({ + message: Globalize.translate("ServerUpdateNeeded", 'https://github.com/jellyfin/jellyfin') + }); + break; + case "Unavailable": + Dashboard.alert({ + message: Globalize.translate("MessageUnableToConnectToServer"), + title: Globalize.translate("HeaderConnectionFailure") + }) + } + } + + function submitManualServer(page) { + var host = page.querySelector("#txtServerHost").value, + port = page.querySelector("#txtServerPort").value; + port && (host += ":" + port), loading.show(), ConnectionManager.connectToAddress(host, { + enableAutoLogin: appSettings.enableAutoLogin() + }).then(function(result) { + handleConnectionResult(page, result) + }, function() { + handleConnectionResult(page, { + State: "Unavailable" + }) + }) + } + + return function(view, params) { + view.querySelector(".manualServerForm").addEventListener("submit", onManualServerSubmit) + function onManualServerSubmit(e) { + return submitManualServer(view), e.preventDefault(), !1 + } + + function goBack() { + require(["appRouter"], function(appRouter) { + appRouter.back() + }) + } + } +}); diff --git a/src/scripts/site.js b/src/scripts/site.js index 070bcb43c5..8c1e6a01a4 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -375,12 +375,12 @@ var Dashboard = { autoFocus: !1, roles: "admin" }), defineRoute({ - path: "/connectlogin.html", + path: "/addserver.html", dependencies: ["emby-button", "emby-input"], autoFocus: !1, anonymous: !0, startup: !0, - controller: "scripts/connectlogin" + controller: "scripts/addserver" }), defineRoute({ path: "/dashboard.html", dependencies: [], diff --git a/src/selectserver.html b/src/selectserver.html index 0b41eb5a14..b7832cc147 100644 --- a/src/selectserver.html +++ b/src/selectserver.html @@ -13,7 +13,7 @@
- + ${ButtonAddServer}