code clean up for default reminder email and added flag to disable registration on front end.
This commit is contained in:
@@ -666,7 +666,7 @@ namespace CarCareTracker.Controllers
|
|||||||
{
|
{
|
||||||
var vehicles = _dataAccess.GetVehicles();
|
var vehicles = _dataAccess.GetVehicles();
|
||||||
List<OperationResponse> operationResponses = new List<OperationResponse>();
|
List<OperationResponse> operationResponses = new List<OperationResponse>();
|
||||||
var defaultEmailAddress = _config.GetDefaultReminderEmail();
|
var defaultEmailAddress = _config.GetUserConfig(User).DefaultReminderEmail;
|
||||||
foreach(Vehicle vehicle in vehicles)
|
foreach(Vehicle vehicle in vehicles)
|
||||||
{
|
{
|
||||||
var vehicleId = vehicle.Id;
|
var vehicleId = vehicle.Id;
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ namespace CarCareTracker.Controllers
|
|||||||
}
|
}
|
||||||
public IActionResult Registration()
|
public IActionResult Registration()
|
||||||
{
|
{
|
||||||
|
if (_config.GetServerDisabledRegistration())
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
public IActionResult ForgotPassword()
|
public IActionResult ForgotPassword()
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ namespace CarCareTracker.Helper
|
|||||||
bool AuthenticateRootUser(string username, string password);
|
bool AuthenticateRootUser(string username, string password);
|
||||||
string GetWebHookUrl();
|
string GetWebHookUrl();
|
||||||
string GetMOTD();
|
string GetMOTD();
|
||||||
string GetDefaultReminderEmail();
|
|
||||||
string GetLogoUrl();
|
string GetLogoUrl();
|
||||||
string GetServerLanguage();
|
string GetServerLanguage();
|
||||||
|
bool GetServerDisabledRegistration();
|
||||||
bool GetServerEnableShopSupplies();
|
bool GetServerEnableShopSupplies();
|
||||||
string GetServerPostgresConnection();
|
string GetServerPostgresConnection();
|
||||||
string GetAllowedFileUploadExtensions();
|
string GetAllowedFileUploadExtensions();
|
||||||
@@ -53,15 +53,6 @@ namespace CarCareTracker.Helper
|
|||||||
}
|
}
|
||||||
return motd;
|
return motd;
|
||||||
}
|
}
|
||||||
public string GetDefaultReminderEmail()
|
|
||||||
{
|
|
||||||
var defaultEmail = _config["DEFAULT_REMINDER_EMAIL"];
|
|
||||||
if (string.IsNullOrWhiteSpace(defaultEmail))
|
|
||||||
{
|
|
||||||
defaultEmail = "";
|
|
||||||
}
|
|
||||||
return defaultEmail;
|
|
||||||
}
|
|
||||||
public OpenIDConfig GetOpenIDConfig()
|
public OpenIDConfig GetOpenIDConfig()
|
||||||
{
|
{
|
||||||
OpenIDConfig openIdConfig = _config.GetSection("OpenIDConfig").Get<OpenIDConfig>() ?? new OpenIDConfig();
|
OpenIDConfig openIdConfig = _config.GetSection("OpenIDConfig").Get<OpenIDConfig>() ?? new OpenIDConfig();
|
||||||
@@ -104,6 +95,11 @@ namespace CarCareTracker.Helper
|
|||||||
var serverLanguage = _config[nameof(UserConfig.UserLanguage)] ?? "en_US";
|
var serverLanguage = _config[nameof(UserConfig.UserLanguage)] ?? "en_US";
|
||||||
return serverLanguage;
|
return serverLanguage;
|
||||||
}
|
}
|
||||||
|
public bool GetServerDisabledRegistration()
|
||||||
|
{
|
||||||
|
var registrationDisabled = bool.Parse(_config[nameof(UserConfig.DisableRegistration)]);
|
||||||
|
return registrationDisabled;
|
||||||
|
}
|
||||||
public string GetServerPostgresConnection()
|
public string GetServerPostgresConnection()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(_config["POSTGRES_CONNECTION"]))
|
if (!string.IsNullOrWhiteSpace(_config["POSTGRES_CONNECTION"]))
|
||||||
@@ -190,7 +186,9 @@ namespace CarCareTracker.Helper
|
|||||||
VisibleTabs = _config.GetSection(nameof(UserConfig.VisibleTabs)).Get<List<ImportMode>>(),
|
VisibleTabs = _config.GetSection(nameof(UserConfig.VisibleTabs)).Get<List<ImportMode>>(),
|
||||||
UserColumnPreferences = _config.GetSection(nameof(UserConfig.UserColumnPreferences)).Get<List<UserColumnPreference>>() ?? new List<UserColumnPreference>(),
|
UserColumnPreferences = _config.GetSection(nameof(UserConfig.UserColumnPreferences)).Get<List<UserColumnPreference>>() ?? new List<UserColumnPreference>(),
|
||||||
ReminderUrgencyConfig = _config.GetSection(nameof(UserConfig.ReminderUrgencyConfig)).Get<ReminderUrgencyConfig>() ?? new ReminderUrgencyConfig(),
|
ReminderUrgencyConfig = _config.GetSection(nameof(UserConfig.ReminderUrgencyConfig)).Get<ReminderUrgencyConfig>() ?? new ReminderUrgencyConfig(),
|
||||||
DefaultTab = (ImportMode)int.Parse(_config[nameof(UserConfig.DefaultTab)])
|
DefaultTab = (ImportMode)int.Parse(_config[nameof(UserConfig.DefaultTab)]),
|
||||||
|
DefaultReminderEmail = _config[nameof(UserConfig.DefaultReminderEmail)],
|
||||||
|
DisableRegistration = bool.Parse(_config[nameof(UserConfig.DisableRegistration)])
|
||||||
};
|
};
|
||||||
int userId = 0;
|
int userId = 0;
|
||||||
if (user != null)
|
if (user != null)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
public bool UseMPG { get; set; }
|
public bool UseMPG { get; set; }
|
||||||
public bool UseDescending { get; set; }
|
public bool UseDescending { get; set; }
|
||||||
public bool EnableAuth { get; set; }
|
public bool EnableAuth { get; set; }
|
||||||
|
public bool DisableRegistration { get; set; }
|
||||||
public bool HideZero { get; set; }
|
public bool HideZero { get; set; }
|
||||||
public bool UseUKMPG {get;set;}
|
public bool UseUKMPG {get;set;}
|
||||||
public bool UseThreeDecimalGasCost { get; set; }
|
public bool UseThreeDecimalGasCost { get; set; }
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
public ReminderUrgencyConfig ReminderUrgencyConfig { get; set; } = new ReminderUrgencyConfig();
|
public ReminderUrgencyConfig ReminderUrgencyConfig { get; set; } = new ReminderUrgencyConfig();
|
||||||
public string UserNameHash { get; set; }
|
public string UserNameHash { get; set; }
|
||||||
public string UserPasswordHash { get; set;}
|
public string UserPasswordHash { get; set;}
|
||||||
|
public string DefaultReminderEmail { get; set; } = string.Empty;
|
||||||
public string UserLanguage { get; set; } = "en_US";
|
public string UserLanguage { get; set; } = "en_US";
|
||||||
public List<ImportMode> VisibleTabs { get; set; } = new List<ImportMode>() {
|
public List<ImportMode> VisibleTabs { get; set; } = new List<ImportMode>() {
|
||||||
ImportMode.Dashboard,
|
ImportMode.Dashboard,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
}
|
}
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script src="~/js/garage.js?v=@StaticHelper.VersionNumber"></script>
|
<script src="~/js/garage.js?v=@StaticHelper.VersionNumber"></script>
|
||||||
|
<script src="~/js/settings.js?v=@StaticHelper.VersionNumber"></script>
|
||||||
<script src="~/js/supplyrecord.js?v=@StaticHelper.VersionNumber"></script>
|
<script src="~/js/supplyrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||||
<script src="~/lib/drawdown/drawdown.js"></script>
|
<script src="~/lib/drawdown/drawdown.js"></script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,13 @@
|
|||||||
<input class="form-check-input" onChange="enableAuthCheckChanged()" type="checkbox" role="switch" id="enableAuth" checked="@Model.UserConfig.EnableAuth">
|
<input class="form-check-input" onChange="enableAuthCheckChanged()" type="checkbox" role="switch" id="enableAuth" checked="@Model.UserConfig.EnableAuth">
|
||||||
<label class="form-check-label" for="enableAuth">@translator.Translate(userLanguage, "Enable Authentication")</label>
|
<label class="form-check-label" for="enableAuth">@translator.Translate(userLanguage, "Enable Authentication")</label>
|
||||||
</div>
|
</div>
|
||||||
|
@if (Model.UserConfig.EnableAuth)
|
||||||
|
{
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="disableRegistration" checked="@Model.UserConfig.DisableRegistration">
|
||||||
|
<label class="form-check-label" for="disableRegistration">@translator.Translate(userLanguage, "Disable Registration")</label>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
@@ -198,6 +205,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
<span class="lead">@translator.Translate(userLanguage, "Default Reminder Email")</span>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 d-grid">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="inputDefaultEmail" class="form-control" placeholder="@translator.Translate(userLanguage,"Default Email for Reminder")" value="@Model.UserConfig.DefaultReminderEmail">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary zero-y-padding" onclick="updateSettings()"><i class="bi bi-floppy"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -306,137 +326,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function showExtraFieldModal() {
|
|
||||||
$.get(`/Home/GetExtraFieldsModal?importMode=0`, function (data) {
|
|
||||||
$("#extraFieldModalContent").html(data);
|
|
||||||
$("#extraFieldModal").modal('show');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function hideExtraFieldModal() {
|
|
||||||
$("#extraFieldModal").modal('hide');
|
|
||||||
}
|
|
||||||
function getCheckedTabs() {
|
|
||||||
var visibleTabs = $("#visibleTabs :checked").map(function () {
|
|
||||||
return this.value;
|
|
||||||
});
|
|
||||||
return visibleTabs.toArray();
|
|
||||||
}
|
|
||||||
function deleteLanguage() {
|
|
||||||
var languageFileLocation = `/translations/${$("#defaultLanguage").val()}.json`;
|
|
||||||
$.post('/Files/DeleteFiles', { fileLocation: languageFileLocation }, function (data) {
|
|
||||||
//reset user language back to en_US
|
|
||||||
$("#defaultLanguage").val('en_US');
|
|
||||||
updateSettings();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function updateSettings() {
|
|
||||||
var visibleTabs = getCheckedTabs();
|
|
||||||
var defaultTab = $("#defaultTab").val();
|
|
||||||
if (!visibleTabs.includes(defaultTab)) {
|
|
||||||
defaultTab = "Dashboard"; //default to dashboard.
|
|
||||||
}
|
|
||||||
var userConfigObject = {
|
|
||||||
useDarkMode: $("#enableDarkMode").is(':checked'),
|
|
||||||
enableCsvImports: $("#enableCsvImports").is(':checked'),
|
|
||||||
useMPG: $("#useMPG").is(':checked'),
|
|
||||||
useDescending: $("#useDescending").is(':checked'),
|
|
||||||
hideZero: $("#hideZero").is(":checked"),
|
|
||||||
useUKMpg: $("#useUKMPG").is(":checked"),
|
|
||||||
useThreeDecimalGasCost: $("#useThreeDecimal").is(":checked"),
|
|
||||||
useMarkDownOnSavedNotes: $("#useMarkDownOnSavedNotes").is(":checked"),
|
|
||||||
enableAutoReminderRefresh: $("#enableAutoReminderRefresh").is(":checked"),
|
|
||||||
enableAutoOdometerInsert: $("#enableAutoOdometerInsert").is(":checked"),
|
|
||||||
enableShopSupplies: $("#enableShopSupplies").is(":checked"),
|
|
||||||
enableExtraFieldColumns: $("#enableExtraFieldColumns").is(":checked"),
|
|
||||||
hideSoldVehicles: $("#hideSoldVehicles").is(":checked"),
|
|
||||||
preferredGasUnit: $("#preferredGasUnit").val(),
|
|
||||||
preferredGasMileageUnit: $("#preferredFuelMileageUnit").val(),
|
|
||||||
userLanguage: $("#defaultLanguage").val(),
|
|
||||||
visibleTabs: visibleTabs,
|
|
||||||
defaultTab: defaultTab
|
|
||||||
}
|
|
||||||
sloader.show();
|
|
||||||
$.post('/Home/WriteToSettings', { userConfig: userConfigObject }, function (data) {
|
|
||||||
sloader.hide();
|
|
||||||
if (data) {
|
|
||||||
setTimeout(function () { window.location.href = '/Home/Index?tab=settings' }, 500);
|
|
||||||
} else {
|
|
||||||
errorToast(genericErrorMessage());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
function makeBackup() {
|
|
||||||
$.get('/Files/MakeBackup', function (data) {
|
|
||||||
window.location.href = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function openUploadLanguage() {
|
|
||||||
$("#inputLanguage").click();
|
|
||||||
}
|
|
||||||
function openRestoreBackup() {
|
|
||||||
$("#inputBackup").click();
|
|
||||||
}
|
|
||||||
function uploadLanguage(event) {
|
|
||||||
let formData = new FormData();
|
|
||||||
formData.append("file", event.files[0]);
|
|
||||||
sloader.show();
|
|
||||||
$.ajax({
|
|
||||||
url: "/Files/HandleTranslationFileUpload",
|
|
||||||
data: formData,
|
|
||||||
cache: false,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
type: 'POST',
|
|
||||||
success: function (response) {
|
|
||||||
sloader.hide();
|
|
||||||
if (response.success) {
|
|
||||||
setTimeout(function () { window.location.href = '/Home/Index?tab=settings' }, 500);
|
|
||||||
} else {
|
|
||||||
errorToast(response.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function () {
|
|
||||||
sloader.hide();
|
|
||||||
errorToast("An error has occurred, please check the file size and try again later.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function restoreBackup(event) {
|
|
||||||
let formData = new FormData();
|
|
||||||
formData.append("file", event.files[0]);
|
|
||||||
console.log('LubeLogger - DB Restoration Started');
|
|
||||||
sloader.show();
|
|
||||||
$.ajax({
|
|
||||||
url: "/Files/HandleFileUpload",
|
|
||||||
data: formData,
|
|
||||||
cache: false,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
type: 'POST',
|
|
||||||
success: function (response) {
|
|
||||||
if (response.trim() != '') {
|
|
||||||
$.post('/Files/RestoreBackup', { fileName: response }, function (data) {
|
|
||||||
sloader.hide();
|
|
||||||
if (data) {
|
|
||||||
console.log('LubeLogger - DB Restoration Completed');
|
|
||||||
successToast("Backup Restored");
|
|
||||||
setTimeout(function () { window.location.href = '/Home/Index' }, 500);
|
|
||||||
} else {
|
|
||||||
errorToast(genericErrorMessage());
|
|
||||||
console.log('LubeLogger - DB Restoration Failed - Failed to process backup file.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('LubeLogger - DB Restoration Failed - Failed to upload backup file.');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function () {
|
|
||||||
sloader.hide();
|
|
||||||
console.log('LubeLogger - DB Restoration Failed - Request failed to reach backend, please check file size.');
|
|
||||||
errorToast("An error has occurred, please check the file size and try again later.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function enableAuthCheckChanged() {
|
function enableAuthCheckChanged() {
|
||||||
var enableAuth = $("#enableAuth").is(":checked");
|
var enableAuth = $("#enableAuth").is(":checked");
|
||||||
if (enableAuth) {
|
if (enableAuth) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
@{
|
@{
|
||||||
var logoUrl = config.GetLogoUrl();
|
var logoUrl = config.GetLogoUrl();
|
||||||
var userLanguage = config.GetServerLanguage();
|
var userLanguage = config.GetServerLanguage();
|
||||||
|
var registrationDisabled = config.GetServerDisabledRegistration();
|
||||||
var openIdConfigName = config.GetOpenIDConfig().Name;
|
var openIdConfigName = config.GetOpenIDConfig().Name;
|
||||||
}
|
}
|
||||||
@{
|
@{
|
||||||
@@ -46,9 +47,12 @@
|
|||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
<a href="/Login/ForgotPassword" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Forgot Password")</a>
|
<a href="/Login/ForgotPassword" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Forgot Password")</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid">
|
@if (!registrationDisabled)
|
||||||
<a href="/Login/Registration" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Register")</a>
|
{
|
||||||
</div>
|
<div class="d-grid">
|
||||||
|
<a href="/Login/Registration" class="btn btn-link mt-2">@translator.Translate(userLanguage, "Register")</a>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"UseMPG": true,
|
"UseMPG": true,
|
||||||
"UseDescending": false,
|
"UseDescending": false,
|
||||||
"EnableAuth": false,
|
"EnableAuth": false,
|
||||||
|
"DisableRegistration": false,
|
||||||
"HideZero": false,
|
"HideZero": false,
|
||||||
"EnableAutoReminderRefresh": false,
|
"EnableAutoReminderRefresh": false,
|
||||||
"EnableAutoOdometerInsert": false,
|
"EnableAutoOdometerInsert": false,
|
||||||
@@ -27,5 +28,6 @@
|
|||||||
"VisibleTabs": [ 0, 1, 4, 2, 3, 6, 5, 8 ],
|
"VisibleTabs": [ 0, 1, 4, 2, 3, 6, 5, 8 ],
|
||||||
"DefaultTab": 8,
|
"DefaultTab": 8,
|
||||||
"UserNameHash": "",
|
"UserNameHash": "",
|
||||||
"UserPasswordHash": ""
|
"UserPasswordHash": "",
|
||||||
|
"DefaultReminderEmail": ""
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
137
wwwroot/js/settings.js
Normal file
137
wwwroot/js/settings.js
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
function showExtraFieldModal() {
|
||||||
|
$.get(`/Home/GetExtraFieldsModal?importMode=0`, function (data) {
|
||||||
|
$("#extraFieldModalContent").html(data);
|
||||||
|
$("#extraFieldModal").modal('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function hideExtraFieldModal() {
|
||||||
|
$("#extraFieldModal").modal('hide');
|
||||||
|
}
|
||||||
|
function getCheckedTabs() {
|
||||||
|
var visibleTabs = $("#visibleTabs :checked").map(function () {
|
||||||
|
return this.value;
|
||||||
|
});
|
||||||
|
return visibleTabs.toArray();
|
||||||
|
}
|
||||||
|
function deleteLanguage() {
|
||||||
|
var languageFileLocation = `/translations/${$("#defaultLanguage").val()}.json`;
|
||||||
|
$.post('/Files/DeleteFiles', { fileLocation: languageFileLocation }, function (data) {
|
||||||
|
//reset user language back to en_US
|
||||||
|
$("#defaultLanguage").val('en_US');
|
||||||
|
updateSettings();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function updateSettings() {
|
||||||
|
var visibleTabs = getCheckedTabs();
|
||||||
|
var defaultTab = $("#defaultTab").val();
|
||||||
|
if (!visibleTabs.includes(defaultTab)) {
|
||||||
|
defaultTab = "Dashboard"; //default to dashboard.
|
||||||
|
}
|
||||||
|
//Root User Only Settings that aren't rendered:
|
||||||
|
var defaultReminderEmail = $("#inputDefaultEmail").length > 0 ? $("#inputDefaultEmail").val() : "";
|
||||||
|
var disableRegistration = $("#disableRegistration").length > 0 ? $("#disableRegistration").is(":checked") : false;
|
||||||
|
|
||||||
|
var userConfigObject = {
|
||||||
|
useDarkMode: $("#enableDarkMode").is(':checked'),
|
||||||
|
enableCsvImports: $("#enableCsvImports").is(':checked'),
|
||||||
|
useMPG: $("#useMPG").is(':checked'),
|
||||||
|
useDescending: $("#useDescending").is(':checked'),
|
||||||
|
hideZero: $("#hideZero").is(":checked"),
|
||||||
|
useUKMpg: $("#useUKMPG").is(":checked"),
|
||||||
|
useThreeDecimalGasCost: $("#useThreeDecimal").is(":checked"),
|
||||||
|
useMarkDownOnSavedNotes: $("#useMarkDownOnSavedNotes").is(":checked"),
|
||||||
|
enableAutoReminderRefresh: $("#enableAutoReminderRefresh").is(":checked"),
|
||||||
|
enableAutoOdometerInsert: $("#enableAutoOdometerInsert").is(":checked"),
|
||||||
|
enableShopSupplies: $("#enableShopSupplies").is(":checked"),
|
||||||
|
enableExtraFieldColumns: $("#enableExtraFieldColumns").is(":checked"),
|
||||||
|
hideSoldVehicles: $("#hideSoldVehicles").is(":checked"),
|
||||||
|
preferredGasUnit: $("#preferredGasUnit").val(),
|
||||||
|
preferredGasMileageUnit: $("#preferredFuelMileageUnit").val(),
|
||||||
|
userLanguage: $("#defaultLanguage").val(),
|
||||||
|
visibleTabs: visibleTabs,
|
||||||
|
defaultTab: defaultTab,
|
||||||
|
disableRegistration: disableRegistration,
|
||||||
|
defaultReminderEmail: defaultReminderEmail
|
||||||
|
}
|
||||||
|
sloader.show();
|
||||||
|
$.post('/Home/WriteToSettings', { userConfig: userConfigObject }, function (data) {
|
||||||
|
sloader.hide();
|
||||||
|
if (data) {
|
||||||
|
setTimeout(function () { window.location.href = '/Home/Index?tab=settings' }, 500);
|
||||||
|
} else {
|
||||||
|
errorToast(genericErrorMessage());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function makeBackup() {
|
||||||
|
$.get('/Files/MakeBackup', function (data) {
|
||||||
|
window.location.href = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function openUploadLanguage() {
|
||||||
|
$("#inputLanguage").click();
|
||||||
|
}
|
||||||
|
function openRestoreBackup() {
|
||||||
|
$("#inputBackup").click();
|
||||||
|
}
|
||||||
|
function uploadLanguage(event) {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("file", event.files[0]);
|
||||||
|
sloader.show();
|
||||||
|
$.ajax({
|
||||||
|
url: "/Files/HandleTranslationFileUpload",
|
||||||
|
data: formData,
|
||||||
|
cache: false,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
type: 'POST',
|
||||||
|
success: function (response) {
|
||||||
|
sloader.hide();
|
||||||
|
if (response.success) {
|
||||||
|
setTimeout(function () { window.location.href = '/Home/Index?tab=settings' }, 500);
|
||||||
|
} else {
|
||||||
|
errorToast(response.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
sloader.hide();
|
||||||
|
errorToast("An error has occurred, please check the file size and try again later.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function restoreBackup(event) {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("file", event.files[0]);
|
||||||
|
console.log('LubeLogger - DB Restoration Started');
|
||||||
|
sloader.show();
|
||||||
|
$.ajax({
|
||||||
|
url: "/Files/HandleFileUpload",
|
||||||
|
data: formData,
|
||||||
|
cache: false,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
type: 'POST',
|
||||||
|
success: function (response) {
|
||||||
|
if (response.trim() != '') {
|
||||||
|
$.post('/Files/RestoreBackup', { fileName: response }, function (data) {
|
||||||
|
sloader.hide();
|
||||||
|
if (data) {
|
||||||
|
console.log('LubeLogger - DB Restoration Completed');
|
||||||
|
successToast("Backup Restored");
|
||||||
|
setTimeout(function () { window.location.href = '/Home/Index' }, 500);
|
||||||
|
} else {
|
||||||
|
errorToast(genericErrorMessage());
|
||||||
|
console.log('LubeLogger - DB Restoration Failed - Failed to process backup file.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('LubeLogger - DB Restoration Failed - Failed to upload backup file.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
sloader.hide();
|
||||||
|
console.log('LubeLogger - DB Restoration Failed - Request failed to reach backend, please check file size.');
|
||||||
|
errorToast("An error has occurred, please check the file size and try again later.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user