From f5b4131160520a2540445619188c3c8e0f37da37 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 12 Oct 2018 16:38:11 +0200 Subject: Notifications for chat ; useless user info page --- shardweb/assets/css/app.css | 5 ++ shardweb/lib/channels/chat_channel.ex | 3 + shardweb/lib/controllers/identity_controller.ex | 14 +++- shardweb/lib/templates/chat/chat.html.eex | 6 +- shardweb/lib/templates/identity/list.html.eex | 5 +- shardweb/lib/templates/identity/view.html.eex | 25 ++++++ shardweb/lib/templates/layout/app.html.eex | 101 ++++++++++-------------- shardweb/lib/templates/page/peer_list.html.eex | 7 +- shardweb/lib/views/layout_view.ex | 21 +++++ 9 files changed, 123 insertions(+), 64 deletions(-) create mode 100644 shardweb/lib/templates/identity/view.html.eex (limited to 'shardweb') diff --git a/shardweb/assets/css/app.css b/shardweb/assets/css/app.css index 0676867..e8d40d2 100644 --- a/shardweb/assets/css/app.css +++ b/shardweb/assets/css/app.css @@ -4,3 +4,8 @@ color: #fff; background-color: #080808; } + +.have_unread { + color: #fff; + font-weight: bold; +} diff --git a/shardweb/lib/channels/chat_channel.ex b/shardweb/lib/channels/chat_channel.ex index f898602..a413be1 100644 --- a/shardweb/lib/channels/chat_channel.ex +++ b/shardweb/lib/channels/chat_channel.ex @@ -47,6 +47,7 @@ defmodule ShardWeb.ChatChannel do message: msg, }) end) + GenServer.cast(socket.assigns.pid, :mark_read) {:noreply, socket} end @@ -57,10 +58,12 @@ defmodule ShardWeb.ChatChannel do push socket, "shout", %{"name" => nick, "pk16" => Shard.Keys.pk_display(pk), "message" => msg} + GenServer.cast(socket.assigns.pid, :mark_read) {:noreply, socket} end def handle_info({:chat_send, _, _}, socket) do + GenServer.cast(socket.assigns.pid, :mark_read) {:noreply, socket} end diff --git a/shardweb/lib/controllers/identity_controller.ex b/shardweb/lib/controllers/identity_controller.ex index 3c04fe8..dd254bb 100644 --- a/shardweb/lib/controllers/identity_controller.ex +++ b/shardweb/lib/controllers/identity_controller.ex @@ -10,7 +10,19 @@ defmodule ShardWeb.IdentityController do end def view(conn, %{"pk" => pk}) do - #TODO + {:ok, pk} = Base.decode16(pk) + shard = %SApp.Identity.Manifest{pk: pk} |> SData.term_hash + pid = Shard.Manager.find_proc shard + + if pid == nil do + render conn, ShardWeb.ErrorView, "404.html" + else + render conn, "view.html", + view_pk: pk, + view_nick: SApp.Identity.get_nick(pk), + shard: shard, + pid: pid + end end def update(conn, params) do diff --git a/shardweb/lib/templates/chat/chat.html.eex b/shardweb/lib/templates/chat/chat.html.eex index 8a43acf..45609d8 100644 --- a/shardweb/lib/templates/chat/chat.html.eex +++ b/shardweb/lib/templates/chat/chat.html.eex @@ -18,14 +18,14 @@ Chat rooms
  • - #<%= @chan %> + #<%= @chan %>
  • <% else %>
  • - Private chat + Private chat
  • - <%= @nicks %> + <%= @nicks %>
  • <% end %> diff --git a/shardweb/lib/templates/identity/list.html.eex b/shardweb/lib/templates/identity/list.html.eex index 007af3d..6437f9c 100644 --- a/shardweb/lib/templates/identity/list.html.eex +++ b/shardweb/lib/templates/identity/list.html.eex @@ -31,7 +31,10 @@ <% end %> - <%= if manifest.pk != @pk do %> + + <%= if manifest.pk == @pk do %> + Edit + <% else %> PM <% end %> diff --git a/shardweb/lib/templates/identity/view.html.eex b/shardweb/lib/templates/identity/view.html.eex new file mode 100644 index 0000000..8bb8ca2 --- /dev/null +++ b/shardweb/lib/templates/identity/view.html.eex @@ -0,0 +1,25 @@ + +
    +
    +

    + <%= @view_nick %> <%= @view_pk |> Base.encode16 %> +

    + +
    +
    + + +<%= render ShardWeb.LayoutView, "flashes.html", assigns %> + +
    +  <%= inspect((GenServer.call(@pid, :get_info)), pretty: true, width: 40) %>
    +
    + + diff --git a/shardweb/lib/templates/layout/app.html.eex b/shardweb/lib/templates/layout/app.html.eex index f49c8e6..067ad57 100644 --- a/shardweb/lib/templates/layout/app.html.eex +++ b/shardweb/lib/templates/layout/app.html.eex @@ -52,79 +52,52 @@