Use actual funkos in the admin backend
This commit is contained in:
parent
3d0dc1539a
commit
a4f722a1e0
@ -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"
|
||||
|
@ -1,5 +1,7 @@
|
||||
<%- funkos.each do |funko| -%>
|
||||
<tr>
|
||||
<td><%= funko.name %></td>
|
||||
<td>sarasa</td>
|
||||
<td><button>DOSTUFF</button></td>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
|
Loading…
Reference in New Issue
Block a user