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/* {
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>
<tr>
<th>Name</th>
<th>Instances</th>
<th>Scale</th>
<th>Containers</th>
<th>Images</th>
<th>Actions</th>
</tr>
</thead>

View File

@ -79,14 +79,14 @@ module Funko
get "/funkos/" do |env|
funkos = Funko.from_docker
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|
result << {
"name" => funko.name,
"scale" => funko.scale.to_s,
"containers" => funko.containers,
"latest_image" => funko.latest_image,
"name" => funko.name,
"scale" => funko.scale.to_s,
"containers" => funko.containers.size.to_s,
"images" => funko.images.size.to_s,
}
end

View File

@ -178,16 +178,12 @@ module Funko
end
end
def latest_image
image_history.first
end
# 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.containers.list(all: true).select { |container|
container.@names.any?(&.starts_with?("/faaso-#{name}-")) &&
container.@state == "running"
container.@state == "running"
}
end

View File

@ -1,42 +1,13 @@
<%- result.each do |f| -%>
<tr hx-indicator="#spinner-<%= f["name"] %>">
<td>
<%= f["name"] %>
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator">
</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><%= f["name"] %></td>
<td><%= f["scale"] %></td>
<td><%= f["containers"] %></td>
<td><%= f["images"] %></td>
<td>
<%- if f["name"] == "proxy" -%>
<%- 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 hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<%- else -%>
@ -44,7 +15,10 @@
<button disabled hx-get="funkos/<%= f["name"] %>/stop" hx-on:htmx:after-request="update_funkos()">Stop</button>
<%- end -%>
<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 -%>
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator">
</td>
</tr>
<%- end -%>