Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of changes to the server configuration pages #168

Merged
merged 18 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/appservices.html

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/apphost.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function(appSett
features.push("displaylanguage");
features.push("otherapppromotions");
features.push("targetblank");
features.push("multiserver");
// allows users to connect to more than one server
//features.push("multiserver");
dkanada marked this conversation as resolved.
Show resolved Hide resolved
browser.orsay || browser.tizen || browser.msie || !(browser.firefox || browser.ps4 || browser.edge || cueSupported()) || features.push("subtitleappearancesettings");
browser.orsay || browser.tizen || features.push("subtitleburnsettings");
browser.tv || browser.ps4 || browser.xboxOne || features.push("fileinput");
Expand Down
20 changes: 8 additions & 12 deletions src/components/directorybrowser/directorybrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-b
if (path && typeof path !== 'string') {
throw new Error("invalid path");
}

loading.show();

var promises = [];

if ("Network" === path) {
promises.push(ApiClient.getNetworkDevices())
} else {
if (path) {
if (path) {
promises.push(ApiClient.getDirectoryContents(path, fileOptions));
promises.push(ApiClient.getParentPath(path));
} else {
} else {
promises.push(ApiClient.getDrives());
}
}
Expand All @@ -42,7 +42,7 @@ define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-b

page.querySelector(".results").scrollTop = 0;
page.querySelector("#txtDirectoryPickerPath").value = path || "";

if (path) {
html += getItem("lnkPath lnkDirectory", "", parentPath, "...");
}
Expand All @@ -51,7 +51,7 @@ define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-b
var cssClass = "File" === folder.Type ? "lnkPath lnkFile" : "lnkPath lnkDirectory";
html += getItem(cssClass, folder.Type, folder.Path, folder.Name);
}

if (!path) {
html += getItem("lnkPath lnkDirectory", "", "Network", Globalize.translate("ButtonNetwork"));
}
Expand Down Expand Up @@ -128,7 +128,7 @@ define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-b
html += '<button type="button" is="paper-icon-button-light" class="btnRefreshDirectories emby-input-iconbutton" title="' + Globalize.translate("ButtonRefresh") + '"><i class="md-icon">search</i></button>';
}
html += "</div>";
if (!readOnlyAttribute) {
if (!readOnlyAttribute) {
html += '<div class="results paperList" style="max-height: 200px; overflow-y: auto;"></div>';
}
if (options.enableNetworkSharePath) {
Expand Down Expand Up @@ -222,11 +222,7 @@ define(['loading', 'dialogHelper', 'dom', 'listViewStyle', 'emby-input', 'emby-b
var networkSharePath = this.querySelector("#txtNetworkPath");
networkSharePath = networkSharePath ? networkSharePath.value : null;
var path = this.querySelector("#txtDirectoryPickerPath").value;
validatePath(path, options.validateWriteable, ApiClient).then(
function() {
options.callback(path, networkSharePath);
}
);
validatePath(path, options.validateWriteable, ApiClient).then(options.callback(path, networkSharePath));
}
e.preventDefault();
e.stopPropagation();
Expand Down
9 changes: 5 additions & 4 deletions src/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ <h3>${HeaderRunningTasks}</h3>
<h3 style="margin:0;">${HeaderActiveDevices}</h3>
<i class="md-icon">&#xE5CC;</i>
</a>

<div class="activeDevices itemsContainer vertical-wrap">
</div>

</div>
</div>

Expand All @@ -76,16 +74,19 @@ <h3>${HeaderActiveRecordings}</h3>
</div>

<div class="dashboardSection serverActivitySection hide activityContainer">

<a is="emby-linkbutton" href="serveractivity.html?useractivity=false" class="button-flat sectionTitleTextButton">
<h3>${Alerts}</h3>
<i class="md-icon">&#xE5CC;</i>
</a>
<div class="paperList serverActivityItems" data-activitylimit="4" data-useractivity="false">
</div>
</div>

<div class="dashboardSection">
<h3>${HeaderPaths}</h3>
<a is="emby-linkbutton" href="dashboardgeneral.html" class="button-flat sectionTitleTextButton">
<h3>${HeaderPaths}</h3>
<i class="md-icon">&#xE5CC;</i>
</a>
<div class="paperList">
<div class="listItem listItem-border">
<div class="listItemBody two-line">
Expand Down
118 changes: 97 additions & 21 deletions src/dashboard/dashboardgeneral.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,126 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emb
"use strict";

function loadPage(page, config, languageOptions, systemInfo) {
systemInfo.CanLaunchWebBrowser ? page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide") : page.querySelector("#fldRunWebAppAtStartup").classList.add("hide"), page.querySelector("#txtCachePath").value = config.CachePath || "", $("#selectLocalizationLanguage", page).html(languageOptions.map(function(l) {
return '<option value="' + l.Value + '">' + l.Name + "</option>"
})).val(config.UICulture), currentLanguage = config.UICulture, systemInfo.CanSelfUpdate ? page.querySelector(".fldAutomaticUpdates").classList.remove("hide") : page.querySelector(".fldAutomaticUpdates").classList.add("hide"), $("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate), $("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart), systemInfo.CanSelfRestart ? page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide") : page.querySelector("#fldEnableAutomaticRestart").classList.add("hide"), systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate ? $(".autoUpdatesContainer", page).removeClass("hide") : $(".autoUpdatesContainer", page).addClass("hide"), loading.hide()
if (systemInfo.CanLaunchWebBrowser) {
page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide");
} else {
page.querySelector("#fldRunWebAppAtStartup").classList.add("hide");
}
page.querySelector("#txtCachePath").value = config.CachePath || "";
$("#txtMetadataPath", page).val(config.MetadataPath || "");
$("#txtMetadataNetworkPath", page).val(config.MetadataNetworkPath || "");
$("#selectLocalizationLanguage", page).html(languageOptions.map(function(language) {
return '<option value="' + language.Value + '">' + language.Name + "</option>"
})).val(config.UICulture);
currentLanguage = config.UICulture;
if (systemInfo.CanSelfUpdate) {
page.querySelector(".fldAutomaticUpdates").classList.remove("hide");
} else {
page.querySelector(".fldAutomaticUpdates").classList.add("hide");
}
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
if (systemInfo.CanSelfRestart) {
page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide");
} else {
page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
}
if (systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate) {
$(".autoUpdatesContainer", page).removeClass("hide");
} else {
$(".autoUpdatesContainer", page).addClass("hide");
}
loading.hide();
}

function onSubmit() {
loading.show();
var form = this;
$(form).parents(".page");
return ApiClient.getServerConfiguration().then(function(config) {
config.UICulture = $("#selectLocalizationLanguage", form).val(), config.CachePath = form.querySelector("#txtCachePath").value;
var requiresReload = !1;
config.UICulture !== currentLanguage && (requiresReload = !0), config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked(), config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked(), ApiClient.updateServerConfiguration(config).then(function() {
config.UICulture = $("#selectLocalizationLanguage", form).val();
config.CachePath = form.querySelector("#txtCachePath").value;
config.MetadataPath = $("#txtMetadataPath", form).val();
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
var requiresReload = (config.UICulture !== currentLanguage);
config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked();
config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked();
ApiClient.updateServerConfiguration(config).then(function() {
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value, brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value, currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss && (requiresReload = !0), ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function() {
Dashboard.processServerConfigurationUpdateResult(), requiresReload && !AppInfo.isNativeApp && window.location.reload(!0)
})
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value;
brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value;
if (currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss) {
requiresReload = true;
}
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function() {
Dashboard.processServerConfigurationUpdateResult();
if (requiresReload && !AppInfo.isNativeApp) {
window.location.reload(true);
}
});
})
})
}), !1
}
var currentBrandingOptions, currentLanguage, brandingConfigKey = "branding";

var currentBrandingOptions;
var currentLanguage;
var brandingConfigKey = "branding";

return function(view, params) {
$("#btnSelectCachePath", view).on("click.selectDirectory", function() {
require(["directorybrowser"], function(directoryBrowser) {
var picker = new directoryBrowser;
picker.show({
callback: function(path) {
path && (view.querySelector("#txtCachePath").value = path), picker.close()
if (path) {
view.querySelector("#txtCachePath").value = path;
}
picker.close();
},
validateWriteable: !0,
validateWriteable: true,
header: Globalize.translate("HeaderSelectServerCachePath"),
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
})
})
}), $(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit), view.addEventListener("viewshow", function() {
var promise1 = ApiClient.getServerConfiguration(),
promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options")),
promise3 = ApiClient.getSystemInfo();
Promise.all([promise1, promise2, promise3]).then(function(responses) {
loadPage(view, responses[0], responses[1], responses[2])
}), ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
currentBrandingOptions = config, view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "", view.querySelector("#txtCustomCss").value = config.CustomCss || ""
});

$("#btnSelectMetadataPath", view).on("click.selectDirectory", function() {
JustAMan marked this conversation as resolved.
Show resolved Hide resolved
require(["directorybrowser"], function(directoryBrowser) {
var picker = new directoryBrowser();
picker.show({
path: $("#txtMetadataPath", view).val(),
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
callback: function(path, networkPath) {
if (path) {
$("#txtMetadataPath", view).val(path);
}
if (networkPath) {
$("#txtMetadataNetworkPath", view).val(networkPath));
}
picker.close();
},
validateWriteable: true,
header: Globalize.translate("HeaderSelectMetadataPath"),
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
enableNetworkSharePath: true
})
})
})
});

$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
view.addEventListener("viewshow", function() {
var promiseConfig = ApiClient.getServerConfiguration();
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
var promiseSystemInfo = ApiClient.getSystemInfo();
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function(responses) {
loadPage(view, responses[0], responses[1], responses[2]);
});
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
currentBrandingOptions = config;
view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "";
view.querySelector("#txtCustomCss").value = config.CustomCss || "";
});
});
}
});
Loading