working on sending mails: prerequisite mail configuration in progress
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -39,7 +39,8 @@ function setText(id, text){
|
||||
|
||||
|
||||
function setValue(id,newVal){
|
||||
get(id).value = newVal;
|
||||
var elem = get(id);
|
||||
if (elem) elem.value = newVal;
|
||||
}
|
||||
|
||||
function show(id){
|
||||
|
||||
@@ -10,40 +10,6 @@ function fillForm(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleResponse(response){
|
||||
if (response.ok){
|
||||
hide('update_error')
|
||||
setText('updateBtn', 'saved.');
|
||||
} else {
|
||||
show('update_error');
|
||||
setText('updateBtn', 'Update failed!');
|
||||
}
|
||||
enable('updateBtn');
|
||||
setTimeout(function(){
|
||||
setText('updateBtn','Update');
|
||||
},10000);
|
||||
}
|
||||
|
||||
function update(){
|
||||
disable('updateBtn');
|
||||
var newData = {
|
||||
username : getValue('username'),
|
||||
email : getValue('email'),
|
||||
realname : getValue('realname'),
|
||||
uuid : getValue('uuid')
|
||||
}
|
||||
fetch(user_controller+'/update',{
|
||||
method : 'POST',
|
||||
headers : {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body : JSON.stringify(newData)
|
||||
}).then(handleResponse)
|
||||
setText('updateBtn','sent…');
|
||||
}
|
||||
|
||||
|
||||
async function handlePasswordResponse(response){
|
||||
if (response.ok){
|
||||
hide('wrong_password');
|
||||
@@ -62,6 +28,38 @@ async function handlePasswordResponse(response){
|
||||
},10000);
|
||||
}
|
||||
|
||||
function handleResponse(response){
|
||||
if (response.ok){
|
||||
hide('update_error')
|
||||
setText('updateBtn', 'saved.');
|
||||
} else {
|
||||
show('update_error');
|
||||
setText('updateBtn', 'Update failed!');
|
||||
}
|
||||
enable('updateBtn');
|
||||
setTimeout(function(){
|
||||
setText('updateBtn','Update');
|
||||
},10000);
|
||||
}
|
||||
|
||||
async function handleSettings(response){
|
||||
console.log('handleSettings(…)',response);
|
||||
if (response.ok){
|
||||
var json = await response.json();
|
||||
for (var key in json){
|
||||
setValue(key,json[key]);
|
||||
}
|
||||
show('mail_settings');
|
||||
} else {
|
||||
hide('mail_settings');
|
||||
}
|
||||
}
|
||||
|
||||
function passKeyDown(ev){
|
||||
if (event.keyCode == 13) updatePass();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updatePass(){
|
||||
disable('passBtn');
|
||||
@@ -80,8 +78,25 @@ function updatePass(){
|
||||
setText('passBtn','sent…');
|
||||
}
|
||||
|
||||
function passKeyDown(ev){
|
||||
if (event.keyCode == 13) updatePass();
|
||||
|
||||
|
||||
function update(){
|
||||
disable('updateBtn');
|
||||
var newData = {
|
||||
username : getValue('username'),
|
||||
email : getValue('email'),
|
||||
realname : getValue('realname'),
|
||||
uuid : getValue('uuid')
|
||||
}
|
||||
fetch(user_controller+'/update',{
|
||||
method : 'POST',
|
||||
headers : {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body : JSON.stringify(newData)
|
||||
}).then(handleResponse)
|
||||
setText('updateBtn','sent…');
|
||||
}
|
||||
|
||||
setTimeout(fillForm,100);
|
||||
setTimeout(fillForm,100);
|
||||
fetch("/api/email/settings").then(handleSettings);
|
||||
@@ -78,6 +78,32 @@
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset id="mail_settings" style="display: none">
|
||||
<legend>
|
||||
Mail settings
|
||||
</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Smtp host</th>
|
||||
<td><input type="text" id="smtp_host"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Smtp port</th>
|
||||
<td><input type="text" id="smtp_port"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sender email address</th>
|
||||
<td><input type="text" id="sender_mail"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sender password</th>
|
||||
<td><input type="password" id="sender_password"></td>
|
||||
</tr>
|
||||
<td></td>
|
||||
<td><button id="smtpBtn" type="button" onClick="updateSmtp()">Update</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user