Add transport section to in_forward

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
Kenji Okimoto 2018-06-19 18:05:56 +09:00
parent ee8c45db8a
commit a644442687
No known key found for this signature in database
GPG Key ID: F9E3E329A5C5E4A1
3 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,71 @@
'use strict'
import 'lodash/lodash'
import ConfigField from './config_field'
$(document).ready(() => {
new Vue({
el: '#transport-section',
components: {
"config-field": ConfigField
},
props: [
"transportType",
],
propsData: {
"transportType": "tcp"
},
data: function() {
return {
pluginType: null,
pluginName: null,
options: ["tcp", "tls"],
commonOptions: [],
advancedOptions: []
}
},
computed: {
token: function() {
return Rails.csrfToken()
}
},
filters: {
toUpper: function(value) {
return _.toUpper(value)
}
},
beforeMount: function() {
this.pluginType = this.$el.attributes.pluginType.nodeValue
this.pluginName = this.$el.attributes.pluginName.nodeValue
},
mounted: function() {
},
methods: {
onChange: function() {
console.log(this.pluginType, this.pluginName, this.transportType)
this.updateSection()
},
updateSection: function() {
if (this.transportType === "tcp") {
return
}
$.ajax({
method: "GET",
url: "/api/config_definitions",
headers: {
'X-CSRF-Token': this.token
},
data: {
type: this.pluginType,
name: this.pluginName
}
}).then((data) => {
this.commonOptions = data.transport.commonOptions
this.advancedOptions = data.transport.advancedOptions
})
}
}
})
})

View File

@ -5,6 +5,8 @@
- @setting.common_options.each do |key|
= f.field(key)
= render "shared/vue/transport_section", setting: @setting, form: f
.card.card-body.bg-light
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
= icon('fa-caret-down')

View File

@ -0,0 +1,30 @@
- add_javascript_pack_tag("transport_section")
= render "shared/vue/config_field"
#transport-section.form-group.card.card-body.bg-light{"pluginType" => setting.plugin_type,
"pluginName" => setting.plugin_name}
%label
Transport
.form-group
%select{"class" => "form-control",
"v-model" => "transportType",
"v-on:change" => "onChange"}
%option{"v-for" => "option in options",
"v-bind:value" => "option",
"v-bind:selected" => "transportType === option"}
{{ option | toUpper }}
%p{"v-if" => 'transportType === "tcp"'}
Nothing to configure
%template(v-else)
%template{"v-for" => "option in commonOptions"}
%config-field{"v-bind:plugin-type" => "pluginType",
"v-bind:option" => "option"}
.card.card-body.bg-light
%h4{"data-toggle" => "collapse", "href" => "#transport-advanced-setting"}
= icon('fa-caret-down')
= t('terms.advanced_setting') + '(TLS)'
#transport-advanced-setting.collapse
%template{"v-for" => "option in advancedOptions"}
%config-field{"v-bind:plugin-type" => "pluginType",
"v-bind:option" => "option"}