jellyfin-web/dashboard-ui/scripts/advancedconfigurationpage.js

153 lines
4.8 KiB
JavaScript
Raw Normal View History

2013-04-23 12:17:21 -07:00
(function ($, document, window) {
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
function loadPage(page, config, systemInfo) {
2013-02-20 18:33:05 -07:00
var os = systemInfo.OperatingSystem.toLowerCase();
2013-12-14 18:17:57 -07:00
if (os.indexOf('windows') != -1) {
$('#windowsStartupDescription', page).show();
} else {
$('#windowsStartupDescription', page).hide();
}
2014-01-05 18:59:21 -07:00
if (systemInfo.SupportsAutoRunAtStartup) {
$('#fldRunAtStartup', page).show();
} else {
$('#fldRunAtStartup', page).hide();
}
2014-01-11 13:13:18 -07:00
$('#chkEnableAutomaticRestart', page).checked(config.EnableAutomaticRestart).checkboxradio("refresh");
if (systemInfo.CanSelfRestart) {
$('#fldEnableAutomaticRestart', page).show();
} else {
$('#fldEnableAutomaticRestart', page).hide();
}
2013-12-14 18:17:57 -07:00
$('#selectAutomaticUpdateLevel', page).val(config.SystemUpdateLevel).selectmenu('refresh').trigger('change');
2013-02-20 18:33:05 -07:00
$('#chkDebugLog', page).checked(config.EnableDebugLevelLogging).checkboxradio("refresh");
$('#chkRunAtStartup', page).checked(config.RunAtStartup).checkboxradio("refresh");
2013-12-14 18:17:57 -07:00
$('#txtCachePath', page).val(config.CachePath || '');
var customCachePath = config.CachePath ? true : false;
$('#chkEnableCustomCachePath', page).checked(customCachePath).checkboxradio("refresh");
if (customCachePath) {
$('#fldEnterCachePath', page).show();
$('#txtCachePath', page).attr("required", "required");
} else {
$('#fldEnterCachePath', page).hide();
$('#txtCachePath', page).removeAttr("required");
}
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
2013-04-23 12:17:21 -07:00
}
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
$(document).on('pageshow', "#advancedConfigurationPage", function () {
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
2013-04-23 12:17:21 -07:00
var page = this;
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
var promise1 = ApiClient.getServerConfiguration();
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
var promise2 = ApiClient.getSystemInfo();
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
2013-12-14 18:17:57 -07:00
$('#btnSelectCachePath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtCachePath', page).val(path);
}
picker.close();
},
header: "Select Server Cache Path",
2013-12-15 07:19:24 -07:00
instruction: "Browse or enter the path to use for Media Browser Server cache. The folder must be writeable. The location of this folder will directly impact server performance and should ideally be placed on a solid state drive."
2013-12-14 18:17:57 -07:00
});
});
$('#chkEnableCustomCachePath', page).on("change.showCachePathText", function () {
if (this.checked) {
$('#fldEnterCachePath', page).show();
$('#txtCachePath', page).attr("required", "required");
} else {
$('#fldEnterCachePath', page).hide();
$('#txtCachePath', page).removeAttr("required");
}
});
}).on('pagehide', "#advancedConfigurationPage", function () {
var page = this;
$('#chkEnableCustomCachePath', page).off("change.showCachePathText");
$('#btnSelectCachePath', page).off("click.selectDirectory");
}).on('pageinit', "#advancedConfigurationPage", function () {
var page = this;
$('#selectAutomaticUpdateLevel', page).on('change', function () {
if (this.value == "Dev") {
$('#devBuildWarning', page).show();
} else {
$('#devBuildWarning', page).hide();
}
});
2013-12-14 18:17:57 -07:00
2013-04-23 12:17:21 -07:00
});
function advancedConfigurationPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
2013-12-14 18:17:57 -07:00
if ($('#chkEnableCustomCachePath', form).checked()) {
config.CachePath = $('#txtCachePath', form).val();
} else {
config.CachePath = '';
}
2013-04-23 12:17:21 -07:00
config.EnableDebugLevelLogging = $('#chkDebugLog', form).checked();
config.RunAtStartup = $('#chkRunAtStartup', form).checked();
config.SystemUpdateLevel = $('#selectAutomaticUpdateLevel', form).val();
2014-01-11 13:13:18 -07:00
config.EnableAutomaticRestart = $('#chkEnableAutomaticRestart', form).checked();
2013-04-23 12:17:21 -07:00
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
2013-02-20 18:33:05 -07:00
}
2013-04-23 12:17:21 -07:00
window.AdvancedConfigurationPage = new advancedConfigurationPage();
})(jQuery, document, window);