fluentd-ui/app/javascript/packs/owned_plugin_section.js
Kenji Okimoto 97ef81a7ad Handle onChange event of buffer/storage section configuration
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
2018-06-08 10:23:32 +09:00

63 lines
1.7 KiB
JavaScript

import "lodash/lodash"
$(document).ready(() => {
let configUrl = (name) => {
return `/daemon/setting/${name}/configure`
}
function ownedSectionOnChange() {
const pluginName = _.last(document.documentURI.replace(/\/configure$/, "").split("/"))
$("#buffer-section select").on("change", (event) => {
$.ajax({
url: configUrl(pluginName),
method: "GET",
data: {
buffer_type: $(event.target).val()
}
}).then((data) => {
$("#buffer-section").html($(data).find("#buffer-section").html())
ownedSectionOnChange()
})
})
$("#storage-section select").on("change", (event) => {
$.ajax({
url: configUrl(pluginName),
method: "GET",
data: {
storage_type: $(event.target).val()
}
}).then((data) => {
$("#storage-section").html($(data).find("#storage-section").html())
ownedSectionOnChange()
})
})
$("#parse-section select").on("change", (event) => {
$.ajax({
url: configUrl(pluginName),
method: "GET",
data: {
parse_type: $(event.target).val()
}
}).then((data) => {
$("#parse-section").html($(data).find("#parse-section").html())
ownedSectionOnChange()
})
})
$("#format-section select").on("change", (event) => {
$.ajax({
url: configUrl(pluginName),
method: "GET",
data: {
format_type: $(event.target).val()
}
}).then((data) => {
$("#format-section").html($(data).find("#format-section").html())
ownedSectionOnChange()
})
})
}
ownedSectionOnChange()
})