Use actual funkos in the admin backend

This commit is contained in:
Roberto Alsina 2024-07-02 16:56:19 -03:00
parent 3d0dc1539a
commit a4f722a1e0
2 changed files with 4 additions and 16 deletions

View File

@ -1,25 +1,11 @@
require "docr"
require "kemal"
require "../funko.cr"
module Funkos
struct Funko
include JSON::Serializable
property name : String
def initialize(@name : String)
end
end
get "/funkos/" do |env|
docker_api = Docr::API.new(Docr::Client.new)
containers = docker_api.containers.list(all: true)
funkos : Array(Funko) = Funko.from_docker
funkos = [] of Funko
containers.each { |container|
names = container.names.select &.starts_with? "/faaso-"
next if names.empty?
funkos << Funko.new(name: names[0][7..])
}
funkos.sort! { |a, b| a.name <=> b.name }
if env.params.query.fetch("format", "json") == "html"

View File

@ -1,5 +1,7 @@
<%- funkos.each do |funko| -%>
<tr>
<td><%= funko.name %></td>
<td>sarasa</td>
<td><button>DOSTUFF</button></td>
</tr>
<%- end -%>