mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-07 06:47:09 +02:00
Add basically API support
This commit is contained in:
parent
86a3e684b1
commit
9861f55ac9
@ -2,6 +2,7 @@ PATH
|
||||
remote: .
|
||||
specs:
|
||||
fluentd-ui (0.0.1.pre)
|
||||
addressable
|
||||
bcrypt (~> 3.1.5)
|
||||
bundler (~> 1.5)
|
||||
coffee-rails (~> 4.0.0)
|
||||
|
@ -42,6 +42,6 @@ class FluentdController < ApplicationController
|
||||
end
|
||||
|
||||
def fluentd_params
|
||||
params.require(:fluentd).permit(:log_file, :pid_file, :config_file, :variant)
|
||||
params.require(:fluentd).permit(:log_file, :pid_file, :config_file, :variant, :api_endpoint)
|
||||
end
|
||||
end
|
||||
|
@ -27,6 +27,10 @@ class Fluentd < ActiveRecord::Base
|
||||
})
|
||||
end
|
||||
|
||||
def api
|
||||
@api ||= Api::Http.new(api_endpoint)
|
||||
end
|
||||
|
||||
def label
|
||||
"#{variant} ##{id}"
|
||||
end
|
||||
|
6
app/models/fluentd/api.rb
Normal file
6
app/models/fluentd/api.rb
Normal file
@ -0,0 +1,6 @@
|
||||
require "fluentd/api/http"
|
||||
|
||||
class Fluentd
|
||||
class Api
|
||||
end
|
||||
end
|
26
app/models/fluentd/api/http.rb
Normal file
26
app/models/fluentd/api/http.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require "httpclient"
|
||||
require "addressable/uri"
|
||||
|
||||
class Fluentd
|
||||
class Api
|
||||
class Http
|
||||
def initialize(endpoint)
|
||||
@endpoint = Addressable::URI.parse(endpoint)
|
||||
end
|
||||
|
||||
def config
|
||||
request("/api/config.json")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request(path)
|
||||
uri = @endpoint.dup
|
||||
uri.path = path
|
||||
res = HTTPClient.get(uri)
|
||||
JSON.parse res.body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -15,4 +15,7 @@
|
||||
%div.form-group
|
||||
= f.label :config_file
|
||||
= f.text_field :config_file, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :api_endpoint
|
||||
= f.text_field :api_endpoint, class: "form-control"
|
||||
= f.submit btn, class: "btn btn-primary"
|
||||
|
@ -126,3 +126,4 @@ ja:
|
||||
pid_file: PIDファイル
|
||||
config_file: 設定ファイル
|
||||
variant: タイプ
|
||||
api_endpoint: APIエンドポイント
|
||||
|
5
db/migrate/20140526042609_add_fluentd_api_endpoint.rb
Normal file
5
db/migrate/20140526042609_add_fluentd_api_endpoint.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddFluentdApiEndpoint < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :fluentds, :api_endpoint, :string, default: "http://localhost:24220/"
|
||||
end
|
||||
end
|
@ -11,15 +11,16 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140522055753) do
|
||||
ActiveRecord::Schema.define(version: 20140526042609) do
|
||||
|
||||
create_table "fluentds", force: true do |t|
|
||||
t.string "variant", null: false
|
||||
t.string "variant", null: false
|
||||
t.string "pid_file"
|
||||
t.string "log_file"
|
||||
t.string "config_file"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "api_endpoint", default: "http://localhost:24220/"
|
||||
end
|
||||
|
||||
create_table "login_tokens", force: true do |t|
|
||||
|
@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
||||
spec.add_dependency 'i18n_generators', '1.2.1'
|
||||
spec.add_dependency 'bcrypt', '~> 3.1.5'
|
||||
spec.add_dependency 'sqlite3'
|
||||
spec.add_dependency 'addressable'
|
||||
spec.add_dependency "font-awesome-rails"
|
||||
spec.add_dependency 'sass-rails', '~> 4.0.3'
|
||||
spec.add_dependency 'uglifier', '>= 1.3.0'
|
||||
|
Loading…
Reference in New Issue
Block a user