| 
									
										
										
										
											2017-09-10 23:10:32 -04:00
										 |  |  | function displaySettings() { | 
					
						
							| 
									
										
										
										
											2017-09-12 23:04:17 -04:00
										 |  |  |     $.ajax({ | 
					
						
							|  |  |  |         url: baseUrl + 'settings', | 
					
						
							|  |  |  |         type: 'GET', | 
					
						
							|  |  |  |         success: function (result) { | 
					
						
							|  |  |  |             $("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']); | 
					
						
							| 
									
										
										
										
											2017-09-24 20:50:14 -04:00
										 |  |  |             $("#historySnapshotTimeIntervalInSeconds").val(result['history_snapshot_time_interval']); | 
					
						
							| 
									
										
										
										
											2017-09-12 23:04:17 -04:00
										 |  |  |         }, | 
					
						
							|  |  |  |         error: () => alert("Error getting settings.") | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-10 23:10:32 -04:00
										 |  |  |     $("#settingsDialog").dialog({ | 
					
						
							|  |  |  |         modal: true, | 
					
						
							|  |  |  |         width: 600 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#settingsTabs").tabs(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $("#changePasswordForm").submit(() => { | 
					
						
							| 
									
										
										
										
											2017-09-12 22:23:57 -04:00
										 |  |  |     const oldPassword = $("#oldPassword").val(); | 
					
						
							|  |  |  |     const newPassword1 = $("#newPassword1").val(); | 
					
						
							|  |  |  |     const newPassword2 = $("#newPassword2").val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#oldPassword").val(''); | 
					
						
							|  |  |  |     $("#newPassword1").val(''); | 
					
						
							|  |  |  |     $("#newPassword2").val(''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newPassword1 != newPassword2) { | 
					
						
							|  |  |  |         alert("New passwords are not the same."); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $.ajax({ | 
					
						
							|  |  |  |         url: baseUrl + 'password/change', | 
					
						
							|  |  |  |         type: 'POST', | 
					
						
							|  |  |  |         data: JSON.stringify({ | 
					
						
							|  |  |  |             'current_password': oldPassword, | 
					
						
							|  |  |  |             'new_password': newPassword1 | 
					
						
							|  |  |  |         }), | 
					
						
							|  |  |  |         contentType: "application/json", | 
					
						
							|  |  |  |         success: function (result) { | 
					
						
							|  |  |  |             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
										 |  |  | 
 | 
					
						
							|  |  |  |                 $("#settingsDialog").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; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $("#encryptionTimeoutForm").submit(() => { | 
					
						
							|  |  |  |     const encryptionTimeout = $("#encryptionTimeoutInSeconds").val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $.ajax({ | 
					
						
							|  |  |  |         url: baseUrl + 'settings', | 
					
						
							|  |  |  |         type: 'POST', | 
					
						
							|  |  |  |         data: JSON.stringify({ | 
					
						
							|  |  |  |             name: 'encryption_session_timeout', | 
					
						
							|  |  |  |             value: encryptionTimeout | 
					
						
							|  |  |  |         }), | 
					
						
							|  |  |  |         contentType: "application/json", | 
					
						
							|  |  |  |         success: function () { | 
					
						
							|  |  |  |             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; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $("#historySnapshotTimeIntervalForm").submit(() => { | 
					
						
							|  |  |  |     const historySnapshotTimeInterval = $("#historySnapshotTimeIntervalInSeconds").val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $.ajax({ | 
					
						
							|  |  |  |         url: baseUrl + 'settings', | 
					
						
							|  |  |  |         type: 'POST', | 
					
						
							|  |  |  |         data: JSON.stringify({ | 
					
						
							|  |  |  |             name: 'history_snapshot_time_interval', | 
					
						
							|  |  |  |             value: historySnapshotTimeInterval | 
					
						
							|  |  |  |         }), | 
					
						
							|  |  |  |         contentType: "application/json", | 
					
						
							|  |  |  |         success: function () { | 
					
						
							|  |  |  |             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; | 
					
						
							|  |  |  | }); |