Compare commits

...

4 commits

Author SHA1 Message Date
Vishnu Narayanan
970c740eef
chore: fix specs 2022-12-27 13:41:40 +05:30
Vishnu Narayanan
fff26580c9
Merge branch 'develop' into feat/instance_status 2022-12-26 11:26:25 +05:30
Vishnu Narayanan
ef34b0497e
chore: update text 2022-12-08 20:39:02 +05:30
Vishnu Narayanan
9ed029936a
feat: add chatwoot instance status in superadmin 2022-12-08 20:32:06 +05:30
10 changed files with 120 additions and 0 deletions

View 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

View file

@ -0,0 +1,2 @@
module SuperAdmin::InstanceStatusesHelper
end

View file

@ -50,6 +50,11 @@ as defined by the routes in the `admin/` namespace
</li> </li>
<% end %> <% 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"> <li class="navigation__link">
<i class="ion ion ion-network"></i> <i class="ion ion ion-network"></i>
<%= link_to "Sidekiq", sidekiq_web_url, { target: "_blank" } %> <%= link_to "Sidekiq", sidekiq_web_url, { target: "_blank" } %>

View 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 alive</td>
<td><%= @instance_postgres %></td>
</tr>
<tr>
<td>Redis alive</td>
<td><%= @instance_redis %></td>
</tr>
</table>
</section>

View file

@ -353,6 +353,7 @@ Rails.application.routes.draw do
resources :installation_configs, only: [:index, :new, :create, :show, :edit, :update] resources :installation_configs, only: [:index, :new, :create, :show, :edit, :update]
resources :agent_bots, 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] 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 that doesn't appear in primary navigation in super admin
resources :account_users, only: [:new, :create, :destroy] resources :account_users, only: [:new, :create, :destroy]

View file

@ -5,6 +5,10 @@ module Redis::Config
config config
end end
def current
@redis ||= Redis.new(config)
end
def config def config
@config ||= sentinel? ? sentinel_config : base_config @config ||= sentinel? ? sentinel_config : base_config
end end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
#
# TODO add spec
#

View 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::InstanceStatusesHelper 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::InstanceStatusesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View 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

View file

@ -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