From 15e71bc6088543fa01a04b0b57b11b643aa9078b Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 15 Mar 2024 15:44:44 +0100 Subject: [PATCH 01/36] Generated ecto migration file --- .../migrations/20240315144234_benchmark-refactor.exs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 core/priv/repo/migrations/20240315144234_benchmark-refactor.exs diff --git a/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs b/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs new file mode 100644 index 000000000..560747ea5 --- /dev/null +++ b/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs @@ -0,0 +1,9 @@ +defmodule Core.Repo.Migrations.BenchmarkRefactor do + use Ecto.Migration + + def up do + end + + def down do + end +end From cd2f87d19ce7a844459bc35f01b5b2b9d3a7e52a Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 15 Mar 2024 18:44:14 +0100 Subject: [PATCH 02/36] Draft Benchmark data model refactor --- core/bundles/next/lib/console/page.ex | 16 +-- core/bundles/self/lib/console/page.ex | 16 +-- core/lib/core/authorization.ex | 1 - core/lib/core/factories.ex | 17 +-- .../20240315144234_benchmark-refactor.exs | 49 +++++++ core/systems/benchmark/_public.ex | 95 ++---------- core/systems/benchmark/export_controller.ex | 5 +- core/systems/benchmark/leaderboard_model.ex | 1 - .../systems/benchmark/leaderboard_overview.ex | 4 +- core/systems/benchmark/spot_form.ex | 67 --------- core/systems/benchmark/spot_model.ex | 135 ------------------ .../systems/benchmark/submission_list_form.ex | 82 +++++------ core/systems/benchmark/submission_model.ex | 7 +- core/systems/benchmark/tool_controller.ex | 26 ++-- core/systems/benchmark/tool_model.ex | 26 ++-- core/systems/benchmark/tool_page.ex | 20 +-- core/test/systems/benchmark/_public_test.exs | 85 +++++------ .../benchmark/export_controller_test.exs | 14 +- core/test/systems/project/_assembly_test.exs | 10 +- 19 files changed, 185 insertions(+), 491 deletions(-) delete mode 100644 core/systems/benchmark/spot_form.ex delete mode 100644 core/systems/benchmark/spot_model.ex diff --git a/core/bundles/next/lib/console/page.ex b/core/bundles/next/lib/console/page.ex index a9d36a1a4..48ad3d0f9 100644 --- a/core/bundles/next/lib/console/page.ex +++ b/core/bundles/next/lib/console/page.ex @@ -7,29 +7,19 @@ defmodule Next.Console.Page do alias Frameworks.Pixel.Text - alias Systems.{ - Project, - NextAction, - Benchmark - } + alias Systems.Project + alias Systems.NextAction def mount(_params, _session, %{assigns: %{current_user: user}} = socket) do - spot_items = - user - |> Benchmark.Public.list_spots(Benchmark.SpotModel.preload_graph([:tool])) - |> Enum.map(&convert_to_vm(socket, &1)) - project_items = user |> Project.Public.list_owned_projects(preload: Project.Model.preload_graph(:down)) |> Enum.map(&convert_to_vm(socket, &1)) - content_items = spot_items ++ project_items - socket = socket |> update_menus() - |> assign(content_items: content_items) + |> assign(content_items: project_items) |> assign(next_best_action: NextAction.Public.next_best_action(user)) {:ok, socket} diff --git a/core/bundles/self/lib/console/page.ex b/core/bundles/self/lib/console/page.ex index 7cfa2d530..d5e05b923 100644 --- a/core/bundles/self/lib/console/page.ex +++ b/core/bundles/self/lib/console/page.ex @@ -7,29 +7,19 @@ defmodule Self.Console.Page do alias Frameworks.Pixel.Text - alias Systems.{ - Project, - NextAction, - Benchmark - } + alias Systems.Project + alias Systems.NextAction def mount(_params, _session, %{assigns: %{current_user: user}} = socket) do - spot_items = - user - |> Benchmark.Public.list_spots(Benchmark.SpotModel.preload_graph([:tool])) - |> Enum.map(&convert_to_vm(socket, &1)) - project_items = user |> Project.Public.list_owned_projects(preload: Project.Model.preload_graph(:down)) |> Enum.map(&convert_to_vm(socket, &1)) - content_items = spot_items ++ project_items - socket = socket |> update_menus() - |> assign(content_items: content_items) + |> assign(content_items: project_items) |> assign(next_best_action: NextAction.Public.next_best_action(user)) {:ok, socket} diff --git a/core/lib/core/authorization.ex b/core/lib/core/authorization.ex index 6dbbdefea..305c3b76b 100644 --- a/core/lib/core/authorization.ex +++ b/core/lib/core/authorization.ex @@ -27,7 +27,6 @@ defmodule Core.Authorization do grant_access(Systems.Campaign.Model, [:visitor, :member]) grant_access(Systems.Questionnaire.ToolModel, [:owner, :coordinator, :participant]) grant_access(Systems.Lab.ToolModel, [:owner, :coordinator, :participant]) - grant_access(Systems.Benchmark.SpotModel, [:owner]) # Pages grant_access(Systems.Org.ContentPage, [:admin]) diff --git a/core/lib/core/factories.ex b/core/lib/core/factories.ex index 36815cb1a..9ef5eeb0f 100644 --- a/core/lib/core/factories.ex +++ b/core/lib/core/factories.ex @@ -245,10 +245,6 @@ defmodule Core.Factories do build(:benchmark_submission, %{description: "description"}) end - def build(:benchmark_spot) do - build(:benchmark_spot, %{}) - end - def build(:benchmark_tool) do build(:benchmark_tool, %{}) end @@ -613,26 +609,17 @@ defmodule Core.Factories do |> struct!(attributes) end - def build(:benchmark_spot, %{} = attributes) do + def build(:benchmark_submission, %{} = attributes) do {tool, attributes} = Map.pop(attributes, :tool, build(:benchmark_tool)) {auth_node, attributes} = Map.pop(attributes, :auth_node, build(:auth_node)) - %Benchmark.SpotModel{ + %Benchmark.SubmissionModel{ tool: tool, auth_node: auth_node } |> struct!(attributes) end - def build(:benchmark_submission, %{} = attributes) do - {spot, attributes} = Map.pop(attributes, :spot, build(:benchmark_spot)) - - %Benchmark.SubmissionModel{ - spot: spot - } - |> struct!(attributes) - end - def build(:feldspar_tool, %{} = attributes) do {auth_node, attributes} = Map.pop(attributes, :auth_node, build(:auth_node)) diff --git a/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs b/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs index 560747ea5..775e69a60 100644 --- a/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs +++ b/core/priv/repo/migrations/20240315144234_benchmark-refactor.exs @@ -2,8 +2,57 @@ defmodule Core.Repo.Migrations.BenchmarkRefactor do use Ecto.Migration def up do + alter table(:benchmark_tools) do + remove(:status) + remove(:title) + remove(:expectations) + remove(:data_set) + remove(:template_repo) + remove(:deadline) + remove(:director) + add(:max_submissions, :integer) + end + + alter table(:benchmark_submissions) do + remove(:spot_id) + add(:tool_id, references(:benchmark_tools), null: false) + add(:auth_node_id, references(:authorization_nodes), null: false) + end + + drop(table(:benchmark_spots)) + + alter table(:benchmark_leaderboards) do + remove(:tool_id) + end end def down do + alter table(:benchmark_leaderboards) do + # add(:tool_id, references(:benchmark_tools), null: false) + end + + create table(:benchmark_spots) do + add(:name, :string) + add(:tool_id, references(:benchmark_tools), null: false) + add(:auth_node_id, references(:authorization_nodes), null: false) + timestamps() + end + + alter table(:benchmark_submissions) do + add(:spot_id, references(:benchmark_spots), null: false) + remove(:tool_id) + remove(:auth_node_id) + end + + alter table(:benchmark_tools) do + add(:status, :string, null: false) + add(:title, :string, null: true) + add(:expectations, :text, null: true) + add(:data_set, :string, null: true) + add(:deadline, :string) + add(:director, :string, null: false) + add(:template_repo, :string) + remove(:max_submissions) + end end end diff --git a/core/systems/benchmark/_public.ex b/core/systems/benchmark/_public.ex index a5ed64563..26def26b7 100644 --- a/core/systems/benchmark/_public.ex +++ b/core/systems/benchmark/_public.ex @@ -5,11 +5,8 @@ defmodule Systems.Benchmark.Public do alias Ecto.Multi alias Ecto.Changeset alias Core.Repo - alias Core.Authorization - alias Systems.{ - Benchmark - } + alias Systems.Benchmark # FIXME: should come from CMS @main_category "f1_score" @@ -24,20 +21,6 @@ defmodule Systems.Benchmark.Public do |> Repo.get!(id) end - def get_spot_for_tool(tool_id, spot_id, preload \\ []) do - from(spot in Benchmark.SpotModel, - where: spot.id == ^spot_id, - where: spot.tool_id == ^tool_id, - preload: ^preload - ) - |> Repo.one() - end - - def get_spot!(id, preload \\ []) do - from(spot in Benchmark.SpotModel, preload: ^preload) - |> Repo.get!(id) - end - def set_tool_status(%Benchmark.ToolModel{} = tool, status) do tool |> Benchmark.ToolModel.changeset(%{status: status}) @@ -57,30 +40,6 @@ defmodule Systems.Benchmark.Public do |> Changeset.put_assoc(:auth_node, auth_node) end - def create_spot(tool_id, %{displayname: displayname} = user) do - tool = Benchmark.Public.get_tool!(tool_id) - - Multi.new() - |> Multi.insert(:auth_node, Authorization.prepare_node()) - |> Multi.insert(:spot, fn %{auth_node: auth_node} -> - %Benchmark.SpotModel{} - |> Benchmark.SpotModel.changeset(%{name: displayname}) - |> Changeset.put_assoc(:auth_node, auth_node) - |> Changeset.put_assoc(:tool, tool) - end) - |> Multi.run(:assign_role, fn _, %{spot: spot} -> - {:ok, Authorization.assign_role(user, spot, :owner)} - end) - |> Repo.transaction() - end - - def create_spot!(tool_id, user) do - case create_spot(tool_id, user) do - {:ok, %{spot: spot}} -> spot - _ -> nil - end - end - def create_submission(%Changeset{} = changeset) do changeset |> Repo.insert( @@ -123,16 +82,14 @@ defmodule Systems.Benchmark.Public do end) end - def import_csv_lines(csv_lines, tool_id) when is_integer(tool_id) do - tool = get_tool!(tool_id) - + def import_csv_lines(csv_lines) do csv_lines |> Enum.filter(&(Map.get(&1, "status") == "success")) |> Enum.map(&parse_entry/1) - |> Benchmark.Public.import_entries(tool) + |> Benchmark.Public.import_entries() end - def import_entries(entries, %Benchmark.ToolModel{} = tool) when is_list(entries) do + def import_entries(entries) when is_list(entries) do names = entries |> List.first(%{scores: []}) @@ -140,14 +97,14 @@ defmodule Systems.Benchmark.Public do |> Enum.map(& &1.name) Multi.new() - |> prepare_leaderboards(tool, names) + |> prepare_leaderboards(names) |> prepare_leaderboard_entries(entries) |> Repo.transaction() end - defp prepare_leaderboards(multi, _, []), do: multi + defp prepare_leaderboards(multi, []), do: multi - defp prepare_leaderboards(multi, tool, names) when is_list(names) do + defp prepare_leaderboards(multi, names) when is_list(names) do date = Timestamp.format_user_input_date(Timestamp.now()) multi = @@ -156,14 +113,13 @@ defmodule Systems.Benchmark.Public do {:ok, "#{date}_#{count + 1}"} end) - Enum.reduce(names, multi, &prepare_leaderboard(&2, &1, tool)) + Enum.reduce(names, multi, &prepare_leaderboard(&2, &1)) end - defp prepare_leaderboard(multi, name, tool) when is_binary(name) do + defp prepare_leaderboard(multi, name) when is_binary(name) do Multi.insert(multi, {:leaderboard, name}, fn %{version: version} -> %Benchmark.LeaderboardModel{} |> Benchmark.LeaderboardModel.changeset(%{name: name, version: version}) - |> Ecto.Changeset.put_assoc(:tool, tool) end) end @@ -194,40 +150,9 @@ defmodule Systems.Benchmark.Public do end) end - def list_spots_for_tool(user, tool_id, preload \\ []) do - node_ids = - Authorization.query_node_ids( - role: :owner, - principal: user - ) - - from(spot in Benchmark.SpotModel, - where: spot.tool_id == ^tool_id, - where: spot.auth_node_id in subquery(node_ids), - preload: ^preload - ) - |> Repo.all() - end - - def list_spots(user, preload \\ []) do - node_ids = - Authorization.query_node_ids( - role: :owner, - principal: user - ) - - from(spot in Benchmark.SpotModel, - where: spot.auth_node_id in subquery(node_ids), - preload: ^preload - ) - |> Repo.all() - end - def list_submissions(tool_id, preload \\ []) do from(submission in Benchmark.SubmissionModel, - join: spot in Benchmark.SpotModel, - on: spot.id == submission.spot_id, - where: spot.tool_id == ^tool_id, + where: submission.tool_id == ^tool_id, preload: ^preload ) |> Repo.all() diff --git a/core/systems/benchmark/export_controller.ex b/core/systems/benchmark/export_controller.ex index 5af6289a0..1889735a1 100644 --- a/core/systems/benchmark/export_controller.ex +++ b/core/systems/benchmark/export_controller.ex @@ -32,8 +32,11 @@ defmodule Systems.Benchmark.ExportController do id: submission_id, description: description, github_commit_url: github_commit_url, - spot: %{name: name} + auth_node: _auth_node }) do + # TODO: fetch name of collab out of auth_node + name = "Team-Unknown" + id = "#{submission_id}:#{name}:#{description}" case Regex.run(@extract_owner_repo_and_ref, github_commit_url) do diff --git a/core/systems/benchmark/leaderboard_model.ex b/core/systems/benchmark/leaderboard_model.ex index 2cd28313e..216f74010 100644 --- a/core/systems/benchmark/leaderboard_model.ex +++ b/core/systems/benchmark/leaderboard_model.ex @@ -11,7 +11,6 @@ defmodule Systems.Benchmark.LeaderboardModel do schema "benchmark_leaderboards" do field(:name, :string) field(:version, :string) - belongs_to(:tool, Benchmark.ToolModel) has_many(:scores, Benchmark.ScoreModel, foreign_key: :leaderboard_id) timestamps() diff --git a/core/systems/benchmark/leaderboard_overview.ex b/core/systems/benchmark/leaderboard_overview.ex index 2a6bd7e85..9400d6c28 100644 --- a/core/systems/benchmark/leaderboard_overview.ex +++ b/core/systems/benchmark/leaderboard_overview.ex @@ -6,8 +6,8 @@ defmodule Systems.Benchmark.LeaderboardOverview do } @impl true - def update(%{csv_lines: csv_lines}, %{assigns: %{entity: %{id: tool_id}}} = socket) do - Benchmark.Public.import_csv_lines(csv_lines, tool_id) + def update(%{csv_lines: csv_lines}, socket) do + Benchmark.Public.import_csv_lines(csv_lines) { :ok, diff --git a/core/systems/benchmark/spot_form.ex b/core/systems/benchmark/spot_form.ex deleted file mode 100644 index 7038e8dc1..000000000 --- a/core/systems/benchmark/spot_form.ex +++ /dev/null @@ -1,67 +0,0 @@ -defmodule Systems.Benchmark.SpotForm do - use CoreWeb.LiveForm - - alias Systems.{ - Benchmark - } - - # Handle initial update - @impl true - def update( - %{id: id, spot_id: spot_id}, - socket - ) do - spot = Benchmark.Public.get_spot!(spot_id) - changeset = Benchmark.SpotModel.changeset(spot, %{}) - - { - :ok, - socket - |> assign( - id: id, - entity: spot, - changeset: changeset - ) - } - end - - # Handle Events - @impl true - def handle_event("close", _params, socket) do - send(self(), %{module: __MODULE__, action: :update}) - {:noreply, socket} - end - - # Handle Events - @impl true - def handle_event("save", %{"spot_model" => attrs}, %{assigns: %{entity: entity}} = socket) do - { - :noreply, - socket - |> save(entity, attrs) - } - end - - # Saving - - def save(socket, entity, attrs) do - changeset = Benchmark.SpotModel.changeset(entity, attrs) - - socket - |> save(changeset) - end - - @impl true - def render(assigns) do - ~H""" -
- <%= dgettext("eyra-benchmark", "spot.form.title") %> - <%= dgettext("eyra-benchmark", "spot.form.description") %> - <.spacing value="XS" /> - <.form id={@id} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > - <.text_input form={form} field={:name} label_text={dgettext("eyra-benchmark", "spot.form.name")} /> - -
- """ - end -end diff --git a/core/systems/benchmark/spot_model.ex b/core/systems/benchmark/spot_model.ex deleted file mode 100644 index ac8b15c0a..000000000 --- a/core/systems/benchmark/spot_model.ex +++ /dev/null @@ -1,135 +0,0 @@ -defmodule Systems.Benchmark.SpotModel do - use Ecto.Schema - use Frameworks.Utility.Schema - - import Ecto.Changeset - - alias Systems.{ - Benchmark - } - - schema "benchmark_spots" do - field(:name, :string, default: "") - has_many(:submissions, Benchmark.SubmissionModel, foreign_key: :spot_id) - belongs_to(:tool, Benchmark.ToolModel) - belongs_to(:auth_node, Core.Authorization.Node) - - timestamps() - end - - @fields ~w(name)a - @required_fields ~w()a - - def changeset(tool, params) do - tool - |> cast(params, @fields) - |> validate_required(@required_fields) - end - - def preload_graph(:down), - do: - preload_graph([ - :auth_node, - :submissions - ]) - - def preload_graph(:tool), do: [tool: []] - def preload_graph(:auth_node), do: [auth_node: []] - - def preload_graph(:submissions), - do: [submissions: Benchmark.SubmissionModel.preload_graph(:down)] - - defimpl Frameworks.GreenLight.AuthorizationNode do - def id(spot), do: spot.auth_node_id - end - - defimpl Frameworks.Utility.ViewModelBuilder do - use CoreWeb, :verified_routes - - import CoreWeb.Gettext - - @max_submissions 3 - - def view_model(%Benchmark.SpotModel{} = spot, page, %{active?: active?, myself: target}) do - vm(spot, page, target, active?) - end - - defp vm(%{submissions: submissions}, Systems.Benchmark.SubmissionListForm, target, active?) do - items = Enum.map(submissions, &map_to_item(&1, target, active?)) - - add_button = - if active? and Enum.count(submissions) < @max_submissions do - %{ - action: %{type: :send, event: "add"}, - face: %{type: :primary, label: dgettext("eyra-benchmark", "add.submission.button")} - } - else - nil - end - - subhead = - if active? do - dgettext("eyra-benchmark", "submissions.subhead.active") - else - dgettext("eyra-benchmark", "submissions.subhead.inactive") - end - - %{ - title: dgettext("eyra-benchmark", "submissions.title"), - intro: dgettext("eyra-benchmark", "submissions.intro"), - subhead: subhead, - add_button: add_button, - items: items - } - end - - defp map_to_item( - %{ - id: id, - description: description, - updated_at: updated_at, - github_commit_url: github_commit_url - }, - target, - active? - ) do - summary = - updated_at - |> CoreWeb.UI.Timestamp.apply_timezone() - |> CoreWeb.UI.Timestamp.humanize() - |> Macro.camelize() - - buttons = - if active? do - [ - edit_button(id, target), - remove_button(id, target) - ] - else - [] - end - - %{ - id: id, - description: description, - summary: summary, - url: github_commit_url, - buttons: buttons - } - end - - defp edit_button(id, target) do - %{ - action: %{type: :send, item: id, target: target, event: "edit"}, - face: %{type: :icon, icon: :edit} - } - end - - defp remove_button(id, target) do - %{ - action: %{type: :send, item: id, target: target, event: "remove"}, - face: %{type: :icon, icon: :remove} - } - end - end -end diff --git a/core/systems/benchmark/submission_list_form.ex b/core/systems/benchmark/submission_list_form.ex index addd695ec..d74596751 100644 --- a/core/systems/benchmark/submission_list_form.ex +++ b/core/systems/benchmark/submission_list_form.ex @@ -1,11 +1,7 @@ defmodule Systems.Benchmark.SubmissionListForm do use CoreWeb, :live_component - alias Frameworks.Utility.ViewModelBuilder - - alias Systems.{ - Benchmark - } + alias Systems.Benchmark @impl true def update(%{action: :close}, socket) do @@ -14,52 +10,39 @@ defmodule Systems.Benchmark.SubmissionListForm do { :ok, socket - |> update_spot() |> update_vm() } end @impl true - def update(%{id: id, spot_id: spot_id, active?: active?}, socket) do + def update(%{id: id, active?: active?}, socket) do { :ok, socket |> assign( id: id, - spot_id: spot_id, active?: active? ) - |> update_spot() |> update_vm() } end - defp update_spot(%{assigns: %{spot_id: spot_id}} = socket) do - spot = - Benchmark.Public.get_spot!( - String.to_integer(spot_id), - Benchmark.SpotModel.preload_graph(:down) - ) - - socket |> assign(spot: spot) - end - - defp update_vm(%{assigns: %{spot: spot}} = socket) do - vm = ViewModelBuilder.view_model(spot, __MODULE__, socket.assigns) - socket |> assign(vm: vm) + defp update_vm(socket) do + # TODO: PreRef + socket end @impl true - def handle_event("add", _params, %{assigns: %{spot: spot, id: id}} = socket) do - popup = %{ - id: :submission_form, - module: Benchmark.SubmissionForm, - spot: spot, - submission: %Benchmark.SubmissionModel{}, - parent: %{type: __MODULE__, id: id} - } + def handle_event("add", _params, socket) do + # popup = %{ + # id: :submission_form, + # module: Benchmark.SubmissionForm, + # spot: spot, + # submission: %Benchmark.SubmissionModel{}, + # parent: %{type: __MODULE__, id: id} + # } - send(self(), {:show_popup, popup}) + # send(self(), {:show_popup, popup}) { :noreply, @@ -70,20 +53,20 @@ defmodule Systems.Benchmark.SubmissionListForm do @impl true def handle_event( "edit", - %{"item" => item_id}, - %{assigns: %{id: id, spot: %{submissions: submissions} = spot}} = socket + %{"item" => _item_id}, + socket ) do - if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do - popup = %{ - id: :submission_form, - module: Benchmark.SubmissionForm, - spot: spot, - submission: submission, - parent: %{type: __MODULE__, id: id} - } - - send(self(), {:show_popup, popup}) - end + # if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do + # popup = %{ + # id: :submission_form, + # module: Benchmark.SubmissionForm, + # spot: spot, + # submission: submission, + # parent: %{type: __MODULE__, id: id} + # } + + # send(self(), {:show_popup, popup}) + # end { :noreply, @@ -94,17 +77,16 @@ defmodule Systems.Benchmark.SubmissionListForm do @impl true def handle_event( "remove", - %{"item" => item_id}, - %{assigns: %{spot: %{submissions: submissions}}} = socket + %{"item" => _item_id}, + socket ) do - if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do - Benchmark.Public.delete(submission) - end + # if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do + # Benchmark.Public.delete(submission) + # end { :noreply, socket - |> update_spot() |> update_vm() } end diff --git a/core/systems/benchmark/submission_model.ex b/core/systems/benchmark/submission_model.ex index e4c3d4916..28708063e 100644 --- a/core/systems/benchmark/submission_model.ex +++ b/core/systems/benchmark/submission_model.ex @@ -5,14 +5,13 @@ defmodule Systems.Benchmark.SubmissionModel do import CoreWeb.Gettext import Ecto.Changeset - alias Systems.{ - Benchmark - } + alias Systems.Benchmark schema "benchmark_submissions" do field(:description, :string) field(:github_commit_url, :string) - belongs_to(:spot, Benchmark.SpotModel) + belongs_to(:tool, Benchmark.ToolModel) + belongs_to(:auth_node, Core.Authorization.Node) timestamps() end diff --git a/core/systems/benchmark/tool_controller.ex b/core/systems/benchmark/tool_controller.ex index d3810c466..020fe93aa 100644 --- a/core/systems/benchmark/tool_controller.ex +++ b/core/systems/benchmark/tool_controller.ex @@ -1,23 +1,23 @@ defmodule Systems.Benchmark.ToolController do use CoreWeb, :controller - alias Systems.{ - Benchmark - } + def ensure_spot(%{assigns: %{current_user: _user}} = conn, %{"id" => _id}) do + # TODO: PreRef - def ensure_spot(%{assigns: %{current_user: user}} = conn, %{"id" => id}) do - id = String.to_integer(id) + # id = String.to_integer(id) - spot = - if spot = List.first(Benchmark.Public.list_spots_for_tool(user, id)) do - spot - else - Benchmark.Public.create_spot!(id, user) - end + # spot = + # if spot = List.first(Benchmark.Public.list_spots_for_tool(user, id)) do + # spot + # else + # Benchmark.Public.create_spot!(id, user) + # end - path = ~p"/benchmark/#{id}/#{spot.id}" + # path = ~p"/benchmark/#{id}/#{spot.id}" + + # conn + # |> redirect(to: path) conn - |> redirect(to: path) end end diff --git a/core/systems/benchmark/tool_model.ex b/core/systems/benchmark/tool_model.ex index a199cc69c..00bf89718 100644 --- a/core/systems/benchmark/tool_model.ex +++ b/core/systems/benchmark/tool_model.ex @@ -8,26 +8,17 @@ defmodule Systems.Benchmark.ToolModel do import Ecto.Changeset import CoreWeb.Gettext - alias Systems.{ - Benchmark - } + alias Systems.Benchmark schema "benchmark_tools" do - field(:status, Ecto.Enum, values: Benchmark.ToolStatus.values()) - field(:title, :string) - field(:expectations, :string) - field(:data_set, :string) - field(:template_repo, :string) - field(:deadline, :string) - field(:director, Ecto.Enum, values: [:project, :assignment]) + field(:max_submissions, :integer) belongs_to(:auth_node, Core.Authorization.Node) - has_many(:spots, Benchmark.SpotModel, foreign_key: :tool_id) - has_many(:leaderboards, Benchmark.LeaderboardModel, foreign_key: :tool_id) + has_many(:submissions, Benchmark.SubmissionModel, foreign_key: :tool_id) timestamps() end - @fields ~w(status title expectations data_set template_repo deadline director)a + @fields ~w(max_submissions)a @required_fields @fields def changeset(tool, params) do @@ -43,13 +34,14 @@ defmodule Systems.Benchmark.ToolModel do def preload_graph(:down), do: preload_graph([ - :auth_node, - :spots, - :leaderboards + :submissions, + :auth_node ]) def preload_graph(:auth_node), do: [auth_node: []] - def preload_graph(:spots), do: [spots: Benchmark.SpotModel.preload_graph(:down)] + + def preload_graph(:submissions), + do: [submissions: Benchmark.SubmissionModel.preload_graph(:down)] def preload_graph(:leaderboards), do: [leaderboards: Benchmark.LeaderboardModel.preload_graph(:down)] diff --git a/core/systems/benchmark/tool_page.ex b/core/systems/benchmark/tool_page.ex index b72fca6c3..99779acba 100644 --- a/core/systems/benchmark/tool_page.ex +++ b/core/systems/benchmark/tool_page.ex @@ -12,15 +12,16 @@ defmodule Systems.Benchmark.ToolPage do Benchmark } - @impl true - def get_authorization_context(%{"id" => id, "spot" => spot_id}, _session, %{ - assigns: %{current_user: _user} - }) do - Benchmark.Public.get_spot_for_tool(String.to_integer(id), String.to_integer(spot_id)) - end + # @impl true + # def get_authorization_context(%{"id" => _id}, _session, %{ + # assigns: %{current_user: _user} + # }) do + # # TODO: PreFer use task as authorization context + # nil + # end @impl true - def mount(%{"id" => id, "spot" => spot_id}, _session, socket) do + def mount(%{"id" => id}, _session, socket) do model = Benchmark.Public.get_tool!(String.to_integer(id), Benchmark.ToolModel.preload_graph(:down)) @@ -29,7 +30,6 @@ defmodule Systems.Benchmark.ToolPage do socket |> assign( model: model, - spot_id: spot_id, popup: nil ) |> observe_view_model() @@ -116,8 +116,8 @@ defmodule Systems.Benchmark.ToolPage do <.spacing value="XL" /> - <.live_component {@vm.spot_form} /> - <.spacing value="L" /> + <%!-- <.live_component {@vm.spot_form} /> + <.spacing value="L" /> --%> <.live_component {@vm.submission_list_form} /> <.spacing value="XL" /> diff --git a/core/test/systems/benchmark/_public_test.exs b/core/test/systems/benchmark/_public_test.exs index 1f8c6aec6..c26a4ab68 100644 --- a/core/test/systems/benchmark/_public_test.exs +++ b/core/test/systems/benchmark/_public_test.exs @@ -6,9 +6,9 @@ defmodule Systems.Benchmark.PublicTest do } test "import_csv_lines/1 one line" do - %{id: toold_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id, description: description} = create_submission(spot) + name = "Team1" + tool = create_tool() + %{id: submission_id, description: description} = create_submission(tool) cat1 = "aap" cat2 = "noot" @@ -27,7 +27,7 @@ defmodule Systems.Benchmark.PublicTest do cat3 => "#{cat3_score}" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line], tool.id) + {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" cat2_score_key = "#{cat2}-#{submission_id}" @@ -40,16 +40,13 @@ defmodule Systems.Benchmark.PublicTest do assert %{ {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ - name: ^cat1, - tool_id: ^toold_id + name: ^cat1 }, {:leaderboard, ^cat2} => %Systems.Benchmark.LeaderboardModel{ - name: ^cat2, - tool_id: ^toold_id + name: ^cat2 }, {:leaderboard, ^cat3} => %Systems.Benchmark.LeaderboardModel{ - name: ^cat3, - tool_id: ^toold_id + name: ^cat3 }, {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ score: ^cat1_score, @@ -67,9 +64,9 @@ defmodule Systems.Benchmark.PublicTest do end test "import_csv_lines/1 one line with score `0`" do - %{id: toold_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id, description: description} = create_submission(spot) + name = "Team1" + tool = create_tool() + %{id: submission_id, description: description} = create_submission(tool) cat1 = "aap" @@ -80,7 +77,7 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "0" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line], tool.id) + {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" @@ -91,8 +88,7 @@ defmodule Systems.Benchmark.PublicTest do assert %{ {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ - name: ^cat1, - tool_id: ^toold_id + name: ^cat1 }, {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ score: 0.0, @@ -102,9 +98,9 @@ defmodule Systems.Benchmark.PublicTest do end test "import_csv_lines/1 one line with empty score" do - %{id: toold_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id, description: description} = create_submission(spot) + name = "Team1" + tool = create_tool() + %{id: submission_id, description: description} = create_submission(tool) cat1 = "aap" @@ -115,7 +111,7 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line], tool.id) + {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" @@ -126,8 +122,7 @@ defmodule Systems.Benchmark.PublicTest do assert %{ {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ - name: ^cat1, - tool_id: ^toold_id + name: ^cat1 }, {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ score: 0.0, @@ -137,10 +132,10 @@ defmodule Systems.Benchmark.PublicTest do end test "import_csv_lines/1 two lines two submissions" do - %{id: tool_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id1, description: description1} = create_submission(spot, "Method X") - %{id: submission_id2, description: description2} = create_submission(spot, "Method Y") + name = "Team1" + tool = create_tool() + %{id: submission_id1, description: description1} = create_submission(tool, "Method X") + %{id: submission_id2, description: description2} = create_submission(tool, "Method Y") csv_line1 = %{ "id" => "#{submission_id1}:#{name}:#{description1}", @@ -156,7 +151,7 @@ defmodule Systems.Benchmark.PublicTest do "cat1" => "0.2" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2], tool_id) + {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) assert Enum.count(Map.keys(result)) == 4 @@ -165,9 +160,9 @@ defmodule Systems.Benchmark.PublicTest do end test "import_csv_lines/1 two lines one submission should fail" do - %{id: tool_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id, description: description} = create_submission(spot, "Method X") + name = "Team1" + tool = create_tool() + %{id: submission_id, description: description} = create_submission(tool, "Method X") csv_line1 = %{ "id" => "#{submission_id}:#{name}:#{description}", @@ -184,15 +179,15 @@ defmodule Systems.Benchmark.PublicTest do } assert_raise RuntimeError, fn -> - Benchmark.Public.import_csv_lines([csv_line1, csv_line2], tool_id) + Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) end end test "import_csv_lines/1 ignore errors" do - %{id: tool_id} = tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id1, description: description1} = create_submission(spot, "Method X") - %{id: submission_id2, description: description2} = create_submission(spot, "Method Y") + name = "Team1" + tool = create_tool() + %{id: submission_id1, description: description1} = create_submission(tool, "Method X") + %{id: submission_id2, description: description2} = create_submission(tool, "Method Y") csv_line1 = %{ "id" => "#{submission_id1}:#{name}:#{description1}", @@ -208,15 +203,15 @@ defmodule Systems.Benchmark.PublicTest do "cat1" => "" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2], tool_id) + {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) assert Enum.count(Map.keys(result)) == 3 end test "import_csv_lines/1 two version after two imports" do + name = "Team1" tool = create_tool() - %{name: name} = spot = create_spot(tool) - %{id: submission_id, description: description} = create_submission(spot) + %{id: submission_id, description: description} = create_submission(tool) cat1 = "aap" @@ -227,8 +222,8 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "" } - {:ok, %{version: version1}} = Benchmark.Public.import_csv_lines([csv_line], tool.id) - {:ok, %{version: version2}} = Benchmark.Public.import_csv_lines([csv_line], tool.id) + {:ok, %{version: version1}} = Benchmark.Public.import_csv_lines([csv_line]) + {:ok, %{version: version2}} = Benchmark.Public.import_csv_lines([csv_line]) assert version1 < version2 @@ -237,16 +232,12 @@ defmodule Systems.Benchmark.PublicTest do end defp create_tool() do - Factories.insert!(:benchmark_tool, %{status: :concept, director: :project}) - end - - defp create_spot(tool, name \\ "Team Eyra") do - Factories.insert!(:benchmark_spot, %{tool: tool, name: name}) + Factories.insert!(:benchmark_tool, %{max_submissions: 3}) end - defp create_submission(spot, description \\ "Method X") do + defp create_submission(tool, description \\ "Method X") do submission_attr = %{ - spot: spot, + tool: tool, description: description, github_commit_url: "https://github.com/eyra/mono/commit/9d10bd2907dda135ebe86511489570dbf8c067c0" diff --git a/core/test/systems/benchmark/export_controller_test.exs b/core/test/systems/benchmark/export_controller_test.exs index fa87846f5..113948f71 100644 --- a/core/test/systems/benchmark/export_controller_test.exs +++ b/core/test/systems/benchmark/export_controller_test.exs @@ -6,19 +6,18 @@ defmodule Systems.Benchmark.ExportControllerTest do } test "export/1 with valid submission" do - tool = Factories.insert!(:benchmark_tool, %{status: :concept, director: :project}) - spot = Factories.insert!(:benchmark_spot, %{tool: tool, name: "Team Eyra"}) + tool = Factories.insert!(:benchmark_tool, %{max_submissions: 3}) %{id: id} = submission = Factories.insert!(:benchmark_submission, %{ - spot: spot, + tool: tool, description: "description", github_commit_url: "https://github.com/eyra/mono/commit/5405deccef0aa1a594cc09da99185860bc3e0cd2" }) - expected_id = "#{id}:#{spot.name}:#{submission.description}" + expected_id = "#{id}:Team-Unknown:#{submission.description}" assert %{ id: ^expected_id, @@ -28,19 +27,18 @@ defmodule Systems.Benchmark.ExportControllerTest do end test "export/1 with invalid submission" do - tool = Factories.insert!(:benchmark_tool, %{status: :concept, director: :project}) - spot = Factories.insert!(:benchmark_spot, %{tool: tool, name: "Team Eyra"}) + tool = Factories.insert!(:benchmark_tool, %{max_submissions: 3}) %{id: id} = submission = Factories.insert!(:benchmark_submission, %{ - spot: spot, + tool: tool, description: "description", github_commit_url: "https://github.com/eyra/mono/commit/5405deccef0aa1a594cc09da99185860bc3e0cd" }) - expected_id = "#{id}:#{spot.name}:#{submission.description}" + expected_id = "#{id}:Team-Unknown:#{submission.description}" assert %{ id: ^expected_id, diff --git a/core/test/systems/project/_assembly_test.exs b/core/test/systems/project/_assembly_test.exs index 23971acb0..0e4813025 100644 --- a/core/test/systems/project/_assembly_test.exs +++ b/core/test/systems/project/_assembly_test.exs @@ -23,16 +23,8 @@ defmodule Systems.Project.AssemblyTest do lab_tool: nil, feldspar_tool: nil, benchmark_tool: %Systems.Benchmark.ToolModel{ - status: :concept, - title: nil, - expectations: nil, - data_set: nil, - template_repo: nil, - deadline: nil, - director: :project, auth_node: %Core.Authorization.Node{}, - spots: [], - leaderboards: [] + submissions: [] } }, assignment: nil From b2a9ac570605b9638a42d88d996723f7fec483e9 Mon Sep 17 00:00:00 2001 From: Jan Bot Date: Mon, 18 Mar 2024 12:44:47 +0100 Subject: [PATCH 03/36] Name change for benchmark system to graphite Changes: - routes - models - database table names and indexes Issue - Graphite.ExportController.submissions l20 FIXME --- core/bundles/next/lib/console/page.ex | 2 +- core/bundles/self/lib/console/page.ex | 2 +- core/lib/core/authorization.ex | 6 +-- core/lib/core/factories.ex | 24 +++++----- ...318100531_rename_benchmark_to_graphite.exs | 43 +++++++++++++++++ core/systems/assignment/templates.ex | 2 +- core/systems/benchmark/_presenter.ex | 14 ------ core/systems/graphite/_presenter.ex | 14 ++++++ .../{benchmark => graphite}/_public.ex | 38 +++++++-------- .../{benchmark => graphite}/_routes.ex | 6 +-- .../{benchmark => graphite}/content_page.ex | 8 ++-- .../content_page_builder.ex | 14 +++--- .../export_controller.ex | 14 +++--- .../{benchmark => graphite}/import_form.ex | 2 +- .../leaderboard_category_view.ex | 2 +- .../leaderboard_model.ex | 10 ++-- .../leaderboard_overview.ex | 14 +++--- .../leaderboard_page.ex | 12 ++--- .../leaderboard_view.ex | 6 +-- .../{benchmark => graphite}/score_model.ex | 12 ++--- .../submission_form.ex | 16 +++---- .../submission_list_form.ex | 14 +++--- .../submission_model.ex | 8 ++-- .../submission_overview.ex | 10 ++-- .../submission_view.ex | 2 +- .../tool_controller.ex | 8 ++-- .../{benchmark => graphite}/tool_form.ex | 12 ++--- .../{benchmark => graphite}/tool_model.ex | 20 ++++---- .../{benchmark => graphite}/tool_page.ex | 6 +-- .../tool_page_builder.ex | 14 +++--- .../{benchmark => graphite}/tool_status.ex | 2 +- core/systems/project/_assembly.ex | 14 +++--- core/systems/project/_switch.ex | 2 +- core/systems/project/item_model.ex | 10 ++-- core/systems/project/item_templates.ex | 2 +- core/systems/project/tool_ref_model.ex | 14 +++--- core/systems/routes.ex | 2 +- core/systems/workflow/_public.ex | 4 +- core/test/core/authorization_test.exs | 6 +-- .../{benchmark => graphite}/_public_test.exs | 48 +++++++++---------- .../export_controller_test.exs | 16 +++---- core/test/systems/project/_assembly_test.exs | 6 +-- 42 files changed, 263 insertions(+), 218 deletions(-) create mode 100644 core/priv/repo/migrations/20240318100531_rename_benchmark_to_graphite.exs delete mode 100644 core/systems/benchmark/_presenter.ex create mode 100644 core/systems/graphite/_presenter.ex rename core/systems/{benchmark => graphite}/_public.ex (82%) rename core/systems/{benchmark => graphite}/_routes.ex (76%) rename core/systems/{benchmark => graphite}/content_page.ex (81%) rename core/systems/{benchmark => graphite}/content_page_builder.ex (94%) rename core/systems/{benchmark => graphite}/export_controller.ex (78%) rename core/systems/{benchmark => graphite}/import_form.ex (98%) rename core/systems/{benchmark => graphite}/leaderboard_category_view.ex (98%) rename core/systems/{benchmark => graphite}/leaderboard_model.ex (68%) rename core/systems/{benchmark => graphite}/leaderboard_overview.ex (86%) rename core/systems/{benchmark => graphite}/leaderboard_page.ex (82%) rename core/systems/{benchmark => graphite}/leaderboard_view.ex (94%) rename core/systems/{benchmark => graphite}/score_model.ex (57%) rename core/systems/{benchmark => graphite}/submission_form.ex (88%) rename core/systems/{benchmark => graphite}/submission_list_form.ex (85%) rename core/systems/{benchmark => graphite}/submission_model.ex (85%) rename core/systems/{benchmark => graphite}/submission_overview.ex (88%) rename core/systems/{benchmark => graphite}/submission_view.ex (96%) rename core/systems/{benchmark => graphite}/tool_controller.ex (55%) rename core/systems/{benchmark => graphite}/tool_form.ex (80%) rename core/systems/{benchmark => graphite}/tool_model.ex (77%) rename core/systems/{benchmark => graphite}/tool_page.ex (96%) rename core/systems/{benchmark => graphite}/tool_page_builder.ex (91%) rename core/systems/{benchmark => graphite}/tool_status.ex (58%) rename core/test/systems/{benchmark => graphite}/_public_test.exs (78%) rename core/test/systems/{benchmark => graphite}/export_controller_test.exs (70%) diff --git a/core/bundles/next/lib/console/page.ex b/core/bundles/next/lib/console/page.ex index 48ad3d0f9..6bc051941 100644 --- a/core/bundles/next/lib/console/page.ex +++ b/core/bundles/next/lib/console/page.ex @@ -94,7 +94,7 @@ defmodule Next.Console.Page do |> Macro.camelize() %{ - path: ~p"/benchmark/#{tool_id}/#{spot_id}", + path: ~p"/graphite/#{tool_id}/#{spot_id}", title: title, subtitle: "#{name}", tag: tag, diff --git a/core/bundles/self/lib/console/page.ex b/core/bundles/self/lib/console/page.ex index d5e05b923..5dd495ac0 100644 --- a/core/bundles/self/lib/console/page.ex +++ b/core/bundles/self/lib/console/page.ex @@ -94,7 +94,7 @@ defmodule Self.Console.Page do |> Macro.camelize() %{ - path: ~p"/benchmark/#{tool_id}/#{spot_id}", + path: ~p"/graphite/#{tool_id}/#{spot_id}", title: title, subtitle: "#{name}", tag: tag, diff --git a/core/lib/core/authorization.ex b/core/lib/core/authorization.ex index 305c3b76b..b63584ba6 100644 --- a/core/lib/core/authorization.ex +++ b/core/lib/core/authorization.ex @@ -55,9 +55,9 @@ defmodule Core.Authorization do grant_access(Systems.Test.Page, [:visitor, :member]) grant_access(Systems.Project.OverviewPage, [:admin, :researcher]) grant_access(Systems.Project.NodePage, [:researcher, :owner]) - grant_access(Systems.Benchmark.ContentPage, [:researcher, :owner]) - grant_access(Systems.Benchmark.ToolPage, [:owner]) - grant_access(Systems.Benchmark.LeaderboardPage, [:visitor, :member]) + grant_access(Systems.Graphite.ContentPage, [:researcher, :owner]) + grant_access(Systems.Graphite.ToolPage, [:owner]) + grant_access(Systems.Graphite.LeaderboardPage, [:visitor, :member]) grant_access(Systems.Feldspar.AppPage, [:visitor, :member]) grant_access(CoreWeb.User.Signin, [:visitor]) diff --git a/core/lib/core/factories.ex b/core/lib/core/factories.ex index 9ef5eeb0f..4a79b49bb 100644 --- a/core/lib/core/factories.ex +++ b/core/lib/core/factories.ex @@ -26,7 +26,7 @@ defmodule Core.Factories do Feldspar, Document, Lab, - Benchmark, + Graphite, Pool, Budget, Bookkeeping, @@ -241,12 +241,12 @@ defmodule Core.Factories do build(:submission, %{}) end - def build(:benchmark_submission) do - build(:benchmark_submission, %{description: "description"}) + def build(:graphite_submission) do + build(:graphite_submission, %{description: "description"}) end - def build(:benchmark_tool) do - build(:benchmark_tool, %{}) + def build(:graphite_tool) do + build(:graphite_tool, %{}) end def build(:workflow) do @@ -449,14 +449,14 @@ defmodule Core.Factories do {feldspar_tool, attributes} = get_optional(:feldspar_tool, attributes) {document_tool, attributes} = get_optional(:document_tool, attributes) {lab_tool, attributes} = get_optional(:lab_tool, attributes) - {benchmark_tool, attributes} = get_optional(:benchmark_tool, attributes) + {graphite_tool, attributes} = get_optional(:graphite_tool, attributes) %Project.ToolRefModel{ alliance_tool: alliance_tool, document_tool: document_tool, lab_tool: lab_tool, feldspar_tool: feldspar_tool, - benchmark_tool: benchmark_tool + graphite_tool: graphite_tool } |> struct!(attributes) end @@ -600,20 +600,20 @@ defmodule Core.Factories do |> struct!(attributes) end - def build(:benchmark_tool, %{} = attributes) do + def build(:graphite_tool, %{} = attributes) do {auth_node, attributes} = Map.pop(attributes, :auth_node, build(:auth_node)) - %Benchmark.ToolModel{ + %Graphite.ToolModel{ auth_node: auth_node } |> struct!(attributes) end - def build(:benchmark_submission, %{} = attributes) do - {tool, attributes} = Map.pop(attributes, :tool, build(:benchmark_tool)) + def build(:graphite_submission, %{} = attributes) do + {tool, attributes} = Map.pop(attributes, :tool, build(:graphite_tool)) {auth_node, attributes} = Map.pop(attributes, :auth_node, build(:auth_node)) - %Benchmark.SubmissionModel{ + %Graphite.SubmissionModel{ tool: tool, auth_node: auth_node } diff --git a/core/priv/repo/migrations/20240318100531_rename_benchmark_to_graphite.exs b/core/priv/repo/migrations/20240318100531_rename_benchmark_to_graphite.exs new file mode 100644 index 000000000..aedf248c3 --- /dev/null +++ b/core/priv/repo/migrations/20240318100531_rename_benchmark_to_graphite.exs @@ -0,0 +1,43 @@ +defmodule Core.Repo.Migrations.RenameBenchmarkToGraphite do + use Ecto.Migration + + def up do + rename(table(:tool_refs), :benchmark_tool_id, to: :graphite_tool_id) + + rename(table(:benchmark_leaderboards), to: table(:graphite_leaderboards)) + execute("ALTER INDEX benchmark_leaderboards_pkey RENAME TO graphite_leaderboards_pkey") + + execute( + "ALTER INDEX benchmark_leaderboards_name_version_index RENAME TO graphite_leaderboards_name_version_index" + ) + + rename(table(:benchmark_scores), to: table(:graphite_scores)) + execute("ALTER INDEX benchmark_scores_pkey RENAME TO graphite_scores_pkey") + + rename(table(:benchmark_submissions), to: table(:graphite_submissions)) + execute("ALTER INDEX benchmark_submissions_pkey RENAME TO graphite_submissions_pkey") + + rename(table(:benchmark_tools), to: table(:graphite_tools)) + execute("ALTER INDEX benchmark_tools_pkey RENAME TO graphite_tools_pkey") + end + + def down do + rename(table(:tool_refs), :graphite_tool_id, to: :benchmark_tool_id) + + rename(table(:graphite_leaderboards), to: table(:benchmark_leaderboards)) + execute("ALTER INDEX graphite_leaderboards_pkey RENAME TO benchmark_leaderboards_pkey") + + execute( + "ALTER INDEX graphite_leaderboards_name_version_index RENAME TO benchmark_leaderboards_name_version_index" + ) + + rename(table(:graphite_scores), to: table(:benchmark_scores)) + execute("ALTER INDEX graphite_scores_pkey RENAME TO benchmark_scores_pkey") + + rename(table(:graphite_submissions), to: table(:benchmark_submissions)) + execute("ALTER INDEX graphite_submissions_pkey RENAME TO benchmark_submissions_pkey") + + rename(table(:graphite_tools), to: table(:benchmark_tools)) + execute("ALTER INDEX graphite_tools_pkey RENAME TO benchmark_tools_pkey") + end +end diff --git a/core/systems/assignment/templates.ex b/core/systems/assignment/templates.ex index 928790988..0df5d98b3 100644 --- a/core/systems/assignment/templates.ex +++ b/core/systems/assignment/templates.ex @@ -3,5 +3,5 @@ defmodule Systems.Assignment.Templates do Defines different templates used by Systems.Assignment.Assembly to initialize specials. """ use Core.Enums.Base, - {:templates, [:online, :lab, :data_donation, :benchmark]} + {:templates, [:online, :lab, :data_donation, :graphite]} end diff --git a/core/systems/benchmark/_presenter.ex b/core/systems/benchmark/_presenter.ex deleted file mode 100644 index d42e11579..000000000 --- a/core/systems/benchmark/_presenter.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Systems.Benchmark.Presenter do - @behaviour Frameworks.Concept.Presenter - - alias Systems.{ - Benchmark - } - - @impl true - def view_model(page, %Benchmark.ToolModel{} = tool, assigns) do - builder(page).view_model(tool, assigns) - end - - defp builder(Benchmark.ToolPage), do: Benchmark.ToolPageBuilder -end diff --git a/core/systems/graphite/_presenter.ex b/core/systems/graphite/_presenter.ex new file mode 100644 index 000000000..61e613d21 --- /dev/null +++ b/core/systems/graphite/_presenter.ex @@ -0,0 +1,14 @@ +defmodule Systems.Graphite.Presenter do + @behaviour Frameworks.Concept.Presenter + + alias Systems.{ + Graphite + } + + @impl true + def view_model(page, %Graphite.ToolModel{} = tool, assigns) do + builder(page).view_model(tool, assigns) + end + + defp builder(Graphite.ToolPage), do: Graphite.ToolPageBuilder +end diff --git a/core/systems/benchmark/_public.ex b/core/systems/graphite/_public.ex similarity index 82% rename from core/systems/benchmark/_public.ex rename to core/systems/graphite/_public.ex index 26def26b7..bd75083e1 100644 --- a/core/systems/benchmark/_public.ex +++ b/core/systems/graphite/_public.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.Public do +defmodule Systems.Graphite.Public do import Ecto.Query, warn: false alias CoreWeb.UI.Timestamp @@ -6,24 +6,24 @@ defmodule Systems.Benchmark.Public do alias Ecto.Changeset alias Core.Repo - alias Systems.Benchmark + alias Systems.Graphite # FIXME: should come from CMS @main_category "f1_score" def get_tool!(id, preload \\ []) do - from(tool in Benchmark.ToolModel, preload: ^preload) + from(tool in Graphite.ToolModel, preload: ^preload) |> Repo.get!(id) end def get_submission!(id, preload \\ []) do - from(submission in Benchmark.SubmissionModel, preload: ^preload) + from(submission in Graphite.SubmissionModel, preload: ^preload) |> Repo.get!(id) end - def set_tool_status(%Benchmark.ToolModel{} = tool, status) do + def set_tool_status(%Graphite.ToolModel{} = tool, status) do tool - |> Benchmark.ToolModel.changeset(%{status: status}) + |> Graphite.ToolModel.changeset(%{status: status}) |> Repo.update!() end @@ -35,8 +35,8 @@ defmodule Systems.Benchmark.Public do def prepare_tool(%{} = attrs, auth_node \\ Core.Authorization.prepare_node()) do attrs = Map.put(attrs, :status, :concept) - %Benchmark.ToolModel{} - |> Benchmark.ToolModel.changeset(attrs) + %Graphite.ToolModel{} + |> Graphite.ToolModel.changeset(attrs) |> Changeset.put_assoc(:auth_node, auth_node) end @@ -86,7 +86,7 @@ defmodule Systems.Benchmark.Public do csv_lines |> Enum.filter(&(Map.get(&1, "status") == "success")) |> Enum.map(&parse_entry/1) - |> Benchmark.Public.import_entries() + |> Graphite.Public.import_entries() end def import_entries(entries) when is_list(entries) do @@ -109,7 +109,7 @@ defmodule Systems.Benchmark.Public do multi = Multi.run(multi, :version, fn _, _ -> - count = Benchmark.Public.count_leaderboard_versions() + count = Graphite.Public.count_leaderboard_versions() {:ok, "#{date}_#{count + 1}"} end) @@ -118,8 +118,8 @@ defmodule Systems.Benchmark.Public do defp prepare_leaderboard(multi, name) when is_binary(name) do Multi.insert(multi, {:leaderboard, name}, fn %{version: version} -> - %Benchmark.LeaderboardModel{} - |> Benchmark.LeaderboardModel.changeset(%{name: name, version: version}) + %Graphite.LeaderboardModel{} + |> Graphite.LeaderboardModel.changeset(%{name: name, version: version}) end) end @@ -143,15 +143,15 @@ defmodule Systems.Benchmark.Public do } -> submission = get_submission!(submission_id) - %Benchmark.ScoreModel{} - |> Benchmark.ScoreModel.changeset(%{score: score}) + %Graphite.ScoreModel{} + |> Graphite.ScoreModel.changeset(%{score: score}) |> Ecto.Changeset.put_assoc(:leaderboard, leaderboard) |> Ecto.Changeset.put_assoc(:submission, submission) end) end def list_submissions(tool_id, preload \\ []) do - from(submission in Benchmark.SubmissionModel, + from(submission in Graphite.SubmissionModel, where: submission.tool_id == ^tool_id, preload: ^preload ) @@ -160,14 +160,14 @@ defmodule Systems.Benchmark.Public do def list_leaderboard_categories(tool_id, preload \\ []) do max_version = - from(leaderboard in Benchmark.LeaderboardModel, + from(leaderboard in Graphite.LeaderboardModel, where: leaderboard.tool_id == ^tool_id, select: max(leaderboard.version) ) |> Repo.one() if max_version do - from(leaderboard in Benchmark.LeaderboardModel, + from(leaderboard in Graphite.LeaderboardModel, where: leaderboard.tool_id == ^tool_id, where: leaderboard.version == ^max_version, preload: ^preload @@ -184,7 +184,7 @@ defmodule Systems.Benchmark.Public do def count_leaderboard_versions() do list = - from(leaderboard in Benchmark.LeaderboardModel, + from(leaderboard in Graphite.LeaderboardModel, group_by: leaderboard.version, distinct: leaderboard.version, select: count("*") @@ -194,7 +194,7 @@ defmodule Systems.Benchmark.Public do Enum.count(list) end - def delete(%Benchmark.SubmissionModel{} = submission) do + def delete(%Graphite.SubmissionModel{} = submission) do Repo.delete(submission) end end diff --git a/core/systems/benchmark/_routes.ex b/core/systems/graphite/_routes.ex similarity index 76% rename from core/systems/benchmark/_routes.ex rename to core/systems/graphite/_routes.ex index 9dafc506c..0fa87fb7e 100644 --- a/core/systems/benchmark/_routes.ex +++ b/core/systems/graphite/_routes.ex @@ -1,7 +1,7 @@ -defmodule Systems.Benchmark.Routes do +defmodule Systems.Graphite.Routes do defmacro routes() do quote do - scope "/benchmark", Systems.Benchmark do + scope "/graphite", Systems.Graphite do pipe_through([:browser, :require_authenticated_user]) live("/:id/content", ContentPage) @@ -11,7 +11,7 @@ defmodule Systems.Benchmark.Routes do get("/:id/export/submissions", ExportController, :submissions) end - scope "/benchmark", Systems.Benchmark do + scope "/graphite", Systems.Graphite do pipe_through([:browser]) live("/:id/public/leaderboard", LeaderboardPage) end diff --git a/core/systems/benchmark/content_page.ex b/core/systems/graphite/content_page.ex similarity index 81% rename from core/systems/benchmark/content_page.ex rename to core/systems/graphite/content_page.ex index d49f5f0f4..2f011c505 100644 --- a/core/systems/benchmark/content_page.ex +++ b/core/systems/graphite/content_page.ex @@ -1,14 +1,14 @@ -defmodule Systems.Benchmark.ContentPage do +defmodule Systems.Graphite.ContentPage do use CoreWeb, :live_view use Systems.Content.Page alias Systems.{ - Benchmark + Graphite } @impl true def get_authorization_context(%{"id" => id}, _session, _socket) do - Benchmark.Public.get_tool!(id) + Graphite.Public.get_tool!(id) end @impl true @@ -16,7 +16,7 @@ defmodule Systems.Benchmark.ContentPage do initial_tab = Map.get(params, "tab") model = - Benchmark.Public.get_tool!(String.to_integer(id), Benchmark.ToolModel.preload_graph(:down)) + Graphite.Public.get_tool!(String.to_integer(id), Graphite.ToolModel.preload_graph(:down)) tabbar_id = "benchmark_content/#{id}" diff --git a/core/systems/benchmark/content_page_builder.ex b/core/systems/graphite/content_page_builder.ex similarity index 94% rename from core/systems/benchmark/content_page_builder.ex rename to core/systems/graphite/content_page_builder.ex index aa6427b73..f93aa5886 100644 --- a/core/systems/benchmark/content_page_builder.ex +++ b/core/systems/graphite/content_page_builder.ex @@ -1,8 +1,8 @@ -defmodule Systems.Benchmark.ContentPageBuilder do +defmodule Systems.Graphite.ContentPageBuilder do import CoreWeb.Gettext alias Systems.{ - Benchmark + Graphite } @tabs [:config, :invite, :submissions, :leaderboard] @@ -32,7 +32,7 @@ defmodule Systems.Benchmark.ContentPageBuilder do end defp action_map(%{id: id}) do - preview_action = %{type: :http_get, to: "/benchmark/#{id}", target: "_blank"} + preview_action = %{type: :http_get, to: "/graphite/#{id}", target: "_blank"} publish_action = %{type: :send, event: "action_click", item: :publish} retract_action = %{type: :send, event: "action_click", item: :retract} close_action = %{type: :send, event: "action_click", item: :close} @@ -142,7 +142,7 @@ defmodule Systems.Benchmark.ContentPageBuilder do end defp set_tool_status(%{assigns: %{vm: %{id: id}}} = socket, status) do - Benchmark.Public.set_tool_status(id, status) + Graphite.Public.set_tool_status(id, status) socket end @@ -165,7 +165,7 @@ defmodule Systems.Benchmark.ContentPageBuilder do title: dgettext("eyra-project", "tabbar.item.config"), forward_title: dgettext("eyra-project", "tabbar.item.config.forward"), type: :fullpage, - live_component: Benchmark.ToolForm, + live_component: Graphite.ToolForm, props: %{ entity: tool } @@ -187,7 +187,7 @@ defmodule Systems.Benchmark.ContentPageBuilder do title: dgettext("eyra-benchmark", "tabbar.item.submissions"), forward_title: dgettext("eyra-benchmark", "tabbar.item.submissions.forward"), type: :fullpage, - live_component: Benchmark.SubmissionOverview, + live_component: Graphite.SubmissionOverview, props: %{ entity: tool } @@ -209,7 +209,7 @@ defmodule Systems.Benchmark.ContentPageBuilder do title: dgettext("eyra-benchmark", "tabbar.item.leaderboard"), forward_title: dgettext("eyra-benchmark", "tabbar.item.leaderboard.forward"), type: :fullpage, - live_component: Benchmark.LeaderboardOverview, + live_component: Graphite.LeaderboardOverview, props: %{ entity: tool } diff --git a/core/systems/benchmark/export_controller.ex b/core/systems/graphite/export_controller.ex similarity index 78% rename from core/systems/benchmark/export_controller.ex rename to core/systems/graphite/export_controller.ex index 1889735a1..383d30a95 100644 --- a/core/systems/benchmark/export_controller.ex +++ b/core/systems/graphite/export_controller.ex @@ -1,23 +1,25 @@ -defmodule Systems.Benchmark.ExportController do +defmodule Systems.Graphite.ExportController do use CoreWeb, :controller alias Systems.{ - Benchmark + Graphite } @extract_owner_repo_and_ref ~r/https:\/\/github\.com\/(.*)\/commit\/([0-9a-f]{40})/ @github_url_template "git@github.com:${owner_repo}.git" def submissions(conn, %{"id" => id}) do - submissions = Benchmark.Public.list_submissions(id, [:spot]) + submissions = Graphite.Public.list_submissions(id, []) csv_data = export(submissions) - filename = "benchmark-#{id}-submissions.csv" + filename = "graphite-#{id}-submissions.csv" conn |> put_resp_content_type("text/csv") |> put_resp_header("content-disposition", "attachment; filename=\"#{filename}\"") - |> put_root_layout(false) + # FIXME: Figure out why this breaks + # Settings root layout breaks giving a return value + # |> put_root_layout(false) |> send_resp(200, csv_data) end @@ -28,7 +30,7 @@ defmodule Systems.Benchmark.ExportController do |> Enum.to_list() end - def export(%Benchmark.SubmissionModel{ + def export(%Graphite.SubmissionModel{ id: submission_id, description: description, github_commit_url: github_commit_url, diff --git a/core/systems/benchmark/import_form.ex b/core/systems/graphite/import_form.ex similarity index 98% rename from core/systems/benchmark/import_form.ex rename to core/systems/graphite/import_form.ex index 22edf477c..7e339da59 100644 --- a/core/systems/benchmark/import_form.ex +++ b/core/systems/graphite/import_form.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.ImportForm do +defmodule Systems.Graphite.ImportForm do use CoreWeb, :live_component use CoreWeb.FileUploader, accept: ~w(.csv) diff --git a/core/systems/benchmark/leaderboard_category_view.ex b/core/systems/graphite/leaderboard_category_view.ex similarity index 98% rename from core/systems/benchmark/leaderboard_category_view.ex rename to core/systems/graphite/leaderboard_category_view.ex index 2f0c7b1a4..a6e2954c7 100644 --- a/core/systems/benchmark/leaderboard_category_view.ex +++ b/core/systems/graphite/leaderboard_category_view.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.LeaderboardCategoryView do +defmodule Systems.Graphite.LeaderboardCategoryView do use CoreWeb, :html defp to_item(%{ diff --git a/core/systems/benchmark/leaderboard_model.ex b/core/systems/graphite/leaderboard_model.ex similarity index 68% rename from core/systems/benchmark/leaderboard_model.ex rename to core/systems/graphite/leaderboard_model.ex index 216f74010..588b46762 100644 --- a/core/systems/benchmark/leaderboard_model.ex +++ b/core/systems/graphite/leaderboard_model.ex @@ -1,17 +1,17 @@ -defmodule Systems.Benchmark.LeaderboardModel do +defmodule Systems.Graphite.LeaderboardModel do use Ecto.Schema use Frameworks.Utility.Schema import Ecto.Changeset alias Systems.{ - Benchmark + Graphite } - schema "benchmark_leaderboards" do + schema "graphite_leaderboards" do field(:name, :string) field(:version, :string) - has_many(:scores, Benchmark.ScoreModel, foreign_key: :leaderboard_id) + has_many(:scores, Graphite.ScoreModel, foreign_key: :leaderboard_id) timestamps() end @@ -31,7 +31,7 @@ defmodule Systems.Benchmark.LeaderboardModel do :scores ]) - def preload_graph(:scores), do: [scores: Benchmark.ScoreModel.preload_graph(:down)] + def preload_graph(:scores), do: [scores: Graphite.ScoreModel.preload_graph(:down)] defimpl Frameworks.GreenLight.AuthorizationNode do def id(leaderboard), do: leaderboard.auth_node_id diff --git a/core/systems/benchmark/leaderboard_overview.ex b/core/systems/graphite/leaderboard_overview.ex similarity index 86% rename from core/systems/benchmark/leaderboard_overview.ex rename to core/systems/graphite/leaderboard_overview.ex index 9400d6c28..38694dbd8 100644 --- a/core/systems/benchmark/leaderboard_overview.ex +++ b/core/systems/graphite/leaderboard_overview.ex @@ -1,13 +1,13 @@ -defmodule Systems.Benchmark.LeaderboardOverview do +defmodule Systems.Graphite.LeaderboardOverview do use CoreWeb, :live_component alias Systems.{ - Benchmark + Graphite } @impl true def update(%{csv_lines: csv_lines}, socket) do - Benchmark.Public.import_csv_lines(csv_lines) + Graphite.Public.import_csv_lines(csv_lines) { :ok, @@ -20,7 +20,7 @@ defmodule Systems.Benchmark.LeaderboardOverview do def update(%{id: id, entity: entity}, socket) do import_form = %{ id: :import_form, - module: Benchmark.ImportForm, + module: Graphite.ImportForm, parent: %{type: __MODULE__, id: id}, placeholder: dgettext("eyra-benchmark", "csv-select-placeholder"), select_button: dgettext("eyra-benchmark", "csv-select-file-button"), @@ -43,11 +43,11 @@ defmodule Systems.Benchmark.LeaderboardOverview do defp update_leaderboard(%{assigns: %{entity: %{id: tool_id}}} = socket) do categories = - Benchmark.Public.list_leaderboard_categories(tool_id, scores: [submission: [:spot]]) + Graphite.Public.list_leaderboard_categories(tool_id, scores: [submission: [:spot]]) leaderboard = %{ id: :leaderboard, - module: Benchmark.LeaderboardView, + module: Graphite.LeaderboardView, categories: categories } @@ -58,7 +58,7 @@ defmodule Systems.Benchmark.LeaderboardOverview do forward_button = %{ action: %{ type: :http_get, - to: ~p"/benchmark/#{tool_id}/public/leaderboard", + to: ~p"/graphite/#{tool_id}/public/leaderboard", target: "_blank" }, face: %{ diff --git a/core/systems/benchmark/leaderboard_page.ex b/core/systems/graphite/leaderboard_page.ex similarity index 82% rename from core/systems/benchmark/leaderboard_page.ex rename to core/systems/graphite/leaderboard_page.ex index 7716e4a13..5eda7ecc7 100644 --- a/core/systems/benchmark/leaderboard_page.ex +++ b/core/systems/graphite/leaderboard_page.ex @@ -1,11 +1,11 @@ -defmodule Systems.Benchmark.LeaderboardPage do +defmodule Systems.Graphite.LeaderboardPage do use CoreWeb, :live_view use CoreWeb.Layouts.Stripped.Component, :onboarding alias Frameworks.Pixel.Align alias Systems.{ - Benchmark + Graphite } @impl true @@ -21,13 +21,13 @@ defmodule Systems.Benchmark.LeaderboardPage do end defp update_title(%{assigns: %{id: tool_id}} = socket) do - %{title: title} = Benchmark.Public.get_tool!(tool_id) + %{title: title} = Graphite.Public.get_tool!(tool_id) assign(socket, title: title) end defp update_forward_button(%{assigns: %{id: tool_id}} = socket) do forward_button = %{ - action: %{type: :http_get, to: ~p"/benchmark/#{tool_id}"}, + action: %{type: :http_get, to: ~p"/graphite/#{tool_id}"}, face: %{ type: :plain, label: dgettext("eyra-benchmark", "challenge.forward.button"), @@ -40,11 +40,11 @@ defmodule Systems.Benchmark.LeaderboardPage do defp update_leaderboard(%{assigns: %{id: tool_id}} = socket) do categories = - Benchmark.Public.list_leaderboard_categories(tool_id, scores: [submission: [:spot]]) + Graphite.Public.list_leaderboard_categories(tool_id, scores: [submission: [:spot]]) leaderboard = %{ id: :leaderboard, - module: Benchmark.LeaderboardView, + module: Graphite.LeaderboardView, categories: categories } diff --git a/core/systems/benchmark/leaderboard_view.ex b/core/systems/graphite/leaderboard_view.ex similarity index 94% rename from core/systems/benchmark/leaderboard_view.ex rename to core/systems/graphite/leaderboard_view.ex index 17d04b46f..202140926 100644 --- a/core/systems/benchmark/leaderboard_view.ex +++ b/core/systems/graphite/leaderboard_view.ex @@ -1,14 +1,14 @@ -defmodule Systems.Benchmark.LeaderboardView do +defmodule Systems.Graphite.LeaderboardView do use CoreWeb, :live_component alias Frameworks.Pixel.Selector alias Frameworks.Pixel.Align alias Systems.{ - Benchmark + Graphite } - import Benchmark.LeaderboardCategoryView + import Graphite.LeaderboardCategoryView @impl true def update(%{active_item_id: active_item_id, selector_id: :leaderboard_category}, socket) do diff --git a/core/systems/benchmark/score_model.ex b/core/systems/graphite/score_model.ex similarity index 57% rename from core/systems/benchmark/score_model.ex rename to core/systems/graphite/score_model.ex index 9ad8523c3..13c826c7e 100644 --- a/core/systems/benchmark/score_model.ex +++ b/core/systems/graphite/score_model.ex @@ -1,17 +1,17 @@ -defmodule Systems.Benchmark.ScoreModel do +defmodule Systems.Graphite.ScoreModel do use Ecto.Schema use Frameworks.Utility.Schema import Ecto.Changeset alias Systems.{ - Benchmark + Graphite } - schema "benchmark_scores" do + schema "graphite_scores" do field(:score, :float) - belongs_to(:leaderboard, Benchmark.LeaderboardModel) - belongs_to(:submission, Benchmark.SubmissionModel) + belongs_to(:leaderboard, Graphite.LeaderboardModel) + belongs_to(:submission, Graphite.SubmissionModel) timestamps() end @@ -31,5 +31,5 @@ defmodule Systems.Benchmark.ScoreModel do :submission ]) - def preload_graph(:submission), do: [submission: Benchmark.SubmissionModel.preload_graph(:down)] + def preload_graph(:submission), do: [submission: Graphite.SubmissionModel.preload_graph(:down)] end diff --git a/core/systems/benchmark/submission_form.ex b/core/systems/graphite/submission_form.ex similarity index 88% rename from core/systems/benchmark/submission_form.ex rename to core/systems/graphite/submission_form.ex index bfbc855ee..9a824ae61 100644 --- a/core/systems/benchmark/submission_form.ex +++ b/core/systems/graphite/submission_form.ex @@ -1,8 +1,8 @@ -defmodule Systems.Benchmark.SubmissionForm do +defmodule Systems.Graphite.SubmissionForm do use CoreWeb.LiveForm alias Systems.{ - Benchmark + Graphite } # Handle initial update @@ -18,7 +18,7 @@ defmodule Systems.Benchmark.SubmissionForm do face: %{type: :primary, label: dgettext("eyra-benchmark", "submission.form.submit.button")} } - changeset = Benchmark.SubmissionModel.prepare(submission, %{}) + changeset = Graphite.SubmissionModel.prepare(submission, %{}) { :ok, @@ -60,8 +60,8 @@ defmodule Systems.Benchmark.SubmissionForm do ) do changeset = submission - |> Benchmark.SubmissionModel.change(attrs) - |> Benchmark.SubmissionModel.validate() + |> Graphite.SubmissionModel.change(attrs) + |> Graphite.SubmissionModel.validate() |> Ecto.Changeset.put_assoc(:spot, spot) socket |> upsert(changeset) @@ -70,14 +70,14 @@ defmodule Systems.Benchmark.SubmissionForm do defp handle_submit(%{assigns: %{submission: submission}} = socket, attrs) do changeset = submission - |> Benchmark.SubmissionModel.change(attrs) - |> Benchmark.SubmissionModel.validate() + |> Graphite.SubmissionModel.change(attrs) + |> Graphite.SubmissionModel.validate() socket |> upsert(changeset) end defp upsert(socket, changeset) do - case Benchmark.Public.create_submission(changeset) do + case Graphite.Public.create_submission(changeset) do {:ok, _submission} -> socket |> close() diff --git a/core/systems/benchmark/submission_list_form.ex b/core/systems/graphite/submission_list_form.ex similarity index 85% rename from core/systems/benchmark/submission_list_form.ex rename to core/systems/graphite/submission_list_form.ex index d74596751..073722d9b 100644 --- a/core/systems/benchmark/submission_list_form.ex +++ b/core/systems/graphite/submission_list_form.ex @@ -1,7 +1,7 @@ -defmodule Systems.Benchmark.SubmissionListForm do +defmodule Systems.Graphite.SubmissionListForm do use CoreWeb, :live_component - alias Systems.Benchmark + alias Systems.Graphite @impl true def update(%{action: :close}, socket) do @@ -36,9 +36,9 @@ defmodule Systems.Benchmark.SubmissionListForm do def handle_event("add", _params, socket) do # popup = %{ # id: :submission_form, - # module: Benchmark.SubmissionForm, + # module: Graphite.SubmissionForm, # spot: spot, - # submission: %Benchmark.SubmissionModel{}, + # submission: %Graphite.SubmissionModel{}, # parent: %{type: __MODULE__, id: id} # } @@ -59,7 +59,7 @@ defmodule Systems.Benchmark.SubmissionListForm do # if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do # popup = %{ # id: :submission_form, - # module: Benchmark.SubmissionForm, + # module: Graphite.SubmissionForm, # spot: spot, # submission: submission, # parent: %{type: __MODULE__, id: id} @@ -81,7 +81,7 @@ defmodule Systems.Benchmark.SubmissionListForm do socket ) do # if submission = Enum.find(submissions, &(&1.id == String.to_integer(item_id))) do - # Benchmark.Public.delete(submission) + # Graphite.Public.delete(submission) # end { @@ -100,7 +100,7 @@ defmodule Systems.Benchmark.SubmissionListForm do <%= @vm.subhead %> <.spacing value="M" /> - + <%= if @vm.add_button do %> <.spacing value="M" /> diff --git a/core/systems/benchmark/submission_model.ex b/core/systems/graphite/submission_model.ex similarity index 85% rename from core/systems/benchmark/submission_model.ex rename to core/systems/graphite/submission_model.ex index 28708063e..a4883aaf6 100644 --- a/core/systems/benchmark/submission_model.ex +++ b/core/systems/graphite/submission_model.ex @@ -1,16 +1,16 @@ -defmodule Systems.Benchmark.SubmissionModel do +defmodule Systems.Graphite.SubmissionModel do use Ecto.Schema use Frameworks.Utility.Schema import CoreWeb.Gettext import Ecto.Changeset - alias Systems.Benchmark + alias Systems.Graphite - schema "benchmark_submissions" do + schema "graphite_submissions" do field(:description, :string) field(:github_commit_url, :string) - belongs_to(:tool, Benchmark.ToolModel) + belongs_to(:tool, Graphite.ToolModel) belongs_to(:auth_node, Core.Authorization.Node) timestamps() diff --git a/core/systems/benchmark/submission_overview.ex b/core/systems/graphite/submission_overview.ex similarity index 88% rename from core/systems/benchmark/submission_overview.ex rename to core/systems/graphite/submission_overview.ex index 65c55e437..df0d453bd 100644 --- a/core/systems/benchmark/submission_overview.ex +++ b/core/systems/graphite/submission_overview.ex @@ -1,8 +1,8 @@ -defmodule Systems.Benchmark.SubmissionOverview do +defmodule Systems.Graphite.SubmissionOverview do use CoreWeb, :live_component alias Systems.{ - Benchmark + Graphite } @impl true @@ -24,7 +24,7 @@ defmodule Systems.Benchmark.SubmissionOverview do export_button = %{ action: %{ type: :http_get, - to: ~p"/benchmark/#{tool_id}/export/submissions", + to: ~p"/graphite/#{tool_id}/export/submissions", target: "_blank" }, face: %{type: :label, label: "Export", icon: :export} @@ -34,7 +34,7 @@ defmodule Systems.Benchmark.SubmissionOverview do end defp update_submissions(%{assigns: %{tool_id: tool_id}} = socket) do - submissions = Benchmark.Public.list_submissions(tool_id, [:spot]) + submissions = Graphite.Public.list_submissions(tool_id, [:spot]) assign(socket, submissions: submissions) end @@ -77,7 +77,7 @@ defmodule Systems.Benchmark.SubmissionOverview do
- + """ diff --git a/core/systems/benchmark/submission_view.ex b/core/systems/graphite/submission_view.ex similarity index 96% rename from core/systems/benchmark/submission_view.ex rename to core/systems/graphite/submission_view.ex index 524bd17f6..e4d9dd4a3 100644 --- a/core/systems/benchmark/submission_view.ex +++ b/core/systems/graphite/submission_view.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.SubmissionView do +defmodule Systems.Graphite.SubmissionView do use CoreWeb, :html attr(:items, :list, required: true) diff --git a/core/systems/benchmark/tool_controller.ex b/core/systems/graphite/tool_controller.ex similarity index 55% rename from core/systems/benchmark/tool_controller.ex rename to core/systems/graphite/tool_controller.ex index 020fe93aa..65662bf0e 100644 --- a/core/systems/benchmark/tool_controller.ex +++ b/core/systems/graphite/tool_controller.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.ToolController do +defmodule Systems.Graphite.ToolController do use CoreWeb, :controller def ensure_spot(%{assigns: %{current_user: _user}} = conn, %{"id" => _id}) do @@ -7,13 +7,13 @@ defmodule Systems.Benchmark.ToolController do # id = String.to_integer(id) # spot = - # if spot = List.first(Benchmark.Public.list_spots_for_tool(user, id)) do + # if spot = List.first(Graphite.Public.list_spots_for_tool(user, id)) do # spot # else - # Benchmark.Public.create_spot!(id, user) + # Graphite.Public.create_spot!(id, user) # end - # path = ~p"/benchmark/#{id}/#{spot.id}" + # path = ~p"/graphite/#{id}/#{spot.id}" # conn # |> redirect(to: path) diff --git a/core/systems/benchmark/tool_form.ex b/core/systems/graphite/tool_form.ex similarity index 80% rename from core/systems/benchmark/tool_form.ex rename to core/systems/graphite/tool_form.ex index cdfde7c81..e57158712 100644 --- a/core/systems/benchmark/tool_form.ex +++ b/core/systems/graphite/tool_form.ex @@ -1,8 +1,8 @@ -defmodule Systems.Benchmark.ToolForm do +defmodule Systems.Graphite.ToolForm do use CoreWeb.LiveForm alias Systems.{ - Benchmark + Graphite } # Handle initial update @@ -11,7 +11,7 @@ defmodule Systems.Benchmark.ToolForm do %{id: id, entity: benchmark}, socket ) do - changeset = Benchmark.ToolModel.changeset(benchmark, %{}) + changeset = Graphite.ToolModel.changeset(benchmark, %{}) { :ok, @@ -37,7 +37,7 @@ defmodule Systems.Benchmark.ToolForm do # Saving def save(socket, entity, attrs) do - changeset = Benchmark.ToolModel.changeset(entity, attrs) + changeset = Graphite.ToolModel.changeset(entity, attrs) socket |> save(changeset) @@ -45,7 +45,7 @@ defmodule Systems.Benchmark.ToolForm do end def validate(socket, changeset) do - changeset = Benchmark.ToolModel.validate(changeset) + changeset = Graphite.ToolModel.validate(changeset) socket |> assign(changeset: changeset) @@ -55,7 +55,7 @@ defmodule Systems.Benchmark.ToolForm do def render(assigns) do ~H"""
- <.form id={"#{@id}_benchmark_tool_form"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > + <.form id={"#{@id}_graphite_tool_form"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > <.text_input form={form} field={:title} label_text={dgettext("eyra-benchmark", "form.title.label")} /> <.text_area form={form} field={:expectations} label_text={dgettext("eyra-benchmark", "form.expectations.label")} /> <.url_input form={form} field={:data_set} label_text={dgettext("eyra-benchmark", "form.data_set.label")} /> diff --git a/core/systems/benchmark/tool_model.ex b/core/systems/graphite/tool_model.ex similarity index 77% rename from core/systems/benchmark/tool_model.ex rename to core/systems/graphite/tool_model.ex index 00bf89718..a21c5689b 100644 --- a/core/systems/benchmark/tool_model.ex +++ b/core/systems/graphite/tool_model.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.ToolModel do +defmodule Systems.Graphite.ToolModel do @moduledoc """ The benchmark tool schema. """ @@ -8,12 +8,12 @@ defmodule Systems.Benchmark.ToolModel do import Ecto.Changeset import CoreWeb.Gettext - alias Systems.Benchmark + alias Systems.Graphite - schema "benchmark_tools" do + schema "graphite_tools" do field(:max_submissions, :integer) belongs_to(:auth_node, Core.Authorization.Node) - has_many(:submissions, Benchmark.SubmissionModel, foreign_key: :tool_id) + has_many(:submissions, Graphite.SubmissionModel, foreign_key: :tool_id) timestamps() end @@ -41,10 +41,10 @@ defmodule Systems.Benchmark.ToolModel do def preload_graph(:auth_node), do: [auth_node: []] def preload_graph(:submissions), - do: [submissions: Benchmark.SubmissionModel.preload_graph(:down)] + do: [submissions: Graphite.SubmissionModel.preload_graph(:down)] def preload_graph(:leaderboards), - do: [leaderboards: Benchmark.LeaderboardModel.preload_graph(:down)] + do: [leaderboards: Graphite.LeaderboardModel.preload_graph(:down)] defimpl Frameworks.GreenLight.AuthorizationNode do def id(tool), do: tool.auth_node_id @@ -63,13 +63,13 @@ defmodule Systems.Benchmark.ToolModel do end defimpl Frameworks.Concept.ToolModel do - alias Systems.Benchmark - def key(_), do: :benchmark + alias Systems.Graphite + def key(_), do: :graphite def auth_tree(%{auth_node: auth_node}), do: auth_node def apply_label(_), do: dgettext("eyra-benchmark", "apply.cta.title") def open_label(_), do: dgettext("eyra-benchmark", "open.cta.title") - def ready?(tool), do: Benchmark.ToolModel.ready?(tool) - def form(_), do: Benchmark.Form + def ready?(tool), do: Graphite.ToolModel.ready?(tool) + def form(_), do: Graphite.Form def launcher(_), do: nil def task_labels(_) do diff --git a/core/systems/benchmark/tool_page.ex b/core/systems/graphite/tool_page.ex similarity index 96% rename from core/systems/benchmark/tool_page.ex rename to core/systems/graphite/tool_page.ex index 99779acba..fdd194e6c 100644 --- a/core/systems/benchmark/tool_page.ex +++ b/core/systems/graphite/tool_page.ex @@ -1,4 +1,4 @@ -defmodule Systems.Benchmark.ToolPage do +defmodule Systems.Graphite.ToolPage do use CoreWeb, :live_view use CoreWeb.Layouts.Stripped.Component, :projects use Systems.Observatory.Public @@ -9,7 +9,7 @@ defmodule Systems.Benchmark.ToolPage do } alias Systems.{ - Benchmark + Graphite } # @impl true @@ -23,7 +23,7 @@ defmodule Systems.Benchmark.ToolPage do @impl true def mount(%{"id" => id}, _session, socket) do model = - Benchmark.Public.get_tool!(String.to_integer(id), Benchmark.ToolModel.preload_graph(:down)) + Graphite.Public.get_tool!(String.to_integer(id), Graphite.ToolModel.preload_graph(:down)) { :ok, diff --git a/core/systems/benchmark/tool_page_builder.ex b/core/systems/graphite/tool_page_builder.ex similarity index 91% rename from core/systems/benchmark/tool_page_builder.ex rename to core/systems/graphite/tool_page_builder.ex index 392ba3c38..db3e1ff7d 100644 --- a/core/systems/benchmark/tool_page_builder.ex +++ b/core/systems/graphite/tool_page_builder.ex @@ -1,11 +1,11 @@ -defmodule Systems.Benchmark.ToolPageBuilder do +defmodule Systems.Graphite.ToolPageBuilder do use CoreWeb, :verified_routes import CoreWeb.Gettext alias CoreWeb.UI.Timestamp alias ExAws.S3 alias Systems.{ - Benchmark + Graphite } def view_model( @@ -49,26 +49,26 @@ defmodule Systems.Benchmark.ToolPageBuilder do spot_form = %{ id: :spot_form, - module: Benchmark.SpotForm, + module: Graphite.SpotForm, spot_id: spot_id } submission_list_form = %{ id: :submission_list_form, - module: Benchmark.SubmissionListForm, + module: Graphite.SubmissionListForm, spot_id: spot_id, active?: active? } categories = - Benchmark.Public.list_leaderboard_categories(tool.id, scores: [submission: [:spot]]) + Graphite.Public.list_leaderboard_categories(tool.id, scores: [submission: [:spot]]) leaderboard = if Enum.count(categories) > 0 do forward_button = %{ action: %{ type: :http_get, - to: ~p"/benchmark/#{tool.id}/public/leaderboard", + to: ~p"/graphite/#{tool.id}/public/leaderboard", target: "_blank" }, face: %{ @@ -83,7 +83,7 @@ defmodule Systems.Benchmark.ToolPageBuilder do forward_button: forward_button, component: %{ id: :leaderboard, - module: Benchmark.LeaderboardView, + module: Graphite.LeaderboardView, categories: categories } } diff --git a/core/systems/benchmark/tool_status.ex b/core/systems/graphite/tool_status.ex similarity index 58% rename from core/systems/benchmark/tool_status.ex rename to core/systems/graphite/tool_status.ex index 599eae564..db90dc845 100644 --- a/core/systems/benchmark/tool_status.ex +++ b/core/systems/graphite/tool_status.ex @@ -1,3 +1,3 @@ -defmodule Systems.Benchmark.ToolStatus do +defmodule Systems.Graphite.ToolStatus do def values, do: [:concept, :online, :offline, :idle] end diff --git a/core/systems/project/_assembly.ex b/core/systems/project/_assembly.ex index 5113f9a88..98b2321d0 100644 --- a/core/systems/project/_assembly.ex +++ b/core/systems/project/_assembly.ex @@ -10,7 +10,7 @@ defmodule Systems.Project.Assembly do alias Systems.{ Project, Assignment, - Benchmark + Graphite } def delete(%Project.Model{auth_node: %{id: node_id}}) do @@ -85,20 +85,20 @@ defmodule Systems.Project.Assembly do [prepare_item(:data_donation, "Data Donation Assignment")] end - defp prepare_items(:benchmark) do + defp prepare_items(:graphite) do [ - prepare_item(:benchmark, "Challenge Round 1"), - prepare_item(:benchmark, "Challenge Round 2") + prepare_item(:graphite, "Challenge Round 1"), + prepare_item(:graphite, "Challenge Round 2") ] end - defp prepare_item(:benchmark, name) do + defp prepare_item(:graphite, name) do {:ok, tool} = - Benchmark.Public.prepare_tool(%{title: "", director: :project}) + Graphite.Public.prepare_tool(%{title: "", director: :project}) |> Changeset.apply_action(:prepare) {:ok, tool_ref} = - Project.Public.prepare_tool_ref(:benchmark, :benchmark_tool, tool) + Project.Public.prepare_tool_ref(:graphite, :graphite_tool, tool) |> Changeset.apply_action(:prepare) Project.Public.prepare_item(%{name: name, project_path: []}, tool_ref) diff --git a/core/systems/project/_switch.ex b/core/systems/project/_switch.ex index b07a129f9..1133c7ec8 100644 --- a/core/systems/project/_switch.ex +++ b/core/systems/project/_switch.ex @@ -32,7 +32,7 @@ defmodule Systems.Project.Switch do end @impl true - def intercept({:benchmark_tool, _} = signal, %{benchmark_tool: tool} = message) do + def intercept({:graphite_tool, _} = signal, %{graphite_tool: tool} = message) do handle({:tool, signal}, Map.merge(message, %{tool: tool})) :ok end diff --git a/core/systems/project/item_model.ex b/core/systems/project/item_model.ex index 09e3b730b..3faeb6125 100644 --- a/core/systems/project/item_model.ex +++ b/core/systems/project/item_model.ex @@ -10,7 +10,7 @@ defmodule Systems.Project.ItemModel do alias Systems.{ Project, Assignment, - Benchmark + Graphite } schema "project_items" do @@ -134,9 +134,9 @@ defmodule Systems.Project.ItemModel do id: id, name: name, tool_ref: %{ - benchmark_tool: + graphite_tool: %{ - id: benchmark_id, + id: graphite_id, status: status, director: _director, spots: spots, @@ -148,7 +148,7 @@ defmodule Systems.Project.ItemModel do _user ) do tags = get_card_tags(tool) - path = ~p"/benchmark/#{benchmark_id}/content" + path = ~p"/graphite/#{graphite_id}/content" label = get_label(status) edit = %{ @@ -208,7 +208,7 @@ defmodule Systems.Project.ItemModel do ["Assignment"] end - defp get_card_tags(%Benchmark.ToolModel{}), do: ["Challenge"] + defp get_card_tags(%Graphite.ToolModel{}), do: ["Challenge"] defp get_card_tags(_), do: [] end end diff --git a/core/systems/project/item_templates.ex b/core/systems/project/item_templates.ex index c76a31666..04e05c7c0 100644 --- a/core/systems/project/item_templates.ex +++ b/core/systems/project/item_templates.ex @@ -1,3 +1,3 @@ defmodule Systems.Project.ItemTemplates do - use Core.Enums.Base, {:project_item_templates, [:benchmark, :data_donation]} + use Core.Enums.Base, {:project_item_templates, [:graphite, :data_donation]} end diff --git a/core/systems/project/tool_ref_model.ex b/core/systems/project/tool_ref_model.ex index 1934d4539..68a6f7f96 100644 --- a/core/systems/project/tool_ref_model.ex +++ b/core/systems/project/tool_ref_model.ex @@ -13,7 +13,7 @@ defmodule Systems.Project.ToolRefModel do Alliance, Lab, Feldspar, - Benchmark + Graphite } schema "tool_refs" do @@ -22,7 +22,7 @@ defmodule Systems.Project.ToolRefModel do belongs_to(:alliance_tool, Alliance.ToolModel) belongs_to(:lab_tool, Lab.ToolModel) belongs_to(:feldspar_tool, Feldspar.ToolModel) - belongs_to(:benchmark_tool, Benchmark.ToolModel) + belongs_to(:graphite_tool, Graphite.ToolModel) belongs_to(:document_tool, Document.ToolModel) has_one(:item, Project.ItemModel, foreign_key: :tool_ref_id) @@ -47,7 +47,7 @@ defmodule Systems.Project.ToolRefModel do :document_tool, :lab_tool, :feldspar_tool, - :benchmark_tool + :graphite_tool ]) def preload_graph(:alliance_tool), @@ -61,8 +61,8 @@ defmodule Systems.Project.ToolRefModel do def preload_graph(:feldspar_tool), do: [feldspar_tool: Feldspar.ToolModel.preload_graph(:down)] - def preload_graph(:benchmark_tool), - do: [benchmark_tool: Benchmark.ToolModel.preload_graph(:down)] + def preload_graph(:graphite_tool), + do: [graphite_tool: Graphite.ToolModel.preload_graph(:down)] def auth_tree(%Project.ToolRefModel{} = tool_ref) do Concept.ToolModel.auth_tree(tool(tool_ref)) @@ -83,12 +83,12 @@ defmodule Systems.Project.ToolRefModel do def tool(%{feldspar_tool: %{id: _id} = tool}), do: tool def tool(%{document_tool: %{id: _id} = tool}), do: tool def tool(%{lab_tool: %{id: _id} = tool}), do: tool - def tool(%{benchmark_tool: %{id: _id} = tool}), do: tool + def tool(%{graphite_tool: %{id: _id} = tool}), do: tool def tag(%Project.ToolRefModel{special: :questionnaire}), do: dgettext("eyra-project", "tool_ref.tag.questionnaire") - def tag(%Project.ToolRefModel{special: :benchmark}), + def tag(%Project.ToolRefModel{special: :graphite}), do: dgettext("eyra-project", "tool_ref.tag.benchmark") def tag(%Project.ToolRefModel{special: _special}) do diff --git a/core/systems/routes.ex b/core/systems/routes.ex index 5cd0fd3f7..83f53c9ed 100644 --- a/core/systems/routes.ex +++ b/core/systems/routes.ex @@ -13,7 +13,7 @@ defmodule Systems.Routes do :promotion, :pool, :lab, - :benchmark, + :graphite, :feldspar, :document, :alliance, diff --git a/core/systems/workflow/_public.ex b/core/systems/workflow/_public.ex index 6e72585f3..083c00e57 100644 --- a/core/systems/workflow/_public.ex +++ b/core/systems/workflow/_public.ex @@ -10,7 +10,7 @@ defmodule Systems.Workflow.Public do alias Systems.Alliance alias Systems.Feldspar alias Systems.Lab - alias Systems.Benchmark + alias Systems.Graphite alias Systems.Project def list_items(workflow, preload \\ []) @@ -115,7 +115,7 @@ defmodule Systems.Workflow.Public do defp prepare_tool(:document_tool, %{} = attrs), do: Document.Public.prepare_tool(attrs) defp prepare_tool(:feldspar_tool, %{} = attrs), do: Feldspar.Public.prepare_tool(attrs) defp prepare_tool(:lab_tool, %{} = attrs), do: Lab.Public.prepare_tool(attrs) - defp prepare_tool(:benchmark_tool, %{} = attrs), do: Benchmark.Public.prepare_tool(attrs) + defp prepare_tool(:graphite_tool, %{} = attrs), do: Graphite.Public.prepare_tool(attrs) def delete(%Workflow.ItemModel{workflow_id: workflow_id} = item) do Multi.new() diff --git a/core/test/core/authorization_test.exs b/core/test/core/authorization_test.exs index a4c524141..ab9f799dd 100644 --- a/core/test/core/authorization_test.exs +++ b/core/test/core/authorization_test.exs @@ -91,19 +91,19 @@ defmodule Core.AuthorizationTest do end test "can_access?/3 fail for entity == nil" do - assert Authorization.can_access?(%User{id: 1}, nil, Systems.Benchmark.ToolPage) == false + assert Authorization.can_access?(%User{id: 1}, nil, Systems.Graphite.ToolPage) == false end test "can_access?/3 fail for entity without roles" do {:ok, node_id} = Authorization.create_node() - assert Authorization.can_access?(%User{id: 1}, node_id, Systems.Benchmark.ToolPage) == false + assert Authorization.can_access?(%User{id: 1}, node_id, Systems.Graphite.ToolPage) == false end test "can_access?/3 succeeds for entity with suffient rights" do principal = %User{id: 1} {:ok, node_id} = Authorization.create_node() Authorization.assign_role(principal, node_id, :owner) - assert Authorization.can_access?(principal, node_id, Systems.Benchmark.ToolPage) == true + assert Authorization.can_access?(principal, node_id, Systems.Graphite.ToolPage) == true end test "link/1 succeeds tuple with parent/child" do diff --git a/core/test/systems/benchmark/_public_test.exs b/core/test/systems/graphite/_public_test.exs similarity index 78% rename from core/test/systems/benchmark/_public_test.exs rename to core/test/systems/graphite/_public_test.exs index c26a4ab68..5a6e636eb 100644 --- a/core/test/systems/benchmark/_public_test.exs +++ b/core/test/systems/graphite/_public_test.exs @@ -1,8 +1,8 @@ -defmodule Systems.Benchmark.PublicTest do +defmodule Systems.Graphite.PublicTest do use Core.DataCase alias Systems.{ - Benchmark + Graphite } test "import_csv_lines/1 one line" do @@ -27,7 +27,7 @@ defmodule Systems.Benchmark.PublicTest do cat3 => "#{cat3_score}" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) + {:ok, result} = Graphite.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" cat2_score_key = "#{cat2}-#{submission_id}" @@ -39,24 +39,24 @@ defmodule Systems.Benchmark.PublicTest do assert count_scores() == 3 assert %{ - {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ + {:leaderboard, ^cat1} => %Systems.Graphite.LeaderboardModel{ name: ^cat1 }, - {:leaderboard, ^cat2} => %Systems.Benchmark.LeaderboardModel{ + {:leaderboard, ^cat2} => %Systems.Graphite.LeaderboardModel{ name: ^cat2 }, - {:leaderboard, ^cat3} => %Systems.Benchmark.LeaderboardModel{ + {:leaderboard, ^cat3} => %Systems.Graphite.LeaderboardModel{ name: ^cat3 }, - {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ + {:score, ^cat1_score_key} => %Systems.Graphite.ScoreModel{ score: ^cat1_score, submission_id: ^submission_id }, - {:score, ^cat2_score_key} => %Systems.Benchmark.ScoreModel{ + {:score, ^cat2_score_key} => %Systems.Graphite.ScoreModel{ score: ^cat2_score, submission_id: ^submission_id }, - {:score, ^cat3_score_key} => %Systems.Benchmark.ScoreModel{ + {:score, ^cat3_score_key} => %Systems.Graphite.ScoreModel{ score: ^cat3_score, submission_id: ^submission_id } @@ -77,7 +77,7 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "0" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) + {:ok, result} = Graphite.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" @@ -87,10 +87,10 @@ defmodule Systems.Benchmark.PublicTest do assert count_scores() == 1 assert %{ - {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ + {:leaderboard, ^cat1} => %Systems.Graphite.LeaderboardModel{ name: ^cat1 }, - {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ + {:score, ^cat1_score_key} => %Systems.Graphite.ScoreModel{ score: 0.0, submission_id: ^submission_id } @@ -111,7 +111,7 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line]) + {:ok, result} = Graphite.Public.import_csv_lines([csv_line]) cat1_score_key = "#{cat1}-#{submission_id}" @@ -121,10 +121,10 @@ defmodule Systems.Benchmark.PublicTest do assert count_scores() == 1 assert %{ - {:leaderboard, ^cat1} => %Systems.Benchmark.LeaderboardModel{ + {:leaderboard, ^cat1} => %Systems.Graphite.LeaderboardModel{ name: ^cat1 }, - {:score, ^cat1_score_key} => %Systems.Benchmark.ScoreModel{ + {:score, ^cat1_score_key} => %Systems.Graphite.ScoreModel{ score: 0.0, submission_id: ^submission_id } @@ -151,7 +151,7 @@ defmodule Systems.Benchmark.PublicTest do "cat1" => "0.2" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) + {:ok, result} = Graphite.Public.import_csv_lines([csv_line1, csv_line2]) assert Enum.count(Map.keys(result)) == 4 @@ -179,7 +179,7 @@ defmodule Systems.Benchmark.PublicTest do } assert_raise RuntimeError, fn -> - Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) + Graphite.Public.import_csv_lines([csv_line1, csv_line2]) end end @@ -203,7 +203,7 @@ defmodule Systems.Benchmark.PublicTest do "cat1" => "" } - {:ok, result} = Benchmark.Public.import_csv_lines([csv_line1, csv_line2]) + {:ok, result} = Graphite.Public.import_csv_lines([csv_line1, csv_line2]) assert Enum.count(Map.keys(result)) == 3 end @@ -222,8 +222,8 @@ defmodule Systems.Benchmark.PublicTest do cat1 => "" } - {:ok, %{version: version1}} = Benchmark.Public.import_csv_lines([csv_line]) - {:ok, %{version: version2}} = Benchmark.Public.import_csv_lines([csv_line]) + {:ok, %{version: version1}} = Graphite.Public.import_csv_lines([csv_line]) + {:ok, %{version: version2}} = Graphite.Public.import_csv_lines([csv_line]) assert version1 < version2 @@ -232,7 +232,7 @@ defmodule Systems.Benchmark.PublicTest do end defp create_tool() do - Factories.insert!(:benchmark_tool, %{max_submissions: 3}) + Factories.insert!(:graphite_tool, %{max_submissions: 3}) end defp create_submission(tool, description \\ "Method X") do @@ -243,13 +243,13 @@ defmodule Systems.Benchmark.PublicTest do "https://github.com/eyra/mono/commit/9d10bd2907dda135ebe86511489570dbf8c067c0" } - Factories.insert!(:benchmark_submission, submission_attr) + Factories.insert!(:graphite_submission, submission_attr) end defp count_scores() do Repo.one( Ecto.Query.from( - score in Benchmark.ScoreModel, + score in Graphite.ScoreModel, select: count(score.id) ) ) @@ -258,7 +258,7 @@ defmodule Systems.Benchmark.PublicTest do defp count_leaderboards() do Repo.one( Ecto.Query.from( - leaderboard in Benchmark.LeaderboardModel, + leaderboard in Graphite.LeaderboardModel, select: count(leaderboard.id) ) ) diff --git a/core/test/systems/benchmark/export_controller_test.exs b/core/test/systems/graphite/export_controller_test.exs similarity index 70% rename from core/test/systems/benchmark/export_controller_test.exs rename to core/test/systems/graphite/export_controller_test.exs index 113948f71..b16df0531 100644 --- a/core/test/systems/benchmark/export_controller_test.exs +++ b/core/test/systems/graphite/export_controller_test.exs @@ -1,16 +1,16 @@ -defmodule Systems.Benchmark.ExportControllerTest do +defmodule Systems.Graphite.ExportControllerTest do use Core.DataCase alias Systems.{ - Benchmark + Graphite } test "export/1 with valid submission" do - tool = Factories.insert!(:benchmark_tool, %{max_submissions: 3}) + tool = Factories.insert!(:graphite_tool, %{max_submissions: 3}) %{id: id} = submission = - Factories.insert!(:benchmark_submission, %{ + Factories.insert!(:graphite_submission, %{ tool: tool, description: "description", github_commit_url: @@ -23,15 +23,15 @@ defmodule Systems.Benchmark.ExportControllerTest do id: ^expected_id, url: "git@github.com:eyra/mono.git", ref: "5405deccef0aa1a594cc09da99185860bc3e0cd2" - } = Benchmark.ExportController.export(submission) + } = Graphite.ExportController.export(submission) end test "export/1 with invalid submission" do - tool = Factories.insert!(:benchmark_tool, %{max_submissions: 3}) + tool = Factories.insert!(:graphite_tool, %{max_submissions: 3}) %{id: id} = submission = - Factories.insert!(:benchmark_submission, %{ + Factories.insert!(:graphite_submission, %{ tool: tool, description: "description", github_commit_url: @@ -44,6 +44,6 @@ defmodule Systems.Benchmark.ExportControllerTest do id: ^expected_id, url: "https://github.com/eyra/mono/commit/5405deccef0aa1a594cc09da99185860bc3e0cd", ref: "" - } = Benchmark.ExportController.export(submission) + } = Graphite.ExportController.export(submission) end end diff --git a/core/test/systems/project/_assembly_test.exs b/core/test/systems/project/_assembly_test.exs index 0e4813025..e2ad75b8f 100644 --- a/core/test/systems/project/_assembly_test.exs +++ b/core/test/systems/project/_assembly_test.exs @@ -10,19 +10,19 @@ defmodule Systems.Project.AssemblyTest do item_name = "Item" - {:ok, %{project_item: %{id: id}}} = Project.Assembly.create_item(:benchmark, item_name, root) + {:ok, %{project_item: %{id: id}}} = Project.Assembly.create_item(:graphite, item_name, root) item = Project.Public.get_item!(id, Project.ItemModel.preload_graph(:down)) assert %Systems.Project.ItemModel{ name: ^item_name, project_path: [^root_id], tool_ref: %Systems.Project.ToolRefModel{ - special: :benchmark, + special: :graphite, alliance_tool: nil, document_tool: nil, lab_tool: nil, feldspar_tool: nil, - benchmark_tool: %Systems.Benchmark.ToolModel{ + graphite_tool: %Systems.Graphite.ToolModel{ auth_node: %Core.Authorization.Node{}, submissions: [] } From 3434dfdd3c2621d117093c3f5e5f91830d6b820a Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Thu, 21 Mar 2024 16:59:05 +0100 Subject: [PATCH 04/36] #641 done: Make benchmark assignment template --- .../gettext/en/LC_MESSAGES/eyra-assignment.po | 18 +- .../gettext/en/LC_MESSAGES/eyra-benchmark.po | 32 --- .../priv/gettext/en/LC_MESSAGES/eyra-enums.po | 16 +- .../gettext/en/LC_MESSAGES/eyra-project.po | 16 -- core/priv/gettext/eyra-assignment.pot | 15 ++ core/priv/gettext/eyra-benchmark.pot | 32 --- core/priv/gettext/eyra-enums.pot | 16 +- core/priv/gettext/eyra-project.pot | 16 -- .../gettext/nl/LC_MESSAGES/eyra-assignment.po | 17 +- .../gettext/nl/LC_MESSAGES/eyra-benchmark.po | 32 --- .../priv/gettext/nl/LC_MESSAGES/eyra-enums.po | 16 +- .../gettext/nl/LC_MESSAGES/eyra-project.po | 16 -- .../20240319083330_rename_workflow_type.exs | 17 ++ core/systems/assignment/_assembly.ex | 8 +- core/systems/assignment/_private.ex | 9 +- core/systems/assignment/_public.ex | 6 +- .../assignment/content_page_builder.ex | 200 +++++++++++------- core/systems/assignment/crew_page_builder.ex | 14 +- core/systems/assignment/crew_work_view.ex | 4 +- core/systems/assignment/participants_view.ex | 25 +++ core/systems/assignment/privacy_form.ex | 6 +- core/systems/assignment/settings_view.ex | 57 +++-- core/systems/assignment/templates.ex | 2 +- core/systems/project/_assembly.ex | 24 +-- core/systems/project/item_templates.ex | 2 +- core/systems/workflow/builder_view.ex | 14 +- core/systems/workflow/model.ex | 2 +- core/test/systems/assignment/factories.ex | 2 +- core/test/systems/campaign/_assembly_test.exs | 4 +- core/test/systems/project/_assembly_test.exs | 26 +-- core/test/systems/workflow/_public_test.exs | 20 +- core/test/systems/workflow/factories.ex | 2 +- 32 files changed, 350 insertions(+), 336 deletions(-) create mode 100644 core/priv/repo/migrations/20240319083330_rename_workflow_type.exs create mode 100644 core/systems/assignment/participants_view.ex diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 0bb885767..0784cab32 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -309,6 +309,8 @@ msgstr "

Privacy statement URL

Use the URL below to refer to the uploade #, elixir-autogen, elixir-format msgid "privacy.title" msgstr "Privacy" + +#, elixir-autogen, elixir-format msgid "tabbar.item.monitor" msgstr "Monitor" @@ -336,10 +338,22 @@ msgstr "Declined consent" msgid "settings.general.title" msgstr "General" +#, elixir-autogen, elixir-format, fuzzy +msgid "settings.language.label" +msgstr "Language setting for participants" + #, elixir-autogen, elixir-format, fuzzy msgid "settings.subject_count.label" msgstr "Expected number of participants" +#, elixir-autogen, elixir-format +msgid "participants.title" +msgstr "Participants" + +#, elixir-autogen, elixir-format +msgid "tabbar.item.participants" +msgstr "Participants" + #, elixir-autogen, elixir-format, fuzzy -msgid "settings.language.label" -msgstr "Language setting for participants" +msgid "tabbar.item.participants.forward" +msgstr "Go to Participants" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po b/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po index 459092138..45dd17278 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po @@ -51,18 +51,6 @@ msgstr "Add submission" msgid "expectations.title" msgstr "Description" -#, elixir-autogen, elixir-format -msgid "submissions.intro" -msgstr "When the challenge is open, you can add submissions below. They will be run on the holdout data and added to the leaderboard. " - -#, elixir-autogen, elixir-format -msgid "submissions.subhead.active" -msgstr "Please note that you are allowed to submit up to three methods." - -#, elixir-autogen, elixir-format -msgid "submissions.title" -msgstr "Submissions" - #, elixir-autogen, elixir-format msgid "highlight.deadline.title" msgstr "Days untill deadline" @@ -89,10 +77,6 @@ msgstr "Github commit url" msgid "submission.form.description.label" msgstr "Description" -#, elixir-autogen, elixir-format -msgid "add.submission.button" -msgstr "Add submission" - #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.submit.button" msgstr "Submit" @@ -101,10 +85,6 @@ msgstr "Submit" msgid "invalid.github.commit.url.message" msgstr "Please enter a valid Github commit url" -#, elixir-autogen, elixir-format, fuzzy -msgid "submissions.subhead.inactive" -msgstr "Closed: You can no longer add or edit submissions." - #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" msgid_plural "%{count} submissions" @@ -117,10 +97,6 @@ msgid_plural "%{count} teams" msgstr[0] "" msgstr[1] "" -#, elixir-autogen, elixir-format -msgid "spot.form.title" -msgstr "Team" - #, elixir-autogen, elixir-format msgid "form.template_repo.label" msgstr "Github repository" @@ -149,14 +125,6 @@ msgstr "Download data" msgid "template.button" msgstr "Github example repository" -#, elixir-autogen, elixir-format, fuzzy -msgid "spot.form.description" -msgstr "Provide a team name that will be posted with your submissions on the leaderboard. " - -#, elixir-autogen, elixir-format, fuzzy -msgid "spot.form.name" -msgstr "Name" - #, elixir-autogen, elixir-format msgid "tabbar.item.submissions" msgstr "Submissions" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po index 6c87fa7e0..fb8842ac4 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po @@ -322,10 +322,6 @@ msgstr "YouTube" msgid "organisation_types.team" msgstr "Department" -#, elixir-autogen, elixir-format -msgid "project_item_templates.benchmark" -msgstr "Benchmark" - #, elixir-autogen, elixir-format msgid "project_item_templates.data_donation" msgstr "Data Donation" @@ -370,10 +366,6 @@ msgstr "I&O Research" msgid "external_panel_ids.liss" msgstr "LISS" -#, elixir-autogen, elixir-format, fuzzy -msgid "templates.benchmark" -msgstr "Benchmark" - #, elixir-autogen, elixir-format, fuzzy msgid "platforms.netflix" msgstr "Netflix" @@ -389,3 +381,11 @@ msgstr "English" #, elixir-autogen, elixir-format msgid "assignment_languages.nl" msgstr "Dutch" + +#, elixir-autogen, elixir-format, fuzzy +msgid "project_item_templates.benchmark_challenge" +msgstr "Benchmark Challenge" + +#, elixir-autogen, elixir-format +msgid "templates.benchmark_challenge" +msgstr "Benchmark Challenge" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po index 8518f5e1b..d3d223c57 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po @@ -23,14 +23,6 @@ msgstr "Settings" msgid "tabbar.item.config.forward" msgstr "Go to Settings" -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor" -msgstr "Monitor" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor.forward" -msgstr "Go to Monitor" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "My first project" @@ -143,14 +135,6 @@ msgstr "Name" msgid "item.form.title" msgstr "Settings" -#, elixir-autogen, elixir-format, fuzzy -msgid "tabbar.item.support" -msgstr "Support" - -#, elixir-autogen, elixir-format, fuzzy -msgid "tabbar.item.support.forward" -msgstr "Go to Support" - #, elixir-autogen, elixir-format, fuzzy msgid "tabbar.item.settings" msgstr "Settings" diff --git a/core/priv/gettext/eyra-assignment.pot b/core/priv/gettext/eyra-assignment.pot index 041494d68..0707e5878 100644 --- a/core/priv/gettext/eyra-assignment.pot +++ b/core/priv/gettext/eyra-assignment.pot @@ -308,6 +308,9 @@ msgstr "" #, elixir-autogen, elixir-format msgid "privacy.title" +msgstr "" + +#, elixir-autogen, elixir-format msgid "tabbar.item.monitor" msgstr "" @@ -342,3 +345,15 @@ msgstr "" #, elixir-autogen, elixir-format msgid "settings.subject_count.label" msgstr "" + +#, elixir-autogen, elixir-format +msgid "participants.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "tabbar.item.participants" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "tabbar.item.participants.forward" +msgstr "" diff --git a/core/priv/gettext/eyra-benchmark.pot b/core/priv/gettext/eyra-benchmark.pot index d7dadbdae..aa13f87e9 100644 --- a/core/priv/gettext/eyra-benchmark.pot +++ b/core/priv/gettext/eyra-benchmark.pot @@ -51,18 +51,6 @@ msgstr "" msgid "expectations.title" msgstr "" -#, elixir-autogen, elixir-format -msgid "submissions.intro" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "submissions.subhead.active" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "submissions.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "highlight.deadline.title" msgstr "" @@ -89,10 +77,6 @@ msgstr "" msgid "submission.form.description.label" msgstr "" -#, elixir-autogen, elixir-format -msgid "add.submission.button" -msgstr "" - #, elixir-autogen, elixir-format msgid "submission.form.submit.button" msgstr "" @@ -101,10 +85,6 @@ msgstr "" msgid "invalid.github.commit.url.message" msgstr "" -#, elixir-autogen, elixir-format -msgid "submissions.subhead.inactive" -msgstr "" - #, elixir-autogen, elixir-format msgid "1 submission" msgid_plural "%{count} submissions" @@ -117,10 +97,6 @@ msgid_plural "%{count} teams" msgstr[0] "" msgstr[1] "" -#, elixir-autogen, elixir-format -msgid "spot.form.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "form.template_repo.label" msgstr "" @@ -149,14 +125,6 @@ msgstr "" msgid "template.button" msgstr "" -#, elixir-autogen, elixir-format -msgid "spot.form.description" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "spot.form.name" -msgstr "" - #, elixir-autogen, elixir-format msgid "tabbar.item.submissions" msgstr "" diff --git a/core/priv/gettext/eyra-enums.pot b/core/priv/gettext/eyra-enums.pot index ff74b3404..9ad1ce41a 100644 --- a/core/priv/gettext/eyra-enums.pot +++ b/core/priv/gettext/eyra-enums.pot @@ -322,10 +322,6 @@ msgstr "" msgid "organisation_types.team" msgstr "" -#, elixir-autogen, elixir-format -msgid "project_item_templates.benchmark" -msgstr "" - #, elixir-autogen, elixir-format msgid "project_item_templates.data_donation" msgstr "" @@ -370,10 +366,6 @@ msgstr "" msgid "external_panel_ids.liss" msgstr "" -#, elixir-autogen, elixir-format -msgid "templates.benchmark" -msgstr "" - #, elixir-autogen, elixir-format msgid "platforms.netflix" msgstr "" @@ -389,3 +381,11 @@ msgstr "" #, elixir-autogen, elixir-format msgid "assignment_languages.nl" msgstr "" + +#, elixir-autogen, elixir-format +msgid "project_item_templates.benchmark_challenge" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "templates.benchmark_challenge" +msgstr "" diff --git a/core/priv/gettext/eyra-project.pot b/core/priv/gettext/eyra-project.pot index 124f83057..e77483a30 100644 --- a/core/priv/gettext/eyra-project.pot +++ b/core/priv/gettext/eyra-project.pot @@ -23,14 +23,6 @@ msgstr "" msgid "tabbar.item.config.forward" msgstr "" -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor.forward" -msgstr "" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "" @@ -143,14 +135,6 @@ msgstr "" msgid "item.form.title" msgstr "" -#, elixir-autogen, elixir-format -msgid "tabbar.item.support" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.support.forward" -msgstr "" - #, elixir-autogen, elixir-format msgid "tabbar.item.settings" msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po index 4836c3163..4c3ee6acc 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po @@ -310,6 +310,7 @@ msgstr "

Privacyverklaring URL

Gebruik de URL hieronder om naar de geüp msgid "privacy.title" msgstr "Privacy" +#, elixir-autogen, elixir-format msgid "tabbar.item.monitor" msgstr "Monitor" @@ -337,10 +338,22 @@ msgstr "Toestemming geweigerd" msgid "settings.general.title" msgstr "General" +#, elixir-autogen, elixir-format, fuzzy +msgid "settings.language.label" +msgstr "" + #, elixir-autogen, elixir-format, fuzzy msgid "settings.subject_count.label" msgstr "Verwachtte aantal deelnemers" -#, elixir-autogen, elixir-format, fuzzy -msgid "settings.language.label" +#, elixir-autogen, elixir-format +msgid "participants.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "tabbar.item.participants" msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "tabbar.item.participants.forward" +msgstr "Ga naar Monitor" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po index 39cec4dec..2b991294e 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po @@ -51,18 +51,6 @@ msgstr "Dien methode in" msgid "expectations.title" msgstr "Beschrijving" -#, elixir-autogen, elixir-format -msgid "submissions.intro" -msgstr "Als de challenge open is, kun je hieronder methodes indienen. Deze worden toegepast op de holdout data en toegevoegd aan het scoreboard." - -#, elixir-autogen, elixir-format -msgid "submissions.subhead.active" -msgstr "Let op, je kan maximaal drie methodes indienen." - -#, elixir-autogen, elixir-format -msgid "submissions.title" -msgstr "Indienen" - #, elixir-autogen, elixir-format msgid "highlight.deadline.title" msgstr "Dagen tot deadline" @@ -89,10 +77,6 @@ msgstr "Github commit url" msgid "submission.form.description.label" msgstr "Omschrijving" -#, elixir-autogen, elixir-format -msgid "add.submission.button" -msgstr "Voeg methode toe" - #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.submit.button" msgstr "Dien methode in" @@ -101,10 +85,6 @@ msgstr "Dien methode in" msgid "invalid.github.commit.url.message" msgstr "Voer een geldige Github commit url in" -#, elixir-autogen, elixir-format, fuzzy -msgid "submissions.subhead.inactive" -msgstr "Gesloten: Het is niet meer mogelijk om methodes in te dienen of aan te passen." - #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" msgid_plural "%{count} submissions" @@ -117,10 +97,6 @@ msgid_plural "%{count} teams" msgstr[0] "1 team" msgstr[1] "%{count} teams" -#, elixir-autogen, elixir-format -msgid "spot.form.title" -msgstr "Team" - #, elixir-autogen, elixir-format msgid "form.template_repo.label" msgstr "Github repository" @@ -149,14 +125,6 @@ msgstr "Download data" msgid "template.button" msgstr "Github voorbeeld repository" -#, elixir-autogen, elixir-format, fuzzy -msgid "spot.form.description" -msgstr "Geef een team naam op die op het scoreboard bij jouw ingediende methodes komt te staan." - -#, elixir-autogen, elixir-format, fuzzy -msgid "spot.form.name" -msgstr "Naam" - #, elixir-autogen, elixir-format msgid "tabbar.item.submissions" msgstr "Methodes" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po index 014c5ead3..5cb778d8d 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po @@ -322,10 +322,6 @@ msgstr "YouTube" msgid "organisation_types.team" msgstr "Afdeling" -#, elixir-autogen, elixir-format -msgid "project_item_templates.benchmark" -msgstr "Benchmark" - #, elixir-autogen, elixir-format msgid "project_item_templates.data_donation" msgstr "Data Donatie" @@ -370,10 +366,6 @@ msgstr "I&O Research" msgid "external_panel_ids.liss" msgstr "LISS" -#, elixir-autogen, elixir-format, fuzzy -msgid "templates.benchmark" -msgstr "Benchmark" - #, elixir-autogen, elixir-format, fuzzy msgid "platforms.netflix" msgstr "Netflix" @@ -389,3 +381,11 @@ msgstr "Engels" #, elixir-autogen, elixir-format msgid "assignment_languages.nl" msgstr "Nederlands" + +#, elixir-autogen, elixir-format, fuzzy +msgid "project_item_templates.benchmark_challenge" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "templates.benchmark_challenge" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po index 215c8d724..665fff57f 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po @@ -23,14 +23,6 @@ msgstr "Instellingen" msgid "tabbar.item.config.forward" msgstr "Ga naar Instellingen" -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor" -msgstr "Monitor" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.monitor.forward" -msgstr "Ga naar Monitor" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "Mijn eerste project" @@ -143,14 +135,6 @@ msgstr "Naam" msgid "item.form.title" msgstr "Instellingen" -#, elixir-autogen, elixir-format, fuzzy -msgid "tabbar.item.support" -msgstr "Support" - -#, elixir-autogen, elixir-format, fuzzy -msgid "tabbar.item.support.forward" -msgstr "Ga naar Support" - #, elixir-autogen, elixir-format, fuzzy msgid "tabbar.item.settings" msgstr "Instellingen" diff --git a/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs b/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs new file mode 100644 index 000000000..3437947a4 --- /dev/null +++ b/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs @@ -0,0 +1,17 @@ +defmodule Core.Repo.Migrations.RenameWorkflowType do + use Ecto.Migration + + def up do + update(:workflows, :type, "single_task", "many_optional") + end + + def down do + update(:workflows, :type, "many_optional", "single_task") + end + + def update(table, field, new_value, old_value) do + execute(""" + UPDATE #{table} SET #{field} = '#{new_value}' WHERE #{field} = '#{old_value}'; + """) + end +end diff --git a/core/systems/assignment/_assembly.ex b/core/systems/assignment/_assembly.ex index 0a16136e4..3ccb56d3b 100644 --- a/core/systems/assignment/_assembly.ex +++ b/core/systems/assignment/_assembly.ex @@ -37,7 +37,11 @@ defmodule Systems.Assignment.Assembly do end defp prepare_workflow(:data_donation, _) do - Assignment.Public.prepare_workflow(:data_donation, []) + Assignment.Public.prepare_workflow(:data_donation, [], :many_optional) + end + + defp prepare_workflow(:benchmark_challenge, _) do + Assignment.Public.prepare_workflow(:benchmark_challenge, [], :many_mandatory) end defp prepare_workflow(:online = template, %Authorization.Node{} = auth_node) do @@ -55,7 +59,7 @@ defmodule Systems.Assignment.Assembly do defp prepare_workflow(template, %{} = tool) do tool_ref = prepare_tool_ref(template, tool) item = Assignment.Public.prepare_workflow_item(tool_ref) - Assignment.Public.prepare_workflow(template, [item]) + Assignment.Public.prepare_workflow(template, [item], :one) end defp prepare_tool_ref(special, tool) do diff --git a/core/systems/assignment/_private.ex b/core/systems/assignment/_private.ex index ad3ef4f40..162675377 100644 --- a/core/systems/assignment/_private.ex +++ b/core/systems/assignment/_private.ex @@ -61,13 +61,14 @@ defmodule Systems.Assignment.Private do end end - def page_title_default(:assignment_intro), do: dgettext("eyra-assignment", "intro.page.title") + def page_title_default(:assignment_information), + do: dgettext("eyra-assignment", "intro.page.title") - def page_title_default(:assignment_support), + def page_title_default(:assignment_helpdesk), do: dgettext("eyra-assignment", "support.page.title") - def page_body_default(:assignment_intro), do: "" - def page_body_default(:assignment_support), do: "" + def page_body_default(:assignment_information), do: "" + def page_body_default(:assignment_helpdesk), do: "" def allowed_external_panel_ids() do Keyword.get(config(), :external_panels, []) diff --git a/core/systems/assignment/_public.ex b/core/systems/assignment/_public.ex index 6ccc06d55..292605fca 100644 --- a/core/systems/assignment/_public.ex +++ b/core/systems/assignment/_public.ex @@ -139,7 +139,7 @@ defmodule Systems.Assignment.Public do |> Assignment.InfoModel.changeset(:create, attrs) end - def prepare_workflow(special, items, type \\ :single_task) do + def prepare_workflow(special, items, type) do %Workflow.Model{} |> Workflow.Model.changeset(%{type: type, special: special}) |> Ecto.Changeset.put_assoc(:items, items) @@ -153,7 +153,7 @@ defmodule Systems.Assignment.Public do def prepare_page_refs(_template, auth_node) do [ - prepare_page_ref(auth_node, :assignment_intro) + prepare_page_ref(auth_node, :assignment_information) ] end @@ -549,7 +549,7 @@ defmodule Systems.Assignment.Public do open_spot_count(assignment, type) end - defp open_spot_count(%{crew: crew, info: %{subject_count: subject_count}}, :single_task) do + defp open_spot_count(%{crew: crew, info: %{subject_count: subject_count}}, :many_optional) do all_non_expired_tasks = Crew.Public.count_tasks(crew, Crew.TaskStatus.values()) max(0, subject_count - all_non_expired_tasks) end diff --git a/core/systems/assignment/content_page_builder.ex b/core/systems/assignment/content_page_builder.ex index c30e53d0e..c50b751d1 100644 --- a/core/systems/assignment/content_page_builder.ex +++ b/core/systems/assignment/content_page_builder.ex @@ -3,19 +3,43 @@ defmodule Systems.Assignment.ContentPageBuilder do import CoreWeb.Gettext + alias Frameworks.Utility.List + alias Systems.Assignment - alias Systems.Project alias Systems.Workflow - alias Systems.Support alias Systems.Monitor + @moduledoc """ + Assignment is a generic concept with a template pattern. The content page is therefor rendered with optional components. + This builder module supports several specials with each a specific View Model. + """ + + @doc """ + Returns a view model based on the template table below: + + | Option | Benchmark Challenge | Data Donation | + | :-------------------- | :------------------: | :-----------: | + | General settings | No | Yes | + | Branding settings | Yes | Yes | + | Information page | Yes | Yes | + | Privacy page | Yes | Yes | + | Consent form | Yes | Yes | + | Helpdesk page form | Yes | Yes | + | Panel settings | No | Yes | + | Storage settings | No | Yes | + | Invite participants | Yes | No | + | Worklow initial items | Yes, 3 | No, 0 | + | Workflow Library | No | Yes | + | Monitor | Yes | Yes | + """ def view_model( %{id: id, special: special} = assignment, assigns ) do + config = get_config(special) title = get_title(special) show_errors = show_errors(assignment, assigns) - tabs = create_tabs(assignment, show_errors, assigns) + tabs = create_tabs(assignment, config, show_errors, assigns) action_map = action_map(assignment, assigns) actions = actions(assignment, action_map) @@ -28,8 +52,38 @@ defmodule Systems.Assignment.ContentPageBuilder do } end - defp get_title(nil) do - dgettext("eyra-assignment", "content.title") + defp get_config() do + %{ + general: true, + branding: true, + information: true, + privacy: true, + consent: true, + helpdesk: true, + panel: true, + storage: true, + participants: true, + workflow: true, + workflow_initial_items: true, + workflow_library: true, + monitor: true + } + end + + defp get_config(:benchmark_challenge) do + Map.merge(get_config(), %{ + general: false, + panel: false, + storage: false, + workflow_library: false + }) + end + + defp get_config(:data_donation) do + Map.merge(get_config(), %{ + participants: false, + workflow_initial_items: false + }) end defp get_title(special) do @@ -163,18 +217,22 @@ defmodule Systems.Assignment.ContentPageBuilder do socket |> Phoenix.Component.assign(model: assignment) end - defp create_tabs(assignment, show_errors, assigns) do - get_tab_keys() - |> Enum.map(&create_tab(&1, assignment, show_errors, assigns)) + defp create_tabs(assignment, config, show_errors, assigns) do + get_tab_keys(config) + |> Enum.map(&create_tab(&1, assignment, config, show_errors, assigns)) end - defp get_tab_keys() do - [:config, :items, :monitor] + defp get_tab_keys(%{workflow: workflow, monitor: monitor, participants: participants} = _config) do + [:settings] + |> List.append_if(workflow, :workflow) + |> List.append_if(participants, :participants) + |> List.append_if(monitor, :monitor) end defp create_tab( - :config, + :settings, assignment, + config, show_errors, %{fabric: fabric, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint} = _assigns @@ -186,7 +244,8 @@ defmodule Systems.Assignment.ContentPageBuilder do entity: assignment, uri_origin: uri_origin, viewport: viewport, - breakpoint: breakpoint + breakpoint: breakpoint, + config: config }) %{ @@ -201,8 +260,9 @@ defmodule Systems.Assignment.ContentPageBuilder do end defp create_tab( - :items, - %{workflow: workflow}, + :workflow, + %{workflow: workflow, special: special}, + config, show_errors, %{ current_user: user, @@ -229,44 +289,35 @@ defmodule Systems.Assignment.ContentPageBuilder do title: dgettext("eyra-workflow", "item.list.title"), description: dgettext("eyra-workflow", "item.list.description") }, - library: %{ - title: dgettext("eyra-workflow", "item.library.title"), - description: dgettext("eyra-workflow", "item.library.description"), - items: [ - %{ - id: :donate, - type: :feldspar_tool, - title: dgettext("eyra-workflow", "item.donate.title"), - description: dgettext("eyra-workflow", "item.donate.description") - }, - %{ - id: :questionnaire, - type: :alliance_tool, - title: dgettext("eyra-workflow", "item.questionnaire.title"), - description: dgettext("eyra-workflow", "item.questionnaire.description") - }, - %{ - id: :request, - type: :document_tool, - title: dgettext("eyra-workflow", "item.request.title"), - description: dgettext("eyra-workflow", "item.request.description") - }, - %{ - id: :download, - type: :document_tool, - title: dgettext("eyra-workflow", "item.download.title"), - description: dgettext("eyra-workflow", "item.download.description") - } - ] - } + library: get_workflow_library(config, special) } } } end + defp create_tab( + :participants, + _assignment, + _config, + show_errors, + _assigns + ) do + %{ + id: :participants, + ready: false, + show_errors: show_errors, + title: dgettext("eyra-assignment", "tabbar.item.participants"), + forward_title: dgettext("eyra-assignment", "tabbar.item.participants.forward"), + type: :fullpage, + live_component: Assignment.ParticipantsView, + props: %{} + } + end + defp create_tab( :monitor, assignment, + _config, show_errors, %{fabric: fabric} = _assigns ) do @@ -289,39 +340,38 @@ defmodule Systems.Assignment.ContentPageBuilder do } end - defp create_tab( - :support, - assignment, - _show_errors, - _assigns - ) do - %{ - id: :support, - title: dgettext("eyra-project", "tabbar.item.support"), - forward_title: dgettext("eyra-project", "tabbar.item.support.forward"), - type: :fullpage, - live_component: Support.Form, - props: %{ - entity: assignment - } - } - end + defp get_workflow_library(%{workflow_library: false}, _), do: nil - defp create_tab( - :monitor, - assignment, - _show_errors, - _assigns - ) do + defp get_workflow_library(%{workflow_library: true}, :data_donation) do %{ - id: :monitor, - title: dgettext("eyra-project", "tabbar.item.monitor"), - forward_title: dgettext("eyra-project", "tabbar.item.monitor.forward"), - type: :fullpage, - live_component: Project.ItemMonitorView, - props: %{ - entity: assignment - } + title: dgettext("eyra-workflow", "item.library.title"), + description: dgettext("eyra-workflow", "item.library.description"), + items: [ + %{ + id: :donate, + type: :feldspar_tool, + title: dgettext("eyra-workflow", "item.donate.title"), + description: dgettext("eyra-workflow", "item.donate.description") + }, + %{ + id: :questionnaire, + type: :alliance_tool, + title: dgettext("eyra-workflow", "item.questionnaire.title"), + description: dgettext("eyra-workflow", "item.questionnaire.description") + }, + %{ + id: :request, + type: :document_tool, + title: dgettext("eyra-workflow", "item.request.title"), + description: dgettext("eyra-workflow", "item.request.description") + }, + %{ + id: :download, + type: :document_tool, + title: dgettext("eyra-workflow", "item.download.title"), + description: dgettext("eyra-workflow", "item.download.description") + } + ] } end diff --git a/core/systems/assignment/crew_page_builder.ex b/core/systems/assignment/crew_page_builder.ex index 79bbe2007..11df8c389 100644 --- a/core/systems/assignment/crew_page_builder.ex +++ b/core/systems/assignment/crew_page_builder.ex @@ -51,7 +51,7 @@ defmodule Systems.Assignment.CrewPageBuilder do %{page_refs: page_refs}, %{fabric: fabric} ) do - if intro_page_ref = Enum.find(page_refs, &(&1.key == :assignment_intro)) do + if intro_page_ref = Enum.find(page_refs, &(&1.key == :assignment_information)) do Fabric.prepare_child(fabric, :onboarding_view_intro, Assignment.OnboardingView, %{ page_ref: intro_page_ref, title: dgettext("eyra-assignment", "onboarding.intro.title") @@ -93,8 +93,8 @@ defmodule Systems.Assignment.CrewPageBuilder do work_items = work_items(assignment, assigns) context_menu_items = context_menu_items(assignment, assigns) - intro_page_ref = Enum.find(page_refs, &(&1.key == :assignment_intro)) - support_page_ref = Enum.find(page_refs, &(&1.key == :assignment_support)) + intro_page_ref = Enum.find(page_refs, &(&1.key == :assignment_information)) + support_page_ref = Enum.find(page_refs, &(&1.key == :assignment_helpdesk)) Fabric.prepare_child(fabric, :work_view, Assignment.CrewWorkView, %{ work_items: work_items, @@ -111,7 +111,7 @@ defmodule Systems.Assignment.CrewPageBuilder do end defp context_menu_items(assignment, _assigns) do - [:assignment_intro, :privacy, :consent, :assignment_support] + [:assignment_information, :privacy, :consent, :assignment_helpdesk] |> Enum.map(&context_menu_item(&1, assignment)) |> Enum.filter(&(not is_nil(&1))) end @@ -132,15 +132,15 @@ defmodule Systems.Assignment.CrewPageBuilder do end end - defp context_menu_item(:assignment_intro = key, %{page_refs: page_refs}) do - if Enum.find(page_refs, &(&1.key == :assignment_intro)) != nil do + defp context_menu_item(:assignment_information = key, %{page_refs: page_refs}) do + if Enum.find(page_refs, &(&1.key == :assignment_information)) != nil do %{id: key, label: dgettext("eyra-assignment", "onboarding.intro.title")} else nil end end - defp context_menu_item(:assignment_support = key, %{page_refs: page_refs}) do + defp context_menu_item(:assignment_helpdesk = key, %{page_refs: page_refs}) do if Enum.find(page_refs, &(&1.key == key)) != nil do %{id: key, label: dgettext("eyra-assignment", "support.page.title")} else diff --git a/core/systems/assignment/crew_work_view.ex b/core/systems/assignment/crew_work_view.ex index 129d81c70..1d8e8fa29 100644 --- a/core/systems/assignment/crew_work_view.ex +++ b/core/systems/assignment/crew_work_view.ex @@ -335,7 +335,7 @@ defmodule Systems.Assignment.CrewWorkView do end @impl true - def handle_event("show", %{page: :assignment_intro}, socket) do + def handle_event("show", %{page: :assignment_information}, socket) do { :noreply, socket @@ -345,7 +345,7 @@ defmodule Systems.Assignment.CrewWorkView do end @impl true - def handle_event("show", %{page: :assignment_support}, socket) do + def handle_event("show", %{page: :assignment_helpdesk}, socket) do { :noreply, socket diff --git a/core/systems/assignment/participants_view.ex b/core/systems/assignment/participants_view.ex new file mode 100644 index 000000000..f9e7503e2 --- /dev/null +++ b/core/systems/assignment/participants_view.ex @@ -0,0 +1,25 @@ +defmodule Systems.Assignment.ParticipantsView do + use CoreWeb, :live_component_fabric + use Fabric.LiveComponent + + @impl true + def update(%{}, %{assigns: %{}} = socket) do + { + :ok, + socket + } + end + + @impl true + def render(assigns) do + ~H""" +
+ + + <%= dgettext("eyra-assignment", "participants.title") %> + <.spacing value="L" /> + +
+ """ + end +end diff --git a/core/systems/assignment/privacy_form.ex b/core/systems/assignment/privacy_form.ex index f31994b64..e20271baf 100644 --- a/core/systems/assignment/privacy_form.ex +++ b/core/systems/assignment/privacy_form.ex @@ -91,8 +91,10 @@ defmodule Systems.Assignment.PrivacyForm do select_button={dgettext("eyra-assignment", "privacy_doc.select.button")} replace_button={dgettext("eyra-assignment", "privacy_doc.replace.button")} /> - <.spacing value="S" /> - <.stack fabric={@fabric} /> + <%= if get_child(@fabric, :file_copy_view) do %> + <.spacing value="S" /> + <.child name={:file_copy_view} fabric={@fabric} /> + <% end %>
""" end diff --git a/core/systems/assignment/settings_view.ex b/core/systems/assignment/settings_view.ex index 86b48d1ca..8472e71f9 100644 --- a/core/systems/assignment/settings_view.ex +++ b/core/systems/assignment/settings_view.ex @@ -9,6 +9,7 @@ defmodule Systems.Assignment.SettingsView do %{ id: id, entity: assignment, + config: config, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint @@ -21,22 +22,26 @@ defmodule Systems.Assignment.SettingsView do |> assign( id: id, entity: assignment, + config: config, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint ) - |> compose_child(:info) - |> compose_child(:intro) + |> compose_child(:general) + |> compose_child(:information) |> compose_child(:privacy) |> compose_child(:consent) - |> compose_child(:support) - |> compose_child(:panel_connector) - |> compose_child(:storage_connector) + |> compose_child(:helpdesk) + |> compose_child(:panel) + |> compose_child(:storage) } end @impl true - def compose(:info, %{entity: %{info: info}, viewport: viewport, breakpoint: breakpoint}) do + def compose(:general, %{config: %{general: false}}), do: nil + + @impl true + def compose(:general, %{entity: %{info: info}, viewport: viewport, breakpoint: breakpoint}) do %{ module: Assignment.InfoForm, params: %{ @@ -48,12 +53,15 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:intro, %{entity: assignment}) do + def compose(:information, %{config: %{information: false}}), do: nil + + @impl true + def compose(:information, %{entity: assignment}) do %{ module: Assignment.ContentPageForm, params: %{ assignment: assignment, - page_key: :assignment_intro, + page_key: :assignment_information, opt_in?: false, on_text: dgettext("eyra-assignment", "intro_form.on.label"), off_text: dgettext("eyra-assignment", "intro_form.off.label") @@ -61,6 +69,9 @@ defmodule Systems.Assignment.SettingsView do } end + @impl true + def compose(:privacy, %{config: %{privacy: false}}), do: nil + @impl true def compose(:privacy, %{entity: assignment, uri_origin: uri_origin}) do %{ @@ -72,6 +83,9 @@ defmodule Systems.Assignment.SettingsView do } end + @impl true + def compose(:consent, %{config: %{consent: false}}), do: nil + @impl true def compose(:consent, %{entity: assignment}) do %{ @@ -83,12 +97,15 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:support, %{entity: assignment}) do + def compose(:helpdesk, %{config: %{helpdesk: false}}), do: nil + + @impl true + def compose(:helpdesk, %{entity: assignment}) do %{ module: Assignment.ContentPageForm, params: %{ assignment: assignment, - page_key: :assignment_support, + page_key: :assignment_helpdesk, opt_in?: false, on_text: dgettext("eyra-assignment", "support_form.on.label"), off_text: dgettext("eyra-assignment", "support_form.off.label") @@ -97,7 +114,10 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:panel_connector, %{entity: assignment, uri_origin: uri_origin}) do + def compose(:panel, %{config: %{panel: false}}), do: nil + + @impl true + def compose(:panel, %{entity: assignment, uri_origin: uri_origin}) do %{ module: Assignment.ConnectorView, params: %{ @@ -110,7 +130,10 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:storage_connector, %{entity: assignment, uri_origin: uri_origin}) do + def compose(:storage, %{config: %{storage: false}}), do: nil + + @impl true + def compose(:storage, %{entity: assignment, uri_origin: uri_origin}) do %{ module: Assignment.ConnectorView, params: %{ @@ -136,13 +159,13 @@ defmodule Systems.Assignment.SettingsView do <%= dgettext("eyra-assignment", "settings.title") %> <.spacing value="L" /> - <.child name={:info} fabric={@fabric} > + <.child name={:general} fabric={@fabric} > <:footer> <.spacing value="L" /> - <.child name={:intro} fabric={@fabric} > + <.child name={:information} fabric={@fabric} > <:header> <%= dgettext("eyra-assignment", "settings.intro.title") %> <%= dgettext("eyra-assignment", "settings.intro.body") %> @@ -175,7 +198,7 @@ defmodule Systems.Assignment.SettingsView do - <.child name={:support} fabric={@fabric} > + <.child name={:helpdesk} fabric={@fabric} > <:header> <%= dgettext("eyra-assignment", "settings.support.title") %> <%= dgettext("eyra-assignment", "settings.support.body") %> @@ -186,7 +209,7 @@ defmodule Systems.Assignment.SettingsView do - <.child name={:panel_connector} fabric={@fabric}> + <.child name={:panel} fabric={@fabric}> <:header> <%= dgettext("eyra-assignment", "settings.panel.title") %> <%= dgettext("eyra-assignment", "settings.panel.body") %> @@ -197,7 +220,7 @@ defmodule Systems.Assignment.SettingsView do - <.child name={:storage_connector} fabric={@fabric}> + <.child name={:storage} fabric={@fabric}> <:header> <%= dgettext("eyra-assignment", "settings.data_storage.title") %> <%= dgettext("eyra-assignment", "settings.data_storage.body") %> diff --git a/core/systems/assignment/templates.ex b/core/systems/assignment/templates.ex index 0df5d98b3..c2573ce0d 100644 --- a/core/systems/assignment/templates.ex +++ b/core/systems/assignment/templates.ex @@ -3,5 +3,5 @@ defmodule Systems.Assignment.Templates do Defines different templates used by Systems.Assignment.Assembly to initialize specials. """ use Core.Enums.Base, - {:templates, [:online, :lab, :data_donation, :graphite]} + {:templates, [:online, :lab, :data_donation, :benchmark_challenge]} end diff --git a/core/systems/project/_assembly.ex b/core/systems/project/_assembly.ex index 98b2321d0..00ad87244 100644 --- a/core/systems/project/_assembly.ex +++ b/core/systems/project/_assembly.ex @@ -7,11 +7,8 @@ defmodule Systems.Project.Assembly do alias Frameworks.Signal alias Core.Authorization - alias Systems.{ - Project, - Assignment, - Graphite - } + alias Systems.Project + alias Systems.Assignment def delete(%Project.Model{auth_node: %{id: node_id}}) do from(ra in Authorization.RoleAssignment, @@ -85,23 +82,18 @@ defmodule Systems.Project.Assembly do [prepare_item(:data_donation, "Data Donation Assignment")] end - defp prepare_items(:graphite) do + defp prepare_items(:benchmark) do [ - prepare_item(:graphite, "Challenge Round 1"), - prepare_item(:graphite, "Challenge Round 2") + prepare_item(:benchmark_challenge, "Benchmark Challenge") ] end - defp prepare_item(:graphite, name) do - {:ok, tool} = - Graphite.Public.prepare_tool(%{title: "", director: :project}) - |> Changeset.apply_action(:prepare) - - {:ok, tool_ref} = - Project.Public.prepare_tool_ref(:graphite, :graphite_tool, tool) + defp prepare_item(:benchmark_challenge, name) do + {:ok, assignment} = + Assignment.Assembly.prepare(:benchmark_challenge, :project, nil) |> Changeset.apply_action(:prepare) - Project.Public.prepare_item(%{name: name, project_path: []}, tool_ref) + Project.Public.prepare_item(%{name: name, project_path: []}, assignment) end defp prepare_item(:data_donation, name) do diff --git a/core/systems/project/item_templates.ex b/core/systems/project/item_templates.ex index 04e05c7c0..711c9e9f0 100644 --- a/core/systems/project/item_templates.ex +++ b/core/systems/project/item_templates.ex @@ -1,3 +1,3 @@ defmodule Systems.Project.ItemTemplates do - use Core.Enums.Base, {:project_item_templates, [:graphite, :data_donation]} + use Core.Enums.Base, {:project_item_templates, [:benchmark_challenge, :data_donation]} end diff --git a/core/systems/workflow/builder_view.ex b/core/systems/workflow/builder_view.ex index ef375a8b6..59fe0607a 100644 --- a/core/systems/workflow/builder_view.ex +++ b/core/systems/workflow/builder_view.ex @@ -110,12 +110,14 @@ defmodule Systems.Workflow.BuilderView do <.list items={@ordered_items} types={@item_types} ordering_enabled?={@ordering_enabled?} user={@user} uri_origin={@uri_origin} parent={%{type: __MODULE__, id: @id}} /> -
- <.side_panel id={:library} parent={:item_builder}> - - <.library {@config.library} /> - -
+ <%= if @config.library do %> +
+ <.side_panel id={:library} parent={:item_builder}> + + <.library {@config.library} /> + +
+ <% end %> """ diff --git a/core/systems/workflow/model.ex b/core/systems/workflow/model.ex index f93c19026..87b0378f9 100644 --- a/core/systems/workflow/model.ex +++ b/core/systems/workflow/model.ex @@ -9,7 +9,7 @@ defmodule Systems.Workflow.Model do } schema "workflows" do - field(:type, Ecto.Enum, values: [:single_task, :multi_task]) + field(:type, Ecto.Enum, values: [:one, :many_optional, :many_mandatory]) has_many(:items, Workflow.ItemModel, foreign_key: :workflow_id) timestamps() end diff --git a/core/test/systems/assignment/factories.ex b/core/test/systems/assignment/factories.ex index 2f43f7776..199ca8a9a 100644 --- a/core/test/systems/assignment/factories.ex +++ b/core/test/systems/assignment/factories.ex @@ -29,7 +29,7 @@ defmodule Systems.Assignment.Factories do }) end - def create_workflow(type \\ :single_task) do + def create_workflow(type \\ :many_optional) do Factories.insert!(:workflow, %{type: type}) end diff --git a/core/test/systems/campaign/_assembly_test.exs b/core/test/systems/campaign/_assembly_test.exs index f36816af1..58f7c838f 100644 --- a/core/test/systems/campaign/_assembly_test.exs +++ b/core/test/systems/campaign/_assembly_test.exs @@ -110,7 +110,7 @@ defmodule Systems.Campaign.AssemblyTest do # WORKFLOW assert %Systems.Workflow.Model{ - type: :single_task, + type: :one, items: [ %Systems.Workflow.ItemModel{ group: nil, @@ -229,7 +229,7 @@ defmodule Systems.Campaign.AssemblyTest do # WORKFLOW assert %Systems.Workflow.Model{ - type: :single_task, + type: :one, items: [ %Systems.Workflow.ItemModel{ group: nil, diff --git a/core/test/systems/project/_assembly_test.exs b/core/test/systems/project/_assembly_test.exs index e2ad75b8f..6e84d504b 100644 --- a/core/test/systems/project/_assembly_test.exs +++ b/core/test/systems/project/_assembly_test.exs @@ -10,24 +10,24 @@ defmodule Systems.Project.AssemblyTest do item_name = "Item" - {:ok, %{project_item: %{id: id}}} = Project.Assembly.create_item(:graphite, item_name, root) + {:ok, %{project_item: %{id: id}}} = + Project.Assembly.create_item(:benchmark_challenge, item_name, root) + item = Project.Public.get_item!(id, Project.ItemModel.preload_graph(:down)) assert %Systems.Project.ItemModel{ name: ^item_name, project_path: [^root_id], - tool_ref: %Systems.Project.ToolRefModel{ - special: :graphite, - alliance_tool: nil, - document_tool: nil, - lab_tool: nil, - feldspar_tool: nil, - graphite_tool: %Systems.Graphite.ToolModel{ - auth_node: %Core.Authorization.Node{}, - submissions: [] + assignment: %Systems.Assignment.Model{ + special: :benchmark_challenge, + status: :concept, + external_panel: nil, + storage_endpoint_id: nil, + workflow: %Systems.Workflow.Model{ + type: :many_mandatory, + items: [] } - }, - assignment: nil + } } = item end @@ -48,7 +48,7 @@ defmodule Systems.Project.AssemblyTest do assignment: %Systems.Assignment.Model{ info: %Systems.Assignment.InfoModel{}, workflow: %Systems.Workflow.Model{ - type: :single_task, + type: :many_optional, items: [] }, crew: %Systems.Crew.Model{ diff --git a/core/test/systems/workflow/_public_test.exs b/core/test/systems/workflow/_public_test.exs index 32134034b..5ce452f8b 100644 --- a/core/test/systems/workflow/_public_test.exs +++ b/core/test/systems/workflow/_public_test.exs @@ -9,7 +9,7 @@ defmodule Systems.Workflow.PublicTest do test "rearrange/2 move last to first succeed" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = item_a = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = item_b = Factories.create_item(workflow, tool_ref, 1) @@ -43,7 +43,7 @@ defmodule Systems.Workflow.PublicTest do test "rearrange/2 move first to last succeed" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = item_a = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = item_b = Factories.create_item(workflow, tool_ref, 1) @@ -77,7 +77,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 move first to last succeed" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = item_a = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = Factories.create_item(workflow, tool_ref, 1) @@ -131,7 +131,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 move last to second succeed" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = Factories.create_item(workflow, tool_ref, 1) @@ -185,7 +185,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 move to same position succeeded" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = Factories.create_item(workflow, tool_ref, 1) @@ -219,7 +219,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 out of upper bounds failure" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) Factories.create_item(workflow, tool_ref, 0) Factories.create_item(workflow, tool_ref, 1) @@ -233,7 +233,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 out of lower bounds failure" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) Factories.create_item(workflow, tool_ref, 0) Factories.create_item(workflow, tool_ref, 1) @@ -247,7 +247,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 position out of sync failure" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) Factories.create_item(workflow, tool_ref, 0) Factories.create_item(workflow, tool_ref, 1) @@ -265,7 +265,7 @@ defmodule Systems.Workflow.PublicTest do test "update_position/2 item deleted underwater success" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) Factories.create_item(workflow, tool_ref, 0) Factories.create_item(workflow, tool_ref, 1) @@ -283,7 +283,7 @@ defmodule Systems.Workflow.PublicTest do test "delete/1 succeed" do tool = Factories.create_tool() tool_ref = Factories.create_tool_ref(tool) - workflow = Factories.create_workflow() + workflow = Factories.create_workflow(:many_optional) %{id: id_a} = Factories.create_item(workflow, tool_ref, 0) %{id: id_b} = Factories.create_item(workflow, tool_ref, 1) diff --git a/core/test/systems/workflow/factories.ex b/core/test/systems/workflow/factories.ex index 9932f58b6..be7c4f2c4 100644 --- a/core/test/systems/workflow/factories.ex +++ b/core/test/systems/workflow/factories.ex @@ -14,7 +14,7 @@ defmodule Systems.Workflow.Factories do }) end - def create_workflow(type \\ :single_task) do + def create_workflow(type) do Factories.insert!(:workflow, %{type: type}) end From 530a04a4f31b4237c69061bd6b4f57d55ad33d1e Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Wed, 27 Mar 2024 04:04:47 +0100 Subject: [PATCH 05/36] #644 Add submission benchmark task --- core/frameworks/concept/tool_model.ex | 6 +- core/frameworks/signal/_public.ex | 3 +- core/lib/core/authorization.ex | 2 +- .../gettext/en/LC_MESSAGES/eyra-assignment.po | 32 ++- .../priv/gettext/en/LC_MESSAGES/eyra-enums.po | 28 +++ .../{eyra-benchmark.po => eyra-graphite.po} | 62 +---- .../en/LC_MESSAGES/eyra-instruction.po | 44 ++++ ...{eyra-bechmark.po => eyra-instructions.po} | 0 .../gettext/en/LC_MESSAGES/eyra-project.po | 12 +- core/priv/gettext/en/LC_MESSAGES/eyra-ui.po | 4 + .../gettext/en/LC_MESSAGES/eyra-workflow.po | 32 --- core/priv/gettext/eyra-assignment.pot | 32 ++- core/priv/gettext/eyra-enums.pot | 28 +++ .../{eyra-benchmark.pot => eyra-graphite.pot} | 56 +---- core/priv/gettext/eyra-instruction.pot | 44 ++++ ...yra-bechmark.pot => eyra-instructions.pot} | 0 core/priv/gettext/eyra-project.pot | 10 +- core/priv/gettext/eyra-ui.pot | 4 + core/priv/gettext/eyra-workflow.pot | 32 --- .../gettext/nl/LC_MESSAGES/eyra-assignment.po | 32 ++- .../priv/gettext/nl/LC_MESSAGES/eyra-enums.po | 28 +++ .../{eyra-benchmark.po => eyra-graphite.po} | 60 +---- .../nl/LC_MESSAGES/eyra-instruction.po | 44 ++++ ...{eyra-bechmark.po => eyra-instructions.po} | 0 .../gettext/nl/LC_MESSAGES/eyra-project.po | 10 +- core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po | 4 + .../gettext/nl/LC_MESSAGES/eyra-workflow.po | 32 --- .../migrations/20240321161631_cleanup.exs | 31 +++ .../20240326101333_add_instruction_tool.exs | 84 +++++++ core/systems/alliance/tool_model.ex | 2 +- core/systems/assignment/_assembly.ex | 61 +++-- core/systems/assignment/_private.ex | 15 ++ core/systems/assignment/_public.ex | 25 +- core/systems/assignment/assignment_form.ex | 2 +- .../{info_form.ex => branding_form.ex} | 21 +- .../assignment/content_page_builder.ex | 104 ++------- core/systems/assignment/crew_work_view.ex | 42 +++- core/systems/assignment/general_form.ex | 89 +++++++ core/systems/assignment/settings_view.ex | 44 +++- core/systems/assignment/template.ex | 56 +++++ .../template_benchmark_challenge.ex | 51 ++++ .../assignment/template_data_donation.ex | 53 +++++ .../assignment/workflow_item_specials.ex | 16 ++ core/systems/content/_public.ex | 22 +- core/systems/content/file_model.ex | 2 + core/systems/content/page_model.ex | 2 + core/systems/content/repository_model.ex | 27 +++ core/systems/document/tool_model.ex | 2 +- core/systems/feldspar/tool_model.ex | 2 +- core/systems/graphite/_public.ex | 46 +++- core/systems/graphite/content_page.ex | 48 ---- core/systems/graphite/content_page_builder.ex | 218 ------------------ .../graphite/leaderboard_category_view.ex | 10 +- core/systems/graphite/leaderboard_overview.ex | 14 +- core/systems/graphite/leaderboard_page.ex | 2 +- core/systems/graphite/submission_form.ex | 143 ++++++------ core/systems/graphite/submission_model.ex | 2 +- core/systems/graphite/submission_overview.ex | 2 +- core/systems/graphite/tool_form.ex | 57 +---- core/systems/graphite/tool_model.ex | 34 +-- core/systems/graphite/tool_page.ex | 12 +- core/systems/graphite/tool_page_builder.ex | 18 +- core/systems/graphite/tool_view.ex | 53 +++++ core/systems/instruction/_public.ex | 64 +++++ core/systems/instruction/_queries.ex | 28 +++ core/systems/instruction/_switch.ex | 39 ++++ core/systems/instruction/asset_model.ex | 32 +++ core/systems/instruction/download_form.ex | 19 ++ core/systems/instruction/fork_form.ex | 106 +++++++++ core/systems/instruction/page_model.ex | 30 +++ core/systems/instruction/tool_model.ex | 67 ++++++ core/systems/instruction/tool_view.ex | 73 ++++++ core/systems/lab/tool_model.ex | 2 +- core/systems/project/_switch.ex | 6 + core/systems/project/item_model.ex | 4 +- core/systems/project/tool_ref_model.ex | 29 ++- core/systems/project/tool_ref_view.ex | 17 +- core/systems/workflow/_public.ex | 36 ++- core/systems/workflow/builder_view.ex | 13 +- core/systems/workflow/config.ex | 12 + core/systems/workflow/item_cell.ex | 2 +- core/systems/workflow/item_model.ex | 2 +- core/systems/workflow/item_views.ex | 4 +- core/systems/workflow/library_item_model.ex | 10 + core/systems/workflow/library_model.ex | 8 + core/test/systems/graphite/_public_test.exs | 2 +- .../graphite/export_controller_test.exs | 4 +- core/test/systems/project/_assembly_test.exs | 6 +- 88 files changed, 1724 insertions(+), 944 deletions(-) rename core/priv/gettext/en/LC_MESSAGES/{eyra-benchmark.po => eyra-graphite.po} (76%) create mode 100644 core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po rename core/priv/gettext/en/LC_MESSAGES/{eyra-bechmark.po => eyra-instructions.po} (100%) rename core/priv/gettext/{eyra-benchmark.pot => eyra-graphite.pot} (77%) create mode 100644 core/priv/gettext/eyra-instruction.pot rename core/priv/gettext/{eyra-bechmark.pot => eyra-instructions.pot} (100%) rename core/priv/gettext/nl/LC_MESSAGES/{eyra-benchmark.po => eyra-graphite.po} (78%) create mode 100644 core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po rename core/priv/gettext/nl/LC_MESSAGES/{eyra-bechmark.po => eyra-instructions.po} (100%) create mode 100644 core/priv/repo/migrations/20240321161631_cleanup.exs create mode 100644 core/priv/repo/migrations/20240326101333_add_instruction_tool.exs rename core/systems/assignment/{info_form.ex => branding_form.ex} (87%) create mode 100644 core/systems/assignment/general_form.ex create mode 100644 core/systems/assignment/template.ex create mode 100644 core/systems/assignment/template_benchmark_challenge.ex create mode 100644 core/systems/assignment/template_data_donation.ex create mode 100644 core/systems/assignment/workflow_item_specials.ex create mode 100644 core/systems/content/repository_model.ex delete mode 100644 core/systems/graphite/content_page.ex delete mode 100644 core/systems/graphite/content_page_builder.ex create mode 100644 core/systems/graphite/tool_view.ex create mode 100644 core/systems/instruction/_public.ex create mode 100644 core/systems/instruction/_queries.ex create mode 100644 core/systems/instruction/_switch.ex create mode 100644 core/systems/instruction/asset_model.ex create mode 100644 core/systems/instruction/download_form.ex create mode 100644 core/systems/instruction/fork_form.ex create mode 100644 core/systems/instruction/page_model.ex create mode 100644 core/systems/instruction/tool_model.ex create mode 100644 core/systems/instruction/tool_view.ex create mode 100644 core/systems/workflow/config.ex create mode 100644 core/systems/workflow/library_item_model.ex create mode 100644 core/systems/workflow/library_model.ex diff --git a/core/frameworks/concept/tool_model.ex b/core/frameworks/concept/tool_model.ex index 4aa878306..7e3093c7e 100644 --- a/core/frameworks/concept/tool_model.ex +++ b/core/frameworks/concept/tool_model.ex @@ -14,8 +14,8 @@ defprotocol Frameworks.Concept.ToolModel do @spec ready?(t) :: boolean() def ready?(_t) - @spec form(t) :: atom() - def form(_t) + @spec form(t, special :: atom()) :: atom() + def form(_t, _special) @spec launcher(t) :: %{url: URI.t()} | %{module: atom(), params: map()} | nil def launcher(_t) @@ -37,7 +37,7 @@ defimpl Frameworks.Concept.ToolModel, for: Ecto.Changeset do def apply_label(%{data: tool}), do: ToolModel.apply_label(tool) def open_label(%{data: tool}), do: ToolModel.open_label(tool) def ready?(%{data: tool}), do: ToolModel.ready?(tool) - def form(%{data: tool}), do: ToolModel.form(tool) + def form(%{data: tool}, special), do: ToolModel.form(tool, special) def launcher(%{data: tool}), do: ToolModel.launcher(tool) def task_labels(%{data: tool}), do: ToolModel.task_labels(tool) def attention_list_enabled?(%{data: tool}), do: ToolModel.attention_list_enabled?(tool) diff --git a/core/frameworks/signal/_public.ex b/core/frameworks/signal/_public.ex index 3260ff517..29997ee6b 100644 --- a/core/frameworks/signal/_public.ex +++ b/core/frameworks/signal/_public.ex @@ -17,7 +17,8 @@ defmodule Frameworks.Signal.Public do "Systems.Student.Switch", "Systems.Campaign.Switch", "Systems.NextAction.Switch", - "Systems.Crew.Switch" + "Systems.Crew.Switch", + "Systems.Instruction.Switch" ] def dispatch(signal, message) do diff --git a/core/lib/core/authorization.ex b/core/lib/core/authorization.ex index b63584ba6..63876584d 100644 --- a/core/lib/core/authorization.ex +++ b/core/lib/core/authorization.ex @@ -107,7 +107,7 @@ defmodule Core.Authorization do %Core.Authorization.RoleAssignment{ principal_id: principal_id, - role: :owner + role: role } end diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 0784cab32..70aa62cda 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -58,10 +58,6 @@ msgstr "%{target} credits required" msgid "close.button" msgstr "Finish up" -#, elixir-autogen, elixir-format, fuzzy -msgid "content.title" -msgstr "Data donation" - #, elixir-autogen, elixir-format msgid "open.button" msgstr "Open" @@ -357,3 +353,31 @@ msgstr "Participants" #, elixir-autogen, elixir-format, fuzzy msgid "tabbar.item.participants.forward" msgstr "Go to Participants" + +#, elixir-autogen, elixir-format +msgid "workflow_item.donate.description" +msgstr "Enables participants to donate data." + +#, elixir-autogen, elixir-format +msgid "workflow_item.download.description" +msgstr "Instructions for participants on how to download digital trace data." + +#, elixir-autogen, elixir-format +msgid "workflow_item.questionnaire.description" +msgstr "Redirects participants to an online questionnaire." + +#, elixir-autogen, elixir-format +msgid "workflow_item.request.description" +msgstr "Instructions for participants on how to request digital trace data." + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.download_instruction.description" +msgstr "Instructions for participants on how to download the data set." + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.fork_instruction.description" +msgstr "Instructions for participants on how to fork the repository." + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.submit.description" +msgstr "Enables participants to submit an algorithm." diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po index fb8842ac4..69046cc6a 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po @@ -389,3 +389,31 @@ msgstr "Benchmark Challenge" #, elixir-autogen, elixir-format msgid "templates.benchmark_challenge" msgstr "Benchmark Challenge" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.donate" +msgstr "Donate" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.questionnaire" +msgstr "Questionnaire" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.download_manual" +msgstr "Download manual" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.request_manual" +msgstr "Request manual" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.submit" +msgstr "Submit" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.download_instruction" +msgstr "Download" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.fork_instruction" +msgstr "Fork" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po similarity index 76% rename from core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po rename to core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po index 45dd17278..ae050544c 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-benchmark.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po @@ -11,41 +11,17 @@ msgstr "" "Language: en\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#, elixir-autogen, elixir-format -msgid "content.title" -msgstr "Challenge" - #, elixir-autogen, elixir-format msgid "tabbar.item.leaderboard" msgstr "Leaderboard" -#, elixir-autogen, elixir-format -msgid "tabbar.item.leaderboard.forward" -msgstr "Go to Leaderboard" - -#, elixir-autogen, elixir-format -msgid "form.data_set.label" -msgstr "Data set (url)" - -#, elixir-autogen, elixir-format -msgid "form.deadline.label" -msgstr "Deadline" - -#, elixir-autogen, elixir-format -msgid "form.expectations.label" -msgstr "Expectations" - -#, elixir-autogen, elixir-format -msgid "form.title.label" -msgstr "Title" - #, elixir-autogen, elixir-format msgid "tool.page.title" msgstr "Challenge" #, elixir-autogen, elixir-format msgid "submission.form.title" -msgstr "Add submission" +msgstr "Submission" #, elixir-autogen, elixir-format msgid "expectations.title" @@ -97,10 +73,6 @@ msgid_plural "%{count} teams" msgstr[0] "" msgstr[1] "" -#, elixir-autogen, elixir-format -msgid "form.template_repo.label" -msgstr "Github repository" - #, elixir-autogen, elixir-format msgid "preparation.dataset.title" msgstr "Download the example data to tune your method" @@ -129,10 +101,6 @@ msgstr "Github example repository" msgid "tabbar.item.submissions" msgstr "Submissions" -#, elixir-autogen, elixir-format -msgid "tabbar.item.submissions.forward" -msgstr "Go to Submissions" - #, elixir-autogen, elixir-format msgid "import.leaderboard.title" msgstr "Import" @@ -181,26 +149,10 @@ msgstr "Score" msgid "leaderboard.team.label" msgstr "Team" -#, elixir-autogen, elixir-format -msgid "apply.cta.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "assignment.button" msgstr "" -#, elixir-autogen, elixir-format -msgid "close.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "open.button" -msgstr "" - -#, elixir-autogen, elixir-format, fuzzy -msgid "open.cta.title" -msgstr "Challenge" - #, elixir-autogen, elixir-format msgid "participated.label" msgstr "" @@ -209,14 +161,10 @@ msgstr "" msgid "pending.label" msgstr "" -#, elixir-autogen, elixir-format -msgid "preview.button" -msgstr "" +#, elixir-autogen, elixir-format, fuzzy +msgid "submission.form.update.button" +msgstr "Update" #, elixir-autogen, elixir-format -msgid "publish.button" +msgid "submit.failed.message" msgstr "" - -#, elixir-autogen, elixir-format, fuzzy -msgid "retract.button" -msgstr "Github example repository" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po new file mode 100644 index 000000000..4db0183eb --- /dev/null +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -0,0 +1,44 @@ +## "msgid"s in this file come from POT (.pot) files. +### +### Do not add, change, or remove "msgid"s manually here as +### they're tied to the ones in the corresponding POT file +### (with the same domain). +### +### Use "mix gettext.extract --merge" or "mix gettext.merge" +### to merge POT files into PO files. +msgid "" +msgstr "" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#, elixir-autogen, elixir-format +msgid "apply.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "open.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "participated.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "pending.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "repository_url.label" +msgstr "Repository" + +#, elixir-autogen, elixir-format +msgid "repository_url.placeholder" +msgstr "https://github//" + +#, elixir-autogen, elixir-format +msgid "fork_page.body" +msgstr "Fork the following repository to start working on your algorithm." + +#, elixir-autogen, elixir-format +msgid "page.title" +msgstr "Instructions" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-bechmark.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instructions.po similarity index 100% rename from core/priv/gettext/en/LC_MESSAGES/eyra-bechmark.po rename to core/priv/gettext/en/LC_MESSAGES/eyra-instructions.po diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po index d3d223c57..0444f39ce 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po @@ -15,14 +15,6 @@ msgstr "" msgid "delete.confirm" msgstr "project" -#, elixir-autogen, elixir-format -msgid "tabbar.item.config" -msgstr "Settings" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.config.forward" -msgstr "Go to Settings" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "My first project" @@ -160,8 +152,8 @@ msgid "node.empty.title" msgstr "A fresh start" #, elixir-autogen, elixir-format -msgid "tool_ref.tag.benchmark" -msgstr "Benchmark" +msgid "tool_ref.tag.graphite" +msgstr "Benchmark Challenge" #, elixir-autogen, elixir-format msgid "tool_ref.tag.default" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po b/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po index 2436444d6..9d52c5792 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po @@ -197,3 +197,7 @@ msgstr "Save" #, elixir-autogen, elixir-format, fuzzy msgid "close.button" msgstr "Close" + +#, elixir-autogen, elixir-format, fuzzy +msgid "done.button" +msgstr "Done" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po b/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po index 7ee0d2608..af3e085ab 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po @@ -19,22 +19,6 @@ msgstr "Add" msgid "item.description.label" msgstr "Task description" -#, elixir-autogen, elixir-format -msgid "item.donate.description" -msgstr "Enables participants to donate data." - -#, elixir-autogen, elixir-format -msgid "item.donate.title" -msgstr "Donate" - -#, elixir-autogen, elixir-format -msgid "item.download.description" -msgstr "Instructions for participants on how to download digital trace data." - -#, elixir-autogen, elixir-format -msgid "item.download.title" -msgstr "Download manual" - #, elixir-autogen, elixir-format msgid "item.group.label" msgstr "Data source" @@ -59,14 +43,6 @@ msgstr "Use the arrows to order the tasks" msgid "item.list.title" msgstr "Workflow" -#, elixir-autogen, elixir-format -msgid "item.request.description" -msgstr "Instructions for participants on how to request digital trace data." - -#, elixir-autogen, elixir-format -msgid "item.request.title" -msgstr "Request manual" - #, elixir-autogen, elixir-format msgid "item.title.label" msgstr "Task title" @@ -78,11 +54,3 @@ msgstr "Workflow" #, elixir-autogen, elixir-format msgid "tabbar.item.workflow.forward" msgstr "Workflow" - -#, elixir-autogen, elixir-format, fuzzy -msgid "item.questionnaire.description" -msgstr "Redirects participants to an online questionnaire." - -#, elixir-autogen, elixir-format, fuzzy -msgid "item.questionnaire.title" -msgstr "Questionnaire" diff --git a/core/priv/gettext/eyra-assignment.pot b/core/priv/gettext/eyra-assignment.pot index 0707e5878..9fa163ac3 100644 --- a/core/priv/gettext/eyra-assignment.pot +++ b/core/priv/gettext/eyra-assignment.pot @@ -58,10 +58,6 @@ msgstr "" msgid "close.button" msgstr "" -#, elixir-autogen, elixir-format -msgid "content.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "open.button" msgstr "" @@ -357,3 +353,31 @@ msgstr "" #, elixir-autogen, elixir-format msgid "tabbar.item.participants.forward" msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.donate.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.download.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.questionnaire.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.request.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.download_instruction.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.fork_instruction.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.submit.description" +msgstr "" diff --git a/core/priv/gettext/eyra-enums.pot b/core/priv/gettext/eyra-enums.pot index 9ad1ce41a..fe86b4679 100644 --- a/core/priv/gettext/eyra-enums.pot +++ b/core/priv/gettext/eyra-enums.pot @@ -389,3 +389,31 @@ msgstr "" #, elixir-autogen, elixir-format msgid "templates.benchmark_challenge" msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.donate" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.questionnaire" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.download_manual" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.request_manual" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.submit" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.download_instruction" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.fork_instruction" +msgstr "" diff --git a/core/priv/gettext/eyra-benchmark.pot b/core/priv/gettext/eyra-graphite.pot similarity index 77% rename from core/priv/gettext/eyra-benchmark.pot rename to core/priv/gettext/eyra-graphite.pot index aa13f87e9..a5761b273 100644 --- a/core/priv/gettext/eyra-benchmark.pot +++ b/core/priv/gettext/eyra-graphite.pot @@ -11,34 +11,10 @@ msgid "" msgstr "" -#, elixir-autogen, elixir-format -msgid "content.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "tabbar.item.leaderboard" msgstr "" -#, elixir-autogen, elixir-format -msgid "tabbar.item.leaderboard.forward" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "form.data_set.label" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "form.deadline.label" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "form.expectations.label" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "form.title.label" -msgstr "" - #, elixir-autogen, elixir-format msgid "tool.page.title" msgstr "" @@ -97,10 +73,6 @@ msgid_plural "%{count} teams" msgstr[0] "" msgstr[1] "" -#, elixir-autogen, elixir-format -msgid "form.template_repo.label" -msgstr "" - #, elixir-autogen, elixir-format msgid "preparation.dataset.title" msgstr "" @@ -129,10 +101,6 @@ msgstr "" msgid "tabbar.item.submissions" msgstr "" -#, elixir-autogen, elixir-format -msgid "tabbar.item.submissions.forward" -msgstr "" - #, elixir-autogen, elixir-format msgid "import.leaderboard.title" msgstr "" @@ -181,26 +149,10 @@ msgstr "" msgid "leaderboard.team.label" msgstr "" -#, elixir-autogen, elixir-format -msgid "apply.cta.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "assignment.button" msgstr "" -#, elixir-autogen, elixir-format -msgid "close.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "open.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "open.cta.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "participated.label" msgstr "" @@ -210,13 +162,9 @@ msgid "pending.label" msgstr "" #, elixir-autogen, elixir-format -msgid "preview.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "publish.button" +msgid "submission.form.update.button" msgstr "" #, elixir-autogen, elixir-format -msgid "retract.button" +msgid "submit.failed.message" msgstr "" diff --git a/core/priv/gettext/eyra-instruction.pot b/core/priv/gettext/eyra-instruction.pot new file mode 100644 index 000000000..effde97ea --- /dev/null +++ b/core/priv/gettext/eyra-instruction.pot @@ -0,0 +1,44 @@ +## This file is a PO Template file. +## +## "msgid"s here are often extracted from source code. +## Add new messages manually only if they're dynamic +## messages that can't be statically extracted. +## +## Run "mix gettext.extract" to bring this file up to +## date. Leave "msgstr"s empty as changing them here has no +## effect: edit them in PO (.po) files instead. +# +msgid "" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "apply.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "open.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "participated.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "pending.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "repository_url.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "repository_url.placeholder" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "fork_page.body" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "page.title" +msgstr "" diff --git a/core/priv/gettext/eyra-bechmark.pot b/core/priv/gettext/eyra-instructions.pot similarity index 100% rename from core/priv/gettext/eyra-bechmark.pot rename to core/priv/gettext/eyra-instructions.pot diff --git a/core/priv/gettext/eyra-project.pot b/core/priv/gettext/eyra-project.pot index e77483a30..3c526d7ca 100644 --- a/core/priv/gettext/eyra-project.pot +++ b/core/priv/gettext/eyra-project.pot @@ -15,14 +15,6 @@ msgstr "" msgid "delete.confirm" msgstr "" -#, elixir-autogen, elixir-format -msgid "tabbar.item.config" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.config.forward" -msgstr "" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "" @@ -160,7 +152,7 @@ msgid "node.empty.title" msgstr "" #, elixir-autogen, elixir-format -msgid "tool_ref.tag.benchmark" +msgid "tool_ref.tag.graphite" msgstr "" #, elixir-autogen, elixir-format diff --git a/core/priv/gettext/eyra-ui.pot b/core/priv/gettext/eyra-ui.pot index ba4dbbf48..8e4a9cc44 100644 --- a/core/priv/gettext/eyra-ui.pot +++ b/core/priv/gettext/eyra-ui.pot @@ -197,3 +197,7 @@ msgstr "" #, elixir-autogen, elixir-format msgid "close.button" msgstr "" + +#, elixir-autogen, elixir-format +msgid "done.button" +msgstr "" diff --git a/core/priv/gettext/eyra-workflow.pot b/core/priv/gettext/eyra-workflow.pot index 01294f7cd..40e90d6da 100644 --- a/core/priv/gettext/eyra-workflow.pot +++ b/core/priv/gettext/eyra-workflow.pot @@ -19,22 +19,6 @@ msgstr "" msgid "item.description.label" msgstr "" -#, elixir-autogen, elixir-format -msgid "item.donate.description" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.donate.title" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.download.description" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.download.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "item.group.label" msgstr "" @@ -59,14 +43,6 @@ msgstr "" msgid "item.list.title" msgstr "" -#, elixir-autogen, elixir-format -msgid "item.request.description" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.request.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "item.title.label" msgstr "" @@ -78,11 +54,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "tabbar.item.workflow.forward" msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.questionnaire.description" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "item.questionnaire.title" -msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po index 4c3ee6acc..05def7172 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po @@ -58,10 +58,6 @@ msgstr "%{target} credits vereist" msgid "close.button" msgstr "Afronden" -#, elixir-autogen, elixir-format, fuzzy -msgid "content.title" -msgstr "Data donatie" - #, elixir-autogen, elixir-format msgid "open.button" msgstr "Open" @@ -357,3 +353,31 @@ msgstr "" #, elixir-autogen, elixir-format, fuzzy msgid "tabbar.item.participants.forward" msgstr "Ga naar Monitor" + +#, elixir-autogen, elixir-format +msgid "workflow_item.donate.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.download.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.questionnaire.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "workflow_item.request.description" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.download_instruction.description" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.fork_instruction.description" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "workflow_item.submit.description" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po index 5cb778d8d..9cfc9bdea 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-enums.po @@ -389,3 +389,31 @@ msgstr "" #, elixir-autogen, elixir-format msgid "templates.benchmark_challenge" msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.donate" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "assignment_workflow_item_types.questionnaire" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "assignment_workflow_item_types.download_manual" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "assignment_workflow_item_types.request_manual" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "assignment_workflow_item_types.submit" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "assignment_workflow_item_types.download_instruction" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "assignment_workflow_item_types.fork_instruction" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po similarity index 78% rename from core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po rename to core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po index 2b991294e..437df8d28 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-benchmark.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po @@ -11,34 +11,10 @@ msgstr "" "Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#, elixir-autogen, elixir-format -msgid "content.title" -msgstr "Challenge" - #, elixir-autogen, elixir-format msgid "tabbar.item.leaderboard" msgstr "Ranglijst" -#, elixir-autogen, elixir-format -msgid "tabbar.item.leaderboard.forward" -msgstr "Ranglijst" - -#, elixir-autogen, elixir-format -msgid "form.data_set.label" -msgstr "Data set (url)" - -#, elixir-autogen, elixir-format -msgid "form.deadline.label" -msgstr "Streefdatum" - -#, elixir-autogen, elixir-format -msgid "form.expectations.label" -msgstr "Verwachtingen" - -#, elixir-autogen, elixir-format -msgid "form.title.label" -msgstr "Titel" - #, elixir-autogen, elixir-format msgid "tool.page.title" msgstr "Challenge" @@ -97,10 +73,6 @@ msgid_plural "%{count} teams" msgstr[0] "1 team" msgstr[1] "%{count} teams" -#, elixir-autogen, elixir-format -msgid "form.template_repo.label" -msgstr "Github repository" - #, elixir-autogen, elixir-format msgid "preparation.dataset.title" msgstr "Download de voorbeeld data om jouw methode te trainen" @@ -129,10 +101,6 @@ msgstr "Github voorbeeld repository" msgid "tabbar.item.submissions" msgstr "Methodes" -#, elixir-autogen, elixir-format -msgid "tabbar.item.submissions.forward" -msgstr "Methodes" - #, elixir-autogen, elixir-format msgid "import.leaderboard.title" msgstr "Importeren" @@ -181,26 +149,10 @@ msgstr "Score" msgid "leaderboard.team.label" msgstr "Team" -#, elixir-autogen, elixir-format -msgid "apply.cta.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "assignment.button" msgstr "" -#, elixir-autogen, elixir-format -msgid "close.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "open.button" -msgstr "" - -#, elixir-autogen, elixir-format, fuzzy -msgid "open.cta.title" -msgstr "Challenge" - #, elixir-autogen, elixir-format msgid "participated.label" msgstr "" @@ -209,14 +161,10 @@ msgstr "" msgid "pending.label" msgstr "" -#, elixir-autogen, elixir-format -msgid "preview.button" -msgstr "" +#, elixir-autogen, elixir-format, fuzzy +msgid "submission.form.update.button" +msgstr "Dien methode in" #, elixir-autogen, elixir-format -msgid "publish.button" +msgid "submit.failed.message" msgstr "" - -#, elixir-autogen, elixir-format, fuzzy -msgid "retract.button" -msgstr "Github voorbeeld repository" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po new file mode 100644 index 000000000..b59daaee8 --- /dev/null +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -0,0 +1,44 @@ +## "msgid"s in this file come from POT (.pot) files. +### +### Do not add, change, or remove "msgid"s manually here as +### they're tied to the ones in the corresponding POT file +### (with the same domain). +### +### Use "mix gettext.extract --merge" or "mix gettext.merge" +### to merge POT files into PO files. +msgid "" +msgstr "" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#, elixir-autogen, elixir-format +msgid "apply.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "open.cta.title" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "participated.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "pending.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "repository_url.label" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "repository_url.placeholder" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "fork_page.body" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "page.title" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-bechmark.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instructions.po similarity index 100% rename from core/priv/gettext/nl/LC_MESSAGES/eyra-bechmark.po rename to core/priv/gettext/nl/LC_MESSAGES/eyra-instructions.po diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po index 665fff57f..a88767c54 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po @@ -15,14 +15,6 @@ msgstr "" msgid "delete.confirm" msgstr "project" -#, elixir-autogen, elixir-format -msgid "tabbar.item.config" -msgstr "Instellingen" - -#, elixir-autogen, elixir-format -msgid "tabbar.item.config.forward" -msgstr "Ga naar Instellingen" - #, elixir-autogen, elixir-format msgid "add.first.button" msgstr "Mijn eerste project" @@ -160,7 +152,7 @@ msgid "node.empty.title" msgstr "Een frisse start" #, elixir-autogen, elixir-format -msgid "tool_ref.tag.benchmark" +msgid "tool_ref.tag.graphite" msgstr "Benchmark" #, elixir-autogen, elixir-format diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po index 0023ffbd8..79d9f0d9f 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po @@ -197,3 +197,7 @@ msgstr "Opslaan" #, elixir-autogen, elixir-format, fuzzy msgid "close.button" msgstr "Sluiten" + +#, elixir-autogen, elixir-format, fuzzy +msgid "done.button" +msgstr "Klaar" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-workflow.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-workflow.po index d7d145a28..a8ae7cd62 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-workflow.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-workflow.po @@ -19,22 +19,6 @@ msgstr "Voeg toe" msgid "item.description.label" msgstr "Taak beschrijving" -#, elixir-autogen, elixir-format -msgid "item.donate.description" -msgstr "Biedt deelnemers de mogelijkheid om data te doneren." - -#, elixir-autogen, elixir-format -msgid "item.donate.title" -msgstr "Donatie" - -#, elixir-autogen, elixir-format -msgid "item.download.description" -msgstr "Instructies voor deelnemers over hoe ze de data kunnen downloaden." - -#, elixir-autogen, elixir-format -msgid "item.download.title" -msgstr "Download handleiding" - #, elixir-autogen, elixir-format msgid "item.group.label" msgstr "Databron" @@ -59,14 +43,6 @@ msgstr "Pas de volgorde aan met de pijltjes" msgid "item.list.title" msgstr "Takenlijst" -#, elixir-autogen, elixir-format -msgid "item.request.description" -msgstr "Instructies voor deelnemers over hoe ze de data aan moeten vragen." - -#, elixir-autogen, elixir-format -msgid "item.request.title" -msgstr "Aanvraag handleiding" - #, elixir-autogen, elixir-format msgid "item.title.label" msgstr "Taak titel" @@ -78,11 +54,3 @@ msgstr "Takenlijst" #, elixir-autogen, elixir-format msgid "tabbar.item.workflow.forward" msgstr "Takenlijst" - -#, elixir-autogen, elixir-format, fuzzy -msgid "item.questionnaire.description" -msgstr "Stuurt deelnemers naar een online vragenlijst." - -#, elixir-autogen, elixir-format, fuzzy -msgid "item.questionnaire.title" -msgstr "Vragenlijst" diff --git a/core/priv/repo/migrations/20240321161631_cleanup.exs b/core/priv/repo/migrations/20240321161631_cleanup.exs new file mode 100644 index 000000000..cd92a1202 --- /dev/null +++ b/core/priv/repo/migrations/20240321161631_cleanup.exs @@ -0,0 +1,31 @@ +defmodule Core.Repo.Migrations.CleanUp do + use Ecto.Migration + + def up do + alter table(:graphite_tools) do + remove(:max_submissions, :integer) + end + + execute( + "ALTER TABLE graphite_tools RENAME CONSTRAINT benchmark_tools_auth_node_id_fkey TO graphite_tools_auth_node_id_fkey;" + ) + + execute( + "ALTER TABLE tool_refs RENAME CONSTRAINT tool_refs_benchmark_tool_id_fkey TO tool_refs_graphite_tool_id_fkey;" + ) + end + + def down do + execute( + "ALTER TABLE tool_refs RENAME CONSTRAINT tool_refs_graphite_tool_id_fkey TO tool_refs_benchmark_tool_id_fkey;" + ) + + execute( + "ALTER TABLE graphite_tools RENAME CONSTRAINT graphite_tools_auth_node_id_fkey TO benchmark_tools_auth_node_id_fkey;" + ) + + alter table(:graphite_tools) do + add(:max_submissions, :integer) + end + end +end diff --git a/core/priv/repo/migrations/20240326101333_add_instruction_tool.exs b/core/priv/repo/migrations/20240326101333_add_instruction_tool.exs new file mode 100644 index 000000000..87aeff832 --- /dev/null +++ b/core/priv/repo/migrations/20240326101333_add_instruction_tool.exs @@ -0,0 +1,84 @@ +defmodule Core.Repo.Migrations.AddInstructionTool do + use Ecto.Migration + + def up do + create table(:content_repositories) do + add(:platform, :string) + add(:url, :string) + timestamps() + end + + create table(:instruction_tools) do + add(:auth_node_id, references(:authorization_nodes), null: false) + timestamps() + end + + create table(:instruction_assets) do + add(:tool_id, references(:instruction_tools, on_delete: :delete_all), null: false) + add(:repository_id, references(:content_repositories, on_delete: :delete_all), null: true) + add(:file_id, references(:content_files, on_delete: :delete_all), null: true) + timestamps() + end + + create( + constraint(:instruction_assets, :must_have_at_least_one_ref, + check: """ + repository_id != null or + file_id != null + """ + ) + ) + + create table(:instruction_pages) do + add(:tool_id, references(:instruction_tools, on_delete: :delete_all), null: false) + add(:page_id, references(:content_pages, on_delete: :delete_all), null: false) + timestamps() + end + + drop(constraint(:tool_refs, :must_have_at_least_one_tool)) + + alter table(:tool_refs) do + add(:instruction_tool_id, references(:instruction_tools, on_delete: :delete_all), null: true) + end + + create( + constraint(:tool_refs, :must_have_at_least_one_tool, + check: """ + alliance_tool_id != null or + feldspar_tool_id != null or + document_tool_id != null or + lab_tool_id != null or + graphite_tool_id != null or + instruction_tool_id != null + """ + ) + ) + end + + def down do + drop(constraint(:tool_refs, :must_have_at_least_one_tool)) + + alter table(:tool_refs) do + remove(:instruction_tool_id) + end + + create( + constraint(:tool_refs, :must_have_at_least_one_tool, + check: """ + alliance_tool_id != null or + feldspar_tool_id != null or + document_tool_id != null or + lab_tool_id != null or + graphite_tool_id != null + """ + ) + ) + + drop(constraint(:instruction_assets, :must_have_at_least_one_ref)) + + drop(table(:instruction_pages)) + drop(table(:instruction_assets)) + drop(table(:instruction_tools)) + drop(table(:content_repositories)) + end +end diff --git a/core/systems/alliance/tool_model.ex b/core/systems/alliance/tool_model.ex index 11cd27f08..ad73d5150 100644 --- a/core/systems/alliance/tool_model.ex +++ b/core/systems/alliance/tool_model.ex @@ -187,7 +187,7 @@ defmodule Systems.Alliance.ToolModel do def apply_label(_), do: dgettext("eyra-alliance", "apply.cta.title") def open_label(_), do: dgettext("eyra-alliance", "open.cta.title") def ready?(tool), do: Alliance.ToolModel.ready?(tool) - def form(_), do: Alliance.ToolForm + def form(_, _), do: Alliance.ToolForm def launcher(tool), do: %{url: Systems.Alliance.ToolModel.safe_uri(tool)} def task_labels(_) do diff --git a/core/systems/assignment/_assembly.ex b/core/systems/assignment/_assembly.ex index 3ccb56d3b..c5d022058 100644 --- a/core/systems/assignment/_assembly.ex +++ b/core/systems/assignment/_assembly.ex @@ -2,14 +2,10 @@ defmodule Systems.Assignment.Assembly do alias Core.Repo alias Core.Authorization - alias Systems.{ - Project, - Assignment, - Consent, - Crew, - Alliance, - Lab - } + alias Systems.Assignment + alias Systems.Consent + alias Systems.Crew + alias Systems.Workflow def create(template, director, budget \\ nil, auth_node \\ Authorization.prepare_node()) do prepare(template, director, budget, auth_node) @@ -36,35 +32,52 @@ defmodule Systems.Assignment.Assembly do ) end - defp prepare_workflow(:data_donation, _) do - Assignment.Public.prepare_workflow(:data_donation, [], :many_optional) + defp prepare_workflow(:data_donation = special, %Authorization.Node{} = auth_node) do + template = Assignment.Private.get_template(special) + initial_items = prepare_initial_items(template, auth_node) + prepare_workflow(special, template, initial_items) end - defp prepare_workflow(:benchmark_challenge, _) do - Assignment.Public.prepare_workflow(:benchmark_challenge, [], :many_mandatory) + defp prepare_workflow(:benchmark_challenge = special, %Authorization.Node{} = auth_node) do + template = Assignment.Private.get_template(special) + initial_items = prepare_initial_items(template, auth_node) + prepare_workflow(special, template, initial_items) end - defp prepare_workflow(:online = template, %Authorization.Node{} = auth_node) do + defp prepare_workflow(:online = special, %Authorization.Node{} = auth_node) do tool_auth_node = Authorization.create_node!(auth_node) - tool = Alliance.Public.prepare_tool(%{director: :assignment}, tool_auth_node) - prepare_workflow(template, tool) + tool = Workflow.Public.prepare_tool(:alliance_tool, %{director: :assignment}, tool_auth_node) + prepare_workflow(special, tool, :one) end - defp prepare_workflow(:lab = template, %Authorization.Node{} = auth_node) do + defp prepare_workflow(:lab = special, %Authorization.Node{} = auth_node) do tool_auth_node = Authorization.create_node!(auth_node) - tool = Lab.Public.prepare_tool(%{director: :assignment}, tool_auth_node) - prepare_workflow(template, tool) + tool = Workflow.Public.prepare_tool(:lab_tool, %{director: :assignment}, tool_auth_node) + prepare_workflow(special, tool, :one) end - defp prepare_workflow(template, %{} = tool) do - tool_ref = prepare_tool_ref(template, tool) + defp prepare_workflow(special, template, initial_items) when is_list(initial_items) do + type = Assignment.Template.workflow(template).type + Assignment.Public.prepare_workflow(special, initial_items, type) + end + + defp prepare_workflow(special, tool, type) do + tool_ref = Assignment.Public.prepare_tool_ref(special, tool) item = Assignment.Public.prepare_workflow_item(tool_ref) - Assignment.Public.prepare_workflow(template, [item], :one) + Assignment.Public.prepare_workflow(special, [item], type) end - defp prepare_tool_ref(special, tool) do - field_name = Project.ToolRefModel.tool_field(tool) - Project.Public.prepare_tool_ref(special, field_name, tool) + defp prepare_initial_items(template, auth_node) do + %{initial_items: initial_items, library: %{items: library_items}} = + Assignment.Template.workflow(template) + + Enum.map(initial_items, fn tool_special -> + %{tool: tool_type} = Enum.find(library_items, &(&1.special == tool_special)) + tool_auth_node = Authorization.create_node!(auth_node) + tool = Workflow.Public.prepare_tool(tool_type, %{director: :assignment}, tool_auth_node) + Assignment.Public.prepare_tool_ref(tool_special, tool) + end) + |> Assignment.Public.prepare_workflow_items() end defp prepare_consent_agreement(%Authorization.Node{} = auth_node) do diff --git a/core/systems/assignment/_private.ex b/core/systems/assignment/_private.ex index 162675377..db87d0fe5 100644 --- a/core/systems/assignment/_private.ex +++ b/core/systems/assignment/_private.ex @@ -13,6 +13,13 @@ defmodule Systems.Assignment.Private do alias Systems.Storage alias Systems.Monitor + def get_template(%Assignment.Model{special: special}), do: get_template(special) + + def get_template(:data_donation), do: %Assignment.TemplateDataDonation{id: :data_donation} + + def get_template(:benchmark_challenge), + do: %Assignment.TemplateBenchmarkChallenge{id: :benchmark_challenge} + def log_performance_event( %Assignment.Model{} = assignment, %Crew.TaskModel{} = crew_task, @@ -135,6 +142,14 @@ defmodule Systems.Assignment.Private do ["item=#{item_id}", "member=#{member_id}"] end + def task_identifier( + %{special: :benchmark_challenge}, + %Workflow.ItemModel{id: item_id}, + %Crew.MemberModel{id: member_id} + ) do + ["item=#{item_id}", "member=#{member_id}"] + end + # Deprecated def task_identifier(_tool, _user) do raise RuntimeError, diff --git a/core/systems/assignment/_public.ex b/core/systems/assignment/_public.ex index 292605fca..7a27d9a1e 100644 --- a/core/systems/assignment/_public.ex +++ b/core/systems/assignment/_public.ex @@ -139,18 +139,34 @@ defmodule Systems.Assignment.Public do |> Assignment.InfoModel.changeset(:create, attrs) end - def prepare_workflow(special, items, type) do + def prepare_workflow(special, [_ | _] = items, type) do %Workflow.Model{} |> Workflow.Model.changeset(%{type: type, special: special}) |> Ecto.Changeset.put_assoc(:items, items) end - def prepare_workflow_item(tool_ref) do + def prepare_workflow(special, _, type) do + %Workflow.Model{} + |> Workflow.Model.changeset(%{type: type, special: special}) + end + + def prepare_workflow_items(tool_refs) when is_list(tool_refs) do + tool_refs + |> Enum.with_index() + |> Enum.map(fn {tool_ref, index} -> prepare_workflow_item(tool_ref, %{position: index}) end) + end + + def prepare_workflow_item(tool_ref, attrs \\ %{}) do %Workflow.ItemModel{} - |> Workflow.ItemModel.changeset(%{}) + |> Workflow.ItemModel.changeset(attrs) |> Ecto.Changeset.put_assoc(:tool_ref, tool_ref) end + def prepare_tool_ref(special, tool) do + field_name = Project.ToolRefModel.tool_field(tool) + Project.Public.prepare_tool_ref(special, field_name, tool) + end + def prepare_page_refs(_template, auth_node) do [ prepare_page_ref(auth_node, :assignment_information) @@ -158,10 +174,9 @@ defmodule Systems.Assignment.Public do end def prepare_page_ref(auth_node, key) when is_atom(key) do - page_title = Assignment.Private.page_title_default(key) page_body = Assignment.Private.page_body_default(key) page_auth_node = Authorization.prepare_node(auth_node) - page = Content.Public.prepare_page(page_title, page_body, page_auth_node) + page = Content.Public.prepare_page(page_body, page_auth_node) %Assignment.PageRefModel{} |> Assignment.PageRefModel.changeset(%{key: key}) diff --git a/core/systems/assignment/assignment_form.ex b/core/systems/assignment/assignment_form.ex index 7adbabf57..6aa84d0d0 100644 --- a/core/systems/assignment/assignment_form.ex +++ b/core/systems/assignment/assignment_form.ex @@ -18,7 +18,7 @@ defmodule Systems.Assignment.AssignmentForm do socket ) do [tool | _] = Workflow.Model.flatten(workflow) - tool_form = Frameworks.Concept.ToolModel.form(tool) + tool_form = Frameworks.Concept.ToolModel.form(tool, nil) { :ok, diff --git a/core/systems/assignment/info_form.ex b/core/systems/assignment/branding_form.ex similarity index 87% rename from core/systems/assignment/info_form.ex rename to core/systems/assignment/branding_form.ex index f4074556e..ffcf6c6ba 100644 --- a/core/systems/assignment/info_form.ex +++ b/core/systems/assignment/branding_form.ex @@ -1,4 +1,4 @@ -defmodule Systems.Assignment.InfoForm do +defmodule Systems.Assignment.BrandingForm do use CoreWeb.LiveForm, :fabric use Fabric.LiveComponent use CoreWeb.FileUploader, accept: ~w(.png .jpg .jpeg .svg) @@ -38,7 +38,6 @@ defmodule Systems.Assignment.InfoForm do viewport: viewport, breakpoint: breakpoint ) - |> update_language_items() |> update_image_picker_state() |> update_image_info() |> update_image_picker_button() @@ -46,19 +45,6 @@ defmodule Systems.Assignment.InfoForm do } end - def update_language_items(%{assigns: %{entity: %{language: language}}} = socket) do - language = - if language do - language - else - Assignment.Languages.default() - end - - items = Assignment.Languages.labels(language) - - assign(socket, language_items: items) - end - @impl true def compose(:image_picker, %{ entity: %{title: title}, @@ -174,11 +160,6 @@ defmodule Systems.Assignment.InfoForm do ~H"""
<.form id={"#{@id}_general"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > - <%= dgettext("eyra-assignment", "settings.general.title") %> - <.number_input form={form} field={:subject_count} label_text={dgettext("eyra-assignment", "settings.subject_count.label")} /> - <.radio_group form={form} field={:language} label_text={dgettext("eyra-assignment", "settings.language.label")} items={@language_items}/> - <.spacing value="L" /> - <%= dgettext("eyra-assignment", "settings.branding.title") %> <%= dgettext("eyra-assignment", "settings.branding.text") %> <.spacing value="M" /> diff --git a/core/systems/assignment/content_page_builder.ex b/core/systems/assignment/content_page_builder.ex index c50b751d1..b50a92b3f 100644 --- a/core/systems/assignment/content_page_builder.ex +++ b/core/systems/assignment/content_page_builder.ex @@ -33,63 +33,24 @@ defmodule Systems.Assignment.ContentPageBuilder do | Monitor | Yes | Yes | """ def view_model( - %{id: id, special: special} = assignment, + %{id: id} = assignment, assigns ) do - config = get_config(special) - title = get_title(special) + template = Assignment.Private.get_template(assignment) show_errors = show_errors(assignment, assigns) - tabs = create_tabs(assignment, config, show_errors, assigns) + tabs = create_tabs(assignment, template, show_errors, assigns) action_map = action_map(assignment, assigns) actions = actions(assignment, action_map) %{ id: id, - title: title, + title: Assignment.Template.title(template), tabs: tabs, actions: actions, show_errors: show_errors } end - defp get_config() do - %{ - general: true, - branding: true, - information: true, - privacy: true, - consent: true, - helpdesk: true, - panel: true, - storage: true, - participants: true, - workflow: true, - workflow_initial_items: true, - workflow_library: true, - monitor: true - } - end - - defp get_config(:benchmark_challenge) do - Map.merge(get_config(), %{ - general: false, - panel: false, - storage: false, - workflow_library: false - }) - end - - defp get_config(:data_donation) do - Map.merge(get_config(), %{ - participants: false, - workflow_initial_items: false - }) - end - - defp get_title(special) do - Assignment.Templates.translate(special) - end - defp show_errors(_, _) do # concept? = status == :concept # publish_clicked or not concept? @@ -150,7 +111,7 @@ defmodule Systems.Assignment.ContentPageBuilder do face: %{ type: :icon, icon: :retract, - alt: dgettext("eyra-benchmark", "assignment.button") + alt: dgettext("eyra-graphite", "assignment.button") } }, handle_click: &handle_retract/1 @@ -217,9 +178,9 @@ defmodule Systems.Assignment.ContentPageBuilder do socket |> Phoenix.Component.assign(model: assignment) end - defp create_tabs(assignment, config, show_errors, assigns) do - get_tab_keys(config) - |> Enum.map(&create_tab(&1, assignment, config, show_errors, assigns)) + defp create_tabs(assignment, template, show_errors, assigns) do + get_tab_keys(Assignment.Template.content_flags(template)) + |> Enum.map(&create_tab(&1, assignment, template, show_errors, assigns)) end defp get_tab_keys(%{workflow: workflow, monitor: monitor, participants: participants} = _config) do @@ -232,7 +193,7 @@ defmodule Systems.Assignment.ContentPageBuilder do defp create_tab( :settings, assignment, - config, + template, show_errors, %{fabric: fabric, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint} = _assigns @@ -245,7 +206,7 @@ defmodule Systems.Assignment.ContentPageBuilder do uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint, - config: config + template: template }) %{ @@ -261,8 +222,8 @@ defmodule Systems.Assignment.ContentPageBuilder do defp create_tab( :workflow, - %{workflow: workflow, special: special}, - config, + %{workflow: workflow}, + template, show_errors, %{ current_user: user, @@ -289,7 +250,7 @@ defmodule Systems.Assignment.ContentPageBuilder do title: dgettext("eyra-workflow", "item.list.title"), description: dgettext("eyra-workflow", "item.list.description") }, - library: get_workflow_library(config, special) + library: Assignment.Template.workflow(template).library } } } @@ -298,7 +259,7 @@ defmodule Systems.Assignment.ContentPageBuilder do defp create_tab( :participants, _assignment, - _config, + _template, show_errors, _assigns ) do @@ -317,7 +278,7 @@ defmodule Systems.Assignment.ContentPageBuilder do defp create_tab( :monitor, assignment, - _config, + _template, show_errors, %{fabric: fabric} = _assigns ) do @@ -340,41 +301,6 @@ defmodule Systems.Assignment.ContentPageBuilder do } end - defp get_workflow_library(%{workflow_library: false}, _), do: nil - - defp get_workflow_library(%{workflow_library: true}, :data_donation) do - %{ - title: dgettext("eyra-workflow", "item.library.title"), - description: dgettext("eyra-workflow", "item.library.description"), - items: [ - %{ - id: :donate, - type: :feldspar_tool, - title: dgettext("eyra-workflow", "item.donate.title"), - description: dgettext("eyra-workflow", "item.donate.description") - }, - %{ - id: :questionnaire, - type: :alliance_tool, - title: dgettext("eyra-workflow", "item.questionnaire.title"), - description: dgettext("eyra-workflow", "item.questionnaire.description") - }, - %{ - id: :request, - type: :document_tool, - title: dgettext("eyra-workflow", "item.request.title"), - description: dgettext("eyra-workflow", "item.request.description") - }, - %{ - id: :download, - type: :document_tool, - title: dgettext("eyra-workflow", "item.download.title"), - description: dgettext("eyra-workflow", "item.download.description") - } - ] - } - end - defp number_widgets(assignment) do [:started, :finished, :declined] |> Enum.map(&number_widget(&1, assignment)) diff --git a/core/systems/assignment/crew_work_view.ex b/core/systems/assignment/crew_work_view.ex index 1d8e8fa29..9652e7bfc 100644 --- a/core/systems/assignment/crew_work_view.ex +++ b/core/systems/assignment/crew_work_view.ex @@ -52,6 +52,7 @@ defmodule Systems.Assignment.CrewWorkView do tool_started: tool_started, tool_initialized: tool_initialized ) + |> update_tasks_finished() |> update_selected_item_id() |> update_selected_item() |> compose_child(:work_list_view) @@ -62,6 +63,15 @@ defmodule Systems.Assignment.CrewWorkView do } end + defp update_tasks_finished(%{assigns: %{work_items: work_items}} = socket) do + socket |> assign(tasks_finished: tasks_finished?(work_items)) + end + + defp tasks_finished?(work_items) do + task_ids = Enum.map(work_items, fn {_, task} -> task.id end) + Crew.Public.tasks_finished?(task_ids) + end + defp tool_visible?(%{assigns: assigns} = _socket) do tool_visible?(assigns) end @@ -161,13 +171,20 @@ defmodule Systems.Assignment.CrewWorkView do def compose( :tool_ref_view, %{ + user: user, launcher: %{module: _, params: _}, selected_item: {%{title: title, tool_ref: tool_ref}, task} } = assigns ) do %{ module: Project.ToolRefView, - params: %{title: title, tool_ref: tool_ref, task: task, visible: tool_visible?(assigns)} + params: %{ + title: title, + tool_ref: tool_ref, + task: task, + visible: tool_visible?(assigns), + user: user + } } end @@ -263,6 +280,20 @@ defmodule Systems.Assignment.CrewWorkView do } end + @impl true + def handle_event("cancel_task", _payload, socket) do + { + :noreply, + socket + |> assign( + tool_started: false, + tool_initialized: false + ) + |> compose_child(:start_view) + |> compose_child(:tool_ref_view) + } + end + @impl true def handle_event("complete_task", _, socket) do { @@ -465,10 +496,13 @@ defmodule Systems.Assignment.CrewWorkView do socket end - defp handle_finished_state(%{assigns: %{work_items: work_items}} = socket) do - task_ids = Enum.map(work_items, fn {_, task} -> task.id end) + defp handle_finished_state(%{assigns: %{tasks_finished: true}} = socket) do + # Dont show finished view when task are already finished + socket + end - if Crew.Public.tasks_finished?(task_ids) do + defp handle_finished_state(%{assigns: %{work_items: work_items}} = socket) do + if tasks_finished?(work_items) do socket |> signal_tasks_finished() |> compose_child(:finished_view) diff --git a/core/systems/assignment/general_form.ex b/core/systems/assignment/general_form.ex new file mode 100644 index 000000000..93f6cdc7a --- /dev/null +++ b/core/systems/assignment/general_form.ex @@ -0,0 +1,89 @@ +defmodule Systems.Assignment.GeneralForm do + use CoreWeb.LiveForm, :fabric + use Fabric.LiveComponent + + import Frameworks.Pixel.Form + alias Frameworks.Pixel.Text + + alias Systems.Assignment + + @impl true + def update( + %{id: id, entity: entity, viewport: viewport, breakpoint: breakpoint}, + socket + ) do + changeset = Assignment.InfoModel.changeset(entity, :create, %{}) + + { + :ok, + socket + |> assign( + id: id, + entity: entity, + changeset: changeset, + viewport: viewport, + breakpoint: breakpoint + ) + |> update_language_items() + } + end + + def update_language_items(%{assigns: %{entity: %{language: language}}} = socket) do + language = + if language do + language + else + Assignment.Languages.default() + end + + items = Assignment.Languages.labels(language) + + assign(socket, language_items: items) + end + + # Handle Events + + @impl true + def handle_event( + "update", + %{source: %{name: :language_selector}, status: language}, + %{assigns: %{entity: entity}} = socket + ) do + { + :noreply, + socket + |> save(entity, :auto_save, %{language: language}) + } + end + + @impl true + def handle_event("save", %{"info_model" => attrs}, %{assigns: %{entity: entity}} = socket) do + { + :noreply, + socket + |> save(entity, :auto_save, attrs) + } + end + + # Saving + + def save(socket, entity, type, attrs) do + changeset = Assignment.InfoModel.changeset(entity, type, attrs) + + socket + |> save(changeset) + end + + @impl true + def render(assigns) do + ~H""" +
+ <.form id={"#{@id}_general"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > + <%= dgettext("eyra-assignment", "settings.general.title") %> + <.number_input form={form} field={:subject_count} label_text={dgettext("eyra-assignment", "settings.subject_count.label")} /> + <.radio_group form={form} field={:language} label_text={dgettext("eyra-assignment", "settings.language.label")} items={@language_items}/> + +
+ """ + end +end diff --git a/core/systems/assignment/settings_view.ex b/core/systems/assignment/settings_view.ex index 8472e71f9..b49f7cadc 100644 --- a/core/systems/assignment/settings_view.ex +++ b/core/systems/assignment/settings_view.ex @@ -9,25 +9,28 @@ defmodule Systems.Assignment.SettingsView do %{ id: id, entity: assignment, - config: config, + template: template, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint }, socket ) do + content_flags = Assignment.Template.content_flags(template) + { :ok, socket |> assign( id: id, entity: assignment, - config: config, + content_flags: content_flags, uri_origin: uri_origin, viewport: viewport, breakpoint: breakpoint ) |> compose_child(:general) + |> compose_child(:branding) |> compose_child(:information) |> compose_child(:privacy) |> compose_child(:consent) @@ -38,12 +41,27 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:general, %{config: %{general: false}}), do: nil + def compose(:general, %{content_flags: %{general: false}}), do: nil @impl true def compose(:general, %{entity: %{info: info}, viewport: viewport, breakpoint: breakpoint}) do %{ - module: Assignment.InfoForm, + module: Assignment.GeneralForm, + params: %{ + entity: info, + viewport: viewport, + breakpoint: breakpoint + } + } + end + + @impl true + def compose(:branding, %{content_flags: %{branding: false}}), do: nil + + @impl true + def compose(:branding, %{entity: %{info: info}, viewport: viewport, breakpoint: breakpoint}) do + %{ + module: Assignment.BrandingForm, params: %{ entity: info, viewport: viewport, @@ -53,7 +71,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:information, %{config: %{information: false}}), do: nil + def compose(:information, %{content_flags: %{information: false}}), do: nil @impl true def compose(:information, %{entity: assignment}) do @@ -70,7 +88,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:privacy, %{config: %{privacy: false}}), do: nil + def compose(:privacy, %{content_flags: %{privacy: false}}), do: nil @impl true def compose(:privacy, %{entity: assignment, uri_origin: uri_origin}) do @@ -84,7 +102,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:consent, %{config: %{consent: false}}), do: nil + def compose(:consent, %{content_flags: %{consent: false}}), do: nil @impl true def compose(:consent, %{entity: assignment}) do @@ -97,7 +115,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:helpdesk, %{config: %{helpdesk: false}}), do: nil + def compose(:helpdesk, %{content_flags: %{helpdesk: false}}), do: nil @impl true def compose(:helpdesk, %{entity: assignment}) do @@ -114,7 +132,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:panel, %{config: %{panel: false}}), do: nil + def compose(:panel, %{content_flags: %{panel: false}}), do: nil @impl true def compose(:panel, %{entity: assignment, uri_origin: uri_origin}) do @@ -130,7 +148,7 @@ defmodule Systems.Assignment.SettingsView do end @impl true - def compose(:storage, %{config: %{storage: false}}), do: nil + def compose(:storage, %{content_flags: %{storage: false}}), do: nil @impl true def compose(:storage, %{entity: assignment, uri_origin: uri_origin}) do @@ -165,6 +183,12 @@ defmodule Systems.Assignment.SettingsView do + <.child name={:branding} fabric={@fabric} > + <:footer> + <.spacing value="L" /> + + + <.child name={:information} fabric={@fabric} > <:header> <%= dgettext("eyra-assignment", "settings.intro.title") %> diff --git a/core/systems/assignment/template.ex b/core/systems/assignment/template.ex new file mode 100644 index 000000000..5b70a1796 --- /dev/null +++ b/core/systems/assignment/template.ex @@ -0,0 +1,56 @@ +defprotocol Systems.Assignment.Template do + @spec title(t) :: binary() + def title(t) + + @spec content_flags(t) :: Systems.Assignment.ContentFlags.t() + def content_flags(t) + + @spec workflow(t) :: Systems.Workflow.Config.t() + def workflow(t) +end + +defmodule Systems.Assignment.ContentFlags do + @type t :: %__MODULE__{ + general: boolean(), + branding: boolean(), + information: boolean(), + privacy: boolean(), + consent: boolean(), + helpdesk: boolean(), + panel: boolean(), + storage: boolean(), + participants: boolean(), + workflow: boolean(), + monitor: boolean() + } + + defstruct [ + :general, + :branding, + :information, + :privacy, + :consent, + :helpdesk, + :panel, + :storage, + :participants, + :workflow, + :monitor + ] + + def new() do + %__MODULE__{ + general: true, + branding: true, + information: true, + privacy: true, + consent: true, + helpdesk: true, + panel: true, + storage: true, + participants: true, + workflow: true, + monitor: true + } + end +end diff --git a/core/systems/assignment/template_benchmark_challenge.ex b/core/systems/assignment/template_benchmark_challenge.ex new file mode 100644 index 000000000..2592dc1d5 --- /dev/null +++ b/core/systems/assignment/template_benchmark_challenge.ex @@ -0,0 +1,51 @@ +defmodule Systems.Assignment.TemplateBenchmarkChallenge do + alias Systems.Assignment + alias Systems.Workflow + + import CoreWeb.Gettext + + defstruct [:id] + + defimpl Assignment.Template do + def title(t), do: Assignment.Templates.translate(t.id) + + def content_flags(_t) do + Map.merge(Assignment.ContentFlags.new(), %{ + general: false, + panel: false, + storage: false + }) + end + + def workflow(_t), + do: %Workflow.Config{ + type: :many_mandatory, + library: %Workflow.LibraryModel{ + render?: true, + items: [ + %Workflow.LibraryItemModel{ + special: :fork_instruction, + tool: :instruction_tool, + title: Assignment.WorkflowItemSpecials.translate(:fork_instruction), + description: + dgettext("eyra-assignment", "workflow_item.fork_instruction.description") + }, + %Workflow.LibraryItemModel{ + special: :download_instruction, + tool: :instruction_tool, + title: Assignment.WorkflowItemSpecials.translate(:download_instruction), + description: + dgettext("eyra-assignment", "workflow_item.download_instruction.description") + }, + %Workflow.LibraryItemModel{ + special: :submit, + tool: :graphite_tool, + title: Assignment.WorkflowItemSpecials.translate(:submit), + description: dgettext("eyra-assignment", "workflow_item.submit.description") + } + ] + }, + initial_items: [:fork_instruction, :download_instruction, :submit] + } + end +end diff --git a/core/systems/assignment/template_data_donation.ex b/core/systems/assignment/template_data_donation.ex new file mode 100644 index 000000000..4e8f31938 --- /dev/null +++ b/core/systems/assignment/template_data_donation.ex @@ -0,0 +1,53 @@ +defmodule Systems.Assignment.TemplateDataDonation do + alias Systems.Assignment + alias Systems.Workflow + + import CoreWeb.Gettext + + defstruct [:id] + + defimpl Assignment.Template do + def title(t), do: Assignment.Templates.translate(t.id) + + def content_flags(_t) do + Map.merge(Assignment.ContentFlags.new(), %{ + participants: false + }) + end + + def workflow(_t), + do: %Workflow.Config{ + type: :many_optional, + library: %Workflow.LibraryModel{ + render?: false, + items: [ + %Workflow.LibraryItemModel{ + special: :donate, + tool: :feldspar_tool, + title: Assignment.WorkflowItemSpecials.translate(:donate), + description: dgettext("eyra-assignment", "workflow_item.donate.description") + }, + %Workflow.LibraryItemModel{ + special: :questionnaire, + tool: :alliance_tool, + title: Assignment.WorkflowItemSpecials.translate(:questionnaire), + description: dgettext("eyra-assignment", "workflow_item.questionnaire.description") + }, + %Workflow.LibraryItemModel{ + special: :request_manual, + tool: :document_tool, + title: Assignment.WorkflowItemSpecials.translate(:request_manual), + description: dgettext("eyra-assignment", "workflow_item.request.description") + }, + %Workflow.LibraryItemModel{ + special: :download_manual, + tool: :document_tool, + title: Assignment.WorkflowItemSpecials.translate(:download_manual), + description: dgettext("eyra-assignment", "workflow_item.download.description") + } + ] + }, + initial_items: [] + } + end +end diff --git a/core/systems/assignment/workflow_item_specials.ex b/core/systems/assignment/workflow_item_specials.ex new file mode 100644 index 000000000..3a1d1e1a5 --- /dev/null +++ b/core/systems/assignment/workflow_item_specials.ex @@ -0,0 +1,16 @@ +defmodule Systems.Assignment.WorkflowItemSpecials do + @moduledoc """ + Defines the types of workflow items supported by. + """ + use Core.Enums.Base, + {:assignment_workflow_item_types, + [ + :donate, + :questionnaire, + :request_manual, + :download_manual, + :submit, + :fork_instruction, + :download_instruction + ]} +end diff --git a/core/systems/content/_public.ex b/core/systems/content/_public.ex index 840839010..ecad9004d 100644 --- a/core/systems/content/_public.ex +++ b/core/systems/content/_public.ex @@ -4,6 +4,7 @@ defmodule Systems.Content.Public do alias Core.Repo alias Ecto.Multi + alias Frameworks.Signal alias Systems.Content alias Systems.Content.TextItemModel, as: TextItem alias Systems.Content.TextBundleModel, as: TextBundle @@ -13,12 +14,29 @@ defmodule Systems.Content.Public do |> Content.FileModel.changeset(%{name: name, ref: ref}) end - def prepare_page(title, body, auth_node) do + def prepare_page(body, auth_node) do %Content.PageModel{} - |> Content.PageModel.changeset(%{title: title, body: body}) + |> Content.PageModel.changeset(%{body: body}) |> Ecto.Changeset.put_assoc(:auth_node, auth_node) end + def prepare_repository(attrs) do + %Content.RepositoryModel{} + |> Content.RepositoryModel.changeset(attrs) + |> Content.RepositoryModel.validate() + end + + def update_repository(repository, attrs) do + repository = + Content.RepositoryModel.changeset(repository, attrs) + |> Content.RepositoryModel.validate() + + Multi.new() + |> Multi.update(:content_repository, repository) + |> Signal.Public.multi_dispatch({:content_repository, :update}) + |> Repo.transaction() + end + def store(path, original_filename) do Content.Private.get_backend().store(path, original_filename) end diff --git a/core/systems/content/file_model.ex b/core/systems/content/file_model.ex index 96bbbf716..412ac3744 100644 --- a/core/systems/content/file_model.ex +++ b/core/systems/content/file_model.ex @@ -22,4 +22,6 @@ defmodule Systems.Content.FileModel do changeset |> validate_required(@required_fields) end + + def preload_graph(:down), do: preload_graph([]) end diff --git a/core/systems/content/page_model.ex b/core/systems/content/page_model.ex index 27404701a..5c8c8f848 100644 --- a/core/systems/content/page_model.ex +++ b/core/systems/content/page_model.ex @@ -22,4 +22,6 @@ defmodule Systems.Content.PageModel do changeset |> validate_required(@required_fields) end + + def preload_graph(:down), do: preload_graph([]) end diff --git a/core/systems/content/repository_model.ex b/core/systems/content/repository_model.ex new file mode 100644 index 000000000..81d0f9de6 --- /dev/null +++ b/core/systems/content/repository_model.ex @@ -0,0 +1,27 @@ +defmodule Systems.Content.RepositoryModel do + use Ecto.Schema + use Frameworks.Utility.Schema + + import Ecto.Changeset + + schema "content_repositories" do + field(:platform, Ecto.Enum, values: [:github]) + field(:url, :string) + timestamps() + end + + @fields ~w(platform url)a + @required_fields @fields + + def changeset(repository, attrs \\ %{}) do + repository + |> cast(attrs, @fields) + end + + def validate(changeset) do + changeset + |> validate_required(@required_fields) + end + + def preload_graph(:down), do: preload_graph([]) +end diff --git a/core/systems/document/tool_model.ex b/core/systems/document/tool_model.ex index afa94541c..3df5e7996 100644 --- a/core/systems/document/tool_model.ex +++ b/core/systems/document/tool_model.ex @@ -44,7 +44,7 @@ defmodule Systems.Document.ToolModel do def apply_label(_), do: dgettext("eyra-document", "apply.cta.title") def open_label(_), do: dgettext("eyra-document", "open.cta.title") def ready?(tool), do: Document.ToolModel.ready?(tool) - def form(_), do: Document.ToolForm + def form(_, _), do: Document.ToolForm def launcher(%{id: id, ref: ref}), do: %{ diff --git a/core/systems/feldspar/tool_model.ex b/core/systems/feldspar/tool_model.ex index 84b9b0829..276e132bb 100644 --- a/core/systems/feldspar/tool_model.ex +++ b/core/systems/feldspar/tool_model.ex @@ -45,7 +45,7 @@ defmodule Systems.Feldspar.ToolModel do def apply_label(_), do: dgettext("eyra-feldspar", "apply.cta.title") def open_label(_), do: dgettext("eyra-feldspar", "open.cta.title") def ready?(tool), do: Feldspar.ToolModel.ready?(tool) - def form(_), do: Feldspar.ToolForm + def form(_, _), do: Feldspar.ToolForm def launcher(%{id: id, archive_ref: archive_ref}) when is_binary(archive_ref) do %{ diff --git a/core/systems/graphite/_public.ex b/core/systems/graphite/_public.ex index bd75083e1..4651be880 100644 --- a/core/systems/graphite/_public.ex +++ b/core/systems/graphite/_public.ex @@ -1,11 +1,13 @@ defmodule Systems.Graphite.Public do import Ecto.Query, warn: false + import Systems.Graphite.Queries alias CoreWeb.UI.Timestamp alias Ecto.Multi alias Ecto.Changeset alias Core.Repo + alias Frameworks.Signal alias Systems.Graphite # FIXME: should come from CMS @@ -21,6 +23,15 @@ defmodule Systems.Graphite.Public do |> Repo.get!(id) end + def get_submission(tool, user, role, preload \\ []) do + submissions = + submission_query(tool, user, role) + |> Repo.all() + |> Repo.preload(preload) + + List.first(submissions) + end + def set_tool_status(%Graphite.ToolModel{} = tool, status) do tool |> Graphite.ToolModel.changeset(%{status: status}) @@ -33,19 +44,38 @@ defmodule Systems.Graphite.Public do end def prepare_tool(%{} = attrs, auth_node \\ Core.Authorization.prepare_node()) do - attrs = Map.put(attrs, :status, :concept) - %Graphite.ToolModel{} |> Graphite.ToolModel.changeset(attrs) |> Changeset.put_assoc(:auth_node, auth_node) end - def create_submission(%Changeset{} = changeset) do - changeset - |> Repo.insert( - conflict_target: [:id], - on_conflict: :replace_all - ) + def prepare_submission(%{} = attrs, user, tool) do + auth_node = Core.Authorization.prepare_node(user, :owner) + + %Graphite.SubmissionModel{} + |> Graphite.SubmissionModel.change(attrs) + |> Graphite.SubmissionModel.validate() + |> Changeset.put_assoc(:tool, tool) + |> Changeset.put_assoc(:auth_node, auth_node) + end + + def add_submission(tool, user, attrs) do + submission = prepare_submission(attrs, user, tool) + + Multi.new() + |> Multi.insert(:graphite_submission, submission) + |> Signal.Public.multi_dispatch({:graphite_submission, :inserted}) + |> Repo.transaction() + end + + def update_submission(submission, attrs) do + Multi.new() + |> Multi.update(:graphite_submission, fn _ -> + Graphite.SubmissionModel.change(submission, attrs) + |> Graphite.SubmissionModel.validate() + end) + |> Signal.Public.multi_dispatch({:graphite_submission, :updated}) + |> Repo.transaction() end defp parse_entry(line) do diff --git a/core/systems/graphite/content_page.ex b/core/systems/graphite/content_page.ex deleted file mode 100644 index 2f011c505..000000000 --- a/core/systems/graphite/content_page.ex +++ /dev/null @@ -1,48 +0,0 @@ -defmodule Systems.Graphite.ContentPage do - use CoreWeb, :live_view - use Systems.Content.Page - - alias Systems.{ - Graphite - } - - @impl true - def get_authorization_context(%{"id" => id}, _session, _socket) do - Graphite.Public.get_tool!(id) - end - - @impl true - def mount(%{"id" => id} = params, _, socket) do - initial_tab = Map.get(params, "tab") - - model = - Graphite.Public.get_tool!(String.to_integer(id), Graphite.ToolModel.preload_graph(:down)) - - tabbar_id = "benchmark_content/#{id}" - - { - :ok, - socket |> initialize(id, model, tabbar_id, initial_tab) - } - end - - @impl true - def render(assigns) do - ~H""" - <.content_page - title={@vm.title} - menus={@menus} - tabs={@vm.tabs} - actions={@actions} - more_actions={@more_actions} - initial_tab={@initial_tab} - tabbar_id={@tabbar_id} - tabbar_size={@tabbar_size} - breakpoint={@breakpoint} - popup={@popup} - dialog={@dialog} - show_errors={@show_errors} - /> - """ - end -end diff --git a/core/systems/graphite/content_page_builder.ex b/core/systems/graphite/content_page_builder.ex deleted file mode 100644 index f93aa5886..000000000 --- a/core/systems/graphite/content_page_builder.ex +++ /dev/null @@ -1,218 +0,0 @@ -defmodule Systems.Graphite.ContentPageBuilder do - import CoreWeb.Gettext - - alias Systems.{ - Graphite - } - - @tabs [:config, :invite, :submissions, :leaderboard] - - def view_model( - %{id: id} = tool, - assigns - ) do - show_errors = show_errors(tool, assigns) - tabs = create_tabs(tool, show_errors, assigns) - action_map = action_map(tool) - actions = actions(tool, action_map) - - %{ - id: id, - title: dgettext("eyra-benchmark", "content.title"), - tabs: tabs, - actions: actions, - show_errors: show_errors - } - end - - defp show_errors(%{status: _status}, %{publish_clicked: _publish_clicked}) do - # concept? = status == :concept - # publish_clicked or not concept? - false - end - - defp action_map(%{id: id}) do - preview_action = %{type: :http_get, to: "/graphite/#{id}", target: "_blank"} - publish_action = %{type: :send, event: "action_click", item: :publish} - retract_action = %{type: :send, event: "action_click", item: :retract} - close_action = %{type: :send, event: "action_click", item: :close} - open_action = %{type: :send, event: "action_click", item: :open} - - %{ - preview: %{ - label: %{ - action: preview_action, - face: %{ - type: :primary, - label: dgettext("eyra-benchmark", "preview.button"), - bg_color: "bg-primary" - } - }, - icon: %{ - action: preview_action, - face: %{type: :icon, icon: :preview, alt: dgettext("eyra-benchmark", "preview.button")} - } - }, - publish: %{ - label: %{ - action: publish_action, - face: %{ - type: :primary, - label: dgettext("eyra-benchmark", "publish.button"), - bg_color: "bg-success" - } - }, - icon: %{ - action: publish_action, - face: %{type: :icon, icon: :publish, alt: dgettext("eyra-benchmark", "publish.button")} - }, - handle_click: &handle_publish/1 - }, - retract: %{ - label: %{ - action: retract_action, - face: %{ - type: :secondary, - label: dgettext("eyra-benchmark", "retract.button"), - text_color: "text-error", - border_color: "border-error" - } - }, - icon: %{ - action: retract_action, - face: %{type: :icon, icon: :retract, alt: dgettext("eyra-benchmark", "retract.button")} - }, - handle_click: &handle_retract/1 - }, - close: %{ - label: %{ - action: close_action, - face: %{ - type: :primary, - label: dgettext("eyra-benchmark", "close.button") - } - }, - icon: %{ - action: close_action, - face: %{type: :icon, icon: :close, alt: dgettext("eyra-benchmark", "close.button")} - }, - handle_click: &handle_close/1 - }, - open: %{ - label: %{ - action: open_action, - face: %{ - type: :primary, - label: dgettext("eyra-benchmark", "open.button") - } - }, - icon: %{ - action: open_action, - face: %{type: :icon, icon: :open, alt: dgettext("eyra-benchmark", "open.button")} - }, - handle_click: &handle_open/1 - } - } - end - - defp actions(%{status: :concept}, %{publish: publish, preview: preview}), - do: [publish: publish, preview: preview] - - defp actions(%{status: :online}, %{retract: retract}), do: [retract: retract] - - defp actions(%{status: :offline}, %{publish: publish, close: close}), - do: [publish: publish, close: close] - - defp actions(%{status: :idle}, %{open: open}), do: [open: open] - - defp handle_publish(socket) do - socket |> set_tool_status(:online) - end - - defp handle_retract(socket) do - socket |> set_tool_status(:offline) - end - - defp handle_close(socket) do - socket |> set_tool_status(:idle) - end - - defp handle_open(socket) do - socket |> set_tool_status(:concept) - end - - defp set_tool_status(%{assigns: %{vm: %{id: id}}} = socket, status) do - Graphite.Public.set_tool_status(id, status) - socket - end - - defp create_tabs(tool, show_errors, assigns) do - Enum.map(@tabs, &create_tab(&1, tool, show_errors, assigns)) - end - - defp create_tab( - :config, - tool, - show_errors, - _assigns - ) do - ready? = false - - %{ - id: :config_form, - ready: ready?, - show_errors: show_errors, - title: dgettext("eyra-project", "tabbar.item.config"), - forward_title: dgettext("eyra-project", "tabbar.item.config.forward"), - type: :fullpage, - live_component: Graphite.ToolForm, - props: %{ - entity: tool - } - } - end - - defp create_tab( - :submissions, - tool, - show_errors, - _assigns - ) do - ready? = false - - %{ - id: :submissions, - ready: ready?, - show_errors: show_errors, - title: dgettext("eyra-benchmark", "tabbar.item.submissions"), - forward_title: dgettext("eyra-benchmark", "tabbar.item.submissions.forward"), - type: :fullpage, - live_component: Graphite.SubmissionOverview, - props: %{ - entity: tool - } - } - end - - defp create_tab( - :leaderboard, - tool, - show_errors, - _assigns - ) do - ready? = false - - %{ - id: :leaderboard, - ready: ready?, - show_errors: show_errors, - title: dgettext("eyra-benchmark", "tabbar.item.leaderboard"), - forward_title: dgettext("eyra-benchmark", "tabbar.item.leaderboard.forward"), - type: :fullpage, - live_component: Graphite.LeaderboardOverview, - props: %{ - entity: tool - } - } - end -end diff --git a/core/systems/graphite/leaderboard_category_view.ex b/core/systems/graphite/leaderboard_category_view.ex index a6e2954c7..1493c6e40 100644 --- a/core/systems/graphite/leaderboard_category_view.ex +++ b/core/systems/graphite/leaderboard_category_view.ex @@ -33,11 +33,11 @@ defmodule Systems.Graphite.LeaderboardCategoryView do |> Enum.sort_by(& &1.score, :desc) head_cells = [ - dgettext("eyra-benchmark", "leaderboard.position.label"), - dgettext("eyra-benchmark", "leaderboard.team.label"), - dgettext("eyra-benchmark", "leaderboard.method.label"), - dgettext("eyra-benchmark", "leaderboard.github.label"), - dgettext("eyra-benchmark", "leaderboard.score.label") + dgettext("eyra-graphite", "leaderboard.position.label"), + dgettext("eyra-graphite", "leaderboard.team.label"), + dgettext("eyra-graphite", "leaderboard.method.label"), + dgettext("eyra-graphite", "leaderboard.github.label"), + dgettext("eyra-graphite", "leaderboard.score.label") ] layout = [ diff --git a/core/systems/graphite/leaderboard_overview.ex b/core/systems/graphite/leaderboard_overview.ex index 38694dbd8..b9545bb84 100644 --- a/core/systems/graphite/leaderboard_overview.ex +++ b/core/systems/graphite/leaderboard_overview.ex @@ -22,10 +22,10 @@ defmodule Systems.Graphite.LeaderboardOverview do id: :import_form, module: Graphite.ImportForm, parent: %{type: __MODULE__, id: id}, - placeholder: dgettext("eyra-benchmark", "csv-select-placeholder"), - select_button: dgettext("eyra-benchmark", "csv-select-file-button"), - replace_button: dgettext("eyra-benchmark", "csv-replace-file-button"), - process_button: dgettext("eyra-benchmark", "csv-import-button") + placeholder: dgettext("eyra-graphite", "csv-select-placeholder"), + select_button: dgettext("eyra-graphite", "csv-select-file-button"), + replace_button: dgettext("eyra-graphite", "csv-replace-file-button"), + process_button: dgettext("eyra-graphite", "csv-import-button") } { @@ -63,7 +63,7 @@ defmodule Systems.Graphite.LeaderboardOverview do }, face: %{ type: :plain, - label: dgettext("eyra-benchmark", "leaderboard.forward.button"), + label: dgettext("eyra-graphite", "leaderboard.forward.button"), icon: :forward } } @@ -78,14 +78,14 @@ defmodule Systems.Graphite.LeaderboardOverview do
- <%= dgettext("eyra-benchmark", "tabbar.item.leaderboard")%> + <%= dgettext("eyra-graphite", "tabbar.item.leaderboard")%>
<.spacing value="M" /> <.live_component {@leaderboard} /> <.spacing value="XL" /> - <%= dgettext("eyra-benchmark", "import.leaderboard.title")%> + <%= dgettext("eyra-graphite", "import.leaderboard.title")%> <.spacing value="S" /> <.live_component {@import_form} /> diff --git a/core/systems/graphite/leaderboard_page.ex b/core/systems/graphite/leaderboard_page.ex index 5eda7ecc7..7957f51a9 100644 --- a/core/systems/graphite/leaderboard_page.ex +++ b/core/systems/graphite/leaderboard_page.ex @@ -30,7 +30,7 @@ defmodule Systems.Graphite.LeaderboardPage do action: %{type: :http_get, to: ~p"/graphite/#{tool_id}"}, face: %{ type: :plain, - label: dgettext("eyra-benchmark", "challenge.forward.button"), + label: dgettext("eyra-graphite", "challenge.forward.button"), icon: :forward } } diff --git a/core/systems/graphite/submission_form.ex b/core/systems/graphite/submission_form.ex index 9a824ae61..bdfb755d6 100644 --- a/core/systems/graphite/submission_form.ex +++ b/core/systems/graphite/submission_form.ex @@ -1,48 +1,71 @@ defmodule Systems.Graphite.SubmissionForm do - use CoreWeb.LiveForm + use CoreWeb.LiveForm, :fabric + use Fabric.LiveComponent - alias Systems.{ - Graphite - } + alias Systems.Graphite # Handle initial update @impl true - def update(%{id: id, spot: spot, submission: submission, parent: parent}, socket) do - close_button = %{ - action: %{type: :send, event: "close"}, - face: %{type: :icon, icon: :close} - } - - submit_button = %{ - action: %{type: :submit, form_id: id}, - face: %{type: :primary, label: dgettext("eyra-benchmark", "submission.form.submit.button")} - } - - changeset = Graphite.SubmissionModel.prepare(submission, %{}) - + def update(%{id: id, tool: tool, user: user}, socket) do { :ok, socket |> assign( id: id, - spot: spot, - submission: submission, - parent: parent, - close_button: close_button, - submit_button: submit_button, - changeset: changeset, + tool: tool, + user: user, show_errors: false ) + |> update_submission() + |> update_changeset() + |> update_submit_button() + |> update_cancel_button() } end - # Handle Events + defp update_submission(%{assigns: %{tool: tool, user: user}} = socket) do + submission = Graphite.Public.get_submission(tool, user, :owner) + socket |> assign(submission: submission) + end - @impl true - def handle_event("close", _params, socket) do - {:noreply, socket |> close()} + defp update_changeset(%{assigns: %{submission: submission}} = socket) do + changeset = + if submission do + Graphite.SubmissionModel.prepare(submission, %{}) + else + Graphite.SubmissionModel.prepare(%Graphite.SubmissionModel{}, %{}) + end + + socket |> assign(changeset: changeset) + end + + defp update_submit_button(%{assigns: %{id: id, submission: submission}} = socket) do + submit_button_face = + if submission do + %{type: :primary, label: dgettext("eyra-graphite", "submission.form.update.button")} + else + %{type: :primary, label: dgettext("eyra-graphite", "submission.form.submit.button")} + end + + submit_button = %{ + action: %{type: :submit, form_id: id}, + face: submit_button_face + } + + socket |> assign(submit_button: submit_button) end + defp update_cancel_button(%{assigns: %{myself: myself}} = socket) do + cancel_button = %{ + action: %{type: :send, event: "cancel", target: myself}, + face: %{type: :label, label: dgettext("eyra-ui", "cancel.button")} + } + + socket |> assign(cancel_button: cancel_button) + end + + # Handle Events + @impl true def handle_event("submit", %{"submission_model" => attrs}, socket) do { @@ -52,63 +75,51 @@ defmodule Systems.Graphite.SubmissionForm do } end + @impl true + def handle_event("cancel", _payload, socket) do + {:noreply, socket |> send_event(:parent, "cancel")} + end + # Submit - defp handle_submit( - %{assigns: %{spot: spot, submission: %{spot_id: nil} = submission}} = socket, - attrs - ) do - changeset = - submission - |> Graphite.SubmissionModel.change(attrs) - |> Graphite.SubmissionModel.validate() - |> Ecto.Changeset.put_assoc(:spot, spot) + defp handle_submit(%{assigns: %{submission: nil, tool: tool, user: user}} = socket, attrs) do + case Graphite.Public.add_submission(tool, user, attrs) do + {:ok, %{graphite_submission: submission}} -> + socket + |> assign(submission: submission) + |> send_event(:parent, "submitted") - socket |> upsert(changeset) - end - - defp handle_submit(%{assigns: %{submission: submission}} = socket, attrs) do - changeset = - submission - |> Graphite.SubmissionModel.change(attrs) - |> Graphite.SubmissionModel.validate() + {:error, :graphite_submission, changeset, _} -> + socket |> assign(show_errors: true, changeset: changeset) - socket |> upsert(changeset) + {:error, :graphite_tool, _changeset, _} -> + socket |> put_flash(:error, dgettext("eyra-graphite", "submit.failed.message")) + end end - defp upsert(socket, changeset) do - case Graphite.Public.create_submission(changeset) do - {:ok, _submission} -> - socket |> close() + defp handle_submit(%{assigns: %{submission: submission}} = socket, attrs) do + case Graphite.Public.update_submission(submission, attrs) do + {:ok, %{graphite_submission: _submission}} -> + socket |> send_event(:parent, "submitted") - {:error, changeset} -> + {:error, :graphite_submission, changeset, _} -> socket |> assign(show_errors: true, changeset: changeset) end end - defp close(%{assigns: %{parent: parent}} = socket) do - update_target(parent, %{module: __MODULE__, action: :close}) - socket - end - @impl true def render(assigns) do ~H"""
-
-
- <%= dgettext("eyra-benchmark", "submission.form.title") %> -
-
- -
- <.spacing value="XS" /> <.form id={@id} :let={form} for={@changeset} phx-submit="submit" phx-target={@myself} > - <.text_input form={form} field={:description} label_text={dgettext("eyra-benchmark", "submission.form.description.label")} /> - <.text_input form={form} field={:github_commit_url} placeholder="http://github///commit/" label_text={dgettext("eyra-benchmark", "submission.form.url.label")} /> + <.text_input form={form} field={:description} label_text={dgettext("eyra-graphite", "submission.form.description.label")} /> + <.text_input form={form} field={:github_commit_url} placeholder="https://github///commit/" label_text={dgettext("eyra-graphite", "submission.form.url.label")} /> <.spacing value="XS" /> - +
+ + +
""" diff --git a/core/systems/graphite/submission_model.ex b/core/systems/graphite/submission_model.ex index a4883aaf6..4088cb391 100644 --- a/core/systems/graphite/submission_model.ex +++ b/core/systems/graphite/submission_model.ex @@ -34,7 +34,7 @@ defmodule Systems.Graphite.SubmissionModel do changeset |> validate_required(@required_fields) |> validate_format(:github_commit_url, @valid_github_commit_url, - message: dgettext("eyra-benchmark", "invalid.github.commit.url.message") + message: dgettext("eyra-graphite", "invalid.github.commit.url.message") ) end diff --git a/core/systems/graphite/submission_overview.ex b/core/systems/graphite/submission_overview.ex index df0d453bd..9fefec11a 100644 --- a/core/systems/graphite/submission_overview.ex +++ b/core/systems/graphite/submission_overview.ex @@ -72,7 +72,7 @@ defmodule Systems.Graphite.SubmissionOverview do
- <%= dgettext("eyra-benchmark", "tabbar.item.submissions")%> <%= Enum.count(@submission_items) %> + <%= dgettext("eyra-graphite", "tabbar.item.submissions")%> <%= Enum.count(@submission_items) %>
diff --git a/core/systems/graphite/tool_form.ex b/core/systems/graphite/tool_form.ex index e57158712..2b40c1e0c 100644 --- a/core/systems/graphite/tool_form.ex +++ b/core/systems/graphite/tool_form.ex @@ -1,68 +1,19 @@ defmodule Systems.Graphite.ToolForm do - use CoreWeb.LiveForm + use CoreWeb, :live_component_fabric + use Fabric.LiveComponent - alias Systems.{ - Graphite - } - - # Handle initial update @impl true - def update( - %{id: id, entity: benchmark}, - socket - ) do - changeset = Graphite.ToolModel.changeset(benchmark, %{}) - + def update(_, socket) do { :ok, socket - |> assign( - id: id, - entity: benchmark, - changeset: changeset - ) - } - end - - # Handle Events - @impl true - def handle_event("save", %{"tool_model" => attrs}, %{assigns: %{entity: entity}} = socket) do - { - :noreply, - socket - |> save(entity, attrs) } end - # Saving - - def save(socket, entity, attrs) do - changeset = Graphite.ToolModel.changeset(entity, attrs) - - socket - |> save(changeset) - |> validate(changeset) - end - - def validate(socket, changeset) do - changeset = Graphite.ToolModel.validate(changeset) - - socket - |> assign(changeset: changeset) - end - @impl true def render(assigns) do ~H""" -
- <.form id={"#{@id}_graphite_tool_form"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > - <.text_input form={form} field={:title} label_text={dgettext("eyra-benchmark", "form.title.label")} /> - <.text_area form={form} field={:expectations} label_text={dgettext("eyra-benchmark", "form.expectations.label")} /> - <.url_input form={form} field={:data_set} label_text={dgettext("eyra-benchmark", "form.data_set.label")} /> - <.url_input form={form} field={:template_repo} label_text={dgettext("eyra-benchmark", "form.template_repo.label")} /> - <.date_input form={form} field={:deadline} label_text={dgettext("eyra-benchmark", "form.deadline.label")} /> - -
+
""" end end diff --git a/core/systems/graphite/tool_model.ex b/core/systems/graphite/tool_model.ex index a21c5689b..017fcb405 100644 --- a/core/systems/graphite/tool_model.ex +++ b/core/systems/graphite/tool_model.ex @@ -11,14 +11,13 @@ defmodule Systems.Graphite.ToolModel do alias Systems.Graphite schema "graphite_tools" do - field(:max_submissions, :integer) belongs_to(:auth_node, Core.Authorization.Node) has_many(:submissions, Graphite.SubmissionModel, foreign_key: :tool_id) timestamps() end - @fields ~w(max_submissions)a + @fields ~w()a @required_fields @fields def changeset(tool, params) do @@ -43,17 +42,10 @@ defmodule Systems.Graphite.ToolModel do def preload_graph(:submissions), do: [submissions: Graphite.SubmissionModel.preload_graph(:down)] - def preload_graph(:leaderboards), - do: [leaderboards: Graphite.LeaderboardModel.preload_graph(:down)] - defimpl Frameworks.GreenLight.AuthorizationNode do def id(tool), do: tool.auth_node_id end - defimpl Frameworks.Concept.Directable do - def director(%{director: director}), do: Frameworks.Concept.System.director(director) - end - def ready?(tool) do changeset = changeset(tool, %{}) @@ -66,20 +58,28 @@ defmodule Systems.Graphite.ToolModel do alias Systems.Graphite def key(_), do: :graphite def auth_tree(%{auth_node: auth_node}), do: auth_node - def apply_label(_), do: dgettext("eyra-benchmark", "apply.cta.title") - def open_label(_), do: dgettext("eyra-benchmark", "open.cta.title") - def ready?(tool), do: Graphite.ToolModel.ready?(tool) - def form(_), do: Graphite.Form - def launcher(_), do: nil + def apply_label(_), do: "" + def open_label(_), do: "" + def ready?(_), do: true + def form(_, _), do: Graphite.ToolForm + + def launcher(tool) do + %{ + module: Graphite.ToolView, + params: %{ + tool: tool + } + } + end def task_labels(_) do %{ - pending: dgettext("eyra-benchmark", "pending.label"), - participated: dgettext("eyra-benchmark", "participated.label") + pending: dgettext("eyra-graphite", "pending.label"), + participated: dgettext("eyra-graphite", "participated.label") } end def attention_list_enabled?(_t), do: false - def group_enabled?(_t), do: true + def group_enabled?(_t), do: false end end diff --git a/core/systems/graphite/tool_page.ex b/core/systems/graphite/tool_page.ex index fdd194e6c..e10d7915e 100644 --- a/core/systems/graphite/tool_page.ex +++ b/core/systems/graphite/tool_page.ex @@ -91,16 +91,16 @@ defmodule Systems.Graphite.ToolPage do
<.spacing value="XL" /> - <%= dgettext("eyra-benchmark", "expectations.title") %> + <%= dgettext("eyra-graphite", "expectations.title") %> <%= raw(@vm.expectations) %> <%!-- <.spacing value="XS" /> - <%= dgettext("eyra-benchmark", "expectations.subhead") %> --%> + <%= dgettext("eyra-graphite", "expectations.subhead") %> --%> <.spacing value="XL" /> - <%= dgettext("eyra-benchmark", "preparation.title") %> - <%= dgettext("eyra-benchmark", "preparation.description") %> + <%= dgettext("eyra-graphite", "preparation.title") %> + <%= dgettext("eyra-graphite", "preparation.description") %> <.spacing value="XS" /> - 1. <%= dgettext("eyra-benchmark", "preparation.dataset.title") %> + 1. <%= dgettext("eyra-graphite", "preparation.dataset.title") %> <.spacing value="M" /> <%= if @vm.dataset_button do %>
@@ -111,7 +111,7 @@ defmodule Systems.Graphite.ToolPage do <% end %> <.spacing value="M" /> - 2. <%= dgettext("eyra-benchmark", "preparation.template.title") %> + 2. <%= dgettext("eyra-graphite", "preparation.template.title") %> <.spacing value="XS" /> <.spacing value="XL" /> diff --git a/core/systems/graphite/tool_page_builder.ex b/core/systems/graphite/tool_page_builder.ex index db3e1ff7d..a9e2da80d 100644 --- a/core/systems/graphite/tool_page_builder.ex +++ b/core/systems/graphite/tool_page_builder.ex @@ -29,7 +29,7 @@ defmodule Systems.Graphite.ToolPageBuilder do if active? do %{ action: %{type: :http_get, to: presigned_data_set, target: "_blank"}, - face: %{type: :primary, label: dgettext("eyra-benchmark", "dataset.button")} + face: %{type: :primary, label: dgettext("eyra-graphite", "dataset.button")} } else nil @@ -37,7 +37,7 @@ defmodule Systems.Graphite.ToolPageBuilder do template_button = %{ action: %{type: :http_get, to: template_repo, target: "_blank"}, - face: %{type: :link, text: dgettext("eyra-benchmark", "template.button"), font: ""} + face: %{type: :link, text: dgettext("eyra-graphite", "template.button"), font: ""} } title = @@ -73,13 +73,13 @@ defmodule Systems.Graphite.ToolPageBuilder do }, face: %{ type: :plain, - label: dgettext("eyra-benchmark", "leaderboard.forward.button"), + label: dgettext("eyra-graphite", "leaderboard.forward.button"), icon: :forward } } %{ - title: dgettext("eyra-benchmark", "tabbar.item.leaderboard"), + title: dgettext("eyra-graphite", "tabbar.item.leaderboard"), forward_button: forward_button, component: %{ id: :leaderboard, @@ -92,7 +92,7 @@ defmodule Systems.Graphite.ToolPageBuilder do end %{ - hero_title: dgettext("eyra-benchmark", "tool.page.title"), + hero_title: dgettext("eyra-graphite", "tool.page.title"), title: title, highlights: highlights, expectations: expectations, @@ -125,13 +125,13 @@ defmodule Systems.Graphite.ToolPageBuilder do |> Enum.reduce(0, fn count, acc -> acc + count end) %{ - title: dgettext("eyra-benchmark", "highlight.submissions.title"), + title: dgettext("eyra-graphite", "highlight.submissions.title"), text: "#{submission_count}" } end def highlight(%{spots: spots}, :spot_count) do - %{title: dgettext("eyra-benchmark", "highlight.spots.title"), text: "#{Enum.count(spots)}"} + %{title: dgettext("eyra-graphite", "highlight.spots.title"), text: "#{Enum.count(spots)}"} end def highlight(%{deadline: nil}, :deadline) do @@ -146,8 +146,8 @@ defmodule Systems.Graphite.ToolPageBuilder do end def highlight(days_to_go, :deadline) when is_integer(days_to_go) do - title = dgettext("eyra-benchmark", "highlight.deadline.title") - text = dngettext("eyra-benchmark", "1 day", "%{count} days", max(0, days_to_go)) + title = dgettext("eyra-graphite", "highlight.deadline.title") + text = dngettext("eyra-graphite", "1 day", "%{count} days", max(0, days_to_go)) %{title: title, text: text} end diff --git a/core/systems/graphite/tool_view.ex b/core/systems/graphite/tool_view.ex new file mode 100644 index 000000000..d9f16cc2c --- /dev/null +++ b/core/systems/graphite/tool_view.ex @@ -0,0 +1,53 @@ +defmodule Systems.Graphite.ToolView do + use CoreWeb, :live_component_fabric + use Fabric.LiveComponent + + @impl true + def update(%{tool: tool, user: user}, socket) do + { + :ok, + socket + |> assign( + tool: tool, + user: user + ) + |> send_event(:parent, "tool_initialized") + |> compose_child(:submission_form) + } + end + + @impl true + def compose(:submission_form, %{tool: tool, user: user}) do + %{ + module: Systems.Graphite.SubmissionForm, + params: %{ + tool: tool, + user: user + } + } + end + + @impl true + def handle_event("submitted", _payload, socket) do + {:noreply, socket |> send_event(:parent, "complete_task")} + end + + @impl true + def handle_event("cancel", _payload, socket) do + {:noreply, socket |> send_event(:parent, "cancel_task")} + end + + @impl true + def render(assigns) do + ~H""" +
+ + + <%= dgettext("eyra-graphite", "submission.form.title") %> + <.spacing value="M" /> + <.child name={:submission_form} fabric={@fabric} /> + +
+ """ + end +end diff --git a/core/systems/instruction/_public.ex b/core/systems/instruction/_public.ex new file mode 100644 index 000000000..f41f0452f --- /dev/null +++ b/core/systems/instruction/_public.ex @@ -0,0 +1,64 @@ +defmodule Systems.Instruction.Public do + import Ecto.Query, warn: false + alias Core.Repo + alias Ecto.Multi + + alias Frameworks.Signal + alias Systems.Instruction + alias Systems.Content + + def get_tool!(id, preload \\ []) do + from(tool in Instruction.ToolModel, preload: ^preload) + |> Repo.get!(id) + end + + def get_asset_by(%Content.RepositoryModel{id: id}, preload \\ []) do + from(asset in Instruction.AssetModel, + where: asset.repository_id == ^id, + preload: ^preload + ) + |> Repo.one() + end + + def prepare_tool(attrs, auth_node \\ Core.Authorization.prepare_node()) do + %Instruction.ToolModel{} + |> Instruction.ToolModel.changeset(attrs) + |> Ecto.Changeset.put_assoc(:auth_node, auth_node) + end + + def prepare_asset(tool, special_key, special) do + %Instruction.AssetModel{} + |> Instruction.AssetModel.changeset(%{}) + |> Ecto.Changeset.put_assoc(:tool, tool) + |> Ecto.Changeset.put_assoc(special_key, special) + end + + def prepare_page(tool, content_page) do + %Instruction.PageModel{} + |> Instruction.PageModel.changeset(%{}) + |> Ecto.Changeset.put_assoc(:tool, tool) + |> Ecto.Changeset.put_assoc(:page, content_page) + end + + def add_repository_and_page(tool, repository, page) do + Multi.new() + |> Multi.insert(:content_repository, repository) + |> Multi.insert(:instruction_asset, fn %{content_repository: content_repository} -> + prepare_asset(tool, :repository, content_repository) + end) + |> Multi.insert(:content_page, page) + |> Multi.insert(:instruction_page, fn %{content_page: content_page} -> + prepare_page(tool, content_page) + end) + |> Signal.Public.multi_dispatch({:instruction_tool, :update}, %{instruction_tool: tool}) + |> Repo.transaction() + end + + def update_repository_and_page(tool, repository, page) do + Multi.new() + |> Multi.update(:content_repository, repository) + |> Multi.update(:content_page, page) + |> Signal.Public.multi_dispatch({:instruction_tool, :update}, %{instruction_tool: tool}) + |> Repo.transaction() + end +end diff --git a/core/systems/instruction/_queries.ex b/core/systems/instruction/_queries.ex new file mode 100644 index 000000000..15c89906f --- /dev/null +++ b/core/systems/instruction/_queries.ex @@ -0,0 +1,28 @@ +defmodule Systems.Graphite.Queries do + require Ecto.Query + require Frameworks.Utility.Query + + import Ecto.Query, warn: false + import Frameworks.Utility.Query, only: [build: 3] + + alias Systems.Graphite + alias Core.Accounts.User + + def submission_query() do + from(Graphite.SubmissionModel, as: :submission) + end + + def submission_query(%Graphite.ToolModel{id: tool_id}, user_ref, role) do + user_id = User.user_id(user_ref) + + build(submission_query(), :submission, [ + tool_id == ^tool_id, + auth_node: [ + role_assignments: [ + role == ^role, + principal_id == ^user_id + ] + ] + ]) + end +end diff --git a/core/systems/instruction/_switch.ex b/core/systems/instruction/_switch.ex new file mode 100644 index 000000000..c7291cd01 --- /dev/null +++ b/core/systems/instruction/_switch.ex @@ -0,0 +1,39 @@ +defmodule Systems.Instruction.Switch do + use Frameworks.Signal.Handler + + alias Systems.Instruction + + @impl true + def intercept( + {:content_repository, _} = signal, + %{content_repository: content_repository} = message + ) do + if asset = + Instruction.Public.get_asset_by( + content_repository, + Instruction.AssetModel.preload_graph(:down) + ) do + dispatch!( + {:instruction_asset, signal}, + Map.merge(message, %{instruction_asset: asset}) + ) + end + + :ok + end + + @impl true + def intercept( + {:instruction_asset, _} = signal, + %{instruction_asset: %{tool_id: tool_id}} = message + ) do + tool = Instruction.Public.get_tool!(tool_id, Instruction.ToolModel.preload_graph(:down)) + + dispatch!( + {:instruction_tool, signal}, + Map.merge(message, %{instruction_tool: tool}) + ) + + :ok + end +end diff --git a/core/systems/instruction/asset_model.ex b/core/systems/instruction/asset_model.ex new file mode 100644 index 000000000..90e1bb005 --- /dev/null +++ b/core/systems/instruction/asset_model.ex @@ -0,0 +1,32 @@ +defmodule Systems.Instruction.AssetModel do + use Ecto.Schema + use Frameworks.Utility.Schema + + import Ecto.Changeset + + alias Systems.Instruction + alias Systems.Content + + schema "instruction_assets" do + belongs_to(:tool, Instruction.ToolModel) + belongs_to(:repository, Content.RepositoryModel) + belongs_to(:file, Content.FileModel) + + timestamps() + end + + @fields ~w()a + @required_fields @fields + + def changeset(page, attrs \\ %{}) do + cast(page, attrs, @fields) + end + + def validate(changeset) do + validate_required(changeset, @required_fields) + end + + def preload_graph(:down), do: preload_graph([:repository, :file]) + def preload_graph(:repository), do: [repository: Content.RepositoryModel.preload_graph(:down)] + def preload_graph(:file), do: [file: Content.FileModel.preload_graph(:down)] +end diff --git a/core/systems/instruction/download_form.ex b/core/systems/instruction/download_form.ex new file mode 100644 index 000000000..bf0191f19 --- /dev/null +++ b/core/systems/instruction/download_form.ex @@ -0,0 +1,19 @@ +defmodule Systems.Instruction.DownloadForm do + use CoreWeb, :live_component_fabric + use Fabric.LiveComponent + + @impl true + def update(%{}, %{assigns: %{}} = socket) do + { + :ok, + socket + } + end + + @impl true + def render(assigns) do + ~H""" +
+ """ + end +end diff --git a/core/systems/instruction/fork_form.ex b/core/systems/instruction/fork_form.ex new file mode 100644 index 000000000..f87e89f24 --- /dev/null +++ b/core/systems/instruction/fork_form.ex @@ -0,0 +1,106 @@ +defmodule Systems.Instruction.ForkForm do + use CoreWeb.LiveForm, :fabric + use Fabric.LiveComponent + + import CoreWeb.Gettext + + alias Systems.Instruction + alias Systems.Content + + @impl true + def update(%{id: id, entity: tool}, socket) do + { + :ok, + socket + |> assign( + id: id, + tool: tool + ) + |> update_page() + |> update_repository() + |> update_changeset() + } + end + + defp update_repository(%{assigns: %{tool: %{assets: [%{repository: repository} | _]}}} = socket) + when not is_nil(repository) do + socket |> assign(repository: repository) + end + + defp update_repository(socket) do + socket |> assign(repository: %Content.RepositoryModel{}) + end + + defp update_changeset(%{assigns: %{repository: repository}} = socket) do + changeset = Content.RepositoryModel.changeset(repository) + socket |> assign(changeset: changeset) + end + + defp update_page(%{assigns: %{tool: %{pages: [%{page: page} | _]}}} = socket) + when not is_nil(page) do + socket |> assign(page: page) + end + + defp update_page(socket) do + socket |> assign(page: nil) + end + + @impl true + def handle_event("save", %{"repository_model" => %{"url" => url}}, socket) do + {:noreply, socket |> handle_save(url)} + end + + def handle_save(%{assigns: %{page: nil, tool: %{auth_node: auth_node} = tool}} = socket, url) do + repository = Content.Public.prepare_repository(%{platform: :github, url: url}) + + page = + Content.Public.prepare_page( + dgettext("eyra-instruction", "fork_page.body", url: url), + Core.Authorization.prepare_node(auth_node) + ) + + result = Instruction.Public.add_repository_and_page(tool, repository, page) + socket |> handle_result(result) + end + + def handle_save(%{assigns: %{repository: repository, page: page, tool: tool}} = socket, url) do + repository = + Content.RepositoryModel.changeset(repository, %{url: url}) + |> Content.RepositoryModel.validate() + + page = + Content.PageModel.changeset(page, %{ + body: dgettext("eyra-instruction", "fork_page.body", url: url) + }) + |> Content.PageModel.validate() + + result = Instruction.Public.update_repository_and_page(tool, repository, page) + socket |> handle_result(result) + end + + defp handle_result(socket, result) do + case result do + {:ok, %{content_repository: repository, content_page: page}} -> + socket |> assign(repository: repository, page: page) + + {:error, :content_repository, changeset, _} -> + socket |> assign(changeset: changeset) + end + end + + @impl true + def render(assigns) do + ~H""" +
+ <.form id={"#{@id}_fork"} :let={form} for={@changeset} phx-change="save" phx-target={@myself} > + <.text_input + form={form} + field={:url} + placeholder={dgettext("eyra-instruction", "repository_url.placeholder")} + label_text={dgettext("eyra-instruction", "repository_url.label")} + /> + +
+ """ + end +end diff --git a/core/systems/instruction/page_model.ex b/core/systems/instruction/page_model.ex new file mode 100644 index 000000000..96f8086c9 --- /dev/null +++ b/core/systems/instruction/page_model.ex @@ -0,0 +1,30 @@ +defmodule Systems.Instruction.PageModel do + use Ecto.Schema + use Frameworks.Utility.Schema + + import Ecto.Changeset + + alias Systems.Instruction + alias Systems.Content + + schema "instruction_pages" do + belongs_to(:tool, Instruction.ToolModel) + belongs_to(:page, Content.PageModel) + + timestamps() + end + + @fields ~w()a + @required_fields @fields + + def changeset(page, attrs \\ %{}) do + cast(page, attrs, @fields) + end + + def validate(changeset) do + validate_required(changeset, @required_fields) + end + + def preload_graph(:down), do: preload_graph([:page]) + def preload_graph(:page), do: [page: Content.PageModel.preload_graph(:down)] +end diff --git a/core/systems/instruction/tool_model.ex b/core/systems/instruction/tool_model.ex new file mode 100644 index 000000000..57a40df20 --- /dev/null +++ b/core/systems/instruction/tool_model.ex @@ -0,0 +1,67 @@ +defmodule Systems.Instruction.ToolModel do + use Ecto.Schema + use Frameworks.Utility.Schema + + import Ecto.Changeset + import CoreWeb.Gettext + + alias Systems.Instruction + + schema "instruction_tools" do + has_many(:assets, Instruction.AssetModel, foreign_key: :tool_id) + has_many(:pages, Instruction.PageModel, foreign_key: :tool_id) + belongs_to(:auth_node, Core.Authorization.Node) + + timestamps() + end + + @fields ~w()a + @required_fields @fields + + def changeset(repository, attrs \\ %{}) do + repository + |> cast(attrs, @fields) + end + + def validate(changeset) do + changeset + |> validate_required(@required_fields) + end + + def ready?(%{pages: []}), do: false + def ready?(%{pages: [_ | _]}), do: true + + def preload_graph(:down), do: preload_graph([:assets, :pages, :auth_node]) + def preload_graph(:assets), do: [assets: Instruction.AssetModel.preload_graph(:down)] + def preload_graph(:pages), do: [pages: Instruction.PageModel.preload_graph(:down)] + def preload_graph(:auth_node), do: [auth_node: []] + + defimpl Frameworks.Concept.ToolModel do + alias Systems.Instruction + def key(_), do: :instruction + def auth_tree(%{auth_node: auth_node}), do: auth_node + def apply_label(_), do: dgettext("eyra-instruction", "apply.cta.title") + def open_label(_), do: dgettext("eyra-instruction", "open.cta.title") + def ready?(tool), do: Instruction.ToolModel.ready?(tool) + def form(_, :fork_instruction), do: Instruction.ForkForm + def form(_, :download_instruction), do: Instruction.DownloadForm + + def launcher(tool), + do: %{ + module: Instruction.ToolView, + params: %{ + tool: tool + } + } + + def task_labels(_) do + %{ + pending: dgettext("eyra-instruction", "pending.label"), + participated: dgettext("eyra-instruction", "participated.label") + } + end + + def attention_list_enabled?(_t), do: false + def group_enabled?(_t), do: false + end +end diff --git a/core/systems/instruction/tool_view.ex b/core/systems/instruction/tool_view.ex new file mode 100644 index 000000000..010dd852a --- /dev/null +++ b/core/systems/instruction/tool_view.ex @@ -0,0 +1,73 @@ +defmodule Systems.Instruction.ToolView do + use CoreWeb, :live_component_fabric + use Fabric.LiveComponent + + import CoreWeb.Gettext + + alias Systems.Content + + @impl true + def update(%{tool: tool}, socket) do + { + :ok, + socket + |> send_event(:parent, "tool_initialized") + |> assign(tool: tool) + |> update_page() + |> update_done_button() + |> compose_child(:page_view) + } + end + + defp update_page(%{assigns: %{tool: %{pages: [%{page: page} | _]}}} = socket) do + socket |> assign(page: page) + end + + defp update_page(socket) do + socket |> assign(page: nil) + end + + defp update_done_button(%{assigns: %{myself: myself}} = socket) do + done_button = %{ + action: %{type: :send, event: "done", target: myself}, + face: %{type: :primary, label: dgettext("eyra-ui", "done.button")} + } + + socket |> assign(done_button: done_button) + end + + @impl true + def compose(:page_view, %{page: nil}), do: nil + + @impl true + def compose(:page_view, %{page: page}) do + %{ + module: Content.PageView, + params: %{ + page: page + } + } + end + + @impl true + def handle_event("done", _payload, socket) do + {:noreply, socket |> send_event(:parent, "complete_task")} + end + + @impl true + def render(assigns) do + ~H""" +
+ + + <%= dgettext("eyra-instruction", "page.title") %> + <.child name={:page_view} fabric={@fabric} /> + <.spacing value="M" /> + <.wrap> + + + +
+ """ + end +end diff --git a/core/systems/lab/tool_model.ex b/core/systems/lab/tool_model.ex index 551e3bfc7..6fd05f8c8 100644 --- a/core/systems/lab/tool_model.ex +++ b/core/systems/lab/tool_model.ex @@ -82,7 +82,7 @@ defmodule Systems.Lab.ToolModel do def apply_label(_), do: dgettext("link-lab", "apply.cta.title") def open_label(_), do: dgettext("link-lab", "open.cta.title") def ready?(tool), do: Lab.ToolModel.ready?(tool) - def form(_), do: Lab.Form + def form(_, _), do: Lab.Form def launcher(_), do: nil def task_labels(_) do diff --git a/core/systems/project/_switch.ex b/core/systems/project/_switch.ex index 1133c7ec8..e6fc34781 100644 --- a/core/systems/project/_switch.ex +++ b/core/systems/project/_switch.ex @@ -37,6 +37,12 @@ defmodule Systems.Project.Switch do :ok end + @impl true + def intercept({:instruction_tool, _} = signal, %{instruction_tool: tool} = message) do + handle({:tool, signal}, Map.merge(message, %{tool: tool})) + :ok + end + @impl true def intercept({:tool_ref, _} = signal, %{tool_ref: tool_ref} = message) do if project_item = Project.Public.get_item_by_tool_ref(tool_ref) do diff --git a/core/systems/project/item_model.ex b/core/systems/project/item_model.ex index 3faeb6125..b39e478a8 100644 --- a/core/systems/project/item_model.ex +++ b/core/systems/project/item_model.ex @@ -161,11 +161,11 @@ defmodule Systems.Project.ItemModel do face: %{type: :icon, icon: :delete} } - team_info = dngettext("eyra-benchmark", "1 team", "%{count} teams", Enum.count(spots)) + team_info = dngettext("eyra-graphite", "1 team", "%{count} teams", Enum.count(spots)) submission_info = dngettext( - "eyra-benchmark", + "eyra-graphite", "1 submission", "%{count} submissions", count_submissions(spots) diff --git a/core/systems/project/tool_ref_model.ex b/core/systems/project/tool_ref_model.ex index 68a6f7f96..34a1bc6ce 100644 --- a/core/systems/project/tool_ref_model.ex +++ b/core/systems/project/tool_ref_model.ex @@ -7,14 +7,13 @@ defmodule Systems.Project.ToolRefModel do alias Frameworks.Concept - alias Systems.{ - Project, - Document, - Alliance, - Lab, - Feldspar, - Graphite - } + alias Systems.Project + alias Systems.Document + alias Systems.Alliance + alias Systems.Lab + alias Systems.Feldspar + alias Systems.Graphite + alias Systems.Instruction schema "tool_refs" do field(:special, Ecto.Atom) @@ -24,6 +23,7 @@ defmodule Systems.Project.ToolRefModel do belongs_to(:feldspar_tool, Feldspar.ToolModel) belongs_to(:graphite_tool, Graphite.ToolModel) belongs_to(:document_tool, Document.ToolModel) + belongs_to(:instruction_tool, Instruction.ToolModel) has_one(:item, Project.ItemModel, foreign_key: :tool_ref_id) @@ -47,7 +47,8 @@ defmodule Systems.Project.ToolRefModel do :document_tool, :lab_tool, :feldspar_tool, - :graphite_tool + :graphite_tool, + :instruction_tool ]) def preload_graph(:alliance_tool), @@ -64,11 +65,16 @@ defmodule Systems.Project.ToolRefModel do def preload_graph(:graphite_tool), do: [graphite_tool: Graphite.ToolModel.preload_graph(:down)] + def preload_graph(:instruction_tool), + do: [instruction_tool: Instruction.ToolModel.preload_graph(:down)] + def auth_tree(%Project.ToolRefModel{} = tool_ref) do Concept.ToolModel.auth_tree(tool(tool_ref)) end - def flatten(item), do: tool(item) + def flatten(tool_ref), do: tool(tool_ref) + + def form(%{special: special} = tool_ref), do: Concept.ToolModel.form(tool(tool_ref), special) def external_path(%{alliance_tool: alliance_tool}, next_id) do Alliance.ToolModel.external_path(alliance_tool, next_id) @@ -84,12 +90,13 @@ defmodule Systems.Project.ToolRefModel do def tool(%{document_tool: %{id: _id} = tool}), do: tool def tool(%{lab_tool: %{id: _id} = tool}), do: tool def tool(%{graphite_tool: %{id: _id} = tool}), do: tool + def tool(%{instruction_tool: %{id: _id} = tool}), do: tool def tag(%Project.ToolRefModel{special: :questionnaire}), do: dgettext("eyra-project", "tool_ref.tag.questionnaire") def tag(%Project.ToolRefModel{special: :graphite}), - do: dgettext("eyra-project", "tool_ref.tag.benchmark") + do: dgettext("eyra-project", "tool_ref.tag.graphite") def tag(%Project.ToolRefModel{special: _special}) do dgettext("eyra-project", "tool_ref.tag.default") diff --git a/core/systems/project/tool_ref_view.ex b/core/systems/project/tool_ref_view.ex index f5ea08732..faf0a9d8f 100644 --- a/core/systems/project/tool_ref_view.ex +++ b/core/systems/project/tool_ref_view.ex @@ -10,7 +10,10 @@ defmodule Systems.Project.ToolRefView do Project } - def update(%{id: id, title: title, tool_ref: tool_ref, task: task, visible: visible}, socket) do + def update( + %{id: id, title: title, tool_ref: tool_ref, task: task, visible: visible, user: user}, + socket + ) do { :ok, socket @@ -19,7 +22,8 @@ defmodule Systems.Project.ToolRefView do title: title, tool_ref: tool_ref, task: task, - visible: visible + visible: visible, + user: user ) |> reset_fabric() |> update_launcher() @@ -36,10 +40,10 @@ defmodule Systems.Project.ToolRefView do end def update_launcher( - %{assigns: %{tool_ref: %{id: id}, title: title, visible: visible}} = socket, + %{assigns: %{tool_ref: %{id: id}, user: user, title: title, visible: visible}} = socket, %{module: module, params: params} ) do - params = Map.merge(params, %{title: title, visible: visible}) + params = Map.merge(params, %{user: user, title: title, visible: visible}) child = Fabric.prepare_child(socket, "tool_ref_#{id}", module, params) socket |> show_child(child) end @@ -56,6 +60,11 @@ defmodule Systems.Project.ToolRefView do {:noreply, socket |> send_event(:parent, "complete_task")} end + @impl true + def handle_event("cancel_task", _payload, socket) do + {:noreply, socket |> send_event(:parent, "cancel_task")} + end + @impl true def handle_event("tool_initialized", _payload, socket) do {:noreply, socket |> send_event(:parent, "tool_initialized")} diff --git a/core/systems/workflow/_public.ex b/core/systems/workflow/_public.ex index 083c00e57..8b4115852 100644 --- a/core/systems/workflow/_public.ex +++ b/core/systems/workflow/_public.ex @@ -3,6 +3,7 @@ defmodule Systems.Workflow.Public do alias Ecto.Multi alias Core.Repo + alias Core.Authorization alias Frameworks.Signal alias Systems.Workflow @@ -12,6 +13,7 @@ defmodule Systems.Workflow.Public do alias Systems.Lab alias Systems.Graphite alias Systems.Project + alias Systems.Instruction def list_items(workflow, preload \\ []) def list_items(%Workflow.Model{id: id}, preload), do: list_items(id, preload) @@ -75,15 +77,19 @@ defmodule Systems.Workflow.Public do |> add_item(item, director) end - def add_item(%Workflow.Model{} = workflow, %{id: id, type: type} = _item, director) + def add_item( + %Workflow.Model{} = workflow, + %{special: special, tool: tool_type} = _item, + director + ) when is_atom(director) do Multi.new() |> Multi.run(:position, fn _, _ -> {:ok, item_count(workflow)} end) - |> Multi.insert(:tool, prepare_tool(type, %{director: director})) + |> Multi.insert(:tool, prepare_tool(tool_type, %{director: director})) |> Multi.insert(:workflow_item, fn %{position: position, tool: tool} -> - tool_ref = prepare_tool_ref(id, type, tool) + tool_ref = prepare_tool_ref(special, tool_type, tool) prepare_item(workflow, position, tool_ref) end) |> Signal.Public.multi_dispatch({:workflow_item, :added}) @@ -111,11 +117,25 @@ defmodule Systems.Workflow.Public do |> Ecto.Changeset.put_assoc(tool_type, tool) end - defp prepare_tool(:alliance_tool, %{} = attrs), do: Alliance.Public.prepare_tool(attrs) - defp prepare_tool(:document_tool, %{} = attrs), do: Document.Public.prepare_tool(attrs) - defp prepare_tool(:feldspar_tool, %{} = attrs), do: Feldspar.Public.prepare_tool(attrs) - defp prepare_tool(:lab_tool, %{} = attrs), do: Lab.Public.prepare_tool(attrs) - defp prepare_tool(:graphite_tool, %{} = attrs), do: Graphite.Public.prepare_tool(attrs) + def prepare_tool(_, _, auth_node \\ Authorization.prepare_node()) + + def prepare_tool(:alliance_tool, %{} = attrs, auth_node), + do: Alliance.Public.prepare_tool(attrs, auth_node) + + def prepare_tool(:document_tool, %{} = attrs, auth_node), + do: Document.Public.prepare_tool(attrs, auth_node) + + def prepare_tool(:feldspar_tool, %{} = attrs, auth_node), + do: Feldspar.Public.prepare_tool(attrs, auth_node) + + def prepare_tool(:lab_tool, %{} = attrs, auth_node), + do: Lab.Public.prepare_tool(attrs, auth_node) + + def prepare_tool(:graphite_tool, %{} = attrs, auth_node), + do: Graphite.Public.prepare_tool(attrs, auth_node) + + def prepare_tool(:instruction_tool, %{} = attrs, auth_node), + do: Instruction.Public.prepare_tool(attrs, auth_node) def delete(%Workflow.ItemModel{workflow_id: workflow_id} = item) do Multi.new() diff --git a/core/systems/workflow/builder_view.ex b/core/systems/workflow/builder_view.ex index 59fe0607a..221ea66ef 100644 --- a/core/systems/workflow/builder_view.ex +++ b/core/systems/workflow/builder_view.ex @@ -63,6 +63,7 @@ defmodule Systems.Workflow.BuilderView do %{assigns: %{workflow: %{id: id}, config: %{director: director}}} = socket ) do item = get_library_item(socket, item_id) + {:ok, _} = Workflow.Public.add_item(id, item, director) { @@ -83,7 +84,7 @@ defmodule Systems.Workflow.BuilderView do defp get_title(%{tool_ref: %{special: special}}, %{ assigns: %{config: %{library: %{items: library_items}}} }) do - %{title: title} = Enum.find(library_items, &(&1.id == special)) + %{title: title} = Enum.find(library_items, &(&1.special == special)) title end @@ -93,7 +94,7 @@ defmodule Systems.Workflow.BuilderView do defp get_library_item(%{assigns: %{config: %{library: %{items: items}}}}, item_id) when is_atom(item_id) do - Enum.find(items, &(&1.id == item_id)) + Enum.find(items, &(&1.special == item_id)) end @impl true @@ -110,11 +111,15 @@ defmodule Systems.Workflow.BuilderView do <.list items={@ordered_items} types={@item_types} ordering_enabled?={@ordering_enabled?} user={@user} uri_origin={@uri_origin} parent={%{type: __MODULE__, id: @id}} />
- <%= if @config.library do %> + <%= if @config.library.render? do %>
<.side_panel id={:library} parent={:item_builder}> - <.library {@config.library} /> + <.library + title={dgettext("eyra-workflow", "item.library.title")} + description={dgettext("eyra-workflow", "item.library.description")} + items={Enum.map(@config.library.items, &Map.from_struct/1)} + />
<% end %> diff --git a/core/systems/workflow/config.ex b/core/systems/workflow/config.ex new file mode 100644 index 000000000..0bba8d9e6 --- /dev/null +++ b/core/systems/workflow/config.ex @@ -0,0 +1,12 @@ +defmodule Systems.Workflow.Config do + @type library :: Systems.Workflow.LibraryModel.t() + @type item :: atom() + + @type t :: %__MODULE__{ + type: atom(), + library: library(), + initial_items: list(item()) + } + + defstruct [:type, :library, :initial_items] +end diff --git a/core/systems/workflow/item_cell.ex b/core/systems/workflow/item_cell.ex index f5cae8828..e700828e0 100644 --- a/core/systems/workflow/item_cell.ex +++ b/core/systems/workflow/item_cell.ex @@ -87,7 +87,7 @@ defmodule Systems.Workflow.ItemCell do } = socket ) do tool = Project.ToolRefModel.flatten(tool_ref) - tool_form_module = Concept.ToolModel.form(tool) + tool_form_module = Project.ToolRefModel.form(tool_ref) callback_path = ~p"/assignment/callback/#{item_id}" callback_url = uri_origin <> callback_path diff --git a/core/systems/workflow/item_model.ex b/core/systems/workflow/item_model.ex index b613b09f4..5bdea4f14 100644 --- a/core/systems/workflow/item_model.ex +++ b/core/systems/workflow/item_model.ex @@ -23,7 +23,7 @@ defmodule Systems.Workflow.ItemModel do end @fields ~w(group position title description)a - @required_fields @fields + @required_fields ~w(position title description)a def changeset(item, params) do item diff --git a/core/systems/workflow/item_views.ex b/core/systems/workflow/item_views.ex index 2dbf691dc..49b8cfecd 100644 --- a/core/systems/workflow/item_views.ex +++ b/core/systems/workflow/item_views.ex @@ -29,7 +29,7 @@ defmodule Systems.Workflow.ItemViews do """ end - attr(:id, :string, required: true) + attr(:special, :string, required: true) attr(:title, :string, required: true) attr(:description, :string, required: true) @@ -44,7 +44,7 @@ defmodule Systems.Workflow.ItemViews do <.wrap> diff --git a/core/systems/workflow/library_item_model.ex b/core/systems/workflow/library_item_model.ex new file mode 100644 index 000000000..9108bcaaa --- /dev/null +++ b/core/systems/workflow/library_item_model.ex @@ -0,0 +1,10 @@ +defmodule Systems.Workflow.LibraryItemModel do + @type t :: %__MODULE__{ + special: atom(), + tool: atom(), + title: binary(), + description: binary() | nil + } + + defstruct [:special, :tool, :title, :description] +end diff --git a/core/systems/workflow/library_model.ex b/core/systems/workflow/library_model.ex new file mode 100644 index 000000000..656ac1be5 --- /dev/null +++ b/core/systems/workflow/library_model.ex @@ -0,0 +1,8 @@ +defmodule Systems.Workflow.LibraryModel do + @type t :: %__MODULE__{ + render?: boolean(), + items: list(Systems.Workflow.LibraryItemModel.t()) + } + + defstruct [:render?, :items] +end diff --git a/core/test/systems/graphite/_public_test.exs b/core/test/systems/graphite/_public_test.exs index 5a6e636eb..03a3bad2e 100644 --- a/core/test/systems/graphite/_public_test.exs +++ b/core/test/systems/graphite/_public_test.exs @@ -232,7 +232,7 @@ defmodule Systems.Graphite.PublicTest do end defp create_tool() do - Factories.insert!(:graphite_tool, %{max_submissions: 3}) + Factories.insert!(:graphite_tool, %{}) end defp create_submission(tool, description \\ "Method X") do diff --git a/core/test/systems/graphite/export_controller_test.exs b/core/test/systems/graphite/export_controller_test.exs index b16df0531..b73389eac 100644 --- a/core/test/systems/graphite/export_controller_test.exs +++ b/core/test/systems/graphite/export_controller_test.exs @@ -6,7 +6,7 @@ defmodule Systems.Graphite.ExportControllerTest do } test "export/1 with valid submission" do - tool = Factories.insert!(:graphite_tool, %{max_submissions: 3}) + tool = Factories.insert!(:graphite_tool, %{}) %{id: id} = submission = @@ -27,7 +27,7 @@ defmodule Systems.Graphite.ExportControllerTest do end test "export/1 with invalid submission" do - tool = Factories.insert!(:graphite_tool, %{max_submissions: 3}) + tool = Factories.insert!(:graphite_tool, %{}) %{id: id} = submission = diff --git a/core/test/systems/project/_assembly_test.exs b/core/test/systems/project/_assembly_test.exs index 6e84d504b..8221b6916 100644 --- a/core/test/systems/project/_assembly_test.exs +++ b/core/test/systems/project/_assembly_test.exs @@ -25,7 +25,11 @@ defmodule Systems.Project.AssemblyTest do storage_endpoint_id: nil, workflow: %Systems.Workflow.Model{ type: :many_mandatory, - items: [] + items: [ + %Systems.Workflow.ItemModel{}, + %Systems.Workflow.ItemModel{}, + %Systems.Workflow.ItemModel{} + ] } } } = item From 43899b5b703ef3d2b81352f3d143ab072275552d Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Wed, 27 Mar 2024 04:31:12 +0100 Subject: [PATCH 06/36] Fixed migration bug --- .../repo/migrations/20240319083330_rename_workflow_type.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs b/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs index 3437947a4..e8583c9e8 100644 --- a/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs +++ b/core/priv/repo/migrations/20240319083330_rename_workflow_type.exs @@ -2,11 +2,11 @@ defmodule Core.Repo.Migrations.RenameWorkflowType do use Ecto.Migration def up do - update(:workflows, :type, "single_task", "many_optional") + update(:workflows, :type, "many_optional", "single_task") end def down do - update(:workflows, :type, "many_optional", "single_task") + update(:workflows, :type, "single_task", "many_optional") end def update(table, field, new_value, old_value) do From a0a5b0d433909738c4a931d512d14e88610c16de Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:07:41 +0100 Subject: [PATCH 07/36] Update eyra-assignment.po --- core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 70aa62cda..1f8ab599f 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -208,7 +208,7 @@ msgstr "Organization logo" #, elixir-autogen, elixir-format, fuzzy msgid "settings.branding.text" -msgstr "Use the fields below to customize the header of your data donation participant workflow. Add the name and logo of the organisation that is responsible for the data donation workflow. Curious to see what this will look like for participants? Click 'Preview' at the top right to check it out." +msgstr "Use the fields below to customize the header of your participant workflow. Add the name and logo of the organisation that is responsible for the workflow. Curious to see what this will look like for participants? Click 'Preview' at the top right to check it out." #, elixir-autogen, elixir-format, fuzzy msgid "settings.branding.title" From a0fa17f3fd7affae0ba467f193440d7cb01f00e0 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:14:36 +0100 Subject: [PATCH 08/36] Update eyra-assignment.po Removed data donation specific info in branding and information page that is also used for benchmarking. --- core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 1f8ab599f..0a85553f8 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -232,7 +232,7 @@ msgstr "Show" #, elixir-autogen, elixir-format, fuzzy msgid "settings.intro.body" -msgstr "Use the text field below to inform your participants about your research. Were your participants already informed in some other way? Choose 'Skip'." +msgstr "Add an information page to onboard and inform your participants. Were your participants already informed in some other way? Choose 'Skip'." #, elixir-autogen, elixir-format, fuzzy msgid "settings.intro.title" From 2a1ee3b51e1782fe0dd4cba15ade0997cac98238 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:22:41 +0100 Subject: [PATCH 09/36] Update eyra-assignment.po Changed "Information page" to about page. --- core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 0a85553f8..f961a86ce 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -232,15 +232,15 @@ msgstr "Show" #, elixir-autogen, elixir-format, fuzzy msgid "settings.intro.body" -msgstr "Add an information page to onboard and inform your participants. Were your participants already informed in some other way? Choose 'Skip'." +msgstr "Add an about page to onboard and inform your participants. Were your participants already informed in some other way? Choose 'Skip'." #, elixir-autogen, elixir-format, fuzzy msgid "settings.intro.title" -msgstr "Information page" +msgstr "About page" #, elixir-autogen, elixir-format, fuzzy msgid "onboarding.intro.title" -msgstr "Information" +msgstr "About" #, elixir-autogen, elixir-format, fuzzy msgid "settings.support.body" From 73b4472bc239cd66758532a4c123a2feb9a92e35 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:49:11 +0100 Subject: [PATCH 10/36] Update eyra-workflow.po Removed study --- core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po b/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po index af3e085ab..4bd7e6b97 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-workflow.po @@ -33,7 +33,7 @@ msgstr "Library" #, elixir-autogen, elixir-format msgid "item.list.description" -msgstr "Add tasks from the library to build a custom workflow for participants in your study." +msgstr "Add tasks from the library to build a custom workflow for participants." #, elixir-autogen, elixir-format msgid "item.list.hint" From deb3d4fc4b40b878b596a8c03321e9f984972fce Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Wed, 27 Mar 2024 14:29:22 +0100 Subject: [PATCH 11/36] #643 Add download training data benchmark task --- .../en/LC_MESSAGES/eyra-instruction.po | 21 ++++ core/priv/gettext/eyra-instruction.pot | 20 +++ .../nl/LC_MESSAGES/eyra-instruction.po | 20 +++ core/systems/instruction/_public.ex | 22 ++++ core/systems/instruction/download_form.ex | 118 +++++++++++++++++- 5 files changed, 199 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index 4db0183eb..740fb03b3 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -39,6 +39,27 @@ msgstr "https://github//" msgid "fork_page.body" msgstr "Fork the following repository to start working on your algorithm." +#, elixir-autogen, elixir-format +msgid "download_page.body" +msgstr "Download %{name} to start working on your algorithm." + #, elixir-autogen, elixir-format msgid "page.title" msgstr "Instructions" + +#, elixir-autogen, elixir-format +msgid "download_form.file.label" +msgstr "File" + +#, elixir-autogen, elixir-format +msgid "download_form.file.placeholder" +msgstr "Select a zip file" + +#, elixir-autogen, elixir-format +msgid "download_form.file.replace.button" +msgstr "Replace file" + +#, elixir-autogen, elixir-format +msgid "download_form.file.select.button" +msgstr "Select file" + diff --git a/core/priv/gettext/eyra-instruction.pot b/core/priv/gettext/eyra-instruction.pot index effde97ea..effa3b4c2 100644 --- a/core/priv/gettext/eyra-instruction.pot +++ b/core/priv/gettext/eyra-instruction.pot @@ -42,3 +42,23 @@ msgstr "" #, elixir-autogen, elixir-format msgid "page.title" msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.placeholder" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.replace.button" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.select.button" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_page.body" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index b59daaee8..a93ed3ad6 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -42,3 +42,23 @@ msgstr "" #, elixir-autogen, elixir-format, fuzzy msgid "page.title" msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.label" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.placeholder" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.replace.button" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_form.file.select.button" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "download_page.body" +msgstr "" diff --git a/core/systems/instruction/_public.ex b/core/systems/instruction/_public.ex index f41f0452f..52e5879e5 100644 --- a/core/systems/instruction/_public.ex +++ b/core/systems/instruction/_public.ex @@ -61,4 +61,26 @@ defmodule Systems.Instruction.Public do |> Signal.Public.multi_dispatch({:instruction_tool, :update}, %{instruction_tool: tool}) |> Repo.transaction() end + + def add_file_and_page(tool, file, page) do + Multi.new() + |> Multi.insert(:content_file, file) + |> Multi.insert(:instruction_asset, fn %{content_file: content_file} -> + prepare_asset(tool, :file, content_file) + end) + |> Multi.insert(:content_page, page) + |> Multi.insert(:instruction_page, fn %{content_page: content_page} -> + prepare_page(tool, content_page) + end) + |> Signal.Public.multi_dispatch({:instruction_tool, :update}, %{instruction_tool: tool}) + |> Repo.transaction() + end + + def update_file_and_page(tool, file, page) do + Multi.new() + |> Multi.update(:content_file, file) + |> Multi.update(:content_page, page) + |> Signal.Public.multi_dispatch({:instruction_tool, :update}, %{instruction_tool: tool}) + |> Repo.transaction() + end end diff --git a/core/systems/instruction/download_form.ex b/core/systems/instruction/download_form.ex index bf0191f19..db9d74c74 100644 --- a/core/systems/instruction/download_form.ex +++ b/core/systems/instruction/download_form.ex @@ -1,19 +1,133 @@ defmodule Systems.Instruction.DownloadForm do use CoreWeb, :live_component_fabric use Fabric.LiveComponent + use CoreWeb.FileUploader, accept: ~w(.zip) + + import CoreWeb.Gettext + import Pixel.Components.FileSelector + + alias Systems.Instruction + alias Systems.Content + + @impl true + def process_file(socket, {_path, url, original_filename}) do + socket + |> handle_save(original_filename, url) + |> update_file() + |> update_filename() + end @impl true - def update(%{}, %{assigns: %{}} = socket) do + def update(%{id: id, entity: tool}, socket) do { :ok, socket + |> assign( + id: id, + tool: tool + ) + |> update_page() + |> update_file() + |> update_filename() + |> init_file_uploader(:file) } end + defp update_file(%{assigns: %{tool: %{assets: [%{file: file} | _]}}} = socket) + when not is_nil(file) do + socket |> assign(file: file) + end + + defp update_file(socket) do + socket |> assign(file: nil) + end + + defp update_filename(%{assigns: %{file: %{name: filename}}} = socket) do + socket |> assign(filename: filename) + end + + defp update_filename(socket) do + socket |> assign(filename: nil) + end + + defp update_page(%{assigns: %{tool: %{pages: [%{page: page} | _]}}} = socket) + when not is_nil(page) do + socket |> assign(page: page) + end + + defp update_page(socket) do + socket |> assign(page: nil) + end + + @impl true + def handle_event("save", %{"file_model" => %{"name" => name, "ref" => ref}}, socket) do + {:noreply, socket |> handle_save(name, ref)} + end + + @impl true + def handle_event("change", _params, socket) do + {:noreply, socket} + end + + def handle_save( + %{assigns: %{page: nil, tool: %{auth_node: auth_node} = tool}} = socket, + name, + ref + ) do + file = Content.Public.prepare_file(name, ref) + + page = + Content.Public.prepare_page( + get_body(name, ref), + Core.Authorization.prepare_node(auth_node) + ) + + result = Instruction.Public.add_file_and_page(tool, file, page) + socket |> handle_result(result) + end + + def handle_save(%{assigns: %{file: file, page: page, tool: tool}} = socket, name, ref) do + file = + Content.FileModel.changeset(file, %{name: name, ref: ref}) + |> Content.FileModel.validate() + + page = + Content.PageModel.changeset(page, %{body: get_body(name, ref)}) + |> Content.PageModel.validate() + + result = Instruction.Public.update_file_and_page(tool, file, page) + socket |> handle_result(result) + end + + defp handle_result(socket, result) do + case result do + {:ok, %{content_file: file, content_page: page}} -> + socket |> assign(file: file, page: page) + + {:error, :content_file, changeset, _} -> + socket |> assign(changeset: changeset) + end + end + + defp get_body(name, url) do + dgettext("eyra-instruction", "download_page.body", name: name, url: url) + end + @impl true def render(assigns) do ~H""" -
+
+ <%=dgettext("eyra-instruction", "download_form.file.label") %> + <.spacing value="XXS" /> + <.file_selector + id="file" + uploads={@uploads} + filename={@filename} + placeholder={dgettext("eyra-instruction", "download_form.file.placeholder")} + select_button={dgettext("eyra-instruction", "download_form.file.select.button")} + replace_button={dgettext("eyra-instruction", "download_form.file.replace.button")} + /> +
""" end end From 93f9889cf8ae1d89d4ee715c8b7e1b63b23b2657 Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Thu, 28 Mar 2024 11:42:35 +0100 Subject: [PATCH 12/36] Enabled rendering workflow library in data donation cms --- core/systems/assignment/template_data_donation.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/systems/assignment/template_data_donation.ex b/core/systems/assignment/template_data_donation.ex index 4e8f31938..93f5c7eb1 100644 --- a/core/systems/assignment/template_data_donation.ex +++ b/core/systems/assignment/template_data_donation.ex @@ -19,7 +19,7 @@ defmodule Systems.Assignment.TemplateDataDonation do do: %Workflow.Config{ type: :many_optional, library: %Workflow.LibraryModel{ - render?: false, + render?: true, items: [ %Workflow.LibraryItemModel{ special: :donate, From 0410c686030570831a453b4a5272678760a8f3bb Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Thu, 28 Mar 2024 11:56:33 +0100 Subject: [PATCH 13/36] #674 internal server error --- core/systems/workflow/builder_view.ex | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/systems/workflow/builder_view.ex b/core/systems/workflow/builder_view.ex index 221ea66ef..2a6fccf91 100644 --- a/core/systems/workflow/builder_view.ex +++ b/core/systems/workflow/builder_view.ex @@ -1,6 +1,8 @@ defmodule Systems.Workflow.BuilderView do use CoreWeb, :live_component + require Logger + import Frameworks.Pixel.SidePanel alias Systems.{ @@ -84,8 +86,18 @@ defmodule Systems.Workflow.BuilderView do defp get_title(%{tool_ref: %{special: special}}, %{ assigns: %{config: %{library: %{items: library_items}}} }) do - %{title: title} = Enum.find(library_items, &(&1.special == special)) - title + case Enum.find(library_items, &(&1.special == special)) do + %{title: title} -> + title + + nil -> + Logger.notice("No match found for: #{special}") + + special + |> Atom.to_string() + |> String.replace("_", " ") + |> String.capitalize() + end end defp get_library_item(socket, item_id) when is_binary(item_id) do From 44a055357bf882e38e4e6184849fe37a2a0c3b4c Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Thu, 28 Mar 2024 12:21:45 +0100 Subject: [PATCH 14/36] #674 internal server error --- ...240328111851_migrate_tool_ref_specials.exs | 19 +++++++++++++++++++ core/systems/workflow/builder_view.ex | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 core/priv/repo/migrations/20240328111851_migrate_tool_ref_specials.exs diff --git a/core/priv/repo/migrations/20240328111851_migrate_tool_ref_specials.exs b/core/priv/repo/migrations/20240328111851_migrate_tool_ref_specials.exs new file mode 100644 index 000000000..2d92dd621 --- /dev/null +++ b/core/priv/repo/migrations/20240328111851_migrate_tool_ref_specials.exs @@ -0,0 +1,19 @@ +defmodule Core.Repo.Migrations.MigrateToolRefSpecials do + use Ecto.Migration + + def up do + update(:tool_refs, :special, "request_manual", "request") + update(:tool_refs, :special, "download_manual", "download") + end + + def down do + update(:tool_refs, :special, "request", "request_manual") + update(:tool_refs, :special, "download", "download_manual") + end + + def update(table, field, new_value, old_value) do + execute(""" + UPDATE #{table} SET #{field} = '#{new_value}' WHERE #{field} = '#{old_value}'; + """) + end +end diff --git a/core/systems/workflow/builder_view.ex b/core/systems/workflow/builder_view.ex index 2a6fccf91..36538713b 100644 --- a/core/systems/workflow/builder_view.ex +++ b/core/systems/workflow/builder_view.ex @@ -91,7 +91,7 @@ defmodule Systems.Workflow.BuilderView do title nil -> - Logger.notice("No match found for: #{special}") + Logger.error("No library item found for workflow item with special: #{special}") special |> Atom.to_string() From e333bdbf689114edb058e2bf33fd5b79427e44cc Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Thu, 28 Mar 2024 17:07:00 +0100 Subject: [PATCH 15/36] #680 Invite user as participant on assignment --- core/lib/core_web/controllers/user_auth.ex | 2 +- .../gettext/en/LC_MESSAGES/eyra-assignment.po | 8 +++ .../en/LC_MESSAGES/eyra-instruction.po | 7 +-- core/priv/gettext/en/LC_MESSAGES/eyra-ui.po | 4 +- core/priv/gettext/eyra-assignment.pot | 8 +++ core/priv/gettext/eyra-ui.pot | 2 +- .../gettext/nl/LC_MESSAGES/eyra-assignment.po | 8 +++ core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po | 2 +- core/systems/assignment/_public.ex | 11 +++- core/systems/assignment/_routes.ex | 1 + .../assignment/content_page_builder.ex | 6 +- core/systems/assignment/controller.ex | 42 +++++++++++-- .../assignment/external_panel_controller.ex | 8 +-- core/systems/assignment/participants_view.ex | 60 ++++++++++++++++++- .../template_benchmark_challenge.ex | 1 - .../core_web/controllers/user_auth_test.exs | 4 +- .../systems/assignment/controller_test.exs | 53 ++++++++++++++++ core/test/systems/assignment/factories.ex | 9 +-- 18 files changed, 204 insertions(+), 32 deletions(-) create mode 100644 core/test/systems/assignment/controller_test.exs diff --git a/core/lib/core_web/controllers/user_auth.ex b/core/lib/core_web/controllers/user_auth.ex index a1aa214a8..899388684 100644 --- a/core/lib/core_web/controllers/user_auth.ex +++ b/core/lib/core_web/controllers/user_auth.ex @@ -147,7 +147,7 @@ defmodule CoreWeb.UserAuth do conn else conn - |> put_flash(:error, dgettext("eyra-ui", "authentication.required.error")) + |> put_flash(:info, dgettext("eyra-ui", "authentication.required.message")) |> maybe_store_return_to() |> redirect(to: ~p"/user/signin") |> halt() diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index f961a86ce..20096fca3 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -381,3 +381,11 @@ msgstr "Instructions for participants on how to fork the repository." #, elixir-autogen, elixir-format, fuzzy msgid "workflow_item.submit.description" msgstr "Enables participants to submit an algorithm." + +#, elixir-autogen, elixir-format +msgid "invite.panel.annotation" +msgstr "The url below can be used to invite users to participate on this assignment. When users click on this link they will be asked to log in, registered as participant and forwarded to start on the assignment." + +#, elixir-autogen, elixir-format, fuzzy +msgid "invite.panel.title" +msgstr "Invite your participants" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index 740fb03b3..07c6ae65a 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -39,10 +39,6 @@ msgstr "https://github//" msgid "fork_page.body" msgstr "Fork the following repository to start working on your algorithm." -#, elixir-autogen, elixir-format -msgid "download_page.body" -msgstr "Download %{name} to start working on your algorithm." - #, elixir-autogen, elixir-format msgid "page.title" msgstr "Instructions" @@ -63,3 +59,6 @@ msgstr "Replace file" msgid "download_form.file.select.button" msgstr "Select file" +#, elixir-autogen, elixir-format +msgid "download_page.body" +msgstr "Download %{name} to start working on your algorithm." diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po b/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po index 9d52c5792..8eec2b820 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-ui.po @@ -107,8 +107,8 @@ msgid "timestamp.yesterday" msgstr "yesterday" #, elixir-autogen, elixir-format -msgid "authentication.required.error" -msgstr "Sign in to view this page" +msgid "authentication.required.message" +msgstr "Please sign in first" #, elixir-autogen, elixir-format msgid "start.page.console" diff --git a/core/priv/gettext/eyra-assignment.pot b/core/priv/gettext/eyra-assignment.pot index 9fa163ac3..bfbd1cc4a 100644 --- a/core/priv/gettext/eyra-assignment.pot +++ b/core/priv/gettext/eyra-assignment.pot @@ -381,3 +381,11 @@ msgstr "" #, elixir-autogen, elixir-format msgid "workflow_item.submit.description" msgstr "" + +#, elixir-autogen, elixir-format +msgid "invite.panel.annotation" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "invite.panel.title" +msgstr "" diff --git a/core/priv/gettext/eyra-ui.pot b/core/priv/gettext/eyra-ui.pot index 8e4a9cc44..477c4d567 100644 --- a/core/priv/gettext/eyra-ui.pot +++ b/core/priv/gettext/eyra-ui.pot @@ -107,7 +107,7 @@ msgid "timestamp.yesterday" msgstr "" #, elixir-autogen, elixir-format -msgid "authentication.required.error" +msgid "authentication.required.message" msgstr "" #, elixir-autogen, elixir-format diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po index 05def7172..31ff18d0b 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po @@ -381,3 +381,11 @@ msgstr "" #, elixir-autogen, elixir-format, fuzzy msgid "workflow_item.submit.description" msgstr "" + +#, elixir-autogen, elixir-format +msgid "invite.panel.annotation" +msgstr "" + +#, elixir-autogen, elixir-format, fuzzy +msgid "invite.panel.title" +msgstr "Panel" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po index 79d9f0d9f..1cbfd1657 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-ui.po @@ -107,7 +107,7 @@ msgid "timestamp.yesterday" msgstr "gisteren" #, elixir-autogen, elixir-format -msgid "authentication.required.error" +msgid "authentication.required.message" msgstr "Log in om deze pagina te bekijken" #, elixir-autogen, elixir-format diff --git a/core/systems/assignment/_public.ex b/core/systems/assignment/_public.ex index 7a27d9a1e..f256de3e0 100644 --- a/core/systems/assignment/_public.ex +++ b/core/systems/assignment/_public.ex @@ -33,6 +33,11 @@ defmodule Systems.Assignment.Public do |> Repo.get!(id) end + def get(id, preload \\ []) do + from(a in Assignment.Model, preload: ^preload) + |> Repo.get(id) + end + def get_workflow!(id, preload \\ []) do from(a in Workflow.Model, preload: ^preload) |> Repo.get!(id) @@ -318,8 +323,10 @@ defmodule Systems.Assignment.Public do Core.Persister.save(assignment, changeset) end - def owner?(assignment, user) do - Core.Authorization.user_has_role?(user, assignment, :owner) + def add_participant!(%Assignment.Model{crew: crew}, user) do + if not Crew.Public.member?(crew, user) do + {:ok, _} = Crew.Public.apply_member_with_role(crew, user, :participant) + end end def add_owner!(assignment, user) do diff --git a/core/systems/assignment/_routes.ex b/core/systems/assignment/_routes.ex index 6cdc7e96b..bf74299b9 100644 --- a/core/systems/assignment/_routes.ex +++ b/core/systems/assignment/_routes.ex @@ -6,6 +6,7 @@ defmodule Systems.Assignment.Routes do live("/assignment/:id", CrewPage) live("/assignment/:id/landing", LandingPage) live("/assignment/:id/content", ContentPage) + get("/assignment/:id/invite", Controller, :invite) get("/assignment/callback/:item", Controller, :callback) end diff --git a/core/systems/assignment/content_page_builder.ex b/core/systems/assignment/content_page_builder.ex index b50a92b3f..db90f072e 100644 --- a/core/systems/assignment/content_page_builder.ex +++ b/core/systems/assignment/content_page_builder.ex @@ -258,7 +258,7 @@ defmodule Systems.Assignment.ContentPageBuilder do defp create_tab( :participants, - _assignment, + assignment, _template, show_errors, _assigns @@ -271,7 +271,9 @@ defmodule Systems.Assignment.ContentPageBuilder do forward_title: dgettext("eyra-assignment", "tabbar.item.participants.forward"), type: :fullpage, live_component: Assignment.ParticipantsView, - props: %{} + props: %{ + assignment: assignment + } } end diff --git a/core/systems/assignment/controller.ex b/core/systems/assignment/controller.ex index 6628f48ef..9061744ef 100644 --- a/core/systems/assignment/controller.ex +++ b/core/systems/assignment/controller.ex @@ -1,11 +1,9 @@ defmodule Systems.Assignment.Controller do use CoreWeb, :controller - alias Systems.{ - Assignment, - Workflow, - Crew - } + alias Systems.Assignment + alias Systems.Workflow + alias Systems.Crew def callback(%{assigns: %{current_user: user}} = conn, %{"item" => item_id}) do %{workflow_id: workflow_id} = item = Workflow.Public.get_item!(String.to_integer(item_id)) @@ -21,4 +19,38 @@ defmodule Systems.Assignment.Controller do conn |> redirect(to: ~p"/assignment/#{id}") end + + def invite(conn, %{"id" => id}) do + if assignment = Assignment.Public.get(String.to_integer(id), [:crew]) do + if offline?(assignment) do + service_unavailable(conn) + else + start_participant(conn, assignment) + end + else + service_unavailable(conn) + end + end + + defp offline?(%{status: status}) do + status != :online + end + + defp service_unavailable(conn) do + conn + |> put_status(:service_unavailable) + |> put_view(html: CoreWeb.ErrorHTML) + |> render(:"503") + end + + defp start_participant(conn, %{id: id} = assignment) do + conn + |> authorize_user(assignment) + |> redirect(to: ~p"/assignment/#{id}") + end + + defp authorize_user(%{assigns: %{current_user: user}} = conn, %Assignment.Model{} = assignment) do + Assignment.Public.add_participant!(assignment, user) + conn + end end diff --git a/core/systems/assignment/external_panel_controller.ex b/core/systems/assignment/external_panel_controller.ex index 97d354f2a..4e8e32cf1 100644 --- a/core/systems/assignment/external_panel_controller.ex +++ b/core/systems/assignment/external_panel_controller.ex @@ -2,7 +2,6 @@ defmodule Systems.Assignment.ExternalPanelController do use CoreWeb, :controller alias Systems.Assignment - alias Systems.Crew require Logger @@ -90,11 +89,8 @@ defmodule Systems.Assignment.ExternalPanelController do |> render(:"503") end - defp authorize_user(%{assigns: %{current_user: user}} = conn, %{crew: crew}) do - if not Crew.Public.member?(crew, user) do - Crew.Public.apply_member_with_role(crew, user, :participant) - end - + defp authorize_user(%{assigns: %{current_user: user}} = conn, assignment) do + Assignment.Public.add_participant!(assignment, user) conn end diff --git a/core/systems/assignment/participants_view.ex b/core/systems/assignment/participants_view.ex index f9e7503e2..746f786d9 100644 --- a/core/systems/assignment/participants_view.ex +++ b/core/systems/assignment/participants_view.ex @@ -2,14 +2,43 @@ defmodule Systems.Assignment.ParticipantsView do use CoreWeb, :live_component_fabric use Fabric.LiveComponent + import CoreWeb.Gettext + + alias Frameworks.Pixel.Panel + alias Frameworks.Pixel.Annotation + @impl true - def update(%{}, %{assigns: %{}} = socket) do + def update(%{id: id, assignment: assignment}, socket) do { :ok, socket + |> assign(id: id, assignment: assignment) + |> update_title() + |> update_annotation() + |> update_url() } end + defp update_title(socket) do + title = dgettext("eyra-assignment", "invite.panel.title") + assign(socket, title: title) + end + + defp update_annotation(socket) do + annotation = dgettext("eyra-assignment", "invite.panel.annotation") + assign(socket, annotation: annotation) + end + + defp update_url(%{assigns: %{assignment: %{id: id}}} = socket) do + path = ~p"/assignment/#{id}/invite" + url = get_base_url() <> path + assign(socket, url: url) + end + + defp get_base_url do + Application.get_env(:core, :base_url) + end + @impl true def render(assigns) do ~H""" @@ -18,6 +47,35 @@ defmodule Systems.Assignment.ParticipantsView do <%= dgettext("eyra-assignment", "participants.title") %> <.spacing value="L" /> + + + <:title> +
+ <%= @title %> +
+ + <.spacing value="S" /> + <%= if @annotation do %> + + <% end %> + <%= if @url do %> + <.spacing value="S" /> +
+
+ <%= @url %> +
+
+
+ +
+
+
+ <% end %> +
""" diff --git a/core/systems/assignment/template_benchmark_challenge.ex b/core/systems/assignment/template_benchmark_challenge.ex index 2592dc1d5..0e1c7093c 100644 --- a/core/systems/assignment/template_benchmark_challenge.ex +++ b/core/systems/assignment/template_benchmark_challenge.ex @@ -11,7 +11,6 @@ defmodule Systems.Assignment.TemplateBenchmarkChallenge do def content_flags(_t) do Map.merge(Assignment.ContentFlags.new(), %{ - general: false, panel: false, storage: false }) diff --git a/core/test/core_web/controllers/user_auth_test.exs b/core/test/core_web/controllers/user_auth_test.exs index 00f9ce5cc..45f29230a 100644 --- a/core/test/core_web/controllers/user_auth_test.exs +++ b/core/test/core_web/controllers/user_auth_test.exs @@ -175,8 +175,8 @@ defmodule CoreWeb.UserAuthTest do assert conn.halted assert redirected_to(conn) == ~p"/user/signin" - assert Phoenix.Flash.get(conn.assigns.flash, :error) == - "Sign in to view this page" + assert Phoenix.Flash.get(conn.assigns.flash, :info) == + "Please sign in first" end test "stores the path to redirect to on GET", %{conn: conn} do diff --git a/core/test/systems/assignment/controller_test.exs b/core/test/systems/assignment/controller_test.exs new file mode 100644 index 000000000..dbd8cd88c --- /dev/null +++ b/core/test/systems/assignment/controller_test.exs @@ -0,0 +1,53 @@ +defmodule Systems.Assignment.ControllerTest do + use CoreWeb.ConnCase, async: true + + alias Systems.Assignment + + describe "invite member" do + setup :login_as_member + + test "assignment not published", %{conn: conn} do + %{id: id} = Assignment.Factories.create_assignment(31, 0, :offline) + + conn = get(conn, "/assignment/#{id}/invite") + html_response(conn, 503) + end + + test "assignment published", %{conn: conn} do + %{id: id} = Assignment.Factories.create_assignment(31, 0, :online) + + conn = get(conn, "/assignment/#{id}/invite") + response = html_response(conn, 302) + assert response =~ "href=\"/assignment/#{id}" + end + + test "assignment not existing", %{conn: conn} do + conn = get(conn, "/assignment/1/invite") + html_response(conn, 503) + end + end + + describe "invite visitor" do + test "assignment not published", %{conn: conn} do + %{id: id} = Assignment.Factories.create_assignment(31, 0, :offline) + + conn = get(conn, "/assignment/#{id}/invite") + response = html_response(conn, 302) + assert response =~ "href=\"/user/signin" + end + + test "assignment published", %{conn: conn} do + %{id: id} = Assignment.Factories.create_assignment(31, 0, :online) + + conn = get(conn, "/assignment/#{id}/invite") + response = html_response(conn, 302) + assert response =~ "href=\"/user/signin" + end + + test "assignment not existing", %{conn: conn} do + conn = get(conn, "/assignment/1/invite") + response = html_response(conn, 302) + assert response =~ "href=\"/user/signin" + end + end +end diff --git a/core/test/systems/assignment/factories.ex b/core/test/systems/assignment/factories.ex index 199ca8a9a..8f58ffe4f 100644 --- a/core/test/systems/assignment/factories.ex +++ b/core/test/systems/assignment/factories.ex @@ -53,7 +53,7 @@ defmodule Systems.Assignment.Factories do }) end - def create_assignment(info, workflow, auth_node) do + def create_assignment(info, workflow, auth_node, status) do crew = Factories.insert!(:crew) Factories.insert!(:assignment, %{ @@ -61,11 +61,12 @@ defmodule Systems.Assignment.Factories do workflow: workflow, crew: crew, auth_node: auth_node, - special: :data_donation + special: :data_donation, + status: status }) end - def create_assignment(duration, subject_count) when is_integer(duration) do + def create_assignment(duration, subject_count, status \\ :online) when is_integer(duration) do assignment_auth_node = Factories.build(:auth_node) tool_auth_node = Factories.build(:auth_node, %{parent: assignment_auth_node}) @@ -75,6 +76,6 @@ defmodule Systems.Assignment.Factories do workflow = create_workflow() _workflow_item = create_workflow_item(workflow, tool_ref) - create_assignment(info, workflow, assignment_auth_node) + create_assignment(info, workflow, assignment_auth_node, status) end end From 017776e5439b37b0b4ee7b8a7a4e0bebab8a3323 Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 29 Mar 2024 11:38:49 +0100 Subject: [PATCH 16/36] #685 Done button doesn't worek anymore --- core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index 07c6ae65a..2465890a0 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -37,7 +37,7 @@ msgstr "https://github//" #, elixir-autogen, elixir-format msgid "fork_page.body" -msgstr "Fork the following repository to start working on your algorithm." +msgstr "Fork the following repository to start working on your algorithm." #, elixir-autogen, elixir-format msgid "page.title" @@ -61,4 +61,4 @@ msgstr "Select file" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "Download %{name} to start working on your algorithm." +msgstr "Download %{name} to start working on your algorithm." From 7e3a7902edba8501cecb159c176aa62d81d142ec Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 29 Mar 2024 12:01:50 +0100 Subject: [PATCH 17/36] #684 page.title in Dutch --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index a93ed3ad6..b96f16beb 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -37,11 +37,11 @@ msgstr "" #, elixir-autogen, elixir-format msgid "fork_page.body" -msgstr "" +msgstr "Fork de volgende repository om aan de slag te gaan met je algoritme." #, elixir-autogen, elixir-format, fuzzy msgid "page.title" -msgstr "" +msgstr "Instructies" #, elixir-autogen, elixir-format msgid "download_form.file.label" @@ -61,4 +61,4 @@ msgstr "" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "" +msgstr "Download %{name} om aan de slag te gaan met je algoritme." From ed28b1afdf27d8158537ff5533d4814b2b1ff817 Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 29 Mar 2024 12:14:53 +0100 Subject: [PATCH 18/36] #686 Liss Panel results in a 500 Server Error --- core/systems/assignment/external_panel_controller.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/systems/assignment/external_panel_controller.ex b/core/systems/assignment/external_panel_controller.ex index 4e8e32cf1..5ad747d63 100644 --- a/core/systems/assignment/external_panel_controller.ex +++ b/core/systems/assignment/external_panel_controller.ex @@ -48,6 +48,8 @@ defmodule Systems.Assignment.ExternalPanelController do not valid_id?(id) end + def valid_id?(nil), do: false + def valid_id?(id) do String.length(id) <= @id_max_lenght and Regex.match?(@id_valid_regex, id) end From bbd8f93dadfb4a6e7f12c810f52679fc554a6a0a Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Fri, 29 Mar 2024 12:48:27 +0100 Subject: [PATCH 19/36] fixed urls in dutch translation --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index b96f16beb..f0e650486 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -37,7 +37,7 @@ msgstr "" #, elixir-autogen, elixir-format msgid "fork_page.body" -msgstr "Fork de volgende repository om aan de slag te gaan met je algoritme." +msgstr "Fork de volgende repository om aan de slag te gaan met je algoritme." #, elixir-autogen, elixir-format, fuzzy msgid "page.title" @@ -61,4 +61,4 @@ msgstr "" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "Download %{name} om aan de slag te gaan met je algoritme." +msgstr "Download %{name} om aan de slag te gaan met je algoritme." From 95060bbf32e10299be7da92e9a0c893e32abbaac Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:41:13 +0100 Subject: [PATCH 20/36] Update eyra-instruction.po Adjusted download data instructions --- core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index 2465890a0..f7eccf81b 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -61,4 +61,4 @@ msgstr "Select file" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "Download %{name} to start working on your algorithm." +msgstr "You can use the training data uploaded by the challenge organizers to test and tune your method.

Click on the following link to download the data: %{name}." From 6f51d3e3cb6395e912f9f06670b255dab1833196 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:43:46 +0100 Subject: [PATCH 21/36] Update eyra-instruction.po Download instructies aangepast. --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index f0e650486..49d96fe3f 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -61,4 +61,5 @@ msgstr "" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "Download %{name} om aan de slag te gaan met je algoritme." +msgstr "Gebruik de training data die beschikbaar is gesteld door de challenge organizers om je methode te testen en te tunen.

Klik op de volgende link om de data te downloaden: %{name}." + From fe4875ad1a9c33bf82dcb3f1b4d10226d85c2da6 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:50:12 +0100 Subject: [PATCH 22/36] Update eyra-instruction.po Nederlandse vertalingen toegevoegd. --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index 49d96fe3f..5759a3658 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -29,11 +29,11 @@ msgstr "" #, elixir-autogen, elixir-format msgid "repository_url.label" -msgstr "" +msgstr "Repository" #, elixir-autogen, elixir-format, fuzzy msgid "repository_url.placeholder" -msgstr "" +msgstr "https://github//" #, elixir-autogen, elixir-format msgid "fork_page.body" @@ -45,19 +45,19 @@ msgstr "Instructies" #, elixir-autogen, elixir-format msgid "download_form.file.label" -msgstr "" +msgstr "Bestand" #, elixir-autogen, elixir-format msgid "download_form.file.placeholder" -msgstr "" +msgstr "Selecteer een zip bestand" #, elixir-autogen, elixir-format msgid "download_form.file.replace.button" -msgstr "" +msgstr "Vervang bestand" #, elixir-autogen, elixir-format msgid "download_form.file.select.button" -msgstr "" +msgstr "Selecteer bestand" #, elixir-autogen, elixir-format msgid "download_page.body" From 851a74bcfba0af516ceb5cca7a6beaa2d400fe4f Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:09:45 +0100 Subject: [PATCH 23/36] Update eyra-instruction.po --- core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index f7eccf81b..1548ec7e6 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -37,7 +37,7 @@ msgstr "https://github//" #, elixir-autogen, elixir-format msgid "fork_page.body" -msgstr "Fork the following repository to start working on your algorithm." +msgstr "Prepare your method for submission by using the template GitHub repository. Follow the instructions in the GitHub repository on how to copy the repository and prepare your submission.

Visit the template GitHub repository." #, elixir-autogen, elixir-format msgid "page.title" @@ -61,4 +61,4 @@ msgstr "Select file" #, elixir-autogen, elixir-format msgid "download_page.body" -msgstr "You can use the training data uploaded by the challenge organizers to test and tune your method.

Click on the following link to download the data: %{name}." +msgstr "You can use the participant data uploaded by the challenge organizers to test and tune your method.

Click on the following link to download the data: %{name}." From 80e30f26fb8264069bc0ec560a60089099354622 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:13:57 +0100 Subject: [PATCH 24/36] Update eyra-instruction.po Adjusted Dutch fork instructions. --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index 5759a3658..09bdef25d 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -37,7 +37,7 @@ msgstr "https://github//" #, elixir-autogen, elixir-format msgid "fork_page.body" -msgstr "Fork de volgende repository om aan de slag te gaan met je algoritme." +msgstr "Gebruik de template GitHub repository om je methode voor te bereiden voor submissie. Volg de instructies in de GitHub repository over hoe je een kopie maakt van de repository en deze kan gebruiken om je submissie voor te bereiden. Bezoek de template GitHub repository." #, elixir-autogen, elixir-format, fuzzy msgid "page.title" From 1f5359ebd57810b3367f19615e73d51bfc7c6d4a Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:25:09 +0100 Subject: [PATCH 25/36] Update eyra-instruction.po Changed file into participant data --- core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po index 1548ec7e6..33a6e270f 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-instruction.po @@ -45,11 +45,11 @@ msgstr "Instructions" #, elixir-autogen, elixir-format msgid "download_form.file.label" -msgstr "File" +msgstr "Participant data" #, elixir-autogen, elixir-format msgid "download_form.file.placeholder" -msgstr "Select a zip file" +msgstr "Add a zip file" #, elixir-autogen, elixir-format msgid "download_form.file.replace.button" From a17e54c7a45f106957013979c52fe2d6453048ed Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:27:39 +0100 Subject: [PATCH 26/36] Update eyra-instruction.po Copy participant data Dutch --- core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po index 09bdef25d..4e24df270 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-instruction.po @@ -45,11 +45,11 @@ msgstr "Instructies" #, elixir-autogen, elixir-format msgid "download_form.file.label" -msgstr "Bestand" +msgstr "Data voor participanten" #, elixir-autogen, elixir-format msgid "download_form.file.placeholder" -msgstr "Selecteer een zip bestand" +msgstr "Voeg een zip bestand toe" #, elixir-autogen, elixir-format msgid "download_form.file.replace.button" From d9609469c14b1df382137eb78415f21bf0766f88 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:29:37 +0100 Subject: [PATCH 27/36] Update eyra-enums.po Adjusted benchmark task list titles. --- core/priv/gettext/en/LC_MESSAGES/eyra-enums.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po index 69046cc6a..b7ef75f48 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-enums.po @@ -408,12 +408,12 @@ msgstr "Request manual" #, elixir-autogen, elixir-format msgid "assignment_workflow_item_types.submit" -msgstr "Submit" +msgstr "Submit method" #, elixir-autogen, elixir-format msgid "assignment_workflow_item_types.download_instruction" -msgstr "Download" +msgstr "Download data" #, elixir-autogen, elixir-format msgid "assignment_workflow_item_types.fork_instruction" -msgstr "Fork" +msgstr "Prepare method" From 205d74cc2f8520ab181d72159a3c8d39f0786ef0 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:57:55 +0100 Subject: [PATCH 28/36] Update eyra-assignment.po Adjusted copy task library rank --- core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 20096fca3..4c7160ee9 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -372,20 +372,20 @@ msgstr "Instructions for participants on how to request digital trace data." #, elixir-autogen, elixir-format, fuzzy msgid "workflow_item.download_instruction.description" -msgstr "Instructions for participants on how to download the data set." +msgstr "Enables participants to download your participant data zip file." #, elixir-autogen, elixir-format, fuzzy msgid "workflow_item.fork_instruction.description" -msgstr "Instructions for participants on how to fork the repository." +msgstr "Provides participants with your template GitHub repository link that they need to prepare their method for submission." #, elixir-autogen, elixir-format, fuzzy msgid "workflow_item.submit.description" -msgstr "Enables participants to submit an algorithm." +msgstr "Enables participants to submit their method to the challenge with a GitHub repository commit link." #, elixir-autogen, elixir-format msgid "invite.panel.annotation" -msgstr "The url below can be used to invite users to participate on this assignment. When users click on this link they will be asked to log in, registered as participant and forwarded to start on the assignment." +msgstr "Participants first need to create an account. After this, the url below can be used to invite participants. When participants click on this link they will be asked to sign in. After sign in, they are forwarded to your challenge." #, elixir-autogen, elixir-format, fuzzy msgid "invite.panel.title" -msgstr "Invite your participants" +msgstr "Invite participants" From f84e47b6599e0f00f149c1bf90aaca409e672d42 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:05:32 +0100 Subject: [PATCH 29/36] Update eyra-assignment.po Adjusted thank you copy --- core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po index 4c7160ee9..c451a6a42 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po @@ -264,7 +264,7 @@ msgstr "Show" #, elixir-autogen, elixir-format msgid "declined_view.body" -msgstr "We informed the researcher that you declined to participate. You can close the browser. If you wish to reconsider participation, close this popup to continue." +msgstr "You declined to participate. You can close the browser. If you wish to reconsider participation, close this popup to continue." #, elixir-autogen, elixir-format, fuzzy msgid "declined_view.title" @@ -272,11 +272,11 @@ msgstr "No consent" #, elixir-autogen, elixir-format msgid "finished_view.body" -msgstr "Thank you for your participation. You are now finished and can close your browser." +msgstr "We are grateful for your contribution. You finished all tasks on the list. You can close your browser to quite or close this popup to revisit the task list." #, elixir-autogen, elixir-format msgid "finished_view.title" -msgstr "Thank you" +msgstr "Thank you for your participation" #, elixir-autogen, elixir-format msgid "privacy_doc.placeholder" From 31a642e181277c55817c0fbe0eb22aacce3d2598 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:13:57 +0100 Subject: [PATCH 30/36] Update eyra-graphite.po Submission task form update --- core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po index ae050544c..ef295f767 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po @@ -47,11 +47,11 @@ msgstr[1] "" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.url.label" -msgstr "Github commit url" +msgstr "Your GitHub commit URL" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.description.label" -msgstr "Description" +msgstr "Short method description on leaderboard" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.submit.button" @@ -59,7 +59,7 @@ msgstr "Submit" #, elixir-autogen, elixir-format msgid "invalid.github.commit.url.message" -msgstr "Please enter a valid Github commit url" +msgstr "Please enter a valid GitHub commit URL" #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" From 35a001c3916a978c5a64ebd59f7195526e38c1ce Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:19:55 +0100 Subject: [PATCH 31/36] Update eyra-graphite.po Submission form edits Dutch --- core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po index 437df8d28..71de75838 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-graphite.po @@ -47,19 +47,19 @@ msgstr[1] "%{count} dagen" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.url.label" -msgstr "Github commit url" +msgstr "Jouw GitHub commit URL" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.description.label" -msgstr "Omschrijving" +msgstr "Methode omschrijving voor leaderboard" #, elixir-autogen, elixir-format, fuzzy msgid "submission.form.submit.button" -msgstr "Dien methode in" +msgstr "Indienen" #, elixir-autogen, elixir-format msgid "invalid.github.commit.url.message" -msgstr "Voer een geldige Github commit url in" +msgstr "Ongeldige GitHub commit URL (zie challenge repo instructies)" #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" From 27f612105abc079d1352a54f158b4cdf603e1d03 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:20:22 +0100 Subject: [PATCH 32/36] Update eyra-graphite.po Edited error message commit url --- core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po index ef295f767..c097b5281 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po @@ -59,7 +59,7 @@ msgstr "Submit" #, elixir-autogen, elixir-format msgid "invalid.github.commit.url.message" -msgstr "Please enter a valid GitHub commit URL" +msgstr "Invalid GitHub commit URL (see challenge repo for instructions)" #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" From bf15d1a30063422265b61ffcfbd58f534e4b71f3 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:31:13 +0100 Subject: [PATCH 33/36] Update eyra-graphite.po --- core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po index c097b5281..c0e20702b 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-graphite.po @@ -59,7 +59,7 @@ msgstr "Submit" #, elixir-autogen, elixir-format msgid "invalid.github.commit.url.message" -msgstr "Invalid GitHub commit URL (see challenge repo for instructions)" +msgstr "Invalid GitHub commit URL (see challenge repo instructions)" #, elixir-autogen, elixir-format, fuzzy msgid "1 submission" From a02bf8aea7a875cb11b6af8df750cdac41725633 Mon Sep 17 00:00:00 2001 From: Adrienne Mendrik <79082794+AdrienneMendrik@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:32:15 +0100 Subject: [PATCH 34/36] Update errors.po Added description for can't be blank. --- core/priv/gettext/en/LC_MESSAGES/errors.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/priv/gettext/en/LC_MESSAGES/errors.po b/core/priv/gettext/en/LC_MESSAGES/errors.po index b8de9590a..593eeb92b 100644 --- a/core/priv/gettext/en/LC_MESSAGES/errors.po +++ b/core/priv/gettext/en/LC_MESSAGES/errors.po @@ -11,7 +11,7 @@ msgstr "" "Language: en\n" msgid "can't be blank" -msgstr "" +msgstr "Please fill out this field" msgid "has already been taken" msgstr "" From 25c0312b799ce8053cbc1ab9e6582da60377cca9 Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Mon, 1 Apr 2024 13:39:19 +0200 Subject: [PATCH 35/36] Fixed max file size for Phoenix Live Upload --- core/config/config.exs | 2 ++ core/config/runtime.exs | 5 +++++ core/lib/core_web/file_uploader.ex | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/config/config.exs b/core/config/config.exs index 8a6039146..426e1ce40 100644 --- a/core/config/config.exs +++ b/core/config/config.exs @@ -40,6 +40,8 @@ config :plug, :statuses, %{ 404 => "Page not found" } +config :core, CoreWeb.FileUploader, max_file_size: 100_000_000 + config :core, image_catalog: Core.ImageCatalog.Unsplash, banking_backend: Systems.Banking.Dummy diff --git a/core/config/runtime.exs b/core/config/runtime.exs index 6300345ea..a5f03c0a8 100644 --- a/core/config/runtime.exs +++ b/core/config/runtime.exs @@ -36,6 +36,11 @@ if config_env() == :prod do port: String.to_integer(System.get_env("HTTP_PORT", "8000")) ] + # PHOENIX LIVE UPLOAD + + config :core, CoreWeb.FileUploader, + max_file_size: System.get_env("STORAGE_UPLOAD_MAX_SIZE", 100_000_000) + # MAILGUN if mailgun_api_key = System.get_env("MAILGUN_API_KEY") do diff --git a/core/lib/core_web/file_uploader.ex b/core/lib/core_web/file_uploader.ex index 712bc932f..b41408424 100644 --- a/core/lib/core_web/file_uploader.ex +++ b/core/lib/core_web/file_uploader.ex @@ -25,16 +25,21 @@ defmodule CoreWeb.FileUploader do # Skip init if it already has been called def init_file_uploader(%{assigns: %{uploads: _uploads}} = socket, _key), do: socket - def init_file_uploader(socket, key, max_file_size \\ 20_000_000) do + def init_file_uploader(socket, key) do socket |> allow_upload(key, accept: unquote(accept), progress: &handle_progress/3, - max_file_size: max_file_size, + max_file_size: get_max_file_size(), auto_upload: true ) end + def get_max_file_size() do + config = Application.fetch_env!(:core, CoreWeb.FileUploader) + Keyword.fetch!(config, :max_file_size) + end + def handle_progress(_key, entry, socket) do if entry.done? do upload_result = consume_file(socket, entry) From 451f250ec0d3ada5a9de779e29107d6cd75d0091 Mon Sep 17 00:00:00 2001 From: emielvdveen Date: Mon, 1 Apr 2024 14:03:18 +0200 Subject: [PATCH 36/36] Fixed max file size for Phoenix Live Upload II --- core/config/runtime.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config/runtime.exs b/core/config/runtime.exs index a5f03c0a8..67bbe94a5 100644 --- a/core/config/runtime.exs +++ b/core/config/runtime.exs @@ -39,7 +39,7 @@ if config_env() == :prod do # PHOENIX LIVE UPLOAD config :core, CoreWeb.FileUploader, - max_file_size: System.get_env("STORAGE_UPLOAD_MAX_SIZE", 100_000_000) + max_file_size: System.get_env("STORAGE_UPLOAD_MAX_SIZE", "100000000") |> String.to_integer() # MAILGUN