Okay that's about everything
This commit is contained in:
parent
023ad47ae4
commit
d094ff036f
19 changed files with 236 additions and 79 deletions
|
|
@ -1,39 +1,65 @@
|
|||
defmodule EzcontainerRailwayWeb.ContainerCreateLive do
|
||||
alias EzcontainerRailway.Railway
|
||||
alias Phoenix.Component
|
||||
use Phoenix.LiveView
|
||||
use EzcontainerRailwayWeb, :live_view
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<%= live_flash(@flash, :error) %>
|
||||
<%= live_flash(@flash, :info) %>
|
||||
<dialog open class="modal">
|
||||
<article class="modal-box">
|
||||
<.form
|
||||
for={@form}
|
||||
method="post"
|
||||
action="/container"
|
||||
>
|
||||
<label class="label">
|
||||
<span class="label-text">Container Name</span>
|
||||
<span class="label-text-alt mr-20">Tag</span>
|
||||
</label>
|
||||
<div class="flex space-around w-full">
|
||||
<article>
|
||||
<%= if @target == "container" do %>
|
||||
<.form for={@form} phx-submit="create_container">
|
||||
<label class="label">
|
||||
<span class="label-text">Container Name</span>
|
||||
<span class="label-text-alt mr-20">Tag</span>
|
||||
</label>
|
||||
|
||||
<div class="grid grid-rows-1 grid-cols-4 gap-4">
|
||||
<input class="input input-bordered inline col-span-3" name="container_name" />
|
||||
<input class="input input-bordered inline" name="container_tag" />
|
||||
</div>
|
||||
<div class="text-center mt-6">
|
||||
<button class="btn">Test</button>
|
||||
</div>
|
||||
</.form>
|
||||
</article>
|
||||
</dialog>
|
||||
<div class="grid grid-rows-1 grid-cols-4 gap-4">
|
||||
<input class="input input-bordered inline col-span-3" name="name" />
|
||||
<input class="input input-bordered inline" name="tag" />
|
||||
</div>
|
||||
<div class="text-center mt-6">
|
||||
<button phx-submit class="btn btn-primary">CREATE</button>
|
||||
</div>
|
||||
<input type="hidden" name="target" value="container" />
|
||||
</.form>
|
||||
<% end %>
|
||||
<%= if @target == "repo" do %>
|
||||
<.form for={@form} phx-submit="create_container">
|
||||
<label class="label">
|
||||
<span class="label-text">Github Repo</span>
|
||||
<span class="label-text-alt mr-20">Branch</span>
|
||||
</label>
|
||||
|
||||
<div class="grid grid-rows-1 grid-cols-4 gap-4">
|
||||
<input class="input input-bordered inline col-span-3" name="name" />
|
||||
<input class="input input-bordered inline" name="tag" />
|
||||
</div>
|
||||
<div class="text-center mt-6">
|
||||
<button phx-submit class="btn btn-primary">CREATE</button>
|
||||
</div>
|
||||
<input type="hidden" name="target" value="repo" />
|
||||
</.form>
|
||||
<% end %>
|
||||
</article>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
form = Component.to_form(%{"container_name" => "", "contianer_tag" => ""})
|
||||
def mount(_params, session, socket) do
|
||||
form = Component.to_form(%{"name" => "", "tag" => ""})
|
||||
|
||||
{:ok, socket |> assign(:form, form)}
|
||||
{:ok, socket |> assign(form: form, target: "container", session: session)}
|
||||
end
|
||||
|
||||
def handle_event("create_container", data, socket) do
|
||||
{:ok, resp} = Railway.create_service(
|
||||
data["name"],
|
||||
"image",
|
||||
socket.assigns.session["railway_token"]
|
||||
)
|
||||
|
||||
{:noreply, socket |> push_redirect('/containers')}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue