2017-09-10 23:10:32 -04:00
|
|
|
function displaySettings() {
|
2017-09-12 23:04:17 -04:00
|
|
|
$.ajax({
|
2017-09-30 10:05:12 -04:00
|
|
|
url: baseApiUrl + 'settings',
|
2017-09-12 23:04:17 -04:00
|
|
|
type: 'GET',
|
2017-10-09 18:53:11 -04:00
|
|
|
success: result => {
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#encryption-timeout-in-seconds").val(result['encryption_session_timeout']);
|
|
|
|
$("#history-snapshot-time-interval-in-seconds").val(result['history_snapshot_time_interval']);
|
2017-09-12 23:04:17 -04:00
|
|
|
},
|
|
|
|
error: () => alert("Error getting settings.")
|
|
|
|
});
|
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#settings-dialog").dialog({
|
2017-09-10 23:10:32 -04:00
|
|
|
modal: true,
|
|
|
|
width: 600
|
|
|
|
});
|
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#settings-tabs").tabs();
|
2017-09-10 23:10:32 -04:00
|
|
|
}
|
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#change-password-form").submit(() => {
|
|
|
|
const oldPassword = $("#old-password").val();
|
|
|
|
const newPassword1 = $("#new-password1").val();
|
|
|
|
const newPassword2 = $("#new-password2").val();
|
2017-09-12 22:23:57 -04:00
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#old-password").val('');
|
|
|
|
$("#new-password1").val('');
|
|
|
|
$("#new-password2").val('');
|
2017-09-12 22:23:57 -04:00
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
if (newPassword1 !== newPassword2) {
|
2017-09-12 22:23:57 -04:00
|
|
|
alert("New passwords are not the same.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
2017-09-30 10:05:12 -04:00
|
|
|
url: baseApiUrl + 'password/change',
|
2017-09-12 22:23:57 -04:00
|
|
|
type: 'POST',
|
|
|
|
data: JSON.stringify({
|
|
|
|
'current_password': oldPassword,
|
|
|
|
'new_password': newPassword1
|
|
|
|
}),
|
|
|
|
contentType: "application/json",
|
2017-10-09 18:53:11 -04:00
|
|
|
success: result => {
|
2017-09-12 22:23:57 -04:00
|
|
|
if (result.success) {
|
2017-09-12 23:07:08 -04:00
|
|
|
// encryption password changed so current encryption session is invalid and needs to be cleared
|
|
|
|
resetEncryptionSession();
|
|
|
|
|
2017-09-17 00:18:03 -04:00
|
|
|
globalEncryptedDataKey = result.new_encrypted_data_key;
|
|
|
|
|
2017-09-12 22:23:57 -04:00
|
|
|
alert("Password has been changed.");
|
2017-09-17 00:18:03 -04:00
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#settings-dialog").dialog('close');
|
2017-09-12 22:23:57 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert(result.message);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: () => alert("Error occurred during changing password.")
|
|
|
|
});
|
2017-09-10 23:10:32 -04:00
|
|
|
|
2017-09-12 23:04:17 -04:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#encryption-timeout-form").submit(() => {
|
|
|
|
const encryptionTimeout = $("#encryption-timeout-in-seconds").val();
|
2017-09-12 23:04:17 -04:00
|
|
|
|
|
|
|
$.ajax({
|
2017-09-30 10:05:12 -04:00
|
|
|
url: baseApiUrl + 'settings',
|
2017-09-12 23:04:17 -04:00
|
|
|
type: 'POST',
|
|
|
|
data: JSON.stringify({
|
|
|
|
name: 'encryption_session_timeout',
|
|
|
|
value: encryptionTimeout
|
|
|
|
}),
|
|
|
|
contentType: "application/json",
|
2017-10-09 18:53:11 -04:00
|
|
|
success: () => {
|
2017-09-12 23:04:17 -04:00
|
|
|
alert("Encryption timeout has been changed.");
|
2017-09-23 10:59:36 -04:00
|
|
|
|
|
|
|
globalEncryptionSessionTimeout = encryptionTimeout;
|
2017-09-12 23:04:17 -04:00
|
|
|
},
|
|
|
|
error: () => alert("Error occurred during changing encryption timeout.")
|
|
|
|
});
|
|
|
|
|
2017-09-24 20:50:14 -04:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2017-10-10 20:19:16 -04:00
|
|
|
$("#history-snapshot-time-interval-form").submit(() => {
|
|
|
|
const historySnapshotTimeInterval = $("#history-snapshot-time-interval-in-seconds").val();
|
2017-09-24 20:50:14 -04:00
|
|
|
|
|
|
|
$.ajax({
|
2017-09-30 10:05:12 -04:00
|
|
|
url: baseApiUrl + 'settings',
|
2017-09-24 20:50:14 -04:00
|
|
|
type: 'POST',
|
|
|
|
data: JSON.stringify({
|
|
|
|
name: 'history_snapshot_time_interval',
|
|
|
|
value: historySnapshotTimeInterval
|
|
|
|
}),
|
|
|
|
contentType: "application/json",
|
2017-10-09 18:53:11 -04:00
|
|
|
success: () => {
|
2017-09-24 20:50:14 -04:00
|
|
|
alert("History snapshot time interval has been changed.");
|
|
|
|
},
|
|
|
|
error: () => alert("Error occurred during changing history snapshot time interval.")
|
|
|
|
});
|
|
|
|
|
2017-09-10 23:10:32 -04:00
|
|
|
return false;
|
|
|
|
});
|