Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Next/donate feldspar integration #461

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ gettext:

build: build-digest build-app

build-assets:
@cd .assets && npm run build

build-digest:
@mix phx.digest

Expand Down
18 changes: 10 additions & 8 deletions core/assets/js/feldspar_app.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
export const FeldsparApp = {
mounted() {
console.log("FeldsparApp MOUNTED");

const iframe = this.getIframe();
if (iframe.contentDocument.readyState === "complete") {
iframe.addEventListener("load", () => {
this.onFrameLoaded();
}
else {
iframe.contentDocument.addEventListener("load", ()=>{ this.onFrameLoaded() });
}
});
iframe.setAttribute("src", this.el.dataset.src);
},

getIframe() {
return this.el.querySelector("iframe");
},

onFrameLoaded() {
console.log("Initializing iframe app")
console.log("Initializing iframe app");
this.channel = new MessageChannel();
this.channel.port1.onmessage = (e) => {
this.handleMessage(e);
};
this.getIframe().contentWindow.postMessage("init", "*", [this.channel.port2]);
this.getIframe().contentWindow.postMessage("init", "*", [
this.channel.port2,
]);
},

handleMessage(e) {
this.pushEvent("app_event", e.data);
}
},
};
3 changes: 2 additions & 1 deletion core/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"license": "MIT",
"scripts": {
"deploy": "NODE_ENV=production webpack --mode production",
"watch": "webpack --mode development --watch"
"watch": "webpack --mode development --watch",
"build": "webpack --mode development"
},
"dependencies": {
"@ryangjchandler/spruce": "^2.7.1",
Expand Down
10 changes: 10 additions & 0 deletions core/assets/static/images/icons/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions core/assets/static/images/icons/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions core/assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
"square-border-striped": "url('/images/square_border_striped.png')",
},
spacing: {
"1px": "1px",
aap: "1px",
"2px": "2px",
"3px": "3px",
"5px": "5px",
Expand All @@ -75,7 +75,7 @@ module.exports = {
"200px": "200px",
"224px": "224px",
"248px": "248px",
15: "60x",
15: "60px",
30: "120px",
34: "136px",
35: "140px",
Expand Down Expand Up @@ -112,6 +112,7 @@ module.exports = {
sheet: "760px",
popup: "480px",
"side-panel": "535px",
"left-column": "368px",
"popup-sm": "520px",
"popup-md": "730px",
"popup-lg": "1228px",
Expand Down
10 changes: 6 additions & 4 deletions core/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ config :core, CoreWeb.Endpoint,
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
"--watch",
cd: Path.expand("../assets", __DIR__)
]
]
Expand Down Expand Up @@ -74,7 +74,8 @@ config :core, :apns_backend, Core.APNS.LoggingBackend
config :core,
:static_path,
File.cwd!()
|> Path.join("tmp")
|> Path.join("priv")
|> Path.join("static")
|> Path.join("uploads")
|> tap(&File.mkdir_p!/1)

Expand All @@ -100,8 +101,9 @@ config :core, :feldspar,
backend: Systems.Feldspar.LocalFS,
local_fs_root_path:
File.cwd!()
|> Path.join("tmp")
|> Path.join("feldspar")
|> Path.join("priv")
|> Path.join("static")
|> Path.join("feldspar_apps")
|> tap(&File.mkdir_p!/1)

try do
Expand Down
6 changes: 3 additions & 3 deletions core/config/test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Config

# Print only errors during test
config :logger, level: :warn

# Setup for MinIO
config :ex_aws, :s3,
scheme: "http://",
Expand Down Expand Up @@ -27,9 +30,6 @@ config :core, Core.Repo,
pool_size: 10,
queue_target: 5000

# Print only warnings and errors during test
config :logger, level: :error

# Reduce password hashing impact on test duration
config :bcrypt_elixir,
log_rounds: 4
Expand Down
4 changes: 4 additions & 0 deletions core/frameworks/concept/tool_model.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ defprotocol Frameworks.Concept.ToolModel do
@spec form(t) :: atom()
def form(_t)

@spec launcher(t) :: %{url: binary()} | %{function: (map() -> any()), props: map()}
def launcher(_t)

@spec task_labels(t) :: map()
def task_labels(_t)

Expand All @@ -35,6 +38,7 @@ defimpl Frameworks.Concept.ToolModel, for: Ecto.Changeset do
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 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)
def group_enabled?(%{data: tool}), do: ToolModel.group_enabled?(tool)
Expand Down
2 changes: 1 addition & 1 deletion core/frameworks/pixel/components/align.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Frameworks.Pixel.Align do

def vertical_center(assigns) do
~H"""
<div class="flex flex-col items-center justify-center w-full">
<div class="flex flex-col justify-center w-full h-full">
<%= render_slot(@inner_block) %>
</div>
"""
Expand Down
5 changes: 4 additions & 1 deletion core/frameworks/pixel/components/line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ defmodule Frameworks.Pixel.Line do
"""
use CoreWeb, :html

attr(:color, :string, default: "bg-grey4")
attr(:height, :string, default: "h-px")

def line(assigns) do
~H"""
<div class="bg-grey4 h-px" />
<div class={"#{@color} #{@height}"} />
"""
end
end
2 changes: 1 addition & 1 deletion core/frameworks/pixel/components/text.ex
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ defmodule Frameworks.Pixel.Text do

def title1(assigns) do
~H"""
<div class={"text-title3 font-title3 sm:text-title2 lg:text-title1 lg:font-title1 #{@margin}"}>
<div class={"text-title3 font-title3 sm:text-title2 lg:text-title1 lg:font-title1 #{@margin} #{@color}"}>
<%= render_slot(@inner_block) %>
</div>
"""
Expand Down
38 changes: 0 additions & 38 deletions core/frameworks/utililty/legacy_routes_controller.ex

This file was deleted.

45 changes: 32 additions & 13 deletions core/lib/core/authorization.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ defmodule Core.Authorization do
grant_access(Systems.NextAction.OverviewPage, [:member])
grant_access(Systems.Campaign.OverviewPage, [:researcher])
grant_access(Systems.Campaign.ContentPage, [:owner])
grant_access(Systems.Assignment.ContentPage, [:researcher, :owner])
grant_access(Systems.Assignment.CrewPage, [:participant, :tester])
grant_access(Systems.Assignment.ContentPage, [:owner])
grant_access(Systems.Assignment.LandingPage, [:participant])
grant_access(Systems.Alliance.CallbackPage, [:participant, :tester])
grant_access(Systems.Alliance.CallbackPage, [:owner])
grant_access(Systems.Lab.PublicPage, [:member])
grant_access(Systems.Promotion.LandingPage, [:visitor, :member, :owner])
grant_access(Systems.Pool.OverviewPage, [:researcher])
Expand Down Expand Up @@ -74,9 +75,9 @@ defmodule Core.Authorization do
grant_access(CoreWeb.User.Profile, [:member])
grant_access(CoreWeb.User.Settings, [:member])
grant_access(CoreWeb.User.SecuritySettings, [:member])
grant_access(CoreWeb.FaceAlliance, [:member])
grant_access(CoreWeb.FakeQualtrics, [:member])

grant_actions(CoreWeb.FaceAllianceController, %{
grant_actions(CoreWeb.FakeAllianceController, %{
index: [:visitor, :member]
})

Expand All @@ -86,31 +87,49 @@ defmodule Core.Authorization do

def get_node!(id), do: Repo.get!(Core.Authorization.Node, id)

def make_node(), do: %Core.Authorization.Node{}
def prepare_node() do
%Core.Authorization.Node{}
end

def prepare_node(nil) do
%Core.Authorization.Node{}
end

def make_node(%Core.Authorization.Node{} = parent) do
%Core.Authorization.Node{parent_id: parent.id}
def prepare_node(roles) when is_list(roles) do
%Core.Authorization.Node{role_assignments: roles}
end

def make_node(nil), do: make_node()
def prepare_node(parent_id) when is_integer(parent_id) do
%Core.Authorization.Node{parent_id: parent_id}
end

def make_node(parent_id) when is_integer(parent_id) do
def prepare_node(%Core.Authorization.Node{id: parent_id}) do
%Core.Authorization.Node{parent_id: parent_id}
end

def make_node(parent) do
GreenLight.AuthorizationNode.id(parent) |> make_node
def prepare_node(principal, role) do
role = prepare_role(principal, role)
prepare_node([role])
end

def prepare_role(principal, role) when is_atom(role) do
principal_id = GreenLight.Principal.id(principal)

%Core.Authorization.RoleAssignment{
principal_id: principal_id,
role: :owner
}
end

def create_node(parent \\ nil) do
case make_node(parent) |> Core.Repo.insert() do
case prepare_node(parent) |> Core.Repo.insert() do
{:ok, node} -> {:ok, node.id}
error -> error
end
end

def create_node!(parent \\ nil) do
case make_node(parent) |> Core.Repo.insert() do
case prepare_node(parent) |> Core.Repo.insert() do
{:ok, node} -> node
error -> error
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/core_web/controllers/fake_alliance_controller.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule CoreWeb.FaceAllianceController do
defmodule CoreWeb.FakeAllianceController do
use CoreWeb, :controller

def index(conn, _params) do
Expand Down
2 changes: 1 addition & 1 deletion core/lib/core_web/controllers/fake_alliance_html.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule CoreWeb.FaceAllianceHTML do
defmodule CoreWeb.FakeAllianceHTML do
use CoreWeb, :html

embed_templates("fake_alliance_html/*")
Expand Down
12 changes: 8 additions & 4 deletions core/lib/core_web/controllers/layouts/stripped/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ defmodule CoreWeb.Layouts.Stripped.Component do

attr(:title, :string, default: nil)
attr(:menus, :map, required: true)
attr(:footer?, :boolean, default: true)

slot(:inner_block, required: true)

def stripped(assigns) do
Expand All @@ -70,7 +72,7 @@ defmodule CoreWeb.Layouts.Stripped.Component do
</div>
<% end %>
<div class="flex-1 bg-white">
<div class="flex flex-row">
<div class="flex flex-row w-full h-full">
<div class="flex-1">
<%= render_slot(@inner_block) %>
<Margin.y id={:page_footer_top} />
Expand All @@ -79,9 +81,11 @@ defmodule CoreWeb.Layouts.Stripped.Component do
</div>
</div>
</div>
<div class="bg-white">
<.content_footer />
</div>
<%= if @footer? do %>
<div class="bg-white">
<.content_footer />
</div>
<% end %>
</div>
</div>
<div class="bg-grey5">
Expand Down
Loading
Loading