2014-03-30 19:33:10 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
2014-07-10 21:27:46 -07:00
|
|
|
|
var brandingConfigKey = "branding";
|
2015-01-18 22:41:56 -07:00
|
|
|
|
var currentBrandingOptions;
|
2014-07-10 21:27:46 -07:00
|
|
|
|
|
2015-01-30 09:12:08 -07:00
|
|
|
|
var currentLanguage;
|
|
|
|
|
|
2014-03-30 19:33:10 -07:00
|
|
|
|
function loadPage(page, config, languageOptions) {
|
|
|
|
|
|
2015-01-18 12:53:34 -07:00
|
|
|
|
if (Dashboard.lastSystemInfo) {
|
|
|
|
|
Dashboard.setPageTitle(Dashboard.lastSystemInfo.ServerName);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-18 21:29:57 -07:00
|
|
|
|
refreshPageTitle(page);
|
2015-01-18 12:53:34 -07:00
|
|
|
|
|
2015-07-30 08:18:07 -07:00
|
|
|
|
page.querySelector('#txtServerName').value = config.ServerName || '';
|
|
|
|
|
page.querySelector('#txtCachePath').value = config.CachePath || '';
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
|
|
|
|
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
|
|
|
|
|
|
|
|
|
|
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
})).val(config.UICulture);
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-01-30 09:12:08 -07:00
|
|
|
|
currentLanguage = config.UICulture;
|
|
|
|
|
|
2015-01-18 21:29:57 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
2015-01-06 20:36:42 -07:00
|
|
|
|
|
2015-01-18 21:29:57 -07:00
|
|
|
|
function refreshPageTitle(page) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getSystemInfo().then(function (systemInfo) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-01-18 21:29:57 -07:00
|
|
|
|
Dashboard.setPageTitle(systemInfo.ServerName);
|
|
|
|
|
});
|
2014-03-30 19:33:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
function onSubmit() {
|
2014-03-30 19:33:10 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var form = this;
|
|
|
|
|
var page = $(form).parents('.page');
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-07-30 08:18:07 -07:00
|
|
|
|
config.ServerName = form.querySelector('#txtServerName').value;
|
2015-06-08 14:32:20 -07:00
|
|
|
|
config.UICulture = $('#selectLocalizationLanguage', form).val();
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-07-30 08:18:07 -07:00
|
|
|
|
config.CachePath = form.querySelector('#txtCachePath').value;
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
if (config.UICulture != currentLanguage) {
|
|
|
|
|
Dashboard.showDashboardRefreshNotification();
|
|
|
|
|
}
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).then(function () {
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
refreshPageTitle(page);
|
2014-07-10 21:27:46 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function (brandingConfig) {
|
2015-01-18 22:41:56 -07:00
|
|
|
|
|
2015-07-30 08:18:07 -07:00
|
|
|
|
brandingConfig.LoginDisclaimer = form.querySelector('#txtLoginDisclaimer').value;
|
|
|
|
|
brandingConfig.CustomCss = form.querySelector('#txtCustomCss').value;
|
2015-06-08 14:32:20 -07:00
|
|
|
|
|
|
|
|
|
var cssChanged = currentBrandingOptions && brandingConfig.CustomCss != currentBrandingOptions.CustomCss;
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(Dashboard.processServerConfigurationUpdateResult);
|
2015-06-08 14:32:20 -07:00
|
|
|
|
|
|
|
|
|
if (cssChanged) {
|
|
|
|
|
Dashboard.showDashboardRefreshNotification();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2014-07-10 21:27:46 -07:00
|
|
|
|
});
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#dashboardGeneralPage", function () {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#btnSelectCachePath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
var picker = new directoryBrowser();
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
picker.show({
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
page.querySelector('#txtCachePath').value = path;
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
},
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
header: Globalize.translate('HeaderSelectServerCachePath'),
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
instruction: Globalize.translate('HeaderSelectServerCachePathHelp')
|
|
|
|
|
});
|
2014-07-19 21:46:29 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
$('.dashboardGeneralForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#dashboardGeneralPage", function () {
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2015-01-30 09:12:08 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var page = this;
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var promise1 = ApiClient.getServerConfiguration();
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
2014-07-10 21:27:46 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Promise.all([promise1, promise2]).then(function (responses) {
|
2015-01-18 22:41:56 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
loadPage(page, responses[0], responses[1]);
|
2014-07-10 21:27:46 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
});
|
2015-01-18 22:41:56 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function (config) {
|
2014-07-10 21:27:46 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
currentBrandingOptions = config;
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-07-30 08:18:07 -07:00
|
|
|
|
page.querySelector('#txtLoginDisclaimer').value = config.LoginDisclaimer || '';
|
|
|
|
|
page.querySelector('#txtCustomCss').value = config.CustomCss || '';
|
2015-06-08 14:32:20 -07:00
|
|
|
|
});
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
});
|
2014-03-30 19:33:10 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|