feat: add chatwoot instance status in superadmin
This commit is contained in:
parent
0b5c82ad5f
commit
9ed029936a
9 changed files with 115 additions and 0 deletions
39
app/controllers/super_admin/instance_statuses_controller.rb
Normal file
39
app/controllers/super_admin/instance_statuses_controller.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
class SuperAdmin::InstanceStatusesController < SuperAdmin::ApplicationController
|
||||
def show
|
||||
@instance_version = get_version
|
||||
@instance_sha = get_sha
|
||||
@instance_postgres = get_postgres_status
|
||||
@instance_redis = get_redis_status
|
||||
end
|
||||
|
||||
def get_version
|
||||
Chatwoot.config[:version]
|
||||
end
|
||||
|
||||
def get_sha
|
||||
sha = `git rev-parse HEAD`
|
||||
if sha.blank?
|
||||
return "undefined"
|
||||
else
|
||||
return sha
|
||||
end
|
||||
end
|
||||
|
||||
def get_postgres_status
|
||||
if ActiveRecord::Base.connection.active?
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def get_redis_status
|
||||
r = Redis.new(Redis::Config.app)
|
||||
if r.ping == "PONG"
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
2
app/helpers/super_admin/instance_statuses_helper.rb
Normal file
2
app/helpers/super_admin/instance_statuses_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module SuperAdmin::InstanceStatusesHelper
|
||||
end
|
|
@ -50,6 +50,11 @@ as defined by the routes in the `admin/` namespace
|
|||
</li>
|
||||
<% end %>
|
||||
|
||||
<li class="navigation__link">
|
||||
<i class="ion ion-medkit"></i>
|
||||
<%= link_to "Instance Status", super_admin_instance_status_url %>
|
||||
</li>
|
||||
|
||||
<li class="navigation__link">
|
||||
<i class="ion ion ion-network"></i>
|
||||
<%= link_to "Sidekiq", sidekiq_web_url, { target: "_blank" } %>
|
||||
|
|
33
app/views/super_admin/instance_statuses/show.html.erb
Normal file
33
app/views/super_admin/instance_statuses/show.html.erb
Normal file
|
@ -0,0 +1,33 @@
|
|||
<% content_for(:title) do %>
|
||||
Instance Status
|
||||
<% end %>
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
</header>
|
||||
<section class="main-content__body">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Metric</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Chatwoot Version</td>
|
||||
<td><%= @instance_version %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Git SHA</td>
|
||||
<td><%= @instance_sha %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Postgres</td>
|
||||
<td><%= @instance_postgres %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Redis</td>
|
||||
<td><%= @instance_redis %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</section>
|
|
@ -352,6 +352,7 @@ Rails.application.routes.draw do
|
|||
resources :installation_configs, only: [:index, :new, :create, :show, :edit, :update]
|
||||
resources :agent_bots, only: [:index, :new, :create, :show, :edit, :update]
|
||||
resources :platform_apps, only: [:index, :new, :create, :show, :edit, :update]
|
||||
resource :instance_status, only: [:show]
|
||||
|
||||
# resources that doesn't appear in primary navigation in super admin
|
||||
resources :account_users, only: [:new, :create, :destroy]
|
||||
|
|
|
@ -5,6 +5,10 @@ module Redis::Config
|
|||
config
|
||||
end
|
||||
|
||||
def current
|
||||
@redis ||= Redis.new(config)
|
||||
end
|
||||
|
||||
def config
|
||||
@config ||= sentinel? ? sentinel_config : base_config
|
||||
end
|
||||
|
|
15
spec/helpers/super_admin/instance_status_helper_spec.rb
Normal file
15
spec/helpers/super_admin/instance_status_helper_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the SuperAdmin::InstanceStatusHelper. For example:
|
||||
#
|
||||
# describe SuperAdmin::InstanceStatusHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe SuperAdmin::InstanceStatusHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
11
spec/requests/super_admin/instance_statuses_spec.rb
Normal file
11
spec/requests/super_admin/instance_statuses_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "SuperAdmin::InstanceStatuses", type: :request do
|
||||
describe "GET /show" do
|
||||
it "returns http success" do
|
||||
get "/super_admin/instance_status/show"
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "instance_status/show.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in a new issue