mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
deminify addserver script
This commit is contained in:
parent
20286dd81e
commit
810fee21ab
2 changed files with 25 additions and 15 deletions
|
@ -14,7 +14,7 @@
|
|||
<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">
|
||||
<button is="emby-button" type="button" class="raised button-cancel block btnCancelManualServer">
|
||||
<span>${ButtonCancel}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
|
|
@ -2,16 +2,17 @@ define(["appSettings", "loading", "browser", "emby-linkbutton"], function(appSet
|
|||
"use strict";
|
||||
|
||||
function handleConnectionResult(page, result) {
|
||||
switch (loading.hide(), result.State) {
|
||||
loading.hide();
|
||||
switch (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");
|
||||
Dashboard.navigate("login.html?serverid=" + result.Servers[0].Id, false, "none");
|
||||
break;
|
||||
case "ServerSelection":
|
||||
Dashboard.navigate("selectserver.html", !1, "none");
|
||||
Dashboard.navigate("selectserver.html", false, "none");
|
||||
break;
|
||||
case "ServerUpdateNeeded":
|
||||
Dashboard.alert({
|
||||
|
@ -22,34 +23,43 @@ define(["appSettings", "loading", "browser", "emby-linkbutton"], function(appSet
|
|||
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, {
|
||||
var host = page.querySelector("#txtServerHost").value;
|
||||
var port = page.querySelector("#txtServerPort").value;
|
||||
if (port) {
|
||||
host += ":" + port;
|
||||
}
|
||||
|
||||
loading.show();
|
||||
ConnectionManager.connectToAddress(host, {
|
||||
enableAutoLogin: appSettings.enableAutoLogin()
|
||||
}).then(function(result) {
|
||||
handleConnectionResult(page, result)
|
||||
handleConnectionResult(page, result);
|
||||
}, function() {
|
||||
handleConnectionResult(page, {
|
||||
State: "Unavailable"
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return function(view, params) {
|
||||
view.querySelector(".manualServerForm").addEventListener("submit", onManualServerSubmit)
|
||||
view.querySelector(".manualServerForm").addEventListener("submit", onManualServerSubmit);
|
||||
view.querySelector(".btnCancelManualServer").addEventListener("click", goBack);
|
||||
|
||||
function onManualServerSubmit(e) {
|
||||
return submitManualServer(view), e.preventDefault(), !1
|
||||
submitManualServer(view);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
require(["appRouter"], function(appRouter) {
|
||||
appRouter.back()
|
||||
})
|
||||
appRouter.back();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue