mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 10:56:11 +02:00
Refactoring
This commit is contained in:
parent
c101f15b6b
commit
81acdd9067
4
.gitignore
vendored
4
.gitignore
vendored
@ -26,5 +26,5 @@
|
||||
|
||||
/Gemfile.plugins
|
||||
|
||||
/db/user.txt
|
||||
/db/fluentd.json
|
||||
/db/*-user.txt
|
||||
/db/*-fluentd.json
|
||||
|
||||
@ -46,7 +46,7 @@ class ApplicationController < ActionController::Base
|
||||
private
|
||||
|
||||
def find_fluentd
|
||||
@fluentd = Fluentd.find(params[:fluentd_id])
|
||||
@fluentd = Fluentd.factory
|
||||
end
|
||||
|
||||
def set_locale
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
class FluentdController < ApplicationController
|
||||
before_action :find_fluentd, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@fluentds = Fluentd.all
|
||||
end
|
||||
|
||||
def show
|
||||
@fluentds = Fluentd.all
|
||||
render "index"
|
||||
@fluentds = [Fluentd.factory].compact
|
||||
end
|
||||
|
||||
def new
|
||||
@ -44,7 +39,7 @@ class FluentdController < ApplicationController
|
||||
private
|
||||
|
||||
def find_fluentd
|
||||
@fluentd = Fluentd.find(params[:id])
|
||||
@fluentd = Fluentd.factory
|
||||
end
|
||||
|
||||
def fluentd_params
|
||||
|
||||
@ -27,8 +27,7 @@ class TutorialsController < ApplicationController
|
||||
end
|
||||
|
||||
def find_fluentd
|
||||
# NOTE: use first fluentd for tutorial
|
||||
@fluentd = Fluentd.first
|
||||
@fluentd = Fluentd.factory
|
||||
end
|
||||
|
||||
def check_ready
|
||||
|
||||
@ -116,17 +116,7 @@ class Fluentd
|
||||
end
|
||||
|
||||
|
||||
def self.exists?
|
||||
File.exists?(JSON_PATH)
|
||||
end
|
||||
|
||||
def self.all
|
||||
[factory].compact
|
||||
end
|
||||
|
||||
def self.find(id)
|
||||
factory
|
||||
end
|
||||
# ActiveRecord mimic
|
||||
|
||||
def self.factory
|
||||
return unless exists?
|
||||
@ -134,6 +124,10 @@ class Fluentd
|
||||
Fluentd.new(attr)
|
||||
end
|
||||
|
||||
def self.exists?
|
||||
File.exists?(JSON_PATH)
|
||||
end
|
||||
|
||||
def update_attributes(params)
|
||||
params.each_pair do |k, v|
|
||||
send("#{k}=", v)
|
||||
@ -142,7 +136,6 @@ class Fluentd
|
||||
|
||||
def save
|
||||
return false unless valid?
|
||||
self.id = 1
|
||||
json = COLUMNS.inject({}) do |result, col|
|
||||
result[col] = send(col)
|
||||
result
|
||||
|
||||
@ -10,7 +10,7 @@ class User
|
||||
|
||||
has_secure_password
|
||||
|
||||
ENCRYPTED_PASSWORD_FILE = Rails.env.test? ? "tmp/test.txt" : Rails.root + "db/user.txt"
|
||||
ENCRYPTED_PASSWORD_FILE = Rails.root + "db/#{Rails.env}-user.txt"
|
||||
|
||||
attr_accessor :name, :password, :password_confirmation, :current_password
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
- page_title t('.page_title')
|
||||
|
||||
= render partial: "form", locals: { btn: t(".create"), url: fluentd_index_path, method: :post }
|
||||
= render partial: "form", locals: { btn: t(".create"), url: fluentd_path, method: :post }
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
= t('.step1')
|
||||
- else
|
||||
= icon('fa-warning text text-danger')
|
||||
= link_to t('.step1'), fluentd_index_path
|
||||
= link_to t('.step1'), fluentd_path
|
||||
%li
|
||||
- if @fluentd && @fluentd.agent.running?
|
||||
= icon('fa-check text text-success')
|
||||
|
||||
@ -89,7 +89,7 @@ en:
|
||||
finish: Update config
|
||||
form:
|
||||
<<: *fluentd_common
|
||||
index:
|
||||
show:
|
||||
<<: *fluentd_common
|
||||
page_title: fluentd
|
||||
new:
|
||||
|
||||
@ -89,7 +89,7 @@ ja:
|
||||
finish: 設定する
|
||||
form:
|
||||
<<: *fluentd_common
|
||||
index:
|
||||
show:
|
||||
<<: *fluentd_common
|
||||
page_title: fluentd
|
||||
new:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
root "fluentd#index" # TODO: change to dashboard
|
||||
root "fluentd#show" # TODO: change to dashboard
|
||||
|
||||
resource :fluentd, controller: :fluentd do
|
||||
resource :agent, only: [:show], module: :fluentd do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user