Browse Source

working on list management scripts

drop_old_mail
Stephan Richter 3 years ago
parent
commit
1c84a63e66
  1. 1
      src/main/java/de/srsoftware/widerhall/data/MailingList.java
  2. 28
      static/templates/js.st

1
src/main/java/de/srsoftware/widerhall/data/MailingList.java

@ -21,6 +21,7 @@ public class MailingList {
private static final String SMTP_USER = "smtp_user"; private static final String SMTP_USER = "smtp_user";
private static final String SMTP_PASS = "smtp_pass"; private static final String SMTP_PASS = "smtp_pass";
private static final int ENABLED = 1; private static final int ENABLED = 1;
private static final int PUBLIC = 2;
private final String name; private final String name;
private final String email; private final String email;
public static final String TABLE_NAME = "Lists"; public static final String TABLE_NAME = "Lists";

28
static/templates/js.st

@ -10,6 +10,10 @@ function enableList(listEmail){
console.log('enableList('+listEmail+')'); console.log('enableList('+listEmail+')');
} }
function hideList(listEmail){
console.log('hideList('+listEmail+')');
}
function loadListList(){ function loadListList(){
$.getJSON("/api/list/list", showListList); $.getJSON("/api/list/list", showListList);
} }
@ -18,24 +22,30 @@ function loadUserList(){
$.getJSON("/api/user/list", showUserList); $.getJSON("/api/user/list", showUserList);
} }
function showList(listEmail){
console.log('showList('+listEmail+')');
}
function showListList(data){ function showListList(data){
for (let i in data.lists){ for (let i in data.lists){
let list = data.lists[i]; let list = data.lists[i];
let row = $('<tr/>'); let row = $('<tr/>');
let drop = $('<button/>').text('drop list').click(() => dropList(list.email))
let start = $('<button/>').text('enable').click(() => enableList(list.email))
let stop = $('<button/>').text('disable').click(() => disableList(list.email))
let actions = $('<td/>');
$('<td/>').text(list.name).appendTo(row); $('<td/>').text(list.name).appendTo(row);
$('<td/>').text(list.email).appendTo(row); $('<td/>').text(list.email).appendTo(row);
$('<td/>').text(list.state).appendTo(row); $('<td/>').text(list.state).appendTo(row);
start.appendTo(actions); let select = $('<select/>',{name:list.email}).change(function () {
stop.appendTo(actions); let action = $(this).children("option:selected").val();
drop.appendTo(actions); let list = $(this).attr('name');
actions.appendTo(row); if (confirm("This will "+action+" '"+list+"'. Are you sure?"))self[action+'List'](list);
$('<td/>').text(list.imap_host).appendTo(row); });
$('<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_port).appendTo(row);
$('<td/>').text(list.imap_user).appendTo(row); $('<td/>').text(list.imap_user).appendTo(row);
$('<td/>').text(list.smtp_host).appendTo(row); $('<td/>').text(list.smtp_host).appendTo(row);

Loading…
Cancel
Save