cosmonats 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +73 -22
- data/lib/cosmo/active_job/adapter.rb +2 -0
- data/lib/cosmo/active_job/executor.rb +7 -0
- data/lib/cosmo/active_job/options.rb +6 -0
- data/lib/cosmo/api/batch.rb +26 -0
- data/lib/cosmo/api/counter.rb +52 -4
- data/lib/cosmo/api/cron/entry.rb +34 -20
- data/lib/cosmo/api/cron.rb +24 -10
- data/lib/cosmo/api/job.rb +15 -1
- data/lib/cosmo/api/kv.rb +141 -12
- data/lib/cosmo/api/registry.rb +47 -6
- data/lib/cosmo/api/stats/jobs.rb +84 -0
- data/lib/cosmo/api/stats/metrics.rb +20 -9
- data/lib/cosmo/api/stats/processes.rb +27 -11
- data/lib/cosmo/api/stats/totals.rb +1 -0
- data/lib/cosmo/api/stats.rb +58 -7
- data/lib/cosmo/api/stream.rb +73 -24
- data/lib/cosmo/batch/callback.rb +5 -0
- data/lib/cosmo/batch/dispatcher.rb +4 -4
- data/lib/cosmo/batch.rb +34 -11
- data/lib/cosmo/cli.rb +6 -0
- data/lib/cosmo/client.rb +217 -23
- data/lib/cosmo/config/cosmo.yml +1 -0
- data/lib/cosmo/config/settings.rb +4 -0
- data/lib/cosmo/config.rb +58 -10
- data/lib/cosmo/engine.rb +28 -1
- data/lib/cosmo/heartbeat.rb +12 -3
- data/lib/cosmo/http_server/handler.rb +5 -0
- data/lib/cosmo/http_server/health.rb +2 -0
- data/lib/cosmo/http_server/ping.rb +2 -0
- data/lib/cosmo/http_server.rb +8 -0
- data/lib/cosmo/job/data.rb +12 -1
- data/lib/cosmo/job/enqueuer.rb +100 -1
- data/lib/cosmo/job/limit.rb +5 -1
- data/lib/cosmo/job/processor.rb +56 -21
- data/lib/cosmo/job/setter.rb +53 -0
- data/lib/cosmo/job.rb +71 -2
- data/lib/cosmo/logger.rb +37 -0
- data/lib/cosmo/middleware/chain.rb +12 -0
- data/lib/cosmo/middleware/limit.rb +12 -3
- data/lib/cosmo/middleware/metrics.rb +6 -4
- data/lib/cosmo/middleware/sentry.rb +6 -4
- data/lib/cosmo/middleware/totals.rb +5 -11
- data/lib/cosmo/middleware.rb +0 -1
- data/lib/cosmo/processor.rb +60 -3
- data/lib/cosmo/publisher.rb +8 -0
- data/lib/cosmo/services.rb +7 -2
- data/lib/cosmo/stream/message.rb +5 -0
- data/lib/cosmo/stream/processor.rb +7 -0
- data/lib/cosmo/stream/serializer.rb +4 -0
- data/lib/cosmo/stream.rb +35 -1
- data/lib/cosmo/utils/duration.rb +3 -0
- data/lib/cosmo/utils/hash.rb +12 -0
- data/lib/cosmo/utils/json.rb +8 -0
- data/lib/cosmo/utils/signal.rb +9 -0
- data/lib/cosmo/utils/stopwatch.rb +1 -0
- data/lib/cosmo/utils/string.rb +4 -0
- data/lib/cosmo/utils/thread_pool.rb +8 -0
- data/lib/cosmo/utils/ttl_cache.rb +10 -0
- data/lib/cosmo/utils.rb +0 -1
- data/lib/cosmo/version.rb +1 -1
- data/lib/cosmo/web/assets/app.css +273 -629
- data/lib/cosmo/web/assets/app.js +158 -0
- data/lib/cosmo/web/assets/fonts/OFL.txt +92 -0
- data/lib/cosmo/web/assets/fonts/geist-mono.woff2 +0 -0
- data/lib/cosmo/web/assets/fonts/geist.woff2 +0 -0
- data/lib/cosmo/web/assets/logo.svg +10 -0
- data/lib/cosmo/web/cache.rb +77 -0
- data/lib/cosmo/web/chart.rb +63 -39
- data/lib/cosmo/web/circuit.rb +56 -0
- data/lib/cosmo/web/context.rb +6 -4
- data/lib/cosmo/web/controllers/application.rb +42 -0
- data/lib/cosmo/web/controllers/batches.rb +8 -1
- data/lib/cosmo/web/controllers/crons.rb +24 -3
- data/lib/cosmo/web/controllers/jobs.rb +88 -68
- data/lib/cosmo/web/controllers/metrics.rb +6 -0
- data/lib/cosmo/web/controllers/overview.rb +88 -0
- data/lib/cosmo/web/controllers/processes.rb +36 -0
- data/lib/cosmo/web/controllers/streams.rb +38 -28
- data/lib/cosmo/web/helpers/application.rb +101 -0
- data/lib/cosmo/web/renderer.rb +36 -6
- data/lib/cosmo/web/throughput.rb +104 -0
- data/lib/cosmo/web/views/batches/_table.erb +42 -54
- data/lib/cosmo/web/views/batches/index.erb +3 -10
- data/lib/cosmo/web/views/crons/_table.erb +36 -55
- data/lib/cosmo/web/views/crons/index.erb +2 -9
- data/lib/cosmo/web/views/jobs/_args.erb +5 -0
- data/lib/cosmo/web/views/jobs/_busy.erb +25 -121
- data/lib/cosmo/web/views/jobs/_dead.erb +42 -82
- data/lib/cosmo/web/views/jobs/_enqueued.erb +33 -113
- data/lib/cosmo/web/views/jobs/_panel.erb +34 -0
- data/lib/cosmo/web/views/jobs/_queue_row.erb +18 -0
- data/lib/cosmo/web/views/jobs/_queues.erb +20 -0
- data/lib/cosmo/web/views/jobs/_scheduled.erb +20 -54
- data/lib/cosmo/web/views/jobs/index.erb +4 -17
- data/lib/cosmo/web/views/layout.erb +73 -22
- data/lib/cosmo/web/views/metrics/_chart.erb +37 -32
- data/lib/cosmo/web/views/metrics/_panel.erb +3 -3
- data/lib/cosmo/web/views/metrics/_table.erb +24 -40
- data/lib/cosmo/web/views/metrics/index.erb +8 -16
- data/lib/cosmo/web/views/overview/_badges.erb +3 -0
- data/lib/cosmo/web/views/overview/_kpis.erb +19 -0
- data/lib/cosmo/web/views/overview/_running.erb +18 -0
- data/lib/cosmo/web/views/overview/_throughput.erb +50 -0
- data/lib/cosmo/web/views/overview/_workers.erb +25 -0
- data/lib/cosmo/web/views/overview/index.erb +28 -0
- data/lib/cosmo/web/views/processes/_table.erb +67 -0
- data/lib/cosmo/web/views/processes/index.erb +1 -0
- data/lib/cosmo/web/views/shared/_pager.erb +22 -0
- data/lib/cosmo/web/views/shared/unavailable.erb +7 -0
- data/lib/cosmo/web/views/streams/_info.erb +29 -86
- data/lib/cosmo/web/views/streams/_list.erb +7 -0
- data/lib/cosmo/web/views/streams/_pause_banner.erb +8 -16
- data/lib/cosmo/web/views/streams/_stream.erb +53 -0
- data/lib/cosmo/web/views/streams/index.erb +3 -11
- data/lib/cosmo/web/views/streams/info.erb +3 -11
- data/lib/cosmo/web.rb +73 -35
- data/lib/cosmo.rb +33 -0
- data/sig/cosmo/active_job/adapter.rbs +3 -3
- data/sig/cosmo/active_job/options.rbs +4 -2
- data/sig/cosmo/api/batch.rbs +5 -3
- data/sig/cosmo/api/counter.rbs +16 -6
- data/sig/cosmo/api/cron/entry.rbs +6 -3
- data/sig/cosmo/api/cron.rbs +10 -4
- data/sig/cosmo/api/kv.rbs +21 -4
- data/sig/cosmo/api/registry.rbs +10 -0
- data/sig/cosmo/api/stats/jobs.rbs +34 -0
- data/sig/cosmo/api/stats/metrics.rbs +4 -1
- data/sig/cosmo/api/stats/processes.rbs +9 -1
- data/sig/cosmo/api/stats.rbs +12 -2
- data/sig/cosmo/api/stream.rbs +12 -5
- data/sig/cosmo/batch/callback.rbs +1 -1
- data/sig/cosmo/batch/dispatcher.rbs +1 -1
- data/sig/cosmo/batch.rbs +5 -5
- data/sig/cosmo/cli.rbs +2 -0
- data/sig/cosmo/client.rbs +24 -4
- data/sig/cosmo/config/settings.rbs +6 -0
- data/sig/cosmo/config.rbs +5 -5
- data/sig/cosmo/engine.rbs +5 -0
- data/sig/cosmo/heartbeat.rbs +2 -0
- data/sig/cosmo/job/data.rbs +3 -1
- data/sig/cosmo/job/enqueuer.rbs +12 -0
- data/sig/cosmo/job/processor.rbs +18 -3
- data/sig/cosmo/job/setter.rbs +20 -0
- data/sig/cosmo/job.rbs +10 -4
- data/sig/cosmo/logger.rbs +5 -3
- data/sig/cosmo/middleware.rbs +0 -8
- data/sig/cosmo/processor.rbs +14 -2
- data/sig/cosmo/publisher.rbs +1 -0
- data/sig/cosmo/stream/processor.rbs +4 -0
- data/sig/cosmo/stream.rbs +4 -3
- data/sig/cosmo/utils/hash.rbs +2 -1
- data/sig/cosmo/utils/signal.rbs +5 -5
- data/sig/cosmo/utils/string.rbs +2 -2
- data/sig/cosmo/utils/thread_pool.rbs +1 -1
- data/sig/cosmo/web/cache.rbs +35 -0
- data/sig/cosmo/web/chart.rbs +48 -0
- data/sig/cosmo/web/circuit.rbs +29 -0
- data/sig/cosmo/web/context.rbs +15 -0
- data/sig/cosmo/web/controllers/application.rbs +32 -0
- data/sig/cosmo/web/controllers/batches.rbs +11 -0
- data/sig/cosmo/web/controllers/crons.rbs +23 -0
- data/sig/cosmo/web/controllers/jobs.rbs +47 -0
- data/sig/cosmo/web/controllers/metrics.rbs +21 -0
- data/sig/cosmo/web/controllers/overview.rbs +31 -0
- data/sig/cosmo/web/controllers/processes.rbs +13 -0
- data/sig/cosmo/web/controllers/streams.rbs +27 -0
- data/sig/cosmo/web/helpers/application.rbs +61 -0
- data/sig/cosmo/web/renderer.rbs +33 -0
- data/sig/cosmo/web/throughput.rbs +45 -0
- data/sig/cosmo/web.rbs +25 -0
- data/sig/cosmo.rbs +19 -0
- metadata +53 -23
- data/lib/cosmo/api/stats/busy.rb +0 -63
- data/lib/cosmo/middleware/busy.rb +0 -15
- data/lib/cosmo/utils/overrides.rb +0 -206
- data/lib/cosmo/utils/warnings.rb +0 -17
- data/lib/cosmo/web/controllers/actions.rb +0 -16
- data/lib/cosmo/web/views/actions/index.erb +0 -7
- data/lib/cosmo/web/views/jobs/_processes.erb +0 -145
- data/lib/cosmo/web/views/jobs/_stats.erb +0 -77
- data/lib/cosmo/web/views/jobs/_tabs.erb +0 -14
- data/lib/cosmo/web/views/jobs/busy.erb +0 -18
- data/lib/cosmo/web/views/jobs/dead.erb +0 -18
- data/lib/cosmo/web/views/jobs/enqueued.erb +0 -18
- data/lib/cosmo/web/views/jobs/scheduled.erb +0 -18
- data/lib/cosmo/web/views/streams/_stream_row.erb +0 -42
- data/lib/cosmo/web/views/streams/_table.erb +0 -25
- data/sig/cosmo/api/stats/busy.rbs +0 -31
|
@@ -3,32 +3,83 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>
|
|
7
|
-
<script
|
|
6
|
+
<title>Cosmonats<%= " · #{h(content_for :title)}" if content_for?(:title) %></title>
|
|
7
|
+
<script>(function(r){var m='auto';try{m=localStorage.getItem('cosmo-theme')||'auto'}catch(e){}r.dataset.themeMode=m;r.dataset.theme=m==='auto'?(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'):m})(document.documentElement)</script>
|
|
8
|
+
<link rel="preload" href="<%= url_for('/assets/fonts/geist.woff2') %>" as="font" type="font/woff2" crossorigin>
|
|
8
9
|
<link rel="stylesheet" href="<%= url_for('/assets/app.css') %>">
|
|
10
|
+
<link rel="icon" href="<%= url_for('/assets/logo.svg') %>" type="image/svg+xml">
|
|
11
|
+
<script src="<%= url_for('/assets/htmx.min.js.gz') %>" defer></script>
|
|
12
|
+
<script src="<%= url_for('/assets/app.js') %>" defer></script>
|
|
9
13
|
</head>
|
|
10
14
|
<body>
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
<% server = nats_server -%>
|
|
16
|
+
<% section = current_section -%>
|
|
17
|
+
<div class="backdrop" data-action="close-menu"></div>
|
|
18
|
+
<div class="app">
|
|
19
|
+
<aside class="sidebar">
|
|
20
|
+
<a class="brand" href="<%= url_for('/') %>">
|
|
21
|
+
<img src="<%= url_for('/assets/logo.svg') %>" alt="">
|
|
22
|
+
<div class="brand-text">
|
|
23
|
+
<div class="brand-name">cosmonats</div>
|
|
24
|
+
<div class="eyebrow">mission control</div>
|
|
25
|
+
</div>
|
|
26
|
+
</a>
|
|
13
27
|
<nav class="nav">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</li>
|
|
22
|
-
<li>
|
|
23
|
-
<a href="<%= url_for('/actions') %>" class="<%= "active" if current_page?('/actions') %>">Actions</a>
|
|
24
|
-
</li>
|
|
25
|
-
</ul>
|
|
28
|
+
<% nav_items.each_with_index do |item, index| -%>
|
|
29
|
+
<a class="nav-item<%= ' active' if item[:key] == section %>" style="--hue:var(--c<%= (index % 5) + 1 %>)"
|
|
30
|
+
href="<%= url_for(item[:path]) %>">
|
|
31
|
+
<span class="bar"></span><span class="n"><%= format('%02d', index + 1) %></span>
|
|
32
|
+
<span class="label"><%= item[:label] %></span><span class="badge" id="badge-<%= item[:key] %>"></span>
|
|
33
|
+
</a>
|
|
34
|
+
<% end -%>
|
|
26
35
|
</nav>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
<div hx-get="<%= url_for('/_badges') %>" hx-trigger="load, cosmo:poll" data-poll="30" hx-swap="none"></div>
|
|
37
|
+
<div class="side-foot">
|
|
38
|
+
<div class="conn">
|
|
39
|
+
<div class="conn-title"><span class="conn-dot<%= ' down' if server.empty? %>"></span><%= server.empty? ? 'NATS unreachable' : 'NATS connected' %></div>
|
|
40
|
+
<div class="conn-meta">
|
|
41
|
+
<%= h(server[:url] || "unknown server") %><br>
|
|
42
|
+
<%= h([server[:name], ("v#{server[:version]}" if server[:version])].compact.join(' · ')) %>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="theme-toggle" role="group" aria-label="Theme">
|
|
46
|
+
<button type="button" data-action="theme" data-theme-set="light" title="Light" aria-label="Light theme">
|
|
47
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4.5" fill="currentColor"/><path d="M12 1.5v2.5M12 20v2.5M1.5 12H4M20 12h2.5M4.6 4.6l1.8 1.8M17.6 17.6l1.8 1.8M4.6 19.4l1.8-1.8M17.6 6.4l1.8-1.8"/></svg>
|
|
48
|
+
</button>
|
|
49
|
+
<button type="button" data-action="theme" data-theme-set="dark" title="Dark" aria-label="Dark theme">
|
|
50
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20.5 14.5A8.5 8.5 0 1 1 9.5 3.5a12 12 0 0 0 11 11z" fill="currentColor" stroke="none"/></svg>
|
|
51
|
+
</button>
|
|
52
|
+
<button type="button" data-action="theme" data-theme-set="auto" title="Auto (follow the system)" aria-label="Automatic theme">
|
|
53
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 7a5 5 0 0 0 0 10z" fill="currentColor"/><path d="M1.5 12H4M4.6 4.6l1.8 1.8M4.6 19.4l1.8-1.8"/><path d="M13.5 3a9 9 0 0 1 0 18a12 12 0 0 0 0-18z" fill="currentColor" stroke="none"/></svg>
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="version">cosmonats v<%= Cosmo::VERSION %> · ruby <%= RUBY_VERSION %></div>
|
|
57
|
+
</div>
|
|
58
|
+
</aside>
|
|
59
|
+
|
|
60
|
+
<main class="main">
|
|
61
|
+
<header class="topbar">
|
|
62
|
+
<button type="button" class="icon-btn" data-action="open-menu" aria-label="Open menu"><span></span><span></span><span></span></button>
|
|
63
|
+
<img class="logo-sm" src="<%= url_for('/assets/logo.svg') %>" alt="">
|
|
64
|
+
<div class="crumb"><%= h(server[:name] || server[:url] || "nats") %> <span class="sep">/</span> <span class="cur"><%= h(content_for(:title).to_s.downcase) %></span></div>
|
|
65
|
+
<div class="spacer"></div>
|
|
66
|
+
<div id="global-spinner" class="spinner" aria-hidden="true"></div>
|
|
67
|
+
<div class="live"><span class="live-label">live</span><span class="t" id="clock"></span></div>
|
|
68
|
+
</header>
|
|
69
|
+
|
|
70
|
+
<div class="content">
|
|
71
|
+
<div class="page-head">
|
|
72
|
+
<div class="titles">
|
|
73
|
+
<h1><%= h(content_for :title) %></h1>
|
|
74
|
+
<% if content_for?(:subtitle) -%><p><%= h(content_for :subtitle) %></p><% end -%>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="flash" id="flash"></div>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="view">
|
|
79
|
+
<%= content_for :view %>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</main>
|
|
83
|
+
</div>
|
|
33
84
|
</body>
|
|
34
85
|
</html>
|
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div class="
|
|
3
|
-
<span
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
<span class="metrics-legend-exec">avg execution (ms)</span>
|
|
7
|
-
</span>
|
|
1
|
+
<section class="card card-pad">
|
|
2
|
+
<div class="card-head">
|
|
3
|
+
<div class="card-title"><span class="mono"><%= h(@job) %></span> <span class="mute" style="font-size:13px">last <%= @days %> days</span></div>
|
|
4
|
+
<div class="legend"><i class="bars"></i>runs / day</div>
|
|
5
|
+
<div class="legend"><i class="line"></i>avg execution</div>
|
|
8
6
|
</div>
|
|
9
7
|
<% if @chart.empty? -%>
|
|
10
|
-
<div class="
|
|
8
|
+
<div class="empty"><b>No runs</b><code><%= h(@job) %></code> didn't run in this period.</div>
|
|
11
9
|
<% else -%>
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
<div class="chart dual">
|
|
11
|
+
<div class="yaxis"><% @chart.ticks.each do |tick| -%><span><%= compact_number(tick[:count]) %></span><% end -%></div>
|
|
12
|
+
<div class="plot-col">
|
|
13
|
+
<div class="plot">
|
|
14
|
+
<svg viewBox="0 0 <%= Cosmo::Web::Chart::WIDTH %> <%= Cosmo::Web::Chart::HEIGHT %>" preserveAspectRatio="none" aria-hidden="true">
|
|
15
|
+
<defs>
|
|
16
|
+
<linearGradient id="runsFill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="var(--c1)" stop-opacity="0.55"/><stop offset="1" stop-color="var(--c1)" stop-opacity="0.18"/></linearGradient>
|
|
17
|
+
</defs>
|
|
18
|
+
<path d="<%= @chart.grid %>" stroke="var(--line)" stroke-width="1" vector-effect="non-scaling-stroke" fill="none"/>
|
|
19
|
+
<path d="<%= @chart.bars %>" fill="url(#runsFill)"/>
|
|
20
|
+
<path d="<%= @chart.line %>" stroke="var(--c4)" stroke-width="1.75" vector-effect="non-scaling-stroke" fill="none" stroke-linejoin="round"/>
|
|
21
|
+
</svg>
|
|
22
|
+
<% @chart.points.each do |point| -%>
|
|
23
|
+
<% if point[:dot] -%><i class="pt" style="left:<%= point[:center] %>%;top:<%= point[:dot] %>%"></i><% end -%>
|
|
24
|
+
<div class="hit band<%= ' flip' if point[:center] > 62 %>" style="left:<%= point[:left] %>%;width:<%= point[:width] %>%">
|
|
25
|
+
<div class="hv-dot" style="top:<%= point[:dot] || point[:top] %>%;border-color:<%= point[:dot] ? 'var(--c4)' : 'var(--c1)' %>"></div>
|
|
26
|
+
<div class="tip">
|
|
27
|
+
<span class="mono mute" style="font-size:10.5px"><%= point[:label] %></span>
|
|
28
|
+
<div><span class="mute">runs</span><span class="num"><%= format_numbers(point[:count]) %></span></div>
|
|
29
|
+
<div><span class="mute">failed</span><span class="num" style="color:var(--err)"><%= format_numbers(point[:failed]) %></span></div>
|
|
30
|
+
<div><span class="mute">avg exec</span><span class="num" style="color:var(--c4)"><%= duration(point[:exec_ms]) %></span></div>
|
|
31
|
+
<div><span class="mute">avg wait</span><span class="num"><%= duration(point[:wait_ms]) %></span></div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
<% end -%>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="xaxis abs"><% @chart.labels.each do |label| -%><span style="left:<%= label[:left] %>%"><%= label[:text] %></span><% end -%></div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="yaxis right"><% @chart.ticks.each do |tick| -%><span><%= duration(tick[:exec_ms]) %></span><% end -%></div>
|
|
39
|
+
</div>
|
|
35
40
|
<% end -%>
|
|
36
|
-
</
|
|
41
|
+
</section>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<div id="metrics-panel"
|
|
1
|
+
<div id="metrics-panel" class="view"
|
|
2
2
|
hx-get="<%= url_for('/metrics/_panel', { days: @days, job: u(@job) }) %>"
|
|
3
|
-
hx-trigger="
|
|
3
|
+
hx-trigger="cosmo:poll" data-poll="30"
|
|
4
4
|
hx-swap="outerHTML">
|
|
5
5
|
<% if @rows.empty? -%>
|
|
6
|
-
<
|
|
6
|
+
<section class="card"><div class="empty"><b>No metrics yet</b>Nothing recorded in this period.</div></section>
|
|
7
7
|
<% else -%>
|
|
8
8
|
<% if @chart -%>
|
|
9
9
|
<%= render('metrics/_chart', { job: @job, days: @days, chart: @chart }) %>
|
|
@@ -1,41 +1,25 @@
|
|
|
1
1
|
<% selectable = @days > 1 -%>
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<td><code><%= h(row[:job]) %></code></td>
|
|
27
|
-
<td><%= format_numbers(row[:count]) %></td>
|
|
28
|
-
<td>
|
|
29
|
-
<% if row[:failed].positive? -%>
|
|
30
|
-
<span class="badge badge-danger"><%= format_numbers(row[:failed]) %></span>
|
|
31
|
-
<% else -%>
|
|
32
|
-
<span class="text-muted">0</span>
|
|
33
|
-
<% end -%>
|
|
34
|
-
</td>
|
|
35
|
-
<td><%= duration(row[:exec_ms]) %></td>
|
|
36
|
-
<td><%= duration(row[:wait_ms]) %></td>
|
|
37
|
-
</tr>
|
|
38
|
-
<% end -%>
|
|
39
|
-
</tbody>
|
|
40
|
-
</table>
|
|
41
|
-
</div>
|
|
2
|
+
<section class="card">
|
|
3
|
+
<div class="card-head bar ruled">
|
|
4
|
+
<div class="card-title">Job classes</div>
|
|
5
|
+
<% if selectable -%><span class="small-mono">click a job to chart it</span><% end -%>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="scroll"><div style="min-width:620px">
|
|
8
|
+
<div class="thead t-metrics"><span>Job</span><span class="r">Runs</span><span class="r">Failed</span><span class="r">Avg execution</span><span class="r">Avg wait</span></div>
|
|
9
|
+
<% @rows.each do |row| -%>
|
|
10
|
+
<% selected = selectable && row[:job] == @job -%>
|
|
11
|
+
<div class="trow hover t-metrics<%= ' selectable' if selectable %><%= ' selected' if selected %>"
|
|
12
|
+
<% if selectable -%>
|
|
13
|
+
hx-get="<%= url_for('/metrics/_panel', { days: @days, job: u(row[:job]) }) %>"
|
|
14
|
+
hx-target="#metrics-panel" hx-swap="outerHTML" hx-indicator="#global-spinner"
|
|
15
|
+
<% if selected -%>aria-selected="true"<% end -%>
|
|
16
|
+
<% end -%>>
|
|
17
|
+
<span class="mono ellip"><%= h(row[:job]) %></span>
|
|
18
|
+
<span class="r"><%= format_numbers(row[:count]) %></span>
|
|
19
|
+
<span class="r" style="color:<%= row[:failed].positive? ? 'var(--err)' : 'var(--faint)' %>"><%= format_numbers(row[:failed]) %></span>
|
|
20
|
+
<span class="r mute"><%= duration(row[:exec_ms]) %></span>
|
|
21
|
+
<span class="r mute"><%= duration(row[:wait_ms]) %></span>
|
|
22
|
+
</div>
|
|
23
|
+
<% end -%>
|
|
24
|
+
</div></div>
|
|
25
|
+
</section>
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
1
|
+
<div class="seg" style="align-self:flex-start">
|
|
2
|
+
<% @ranges.each do |range, name| -%>
|
|
3
|
+
<a class="<%= 'on' if @days == range %>" href="<%= url_for('/metrics', { days: range }) %>"><%= h(name) %></a>
|
|
4
|
+
<% end -%>
|
|
5
|
+
</div>
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class="btn <%= 'btn-primary' if @days == range %>"><%= h(name) %></a>
|
|
8
|
-
<% end -%>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<div id="metrics-panel"
|
|
12
|
-
hx-get="<%= url_for('/metrics/_panel', { days: @days }) %>"
|
|
13
|
-
hx-trigger="load"
|
|
14
|
-
hx-swap="outerHTML">
|
|
15
|
-
<div class="alert alert-info">Loading metrics…</div>
|
|
16
|
-
</div>
|
|
17
|
-
</section>
|
|
7
|
+
<div id="metrics-panel" class="view" hx-get="<%= url_for('/metrics/_panel', { days: @days }) %>" hx-trigger="load" hx-swap="outerHTML">
|
|
8
|
+
<section class="card"><div class="loading">Loading metrics…</div></section>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<% metrics_path = Cosmo::Config.metrics.enabled ? '/metrics' : nil -%>
|
|
2
|
+
<% kpis = [
|
|
3
|
+
['Processed', @processed, 'all time', 'var(--c1)', metrics_path],
|
|
4
|
+
['Failed', @failed, 'all time', 'var(--err)', metrics_path],
|
|
5
|
+
['Busy', @busy, 'running now', 'var(--c3)', '/jobs/busy'],
|
|
6
|
+
['Enqueued', @enqueued, 'waiting in queues', 'var(--c2)', '/jobs/enqueued'],
|
|
7
|
+
['Retries', @retries, 'redeliveries', 'var(--warn)', '/jobs']
|
|
8
|
+
] -%>
|
|
9
|
+
<% kpis << ['Scheduled', @scheduled, 'delayed & cron', 'var(--c5)', '/jobs/scheduled'] if Cosmo::Config.scheduled.enabled -%>
|
|
10
|
+
<% kpis << ['Dead', @dead, 'gave up', 'var(--c4)', '/jobs/dead'] if Cosmo::Config.dead.enabled -%>
|
|
11
|
+
<div class="kpis">
|
|
12
|
+
<% kpis.each do |label, value, sub, color, link| -%>
|
|
13
|
+
<<%= link ? %(a href="#{url_for(link)}") : 'div' %> class="kpi" style="--hue:<%= color %>">
|
|
14
|
+
<div class="kpi-label"><i></i><%= label %></div>
|
|
15
|
+
<div class="kpi-val"><b title="<%= format_numbers(value) %>"><%= compact_number(value) %></b></div>
|
|
16
|
+
<div class="kpi-sub"><%= sub %></div>
|
|
17
|
+
</<%= link ? 'a' : 'div' %>>
|
|
18
|
+
<% end -%>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class="card-head bar ruled">
|
|
2
|
+
<div class="card-title">Running sample</div>
|
|
3
|
+
<a class="small-mono" href="<%= url_for('/jobs/busy') %>"><%= @total %> busy →</a>
|
|
4
|
+
</div>
|
|
5
|
+
<% if @jobs.empty? -%>
|
|
6
|
+
<div class="empty"><b>All quiet</b>No jobs are running right now.</div>
|
|
7
|
+
<% else -%>
|
|
8
|
+
<div class="feed">
|
|
9
|
+
<% @jobs.each do |job| -%>
|
|
10
|
+
<div class="feed-row" title="<%= h(job[:jid]) %> · <%= h(job[:worker]) %>">
|
|
11
|
+
<span class="mono faint"><%= Time.at(job[:started_at].to_i).strftime('%H:%M:%S') %></span>
|
|
12
|
+
<span class="dot" style="background:<%= hue(job[:stream]) %>"></span>
|
|
13
|
+
<span class="ellip"><%= h(job[:class]) %></span>
|
|
14
|
+
<span class="mono mute"><%= h(job[:stream]) %> · <%= elapsed(job[:started_at]) %></span>
|
|
15
|
+
</div>
|
|
16
|
+
<% end -%>
|
|
17
|
+
</div>
|
|
18
|
+
<% end -%>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<section class="card card-pad grow2" id="throughput"
|
|
2
|
+
hx-get="<%= url_for('/_throughput', days: @days) %>" hx-trigger="cosmo:poll" data-poll="30" hx-swap="outerHTML">
|
|
3
|
+
<div class="card-head">
|
|
4
|
+
<div class="card-title">Throughput</div>
|
|
5
|
+
<div class="legend"><i></i>succeeded / day</div>
|
|
6
|
+
<div class="legend"><i class="fail"></i>failed</div>
|
|
7
|
+
<div class="seg">
|
|
8
|
+
<% @ranges.each do |range| -%>
|
|
9
|
+
<button type="button" class="<%= 'on' if range == @days %>" hx-get="<%= url_for('/_throughput', days: range) %>"
|
|
10
|
+
hx-target="#throughput" hx-swap="outerHTML" hx-indicator="#global-spinner"><%= range %>d</button>
|
|
11
|
+
<% end -%>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<% if @chart.empty? -%>
|
|
15
|
+
<div class="empty"><b>No runs yet</b>Nothing recorded in the last <%= @days %> days.</div>
|
|
16
|
+
<% else -%>
|
|
17
|
+
<div class="chart">
|
|
18
|
+
<div class="yaxis"><% @chart.ticks.each do |tick| -%><span><%= compact_number(tick) %></span><% end -%></div>
|
|
19
|
+
<div class="plot-col">
|
|
20
|
+
<div class="plot">
|
|
21
|
+
<svg viewBox="0 0 <%= Cosmo::Web::Throughput::WIDTH %> <%= Cosmo::Web::Throughput::HEIGHT %>" preserveAspectRatio="none" aria-hidden="true">
|
|
22
|
+
<defs>
|
|
23
|
+
<linearGradient id="thrFill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="var(--c2)" stop-opacity="0.22"/><stop offset="1" stop-color="var(--c1)" stop-opacity="0"/></linearGradient>
|
|
24
|
+
<linearGradient id="thrLine" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="var(--c3)"/><stop offset="0.55" stop-color="var(--c1)"/><stop offset="1" stop-color="var(--c2)"/></linearGradient>
|
|
25
|
+
<linearGradient id="thrFail" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="var(--err)" stop-opacity="0.95"/><stop offset="1" stop-color="var(--err)" stop-opacity="0.45"/></linearGradient>
|
|
26
|
+
</defs>
|
|
27
|
+
<path d="<%= @chart.grid %>" stroke="var(--line)" stroke-width="1" vector-effect="non-scaling-stroke" fill="none"/>
|
|
28
|
+
<path d="<%= @chart.area %>" fill="url(#thrFill)"/>
|
|
29
|
+
<path d="<%= @chart.line %>" stroke="url(#thrLine)" stroke-width="1.75" vector-effect="non-scaling-stroke" fill="none" stroke-linejoin="round"/>
|
|
30
|
+
<path d="<%= @chart.failures %>" fill="url(#thrFail)"/>
|
|
31
|
+
</svg>
|
|
32
|
+
<% @chart.points.each do |point| -%>
|
|
33
|
+
<div class="hit<%= ' flip' if point[:center] > 62 %>" style="left:<%= point[:left] %>%;width:<%= point[:width] %>%">
|
|
34
|
+
<div class="hv-line"></div>
|
|
35
|
+
<div class="hv-dot" style="top:<%= point[:top] %>%"></div>
|
|
36
|
+
<div class="tip">
|
|
37
|
+
<span class="mono mute" style="font-size:10.5px"><%= point[:label] %></span>
|
|
38
|
+
<div><span class="mute">succeeded</span><span class="num"><%= format_numbers(point[:count]) %></span></div>
|
|
39
|
+
<div><span class="mute">failed</span><span class="num" style="color:var(--err)"><%= format_numbers(point[:failed]) %></span></div>
|
|
40
|
+
<div><span class="mute">avg exec</span><span class="num"><%= duration(point[:exec_ms]) %></span></div>
|
|
41
|
+
<div><span class="mute">avg wait</span><span class="num"><%= duration(point[:wait_ms]) %></span></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<% end -%>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="xaxis"><% @chart.labels.each do |label| -%><span><%= label %></span><% end -%></div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<% end -%>
|
|
50
|
+
</section>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div class="card-head">
|
|
2
|
+
<div class="card-title">Workers</div>
|
|
3
|
+
<div class="mono mute" style="font-size:11px"><%= @busy %> / <%= @threads %> busy</div>
|
|
4
|
+
</div>
|
|
5
|
+
<% if @processes.empty? -%>
|
|
6
|
+
<div class="empty"><b>No worker processes</b>Start one with <code>cosmo -C config/cosmo.yml</code>.</div>
|
|
7
|
+
<% else -%>
|
|
8
|
+
<div class="cells">
|
|
9
|
+
<% @cells.each do |stream| -%>
|
|
10
|
+
<i<% if stream %> style="background:<%= hue(stream) %>" title="<%= h(stream) %>"<% end %>></i>
|
|
11
|
+
<% end -%>
|
|
12
|
+
</div>
|
|
13
|
+
<% if @hidden.positive? -%><div class="small-mono">+<%= @hidden %> more threads</div><% end -%>
|
|
14
|
+
<div class="procs">
|
|
15
|
+
<% @processes.each do |process| -%>
|
|
16
|
+
<div class="proc">
|
|
17
|
+
<div class="ellip" title="<%= h(process[:cmdline]) %>"><%= h(process[:hostname]) %> · pid <%= h(process[:pid]) %></div>
|
|
18
|
+
<span class="mute"><%= h(process[:busy]) %>/<%= h(process[:concurrency]) %></span>
|
|
19
|
+
<span class="faint"><%= process[:rss] ? format_bytes(process[:rss].to_i * 1024) : '—' %></span>
|
|
20
|
+
<span style="color:<%= { 'running' => 'var(--ok)', 'quiet' => 'var(--warn)', 'stopping' => 'var(--err)' }.fetch(process[:state].to_s, 'var(--mute)') %>"><%= h(process[:state]) %></span>
|
|
21
|
+
</div>
|
|
22
|
+
<% end -%>
|
|
23
|
+
</div>
|
|
24
|
+
<a class="small-mono" href="<%= url_for('/processes') %>">All <%= @total %> process(es) →</a>
|
|
25
|
+
<% end -%>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<div hx-get="<%= url_for('/_kpis') %>" hx-trigger="load, cosmo:poll" data-poll="<%= poll_interval %>" hx-swap="innerHTML">
|
|
2
|
+
<div class="kpis"><div class="kpi"><div class="loading">Loading statistics…</div></div></div>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<div class="row-wrap">
|
|
6
|
+
<% if @metrics -%>
|
|
7
|
+
<section class="card card-pad grow2" id="throughput" hx-get="<%= url_for('/_throughput') %>" hx-trigger="load" hx-swap="outerHTML">
|
|
8
|
+
<div class="card-head"><div class="card-title">Throughput</div></div>
|
|
9
|
+
<div class="loading">Loading metrics…</div>
|
|
10
|
+
</section>
|
|
11
|
+
<% end -%>
|
|
12
|
+
<section class="card card-pad <%= @metrics ? 'grow1' : 'grow2' %>"
|
|
13
|
+
hx-get="<%= url_for('/_workers') %>" hx-trigger="load, cosmo:poll" data-poll="<%= poll_interval %>" hx-swap="innerHTML">
|
|
14
|
+
<div class="card-head"><div class="card-title">Workers</div></div>
|
|
15
|
+
<div class="loading">Loading workers…</div>
|
|
16
|
+
</section>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="row-wrap">
|
|
20
|
+
<section class="card grow2" hx-get="<%= url_for('/jobs/_queues', compact: 1) %>" hx-trigger="load, cosmo:poll" data-poll="<%= poll_interval %>" hx-swap="innerHTML">
|
|
21
|
+
<div class="card-head bar"><div class="card-title">Queues</div></div>
|
|
22
|
+
<div class="loading">Loading queues…</div>
|
|
23
|
+
</section>
|
|
24
|
+
<section class="card grow1" hx-get="<%= url_for('/_running') %>" hx-trigger="load, cosmo:poll" data-poll="<%= poll_interval %>" hx-swap="innerHTML">
|
|
25
|
+
<div class="card-head bar ruled"><div class="card-title">Running sample</div></div>
|
|
26
|
+
<div class="loading">Loading jobs…</div>
|
|
27
|
+
</section>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<% states = { 'running' => 'var(--ok)', 'quiet' => 'var(--warn)', 'stopping' => 'var(--err)' } -%>
|
|
2
|
+
<% kinds = { 'jobs' => 'Jobs', 'streams' => 'Streams', 'jobs+streams' => 'Jobs & Streams', 'none' => 'No subscriptions' } -%>
|
|
3
|
+
<section class="card" id="processes"
|
|
4
|
+
<% if @polling -%>
|
|
5
|
+
hx-get="<%= url_for('/processes', @query.merge(page: @page)) %>" hx-trigger="cosmo:poll" data-poll="<%= poll_interval %>" hx-swap="outerHTML"
|
|
6
|
+
<% end -%>>
|
|
7
|
+
<div class="card-head bar ruled">
|
|
8
|
+
<div class="card-title"><%= @total %> process(es) alive</div>
|
|
9
|
+
<% if @polling -%>
|
|
10
|
+
<button type="button" class="btn quiet" hx-get="<%= url_for('/processes', @query.merge(page: @page, poll: 0)) %>"
|
|
11
|
+
hx-target="#processes" hx-swap="outerHTML" hx-indicator="#global-spinner">⏸ Stop polling</button>
|
|
12
|
+
<% else -%>
|
|
13
|
+
<button type="button" class="btn" hx-get="<%= url_for('/processes', @query.except(:poll).merge(page: @page)) %>"
|
|
14
|
+
hx-target="#processes" hx-swap="outerHTML" hx-indicator="#global-spinner">▶ Live poll</button>
|
|
15
|
+
<% end -%>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<% if @groups.empty? -%>
|
|
19
|
+
<div class="empty"><b>No worker processes</b>Start one with <code>cosmo -C config/cosmo.yml</code>.</div>
|
|
20
|
+
<% else -%>
|
|
21
|
+
<div class="scroll"><div style="min-width:1040px">
|
|
22
|
+
<div class="thead t-procs">
|
|
23
|
+
<span>Process</span><span>Command</span><span>Subscriptions</span><span class="r">Busy</span><span>State</span>
|
|
24
|
+
<span class="r">RTT</span><span class="r">Reconn.</span><span class="r">Memory</span><span class="r">Uptime</span><span class="r">Last beat</span>
|
|
25
|
+
</div>
|
|
26
|
+
<% @groups.each do |kind, group| -%>
|
|
27
|
+
<div class="trow group t-procs"><span class="full"><%= h(kinds.fetch(kind, kind)) %> (<%= group.size %>)</span></div>
|
|
28
|
+
<% group.each do |process| -%>
|
|
29
|
+
<% nats = Hash(process[:nats]) -%>
|
|
30
|
+
<% cmdline = process[:cmdline].to_s -%>
|
|
31
|
+
<div class="trow hover t-procs">
|
|
32
|
+
<div class="stack">
|
|
33
|
+
<span class="strong ellip"><%= h(process[:hostname]) %>:<%= h(process[:pid]) %></span>
|
|
34
|
+
<span class="small-mono ellip"><%= h(nats[:ip] || 'unknown IP') %><% if nats[:name] -%> · <%= h(nats[:name]) %><% end -%></span>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="stack">
|
|
37
|
+
<% if cmdline.length > 32 -%>
|
|
38
|
+
<details>
|
|
39
|
+
<summary class="mono ellip" style="font-size:11.5px" title="<%= h(cmdline) %>"><%= h(cmdline) %></summary>
|
|
40
|
+
<pre class="code-block"><%= h(cmdline) %></pre>
|
|
41
|
+
</details>
|
|
42
|
+
<% else -%>
|
|
43
|
+
<span class="mono" style="font-size:11.5px"><%= h(cmdline) %></span>
|
|
44
|
+
<% end -%>
|
|
45
|
+
<span class="small-mono">cosmo <%= h(process[:version]) %> · <%= h(process[:ruby]) %><% if process[:http_port] -%> · http :<%= h(process[:http_port]) %><% end -%></span>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="stack">
|
|
48
|
+
<% Hash(process[:subscriptions]).each do |type, names| -%>
|
|
49
|
+
<% next if Array(names).empty? -%>
|
|
50
|
+
<span class="mono ellip" style="font-size:11.5px" title="<%= h(Array(names).join(', ')) %>"><% if kind == 'jobs+streams' -%><span class="faint"><%= h(type) %>:</span> <% end -%><%= h(Array(names).join(', ')) %></span>
|
|
51
|
+
<% end -%>
|
|
52
|
+
</div>
|
|
53
|
+
<span class="mono r"><%= h(process[:busy]) %>/<%= h(process[:concurrency]) %></span>
|
|
54
|
+
<span class="pill" style="--tone:<%= states.fetch(process[:state].to_s, 'var(--acc)') %>"><%= h(process[:state]) %></span>
|
|
55
|
+
<span class="mono mute r"><%= nats[:rtt] ? "#{h(nats[:rtt])}ms" : '—' %></span>
|
|
56
|
+
<span class="mono mute r"><%= h(nats[:reconnects].to_i) %></span>
|
|
57
|
+
<span class="mono mute r"><%= process[:rss] ? format_bytes(process[:rss].to_i * 1024) : '—' %></span>
|
|
58
|
+
<span class="mono mute r"><%= elapsed(process[:started_at]) %></span>
|
|
59
|
+
<span class="mono mute r"><%= elapsed(process[:beat_at]) %> ago</span>
|
|
60
|
+
</div>
|
|
61
|
+
<% end -%>
|
|
62
|
+
<% end -%>
|
|
63
|
+
</div></div>
|
|
64
|
+
<% end -%>
|
|
65
|
+
|
|
66
|
+
<%= render('shared/_pager', { path: '/processes', query: @query, page: @page, total_pages: @total_pages, target: '#processes' }) %>
|
|
67
|
+
</section>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= @table %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% if @total_pages.to_i > 1 -%>
|
|
2
|
+
<% link = ->(page) { url_for(@path, Hash(@query).merge(page: page)) } -%>
|
|
3
|
+
<nav class="pager">
|
|
4
|
+
<% if @page > 1 -%>
|
|
5
|
+
<a class="btn quiet" hx-get="<%= link.(@page - 1) %>" hx-target="<%= @target %>" hx-swap="outerHTML" hx-indicator="#global-spinner">← Prev</a>
|
|
6
|
+
<% else -%>
|
|
7
|
+
<span class="btn quiet disabled">← Prev</span>
|
|
8
|
+
<% end -%>
|
|
9
|
+
<% pages(@page, @total_pages).each do |p| -%>
|
|
10
|
+
<% if p == :gap -%>
|
|
11
|
+
<span class="gap">…</span>
|
|
12
|
+
<% else -%>
|
|
13
|
+
<a class="btn<%= ' cur' if p == @page %>" hx-get="<%= link.(p) %>" hx-target="<%= @target %>" hx-swap="outerHTML" hx-indicator="#global-spinner"><%= p %></a>
|
|
14
|
+
<% end -%>
|
|
15
|
+
<% end -%>
|
|
16
|
+
<% if @page < @total_pages -%>
|
|
17
|
+
<a class="btn quiet" hx-get="<%= link.(@page + 1) %>" hx-target="<%= @target %>" hx-swap="outerHTML" hx-indicator="#global-spinner">Next →</a>
|
|
18
|
+
<% else -%>
|
|
19
|
+
<span class="btn quiet disabled">Next →</span>
|
|
20
|
+
<% end -%>
|
|
21
|
+
</nav>
|
|
22
|
+
<% end -%>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<section class="card" data-reload="<%= @retry %>">
|
|
2
|
+
<div class="empty">
|
|
3
|
+
<b>NATS is unreachable</b>
|
|
4
|
+
<span>Nothing was fetched, so this page shows no data. It tries again every <%= @retry %> seconds.</span>
|
|
5
|
+
<a class="btn" href="<%= h(@request.fullpath) %>">Retry now</a>
|
|
6
|
+
</div>
|
|
7
|
+
</section>
|