111 lines
2.9 KiB
Smalltalk
111 lines
2.9 KiB
Smalltalk
function disableList(listEmail){
|
|
console.log('disableList('+listEmail+')');
|
|
}
|
|
|
|
function dropList(listEmail){
|
|
console.log('dopList('+listEmail+')');
|
|
}
|
|
|
|
function enableList(listEmail){
|
|
console.log('enableList('+listEmail+')');
|
|
}
|
|
|
|
function hideList(listEmail){
|
|
$.post('/api/list/hide',{list:listEmail},showListResult,'json');
|
|
}
|
|
|
|
function loadListAdminList(){
|
|
$.getJSON('/api/list/list', showListAdminList);
|
|
}
|
|
|
|
function loadListList(){
|
|
$.getJSON('/api/list/list', showListAdminList);
|
|
}
|
|
|
|
function loadUserList(){
|
|
$.getJSON('/api/user/list', showUserList);
|
|
}
|
|
|
|
function reload(){
|
|
window.location.reload(true);
|
|
}
|
|
|
|
function showList(listEmail){
|
|
$.post('/api/list/show',{list:listEmail},showListResult,'json');
|
|
}
|
|
|
|
function showListResult(result){
|
|
console.log(result);
|
|
if ('error' in result){
|
|
alert(result.error);
|
|
return;
|
|
}
|
|
if ('success' in result){
|
|
alert(result.success);
|
|
reload();
|
|
return;
|
|
}
|
|
alert("Api call did not return result");
|
|
}
|
|
|
|
function showListAdminList(data){
|
|
}
|
|
|
|
function showListAdminList(data){
|
|
for (let i in data.lists){
|
|
let list = data.lists[i];
|
|
let row = $('<tr/>');
|
|
|
|
$('<td/>').text(list.name).appendTo(row);
|
|
$('<td/>').text(list.email).appendTo(row);
|
|
$('<td/>').text(list.state).appendTo(row);
|
|
|
|
let select = $('<select/>',{name:list.email}).change(function () {
|
|
let action = $(this).children("option:selected").val();
|
|
let list = $(this).attr('name');
|
|
if (confirm("This will "+action+" '"+list+"'. Are you sure?"))self[action+'List'](list);
|
|
});
|
|
$('<option/>').text('Actions').appendTo(select);
|
|
['enable','disable','drop','hide','show'].forEach(val => $('<option/>',{value:val}).text(val).appendTo(select));
|
|
|
|
select.appendTo($('<td/>')).appendTo(row);
|
|
|
|
$('<td/>').text(list.imap_host).appendTo(row);
|
|
$('<td/>').text(list.imap_port).appendTo(row);
|
|
$('<td/>').text(list.imap_user).appendTo(row);
|
|
$('<td/>').text(list.smtp_host).appendTo(row);
|
|
$('<td/>').text(list.smtp_port).appendTo(row);
|
|
$('<td/>').text(list.smtp_user).appendTo(row);
|
|
row.appendTo('#listlist');
|
|
}
|
|
if (data.user.name == 'Admin'){
|
|
$('a[href=register]').show();
|
|
} else {
|
|
$('a[href=register]').hide();
|
|
}
|
|
}
|
|
|
|
function showUserList(data){
|
|
for (let i in data.users){
|
|
let user = data.users[i];
|
|
let row = $('<tr/>');
|
|
$('<td/>').text(user.name).appendTo(row);
|
|
$('<td/>').text(user.email).appendTo(row);
|
|
$('<td/>').text(user.password).appendTo(row);
|
|
row.appendTo('#userlist');
|
|
}
|
|
if (data.user.name == 'Admin'){
|
|
$('a[href=register]').show();
|
|
} else {
|
|
$('a[href=register]').hide();
|
|
}
|
|
}
|
|
|
|
function start(){
|
|
console.log("application started");
|
|
}
|
|
|
|
|
|
|
|
|
|
$(start); // document.on ready |