mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
move authentication and playback controllers to subdirectories
This commit is contained in:
parent
4bf12b1682
commit
07994e0a40
13 changed files with 12 additions and 12 deletions
39
src/controllers/wizard/access.js
Normal file
39
src/controllers/wizard/access.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
define(["loading", "emby-checkbox", "emby-button", "emby-select"], function (loading) {
|
||||
"use strict";
|
||||
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var config = {};
|
||||
config.EnableRemoteAccess = page.querySelector("#chkRemoteAccess").checked;
|
||||
config.EnableAutomaticPortMapping = page.querySelector("#chkEnableUpnp").checked;
|
||||
apiClient.ajax({
|
||||
type: "POST",
|
||||
data: config,
|
||||
url: apiClient.getUrl("Startup/RemoteAccess")
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate("wizardfinish.html");
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function () {
|
||||
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
|
||||
});
|
||||
view.addEventListener("viewhide", function () {
|
||||
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
|
||||
});
|
||||
};
|
||||
});
|
18
src/controllers/wizard/finish.js
Normal file
18
src/controllers/wizard/finish.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
define(["loading"], function (loading) {
|
||||
"use strict";
|
||||
|
||||
function onFinish() {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
url: ApiClient.getUrl("Startup/Complete"),
|
||||
type: "POST"
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
window.location.href = "index.html";
|
||||
});
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector(".btnWizardNext").addEventListener("click", onFinish);
|
||||
};
|
||||
});
|
84
src/controllers/wizard/settings.js
Normal file
84
src/controllers/wizard/settings.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
define(["loading", "emby-checkbox", "emby-button", "emby-select"], function (loading) {
|
||||
"use strict";
|
||||
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) {
|
||||
config.PreferredMetadataLanguage = page.querySelector("#selectLanguage").value;
|
||||
config.MetadataCountryCode = page.querySelector("#selectCountry").value;
|
||||
apiClient.ajax({
|
||||
type: "POST",
|
||||
data: config,
|
||||
url: apiClient.getUrl("Startup/Configuration")
|
||||
}).then(function () {
|
||||
loading.hide();
|
||||
navigateToNextPage();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function populateLanguages(select, languages) {
|
||||
var html = "";
|
||||
html += "<option value=''></option>";
|
||||
|
||||
for (var i = 0, length = languages.length; i < length; i++) {
|
||||
var culture = languages[i];
|
||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
|
||||
}
|
||||
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
function populateCountries(select, allCountries) {
|
||||
var html = "";
|
||||
html += "<option value=''></option>";
|
||||
|
||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
||||
var culture = allCountries[i];
|
||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
|
||||
}
|
||||
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
function reloadData(page, config, cultures, countries) {
|
||||
populateLanguages(page.querySelector("#selectLanguage"), cultures);
|
||||
populateCountries(page.querySelector("#selectCountry"), countries);
|
||||
page.querySelector("#selectLanguage").value = config.PreferredMetadataLanguage;
|
||||
page.querySelector("#selectCountry").value = config.MetadataCountryCode;
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function reload(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration"));
|
||||
var promise2 = apiClient.getCultures();
|
||||
var promise3 = apiClient.getCountries();
|
||||
Promise.all([promise1, promise2, promise3]).then(function (responses) {
|
||||
reloadData(page, responses[0], responses[1], responses[2]);
|
||||
});
|
||||
}
|
||||
|
||||
function navigateToNextPage() {
|
||||
Dashboard.navigate("wizardremoteaccess.html");
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
save(this);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function () {
|
||||
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
|
||||
reload(this);
|
||||
});
|
||||
view.addEventListener("viewhide", function () {
|
||||
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
|
||||
});
|
||||
};
|
||||
});
|
48
src/controllers/wizard/start.js
Normal file
48
src/controllers/wizard/start.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
define(["jQuery", "loading", "emby-button", "emby-select"], function ($, loading) {
|
||||
"use strict";
|
||||
|
||||
function loadPage(page, config, languageOptions) {
|
||||
$("#selectLocalizationLanguage", page).html(languageOptions.map(function (l) {
|
||||
return '<option value="' + l.Value + '">' + l.Name + "</option>";
|
||||
})).val(config.UICulture);
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) {
|
||||
config.UICulture = $("#selectLocalizationLanguage", page).val();
|
||||
apiClient.ajax({
|
||||
type: "POST",
|
||||
data: config,
|
||||
url: apiClient.getUrl("Startup/Configuration")
|
||||
}).then(function () {
|
||||
Dashboard.navigate("wizarduser.html");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
save($(this).parents(".page"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
$(".wizardStartForm", view).on("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function () {
|
||||
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
|
||||
loading.show();
|
||||
var page = this;
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration"));
|
||||
var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options"));
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
loadPage(page, responses[0], responses[1]);
|
||||
});
|
||||
});
|
||||
view.addEventListener("viewhide", function () {
|
||||
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
|
||||
});
|
||||
};
|
||||
});
|
67
src/controllers/wizard/user.js
Normal file
67
src/controllers/wizard/user.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "emby-button"], function (loading, globalize) {
|
||||
"use strict";
|
||||
|
||||
function getApiClient() {
|
||||
return ApiClient;
|
||||
}
|
||||
|
||||
function nextWizardPage() {
|
||||
Dashboard.navigate("wizardlibrary.html");
|
||||
}
|
||||
|
||||
function onUpdateUserComplete(result) {
|
||||
console.log(result);
|
||||
loading.hide();
|
||||
nextWizardPage();
|
||||
}
|
||||
|
||||
function submit(form) {
|
||||
loading.show();
|
||||
var apiClient = getApiClient();
|
||||
apiClient.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
Name: form.querySelector("#txtUsername").value,
|
||||
Password: form.querySelector("#txtManualPassword").value
|
||||
},
|
||||
url: apiClient.getUrl("Startup/User")
|
||||
}).then(onUpdateUserComplete);
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
var form = this;
|
||||
|
||||
if (form.querySelector("#txtManualPassword").value != form.querySelector("#txtPasswordConfirm").value) {
|
||||
require(["toast"], function (toast) {
|
||||
toast(Globalize.translate("PasswordMatchError"));
|
||||
});
|
||||
} else {
|
||||
submit(form);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onViewShow() {
|
||||
loading.show();
|
||||
var page = this;
|
||||
var apiClient = getApiClient();
|
||||
apiClient.getJSON(apiClient.getUrl("Startup/User")).then(function (user) {
|
||||
page.querySelector("#txtUsername").value = user.Name || "";
|
||||
page.querySelector("#txtManualPassword").value = user.Password || "";
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
view.querySelector(".wizardUserForm").addEventListener("submit", onSubmit);
|
||||
view.addEventListener("viewshow", function () {
|
||||
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
|
||||
});
|
||||
view.addEventListener("viewhide", function () {
|
||||
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
|
||||
});
|
||||
view.addEventListener("viewshow", onViewShow);
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue