feat(notification): 添加通知方式

This commit is contained in:
naiba
2020-12-19 22:14:36 +08:00
parent b118958f35
commit d19de0edc2
16 changed files with 391 additions and 58 deletions

View File

@@ -42,7 +42,7 @@ function showFormModal(modelSelector, formID, URL, getData) {
form.children('.message').remove()
btn.toggleClass('loading')
const data = getData ? getData() : $(formID).serializeArray().reduce(function (obj, item) {
obj[item.name] = (item.name.endsWith('_id') || item.name === 'id') ? parseInt(item.value) : item.value;
obj[item.name] = (item.name.endsWith('_id') || item.name === 'id' || item.name === 'ID' || item.name === 'RequestType' || item.name === 'RequestMethod') ? parseInt(item.value) : item.value;
return obj;
}, {});
$.post(URL, JSON.stringify(data)).done(function (resp) {
@@ -70,11 +70,26 @@ function showFormModal(modelSelector, formID, URL, getData) {
}).modal('show')
}
function addOrEditNotification(notification) {
const modal = $('.notification.modal')
modal.children('.header').text((notification ? '修改' : '添加') + '通知方式')
modal.find('.positive.button').html(notification ? '修改<i class="edit icon"></i>' : '添加<i class="add icon"></i>')
modal.find('input[name=ID]').val(notification ? notification.ID : null)
modal.find('input[name=Name]').val(notification ? notification.Name : null)
modal.find('input[name=URL]').val(notification ? notification.URL : null)
modal.find('textarea[name=RequestBody]').val(notification ? notification.RequestBody : null)
modal.find('select[name=RequestMethod]').val(notification ? notification.RequestMethod : 1)
modal.find('select[name=RequestType]').val(notification ? notification.RequestType : 1)
if (notification && notification.VerifySSL) {
modal.find('.ui.checkbox').checkbox('set checked')
} else {
modal.find('.ui.checkbox').checkbox('set unchecked')
}
showFormModal('.notification.modal', '#notificationForm', '/api/notification')
}
function addOrEditServer(server) {
const modal = $('.server.modal')
if (server) {
server = JSON.parse(server)
}
modal.children('.header').text((server ? '修改' : '添加') + '服务器')
modal.find('.positive.button').html(server ? '修改<i class="edit icon"></i>' : '添加<i class="add icon"></i>')
modal.find('input[name=id]').val(server ? server.ID : null)

View File

@@ -1,21 +1,3 @@
/* Dark mode */
#darkmodeButton {
background-color: black;
width: 3rem;
height: 3rem;
position: fixed;
bottom: 2rem;
right: 0.5rem;
z-index: 9999;
border-radius: 50%;
outline: 0;
}
body.dark #darkmodeButton {
background-color: white;
}
body.dark {
background: #263236;
color: #aaa;
@@ -38,7 +20,8 @@ body.dark .panel {
color: #aaa;
}
body.dark .panel h3, body.dark .panel span {
body.dark .panel h3,
body.dark .panel span {
color: #aaa;
}