Add items() to liliform and service live page
This commit is contained in:
parent
930768aa9d
commit
55d4f1b2c2
2 changed files with 47 additions and 6 deletions
|
@ -1,7 +1,16 @@
|
|||
defmodule FreediveWeb.LiliformLive do
|
||||
defmacro __using__(_) do
|
||||
quote do
|
||||
defmacro __using__(opts) do
|
||||
quote location: :keep, bind_quoted: [opts: opts] do
|
||||
use FreediveWeb, :live_view
|
||||
@behaviour FreediveWeb.LiliformLive
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
socket = assign(socket, :opts, unquote(opts))
|
||||
socket = assign(socket, :items, items())
|
||||
{:ok, socket}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@callback items() :: [map]
|
||||
end
|
||||
|
|
|
@ -1,13 +1,45 @@
|
|||
defmodule FreediveWeb.ServiceLive do
|
||||
use FreediveWeb.LiliformLive
|
||||
use FreediveWeb.LiliformLive,
|
||||
opts: [
|
||||
name: "Services"
|
||||
]
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
Hello, World!
|
||||
<%= inspect(@items) %>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket}
|
||||
def items() do
|
||||
[
|
||||
%{
|
||||
name: "sshd",
|
||||
icon: "blocks",
|
||||
description: "Secure Shell Daemon",
|
||||
enabled: true,
|
||||
running: true
|
||||
},
|
||||
%{
|
||||
name: "pf",
|
||||
icon: "shield",
|
||||
description: "Packet Filter",
|
||||
enabled: true,
|
||||
running: true
|
||||
},
|
||||
%{
|
||||
name: "ntpdate",
|
||||
icon: "clock",
|
||||
description: "Network Time Protocol Daemon",
|
||||
enabled: true,
|
||||
running: false
|
||||
},
|
||||
%{
|
||||
name: "httpd",
|
||||
icon: "globe",
|
||||
description: "Hypertext Transfer Protocol Daemon",
|
||||
enabled: false,
|
||||
running: false
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue