From 4371444fa4d9ef859f7b765cf91439bd9baa1572 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Tue, 2 Jul 2024 12:40:47 -0300 Subject: [PATCH] Embryo of web frontend --- public/index.html | 41 ++++++++++++++++------------------------- src/daemon/funkos.cr | 11 ++++++++--- src/views/funkos.ecr | 5 +++++ 3 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 src/views/funkos.ecr diff --git a/public/index.html b/public/index.html index 17433c5..6f17bd1 100644 --- a/public/index.html +++ b/public/index.html @@ -1,34 +1,25 @@ - + + + + + + + + + + + + + diff --git a/src/daemon/funkos.cr b/src/daemon/funkos.cr index 2bae06f..a414917 100644 --- a/src/daemon/funkos.cr +++ b/src/daemon/funkos.cr @@ -10,7 +10,7 @@ module Funkos end end - get "/funkos/" do |_| + get "/funkos/" do |env| docker_api = Docr::API.new(Docr::Client.new) containers = docker_api.containers.list(all: true) @@ -20,7 +20,12 @@ module Funkos next if names.empty? funkos << Funko.new(name: names[0][7..]) } - funkos.sort! { |a, b| a.name <=> b.name} - funkos.to_json + funkos.sort! { |a, b| a.name <=> b.name } + + if env.params.query.fetch("format", "json") == "html" + render "src/views/funkos.ecr" + else + funkos.to_json + end end end diff --git a/src/views/funkos.ecr b/src/views/funkos.ecr new file mode 100644 index 0000000..73c9a9f --- /dev/null +++ b/src/views/funkos.ecr @@ -0,0 +1,5 @@ +<%- funkos.each do |funko| -%> + + + +<%- end -%>
NameStatusAction
<%= funko.name %>sarasa