Render drive info cards
This commit is contained in:
parent
46a1887982
commit
51aa0c805e
@ -3,7 +3,9 @@
|
||||
require "cgi"
|
||||
require "erb"
|
||||
require "digest"
|
||||
require "json"
|
||||
require "securerandom"
|
||||
require "socket"
|
||||
|
||||
ASSETS_DIR = File.join(__dir__, "../assets")
|
||||
DATA_DIR = File.join(__dir__, "../data")
|
||||
@ -81,9 +83,32 @@ end
|
||||
|
||||
if cgi.params.key?("content")
|
||||
if authenticated
|
||||
sleep 5
|
||||
html = ""
|
||||
|
||||
sock = UNIXSocket.new("/run/malpd/malpd.sock")
|
||||
sock.puts "info"
|
||||
info = JSON.parse(sock.gets)
|
||||
sock.close
|
||||
|
||||
info.each do |entry|
|
||||
case entry["type"]
|
||||
when "drive"
|
||||
dt = entry["drivetype"]
|
||||
model = CGI.escapeHTML(entry["model"])
|
||||
capacity = CGI.escapeHTML(entry["capacity"])
|
||||
html << <<~HTML
|
||||
<div class="card ok">
|
||||
<div class="card-header">
|
||||
<span class="card-title">#{model} <span class="drive-type #{dt}">#{dt.upcase}</span></span>
|
||||
</div>
|
||||
<div class="card-sub">#{capacity}</div>
|
||||
</div>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
||||
cgi.out("type" => "text/html", "charset" => "UTF-8") do
|
||||
"<p>Content placeholder</p>"
|
||||
html
|
||||
end
|
||||
else
|
||||
cgi.out("Status" => "403 Forbidden", "type" => "text/plain", "charset" => "UTF-8") do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user