mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 10:56:11 +02:00
Fix Api::SettingsController#update
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
40881626d4
commit
01442157f3
@ -12,16 +12,22 @@ class Api::SettingsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
label_name = params[:label]
|
||||
coming = Fluent::Config::V1Parser.parse(params[:content], @fluentd.config_file)
|
||||
current = @target_element
|
||||
index = @config.elements.index current
|
||||
unless index
|
||||
coming_element = coming.elements.first
|
||||
|
||||
unless @target_element
|
||||
render_404
|
||||
return
|
||||
end
|
||||
@config.elements[index] = coming.elements.first
|
||||
|
||||
@target_element.elements = coming_element.elements
|
||||
@target_element.merge(coming_element)
|
||||
|
||||
@config.write_to_file
|
||||
redirect_to api_setting_path(id: element_id(coming.elements.first))
|
||||
redirect_to api_setting_path(id: element_id(label_name, @target_element),
|
||||
label: label_name,
|
||||
pluginType: params[:pluginType])
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@ -7,7 +7,7 @@ $(document).ready(() => {
|
||||
const SettingSection = {
|
||||
template: "#vue-setting-section",
|
||||
props: [
|
||||
"label",
|
||||
"initialLabel",
|
||||
"initialId",
|
||||
"initialContent",
|
||||
"initialType",
|
||||
@ -18,6 +18,7 @@ $(document).ready(() => {
|
||||
return {
|
||||
mode: "default",
|
||||
processing: false,
|
||||
current_label: null,
|
||||
id: null,
|
||||
content: null,
|
||||
type: null,
|
||||
@ -27,6 +28,7 @@ $(document).ready(() => {
|
||||
},
|
||||
created: function() {
|
||||
this.initialState();
|
||||
this.current_label = this.initialLabel;
|
||||
this.id = this.initialId;
|
||||
this.content = this.initialContent;
|
||||
this.type = this.initialType;
|
||||
@ -62,6 +64,8 @@ $(document).ready(() => {
|
||||
method: "POST",
|
||||
data: {
|
||||
_method: "PATCH",
|
||||
label: this.current_label,
|
||||
pluginType: this.name,
|
||||
id: this.id,
|
||||
content: this.content
|
||||
},
|
||||
@ -87,7 +91,7 @@ $(document).ready(() => {
|
||||
method: "POST",
|
||||
data: {
|
||||
_method: "DELETE",
|
||||
label: this.label,
|
||||
label: this.current_label,
|
||||
pluginType: this.name,
|
||||
arg: this.arg,
|
||||
id: this.id,
|
||||
|
||||
@ -1 +1 @@
|
||||
json.partial! "api/settings/element", element: @section
|
||||
json.partial! "api/settings/element", current_label: params[:label], element: @target_element
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
%setting-section{"v-if" => "loaded && elements.sources && elements.sources.length > 0",
|
||||
"v-for" => "source in elements.sources",
|
||||
"v-bind:key" => "source.id",
|
||||
"v-bind:label" => "source.current_label",
|
||||
"v-bind:initial-label" => "source.current_label",
|
||||
"v-bind:initial-id" => "source.id",
|
||||
"v-bind:initial-content" => "source.content",
|
||||
"v-bind:initial-type" => "source.type",
|
||||
@ -74,7 +74,7 @@
|
||||
%setting-section{"v-if" => "loaded && elements.filters.length > 0",
|
||||
"v-for" => "filter in elements.filters",
|
||||
"v-bind:key" => "filter.id",
|
||||
"v-bind:label" => "filter.current_label",
|
||||
"v-bind:initial-label" => "filter.current_label",
|
||||
"v-bind:initial-id" => "filter.id",
|
||||
"v-bind:initial-content" => "filter.content",
|
||||
"v-bind:initial-type" => "filter.type",
|
||||
@ -88,7 +88,7 @@
|
||||
%setting-section{"v-if" => "loaded && elements.matches.length > 0",
|
||||
"v-for" => "match in elements.matches",
|
||||
"v-bind:key" => "match.id",
|
||||
"v-bind:label" => "match.current_label",
|
||||
"v-bind:initial-label" => "match.current_label",
|
||||
"v-bind:initial-id" => "match.id",
|
||||
"v-bind:initial-content" => "match.content",
|
||||
"v-bind:initial-type" => "match.type",
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<div class="card-body collapse" v-bind:id="id">
|
||||
<pre v-if="mode != 'edit'">{{ content }}</pre>
|
||||
<p v-if="mode == 'edit'">
|
||||
<textarea v-config-editor class="form-control" v-model="content" v-bind:disabled="processing"></textarea>
|
||||
<textarea v-config-editor class="form-control" v-model.lazy="content" v-bind:disabled="processing"></textarea>
|
||||
</p>
|
||||
<p class="float-right">
|
||||
<button v-if="mode != 'edit'" class="btn btn-secondary" v-on:click="onEdit"><%= t('terms.edit') %></button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user