Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings page rebrand #1378

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/css/explorer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pre {
.input-field::placeholder {
color: white;
opacity: 1;
font-family: $font-default;
font-family: $font-mono;
font-weight: 400;
}

Expand Down Expand Up @@ -447,4 +447,4 @@ hr {

.active {
display: block;
}
}
62 changes: 4 additions & 58 deletions lib/archethic_web/explorer/live/settings_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ defmodule ArchethicWeb.Explorer.SettingsLive do
|> assign(:error, nil)
|> assign(:sending, false)
|> assign(:notification, "")
|> assign(:notification_data, "")
|> assign(:notification_status, "")

{:ok, new_socket}
Expand Down Expand Up @@ -84,14 +85,15 @@ defmodule ArchethicWeb.Explorer.SettingsLive do
end
end

def handle_info({:new_transaction, _tx_address}, socket) do
def handle_info({:new_transaction, tx_address}, socket) do
%Node{reward_address: reward_address} = P2P.get_node_info()

new_socket =
socket
|> assign(:sending, false)
|> assign(:reward_address, Base.encode16(reward_address))
|> assign(:notification, "Change applied!")
|> assign(:notification_data, Base.encode16(tx_address))
|> assign(:notification_status, "success")

{:noreply, new_socket}
Expand All @@ -102,68 +104,12 @@ defmodule ArchethicWeb.Explorer.SettingsLive do
socket
|> assign(:sending, false)
|> assign(:notification, "Transaction is invalid - #{reason}")
|> assign(:notification_data, "")
|> assign(:notification_status, "error")

{:noreply, new_socket}
end

def render(assigns) do
~H"""
<div>
<%= if @notification != "" do %>
<div
class={[
if(@notification_status == "success", do: "is-success", else: "is-danger"),
"notification",
"is-light"
]}
x-data="{ open: true }"
x-init="() => { setTimeout(() => open = false, 3000)}"
x-show="open"
>
<button class="delete"></button>
<%= @notification %>
</div>
<% end %>
<div class="box">
<div class="columns">
<div class="column">
<h1 class="subtitle is-5">Node's settings</h1>
</div>
</div>

<form class="columns" phx-submit="save" phx-change="validate">
<div class="column is-5-desktop">
<div class="field">
<label class="label">Reward's address</label>
<div class="control">
<input
class={[if(@error, do: "is-danger"), "input"]}
type="text"
placeholder="Enter your new reward address"
value={@reward_address}
name="reward_address"
/>
</div>
<p class="help is-danger"><%= @error %></p>
</div>

<div class="field">
<div class="control">
<%= if @sending do %>
<button class="button is-link is-loading" disabled>Save</button>
<% else %>
<button class="button is-link">Save</button>
<% end %>
</div>
</div>
</div>
</form>
</div>
</div>
"""
end

defp send_new_transaction(next_reward_address) do
%Node{
ip: ip,
Expand Down
60 changes: 60 additions & 0 deletions lib/archethic_web/explorer/live/settings_live.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<div class="body">
<div class="text_title">Node's Settings</div>
<div class="text_subtitle">
The setting of this current node. Accessible only via 127.0.0.1
</div>

<div class="my-4 is-size-4">Reward address</div>
<form class="form-container" phx-submit="save" phx-change="validate">
<div class="level">
<div class="level-left">
<div class="level-item">
<input
type="text"
required
name="reward_address"
class="input-field"
maxlength="68"
value={@reward_address}
/>
</div>
<div class="level-item">
<button class="app-button shadow" disabled={@sending}>Set reward address</button>
</div>
</div>
</div>
</form>

<%= if @notification != "" do %>
<div
class={[
if(@notification_status == "success", do: "is-success", else: "is-danger"),
"notification",
"is-dark"
]}
x-data="{ open: true }"
x-init="() => { setTimeout(() => open = false, 3000)}"
x-show="open"
>
<button class="delete"></button>
<%= @notification %>
<%= if @notification_data != "" do %>
<%= link("View the transaction",
to:
Routes.live_path(
@socket,
ArchethicWeb.Explorer.TransactionDetailsLive,
@notification_data
)
) %> or <%= link("View the node's transaction chain",
to:
Routes.live_path(@socket, ArchethicWeb.Explorer.TransactionChainLive,
address: @notification_data
)
) %>
<% end %>
</div>
<% end %>

<p class="help is-danger"><%= @error %></p>
</div>
Loading
Loading