forked from hiway/freedive
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
|
defmodule FreediveWeb.LiliformLive do
|
||||||
defmacro __using__(_) do
|
defmacro __using__(opts) do
|
||||||
quote do
|
quote location: :keep, bind_quoted: [opts: opts] do
|
||||||
use FreediveWeb, :live_view
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@callback items() :: [map]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,45 @@
|
||||||
defmodule FreediveWeb.ServiceLive do
|
defmodule FreediveWeb.ServiceLive do
|
||||||
use FreediveWeb.LiliformLive
|
use FreediveWeb.LiliformLive,
|
||||||
|
opts: [
|
||||||
|
name: "Services"
|
||||||
|
]
|
||||||
|
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
Hello, World!
|
<%= inspect(@items) %>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
def mount(_params, _session, socket) do
|
def items() do
|
||||||
{:ok, socket}
|
[
|
||||||
|
%{
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue