New notification settings

This commit is contained in:
2018-03-15 21:08:30 +01:00
parent 90021ef2f6
commit e0e8ed7996
6 changed files with 108 additions and 10 deletions

View File

@ -48,6 +48,52 @@ export function save(arn: AnimeNotifier, input: HTMLElement) {
})
}
// Enable (bool field)
export async function enable(arn: AnimeNotifier, button: HTMLButtonElement) {
let obj = {}
let apiEndpoint = arn.findAPIEndpoint(button)
obj[button.dataset.field] = true
button.disabled = true
try {
// Update boolean value
await arn.post(apiEndpoint, obj)
// Reload content
arn.reloadContent()
arn.statusMessage.showInfo("Enabled: " + button.title)
} catch(err) {
arn.statusMessage.showError(err)
} finally {
button.disabled = false
}
}
// Disable (bool field)
export async function disable(arn: AnimeNotifier, button: HTMLButtonElement) {
let obj = {}
let apiEndpoint = arn.findAPIEndpoint(button)
obj[button.dataset.field] = false
button.disabled = true
try {
// Update boolean value
await arn.post(apiEndpoint, obj)
// Reload content
arn.reloadContent()
arn.statusMessage.showInfo("Disabled: " + button.title)
} catch(err) {
arn.statusMessage.showError(err)
} finally {
button.disabled = false
}
}
// Append new element to array
export function arrayAppend(arn: AnimeNotifier, element: HTMLElement) {
let field = element.dataset.field