Skip to content

Commit

Permalink
Version 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alxlion committed Oct 5, 2024
1 parent 8099fa8 commit 767c15b
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 57 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v2.1.1

### Fixes and improvements

- Fix OIDC to allow only client_secret_basic and client_secret_post auth methods
- Fix minimum length for 2 characters messages
- Fix poll option order
- Fix translations for current interactions
- Improve poll results UI
- Optimize resource usage of the manager when attendees join the event
- Fix duplicate event being inaccesible

## v2.1.0

### Features
Expand Down
11 changes: 9 additions & 2 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Hooks.PostForm = {
e.preventDefault();
submitBtn.click();
} else {
if (TA.value.length > 1 && TA.value.length < 256) {
if (TA.value.length > 0 && TA.value.length < 256) {
submitBtn.classList.remove("opacity-50");
submitBtn.classList.add("opacity-100");
submitBtn.disabled = false;
Expand Down Expand Up @@ -261,7 +261,7 @@ Hooks.PostForm = {
updated() {
const submitBtn = document.getElementById("submitBtn");
const TA = document.getElementById("postFormTA");
if (TA.value.length > 1 && TA.value.length < 256) {
if (TA.value.length > 0 && TA.value.length < 256) {
submitBtn.classList.remove("opacity-50");
submitBtn.classList.add("opacity-100");
submitBtn.disabled = false;
Expand Down Expand Up @@ -316,6 +316,13 @@ Hooks.Pickr = {
this.pickr.destroy();
},
};
Hooks.UpdateAttendees = {
mounted() {
this.handleEvent("update-attendees", ({ count }) => {
this.el.textContent = count;
});
},
};
Hooks.Presenter = {
mounted() {
this.presenter = new Presenter(this);
Expand Down
2 changes: 1 addition & 1 deletion lib/claper/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ defmodule Claper.Events do
|> Map.drop([:id, :inserted_at, :updated_at])
|> Map.put(:presentation_file_id, new_presentation_file.id)
|> Map.put(:position, 0)
|> Map.put(:banned, nil)
|> Map.put(:banned, [])

Claper.Presentations.create_presentation_state(attrs)
end)
Expand Down
3 changes: 2 additions & 1 deletion lib/claper_web/controllers/user_oidc_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ defmodule ClaperWeb.UserOidcAuth do

%{
redirect_uri: "#{url}/users/oidc/callback",
scopes: scopes()
scopes: scopes(),
preferred_auth_methods: [:client_secret_basic, :client_secret_post]
}
end

Expand Down
18 changes: 7 additions & 11 deletions lib/claper_web/live/event_live/embed_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ defmodule ClaperWeb.EventLive.EmbedComponent do
<div class="text-white flex space-x-2 items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
class="h-6 w-6"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"></path>
<path d="M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"></path>
<path d="M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"></path>
<path d="M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"></path>
<path d="M17 12h.01"></path>
<path d="M13 12h.01"></path>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.25 9.75L16.5 12l-2.25 2.25m-4.5 0L7.5 12l2.25-2.25M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"
/>
</svg>
<span class="font-bold"><%= gettext("See current web content") %></span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/claper_web/live/event_live/manage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ defmodule ClaperWeb.EventLive.Manage do
@impl true
def handle_info(%{event: "presence_diff"}, %{assigns: %{event: event}} = socket) do
attendees = Presence.list("event:#{event.uuid}")
{:noreply, assign(socket, :attendees_nb, Enum.count(attendees))}
{:noreply, push_event(socket, "update-attendees", %{count: Enum.count(attendees)})}
end

@impl true
Expand Down
4 changes: 3 additions & 1 deletion lib/claper_web/live/event_live/manage.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@
clip-rule="evenodd"
/>
</svg>
<span><%= @attendees_nb %></span>
<span id="attendees-count" phx-update="ignore" phx-hook="UpdateAttendees">
<%= @attendees_nb %>
</span>
</div>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions lib/claper_web/live/event_live/poll_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ defmodule ClaperWeb.EventLive.PollComponent do
<% end %>
</div>
<div>
<div class="flex flex-col space-y-3">
<div class="flex flex-col space-y-3 overflow-y-auto max-h-[500px]">
<%= if (length @poll.poll_opts) > 0 do %>
<%= for {opt, idx} <- Enum.with_index(@poll.poll_opts) do %>
<%= if (length @current_poll_vote) > 0 do %>
<button class="bg-gray-500 px-3 py-2 rounded-full flex justify-between items-center relative text-white">
<button class="bg-gray-500 px-3 py-2 rounded-3xl flex justify-between items-center relative text-white">
<div
style={"width: #{if @show_results, do: opt.percentage, else: 0}%;"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-full #{if opt.percentage == "100", do: "rounded-r-full"}"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-3xl #{if opt.percentage == "100", do: "rounded-r-3xl"}"}
>
</div>
<div class="flex space-x-3 z-10 text-left">
<div class="flex space-x-3 items-center z-10 text-left">
<%= if (length Enum.filter(@current_poll_vote, fn(vote) -> vote.poll_opt_id == opt.id end)) > 0 do %>
<%= if @poll.multiple do %>
<span class="h-5 w-5 mt-0.5 point-select bg-white"></span>
Expand All @@ -78,7 +78,7 @@ defmodule ClaperWeb.EventLive.PollComponent do
</span>
<% end %>
<% end %>
<span class="flex-1"><%= opt.content %></span>
<span class="flex-1 pr-2"><%= opt.content %></span>
</div>
<span :if={@show_results} class="text-sm z-10">
<%= opt.percentage %>% (<%= opt.vote_count %>)
Expand All @@ -89,14 +89,14 @@ defmodule ClaperWeb.EventLive.PollComponent do
id={"poll-opt-#{idx}"}
phx-click="select-poll-opt"
phx-value-opt={idx}
class="bg-gray-500 px-3 py-2 rounded-full flex justify-between items-center relative text-white"
class="bg-gray-500 px-3 py-2 flex justify-between items-center rounded-3xl relative text-white"
>
<div
style={"width: #{if @show_results, do: opt.percentage, else: 0}%;"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-full #{if opt.percentage == "100", do: "rounded-r-full"}"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-3xl #{if opt.percentage == "100", do: "rounded-r-3xl"}"}
>
</div>
<div class="flex space-x-3 z-10 text-left">
<div class="flex space-x-3 items-center z-10 text-left">
<%= if Enum.member?(@selected_poll_opt, "#{idx}") do %>
<%= if @poll.multiple do %>
<span class="h-5 w-5 mt-0.5 point-select bg-white"></span>
Expand All @@ -111,7 +111,7 @@ defmodule ClaperWeb.EventLive.PollComponent do
</span>
<% end %>
<% end %>
<span class="flex-1"><%= opt.content %></span>
<span class="flex-1 pr-2"><%= opt.content %></span>
</div>
<span :if={@show_results} class="text-sm z-10">
<%= opt.percentage %>% (<%= opt.vote_count %>)
Expand All @@ -123,14 +123,14 @@ defmodule ClaperWeb.EventLive.PollComponent do
</div>
<%= if (length @selected_poll_opt) == 0 || (length @current_poll_vote) > 0 do %>
<button class="px-3 py-2 text-white font-semibold bg-gray-500 rounded-md my-5 cursor-default">
<button class="px-3 py-2 text-white font-semibold bg-gray-500 rounded-md mt-3 mb-4 cursor-default">
<%= gettext("Vote") %>
</button>
<% else %>
<button
phx-click="vote"
phx-disable-with="..."
class="px-3 py-2 text-white font-semibold bg-primary-500 hover:bg-primary-600 rounded-md my-5"
class="px-3 py-2 text-white font-semibold bg-primary-500 hover:bg-primary-600 rounded-md mt-3 mb-4"
>
<%= gettext("Vote") %>
</button>
Expand Down
4 changes: 2 additions & 2 deletions lib/claper_web/live/event_live/presenter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ defmodule ClaperWeb.EventLive.Presenter do
@impl true
def handle_info(%{event: "presence_diff"}, %{assigns: %{event: event}} = socket) do
attendees = Presence.list("event:#{event.uuid}")
{:noreply, assign(socket, :attendees_nb, Enum.count(attendees))}
{:noreply, push_event(socket, "update-attendees", %{count: Enum.count(attendees)})}
end

@impl true
Expand Down Expand Up @@ -163,7 +163,7 @@ defmodule ClaperWeb.EventLive.Presenter do

@impl true
def handle_info({:form_updated, form}, socket) do
if form.active do
if form.enabled do
{:noreply,
socket
|> update(:current_form, fn _current_form -> form end)}
Expand Down
10 changes: 6 additions & 4 deletions lib/claper_web/live/event_live/presenter.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
<div class={"#{if @iframe, do: "space-y-5", else: "space-y-8"} flex flex-col"}>
<%= if (length @current_poll.poll_opts) > 0 do %>
<%= for opt <- @current_poll.poll_opts do %>
<div class={"#{if @iframe, do: "py-1", else: "py-4"} bg-gray-500 px-6 rounded-full flex justify-between items-center relative text-white"}>
<div class={"#{if @iframe, do: "py-1", else: "py-4"} bg-gray-500 px-6 rounded-3xl flex justify-between items-center relative text-white"}>
<div
style={"width: #{opt.percentage}%;"}
class="bg-gradient-to-r from-primary-500 to-secondary-500 rounded-full h-full absolute left-0 transition-all"
class="bg-gradient-to-r from-primary-500 to-secondary-500 rounded-3xl h-full absolute left-0 transition-all"
>
</div>
<div class="flex space-x-3 z-10 text-left">
<span class={"#{if @iframe, do: "text-base", else: "text-2xl"} flex-1 font-bold"}>
<span class={"#{if @iframe, do: "text-base", else: "text-2xl"} flex-1 font-bold pr-2"}>
<%= opt.content %>
</span>
</div>
Expand Down Expand Up @@ -234,7 +234,9 @@

<div class="inline-flex justify-between items-center text-white text-2xl">
<img src="/images/icons/online-users.svg" class="h-12 mr-2" />
<span id="counter"><%= @attendees_nb %></span>
<span id="counter" phx-hook="UpdateAttendees" phx-update="ignore">
<%= @attendees_nb %>
</span>
</div>
</div>
</div>
37 changes: 27 additions & 10 deletions lib/claper_web/live/event_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ defmodule ClaperWeb.EventLive.Show do
def handle_info(%{event: "presence_diff"}, %{assigns: %{event: event}} = socket) do
attendees = Presence.list("event:#{event.uuid}")

{:noreply, assign(socket, :attendees_nb, Enum.count(attendees))}
{:noreply, push_event(socket, "update-attendees", %{count: Enum.count(attendees)})}
end

@impl true
Expand Down Expand Up @@ -238,7 +238,7 @@ defmodule ClaperWeb.EventLive.Show do
{:current_interaction, interaction},
socket
) do
{:noreply, socket |> load_current_interaction(interaction)}
{:noreply, socket |> load_current_interaction(interaction, false)}
end

@impl true
Expand Down Expand Up @@ -278,7 +278,7 @@ defmodule ClaperWeb.EventLive.Show do
def handle_info({:poll_updated, %Claper.Polls.Poll{enabled: true} = poll}, socket) do
{:noreply,
socket
|> load_current_interaction(poll)}
|> load_current_interaction(poll, true)}
end

@impl true
Expand All @@ -292,7 +292,7 @@ defmodule ClaperWeb.EventLive.Show do
def handle_info({:form_updated, %Claper.Forms.Form{enabled: true} = form}, socket) do
{:noreply,
socket
|> load_current_interaction(form)}
|> load_current_interaction(form, true)}
end

@impl true
Expand All @@ -306,7 +306,7 @@ defmodule ClaperWeb.EventLive.Show do
def handle_info({:embed_updated, %Claper.Embeds.Embed{enabled: true} = embed}, socket) do
{:noreply,
socket
|> load_current_interaction(embed)}
|> load_current_interaction(embed, true)}
end

@impl true
Expand Down Expand Up @@ -695,20 +695,37 @@ defmodule ClaperWeb.EventLive.Show do

defp get_current_interaction(socket, event, position) do
with interaction <- Interactions.get_active_interaction(event, position) do
socket |> assign(:current_interaction, interaction) |> load_current_interaction(interaction)
socket
|> assign(:current_interaction, interaction)
|> load_current_interaction(interaction, false)
end
end

defp load_current_interaction(socket, %Polls.Poll{} = interaction) do
defp load_current_interaction(socket, %Polls.Poll{} = interaction, same_interaction) do
poll = Polls.set_percentages(interaction)
socket |> assign(:current_interaction, poll) |> get_current_vote(poll.id)

socket
|> assign(
:current_interaction,
%{poll | poll_opts: Enum.sort_by(poll.poll_opts, & &1.id, :asc)}
)
|> maybe_reset_selected_poll_opt(same_interaction)
|> get_current_vote(poll.id)
end

defp load_current_interaction(socket, %Forms.Form{} = interaction) do
defp load_current_interaction(socket, %Forms.Form{} = interaction, _same_interaction) do
socket |> assign(:current_interaction, interaction) |> get_current_form_submit(interaction.id)
end

defp load_current_interaction(socket, interaction) do
defp load_current_interaction(socket, interaction, _same_interaction) do
socket |> assign(:current_interaction, interaction)
end

defp maybe_reset_selected_poll_opt(socket, true) do
socket
end

defp maybe_reset_selected_poll_opt(socket, _same_interaction) do
socket |> assign(:selected_poll_opt, [])
end
end
4 changes: 3 additions & 1 deletion lib/claper_web/live/event_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

<div class="inline-flex justify-between items-center text-white text-sm">
<img src="/images/icons/online-users.svg" class="h-6 mr-2" />
<span id="counter"><%= @attendees_nb %></span>
<span id="counter" phx-update="ignore" phx-hook="UpdateAttendees">
<%= @attendees_nb %>
</span>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions lib/claper_web/live/stat_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@
else: 0 %>
<button
id={"poll-opt-#{idx}"}
class="bg-gray-500 px-3 py-2 rounded-full flex justify-between items-center relative text-white"
class="bg-gray-500 px-3 py-2 rounded-3xl flex justify-between items-center relative text-white"
>
<div
style={"width: #{percentage}%;"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-full #{if percentage == "100", do: "rounded-r-full"}"}
class={"bg-gradient-to-r from-primary-500 to-secondary-500 h-full absolute left-0 transition-all rounded-l-3xl #{if percentage == "100", do: "rounded-r-3xl"}"}
>
</div>
<div class="flex space-x-3 z-10 text-left">
<span class="flex-1"><%= opt.content %></span>
<div class="flex space-x-3 items-center z-10 text-left">
<span class="flex-1 pr-2"><%= opt.content %></span>
</div>
<span class="text-sm z-10"><%= percentage %>% (<%= opt.vote_count %>)</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Claper.MixProject do
use Mix.Project

@version "2.1.0"
@version "2.1.1"

def project do
[
Expand Down
4 changes: 2 additions & 2 deletions priv/gettext/de/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ msgstr "Es wurde kein Formular gesendet"
#: lib/claper_web/live/event_live/form_component.ex:32
#, elixir-autogen, elixir-format
msgid "See current form"
msgstr "Siehe aktuelles Formular"
msgstr "Aktuelles Formular anzeigen"

#: lib/claper_web/live/event_live/form_component.ex:97
#, elixir-autogen, elixir-format
Expand Down Expand Up @@ -929,7 +929,7 @@ msgstr "Neuer Webinhalt"
#: lib/claper_web/live/event_live/embed_component.ex:36
#, elixir-autogen, elixir-format, fuzzy
msgid "See current web content"
msgstr "Aktuellen Webinhalt anzeigen"
msgstr "Aktuelle Webinhalte anzeigen"

#: lib/claper_web/live/embed_live/form_component.html.heex:80
#, elixir-autogen, elixir-format, fuzzy
Expand Down
2 changes: 1 addition & 1 deletion priv/gettext/es/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ msgstr "Nuevo contenido web"
#: lib/claper_web/live/event_live/embed_component.ex:36
#, elixir-autogen, elixir-format
msgid "See current web content"
msgstr "Ver contenido"
msgstr "Ver contenido web actual"

#: lib/claper_web/live/embed_live/form_component.html.heex:80
#, elixir-autogen, elixir-format
Expand Down
Loading

0 comments on commit 767c15b

Please sign in to comment.