Skip to content

Commit

Permalink
v0.1.6
Browse files Browse the repository at this point in the history
- Added Last Seen stat
- Changed Styling to fit a 1080p screen
- Added tests
  • Loading branch information
kobaltz committed Feb 9, 2024
1 parent ce0295e commit 412b16e
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mission_control-servers (0.1.5)
mission_control-servers (0.1.6)
importmap-rails
rails (>= 7.1.3)
stimulus-rails
Expand Down
2 changes: 1 addition & 1 deletion app/assets/builds/mission_control_servers_application.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,26 @@
@apply bg-indigo-600;
@apply dark:bg-indigo-800;
}

.pie-chart {
height: 200px;
@apply text-sm font-semibold leading-6 text-gray-600;
}

.stat-chart {
height: 200px;
@apply flex justify-center items-center text-center;
@apply text-6xl font-semibold leading-6 text-gray-600 pt-5;
}

.connected-chart {
height: 200px;
@apply flex justify-center items-center text-center;
@apply text-3xl font-semibold leading-6 text-gray-600 pt-5;
}

.line-chart {
height: 300px;
@apply text-sm font-semibold leading-6 text-gray-600;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module MissionControl::Servers
class Dashboards::LastSeensController < ApplicationController
def show
@project = MissionControl::Servers::Project.find_by(token: params[:project_id])
@hostname = params[:hostname]
@service = @project.services.where(hostname: @hostname).last
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MissionControl::Servers
module Dashboards::LastConnectedsHelper
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html class="h-full">
<html class="">
<head>
<title>Mission control servers</title>
<%= csrf_meta_tags %>
Expand All @@ -8,6 +8,8 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<%= stylesheet_link_tag "mission_control_servers_application", media: "all" %>
<%= javascript_importmap_tags "application-mcs" %>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
<%= yield :head %>
</head>
<body class="h-full">
<div class="m-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="progress-bar" style="height: 5px; width: 100%;">
<div class="progress" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dt class="text-sm font-semibold leading-6 text-gray-600">
<div class="flex flex-col bg-gray-400/5 p-2">
<dt class="line-chart">
<canvas data-controller="line-chart"
data-line-chart-label-value="CPU History"
data-line-chart-label-array-value="<%= @cpu_history_data[:created_at_times] %>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="progress-bar" style="height: 5px; width: 100%;">
<div class="progress" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dt class="text-sm font-semibold leading-6 text-gray-600">
<div class="flex flex-col items-center justify-center bg-gray-400/5 p-8">
<dt class="pie-chart">
<canvas data-controller="pie-chart"
data-pie-chart-label-value="CPU Usage"
data-pie-chart-idle-value="<%= 100.0 - @service.cpu %>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="progress bg-blue-500" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dt class="text-6xl font-semibold leading-6 mt-5 text-gray-600">
<dd class="card-heading">Disk Free</dd>
<dt class="stat-chart">
<%= @service.disk_free %>
</dt>
<dd class="card-heading">Disk Free</dd>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= turbo_frame_tag dom_id(@project, [@hostname, :last_seen].join('-')) do %>
<div class="progress-bar bg-gray-300" style="height: 5px; width: 100%;">
<div class="progress bg-blue-500" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dd class="card-heading">Last Seen</dd>
<dt class="connected-chart">
<%= @service.created_at.strftime("%Y-%-m-%-d") %><br><br>
<%= @service.created_at.strftime("%I:%M:%S %p") %>
</dt>
</div>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="progress-bar" style="height: 5px; width: 100%;">
<div class="progress" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dt class="text-sm font-semibold leading-6 text-gray-600">
<div class="flex flex-col bg-gray-400/5 p-2">
<dt class="line-chart">
<canvas data-controller="line-chart"
data-line-chart-label-value="Memory Used History"
data-line-chart-label-array-value="<%= @memory_history_data[:created_at_times] %>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="progress-bar" style="height: 5px; width: 100%;">
<div class="progress" data-refresh-target="progressBar" style="height: 100%; width: 100%;"></div>
</div>
<div class="flex flex-col bg-gray-400/5 p-8">
<dt class="text-sm font-semibold leading-6 text-gray-600">
<div class="flex flex-col items-center justify-center bg-gray-400/5 p-8">
<dt class="pie-chart">
<canvas data-controller="pie-chart"
data-pie-chart-label-value="Memory Usage"
data-pie-chart-idle-value="<%= @service.mem_free %>"
Expand Down
12 changes: 8 additions & 4 deletions app/views/mission_control/servers/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<div class="text-center">
<h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl"><%= hostname %></h2>
</div>
<dl class="mt-8 grid grid-cols-1 gap-0.5 overflow-hidden rounded-2xl text-center sm:grid-cols-2 lg:grid-cols-3">
<dl class="mt-8 grid grid-cols-1 gap-0.5 overflow-hidden rounded-2xl text-center sm:grid-cols-2 lg:grid-cols-4">
<%= turbo_frame_tag dom_id(@project, [hostname, :cpu_usage].join('-')),
src: project_dashboards_cpu_usage_path(project_id: @project.token, hostname: hostname),
"data-controller": "refresh",
Expand All @@ -67,15 +67,19 @@
"data-controller": "refresh",
"data-refresh-src-value": project_dashboards_disk_free_path(project_id: @project.token, hostname: hostname),
"data-refresh-interval-value": 60000 %>
<%= turbo_frame_tag dom_id(@project, [hostname, :last_seen].join('-')),
src: project_dashboards_last_seen_path(project_id: @project.token, hostname: hostname),
"data-controller": "refresh",
"data-refresh-src-value": project_dashboards_last_seen_path(project_id: @project.token, hostname: hostname),
"data-refresh-interval-value": 60000 %>
</dl>
<dl class="mt-8 grid grid-cols-1 gap-0.5 overflow-hidden rounded-2xl text-center sm:grid-cols-1 lg:grid-cols-1">
<dl class="mt-8 grid grid-cols-1 gap-0.5 overflow-hidden rounded-2xl text-center sm:grid-cols-1 lg:grid-cols-2">
<%= turbo_frame_tag dom_id(@project, [hostname, :cpu_history].join('-')),
src: project_dashboards_cpu_history_path(project_id: @project.token, hostname: hostname),
"data-controller": "refresh",
"data-refresh-src-value": project_dashboards_cpu_history_path(project_id: @project.token, hostname: hostname),
"data-refresh-interval-value": 60000 %>
</dl>
<dl class="mt-8 grid grid-cols-1 gap-0.5 overflow-hidden rounded-2xl text-center sm:grid-cols-1 lg:grid-cols-1">
<%= turbo_frame_tag dom_id(@project, [hostname, :memory_history].join('-')),
src: project_dashboards_memory_history_path(project_id: @project.token, hostname: hostname),
"data-controller": "refresh",
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
resource :cpu_usage, only: :show
resource :memory_usage, only: :show
resource :disk_free, only: :show
resource :last_seen, only: :show
resource :cpu_history, only: :show
resource :memory_history, only: :show
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mission_control/servers/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MissionControl
module Servers
VERSION = "0.1.5"
VERSION = "0.1.6"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "test_helper"

module MissionControl::Servers
class Dashboards::LastSeensControllerTest < ActionDispatch::IntegrationTest
include Engine.routes.url_helpers

include Engine.routes.url_helpers

setup do
@project = mission_control_servers_projects(:one)
end

test "should get show" do
get project_dashboards_last_seen_path(@project.token, hostname: "HOST")
assert_response :success
end
end
end

0 comments on commit 412b16e

Please sign in to comment.