邮件服务器配置-增加清空功能

pull/21/merge
ouqiang 2017-05-12 10:42:03 +08:00
parent 428275f813
commit 0f5c4c3e2a
3 changed files with 19 additions and 1 deletions

View File

@ -105,6 +105,14 @@ func UpdateMailServer(ctx *macaron.Context, form MailServerForm) string {
return utils.JsonResponseByErr(err)
}
func ClearMailServer(ctx *macaron.Context) string {
jsonByte, _ := json.Marshal(MailServerForm{})
settingModel := new(models.Setting)
_, err := settingModel.UpdateMailServer(string(jsonByte))
return utils.JsonResponseByErr(err)
}
func CreateMailUser(ctx *macaron.Context) string {
username := ctx.QueryTrim("username")
email := ctx.QueryTrim("email")

View File

@ -80,6 +80,7 @@ func Register(m *macaron.Macaron) {
m.Get("/", manage.Mail)
m.Get("/edit", manage.EditMail)
m.Post("/server", binding.Bind(manage.MailServerForm{}), manage.UpdateMailServer)
m.Post("/server/clear", manage.ClearMailServer)
m.Post("/user", manage.CreateMailUser)
m.Post("/user/remove/:id", manage.RemoveMailUser)
})

View File

@ -48,6 +48,9 @@
</div>
</div>
<button class="ui primary button"></button>
{{{if .Mail.Host}}}
<a class="ui green button" onclick="clearMailServer()"></a>
{{{end}}}
<br><br><br>
<div>
<div class="content"></div><p></p>
@ -98,7 +101,7 @@
util.post('/manage/mail/server',
fields,
function(code, message) {
util.alertSuccess();
location.reload();
}
);
return false;
@ -188,5 +191,11 @@
location.reload();
});
}
function clearMailServer() {
util.post('/manage/mail/server/clear', {}, function(code, message) {
location.reload();
});
}
</script>
{{{ template "common/footer" . }}}