Compare commits

..

No commits in common. "4c67389d5a0f8898ab9b7a2898789088a124a8b9" and "ead5cfdcc642bb60ab1b00fb22e536f13ed62311" have entirely different histories.

5 changed files with 19 additions and 56 deletions

View File

@ -12,13 +12,4 @@ http://localhost:8888 {
handle_path /admin/* { handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000 reverse_proxy /* http://127.0.0.1:3000
} }
handle_path /faaso/hello/* {
reverse_proxy /* http://faaso-hello-8t3u59:3000 http://faaso-hello-5epnbg:3000 http://faaso-hello-zt5j6g:3000 {
health_uri /ping
fail_duration 30s
}
}
} }

View File

@ -23,7 +23,9 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Instances</th> <th>Scale</th>
<th>Containers</th>
<th>Images</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>

View File

@ -79,14 +79,14 @@ module Funko
get "/funkos/" do |env| get "/funkos/" do |env|
funkos = Funko.from_docker funkos = Funko.from_docker
funkos.sort! { |a, b| a.name <=> b.name } funkos.sort! { |a, b| a.name <=> b.name }
result = [] of Hash(String, String | Array(Docr::Types::ContainerSummary)) result = [] of Hash(String, String)
funkos.each do |funko| funkos.each do |funko|
result << { result << {
"name" => funko.name, "name" => funko.name,
"scale" => funko.scale.to_s, "scale" => funko.scale.to_s,
"containers" => funko.containers, "containers" => funko.containers.size.to_s,
"latest_image" => funko.latest_image, "images" => funko.images.size.to_s,
} }
end end

View File

@ -178,12 +178,8 @@ module Funko
end end
end end
def latest_image
image_history.first
end
# Get all running containers related to this funko # Get all running containers related to this funko
def containers : Array(Docr::Types::ContainerSummary) def containers
docker_api = Docr::API.new(Docr::Client.new) docker_api = Docr::API.new(Docr::Client.new)
docker_api.containers.list(all: true).select { |container| docker_api.containers.list(all: true).select { |container|
container.@names.any?(&.starts_with?("/faaso-#{name}-")) && container.@names.any?(&.starts_with?("/faaso-#{name}-")) &&

View File

@ -1,42 +1,13 @@
<%- result.each do |f| -%> <%- result.each do |f| -%>
<tr hx-indicator="#spinner-<%= f["name"] %>"> <tr hx-indicator="#spinner-<%= f["name"] %>">
<td> <td><%= f["name"] %></td>
<%= f["name"] %> <td><%= f["scale"] %></td>
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator"> <td><%= f["containers"] %></td>
</td> <td><%= f["images"] %></td>
<td>
<table>
<thead>
<th>ID</th>
<th>Current?</th>
<th>Actions</th>
</thead>
<tbody>
<%- f["containers"].as(Array(Docr::Types::ContainerSummary)).each do |c| -%>
<tr>
<td><tt><%= c.@names[0].split("-")[-1] %></tt></td>
<td>
<%- if c.image_id == f["latest_image"] -%>
<span style="color:green;""> 🟢</span>
<%- else -%>
<span style="color:red;""> 🟢</span>
<%- end -%>
</td>
<td>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/logs/">Logs</button>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/shell/">Shell</button>
</td>
</tr>
<%- end -%>
</tbody>
</p>
</td>
</table>
<td> <td>
<%- if f["name"] == "proxy" -%> <%- if f["name"] == "proxy" -%>
<%- else -%> <%- else -%>
<%- if f["scale"].as(String).to_i > 0 -%> <%- if f["scale"].to_i > 0 -%>
<button disabled hx-get="funkos/<%= f["name"] %>/start">Start</button> <button disabled hx-get="funkos/<%= f["name"] %>/start">Start</button>
<button hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button> <button hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<%- else -%> <%- else -%>
@ -44,7 +15,10 @@
<button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button> <button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<%- end -%> <%- end -%>
<button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button> <button hx-get="funkos/<%= f["name"] %>/restart" hx-on:htmx:after-request="update_funkos()">Restart</button>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/logs/">Logs</button>
<button hx-target="#terminal" hx-get="funkos/<%= f["name"] %>/terminal/shell/">Shell</button>
<%- end -%> <%- end -%>
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator">
</td> </td>
</tr> </tr>
<%- end -%> <%- end -%>