Skip to content

Commit

Permalink
Merge pull request #438 from eyra/next/port-task-builder
Browse files Browse the repository at this point in the history
Next/port task builder
  • Loading branch information
mellelieuwes authored Sep 26, 2023
2 parents 8a79af0 + 368579d commit 507a4fa
Show file tree
Hide file tree
Showing 101 changed files with 1,580 additions and 758 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Eyra Mono

Primary collection of Eyra projects
Primary collection of Eyra projects

## Projects

Expand All @@ -19,7 +19,7 @@ Project implementing a SaaS platform based on interlinked modules called Systems
* Campaign
* Assignment
* Lab
* Survey
* Questionnaire
* Pool
* Data Donation
* ..
Expand All @@ -28,12 +28,12 @@ Project implementing a SaaS platform based on interlinked modules called Systems

* Next

Primary bundle with all features available except Link specific features.
Primary bundle with all features available except Link specific features.
Next is hosted on: https://eyra.co

* Link

Secundary bundle with only Panl specific features.
Secundary bundle with only Panl specific features.
Link is hosted on: https://researchpanl.eu

## Banking Proxy
Expand Down
2 changes: 2 additions & 0 deletions core/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import "./100vh-fix";
import { ViewportResize } from "./viewport_resize";
import { SidePanel } from "./side_panel";
import { Toggle } from "./toggle";
import { Cell } from "./cell";
import { LiveContent, LiveField } from "./live_content";
import { Tabbar, TabbarItem, TabbarFooterItem } from "./tabbar";
import { PythonUploader } from "./python_uploader";
Expand Down Expand Up @@ -96,6 +97,7 @@ let Hooks = {
ViewportResize,
SidePanel,
Toggle,
Cell,
LiveContent,
LiveField,
Tabbar,
Expand Down
82 changes: 82 additions & 0 deletions core/assets/js/cell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const COLLAPSED = "collapsed";
const EXPANDED = "expanded";

const COLLAPSED_VIEW = "cell-collapsed-view";
const EXPANDED_VIEW = "cell-expanded-view";

const COLLAPSE_BUTTON = "cell-collapse-button";
const EXPAND_BUTTON = "cell-expand-button";

export const Cell = {
mounted() {
this.collapseButton = this.el.getElementsByClassName(COLLAPSE_BUTTON)[0];
this.collapsedView = this.el.getElementsByClassName(COLLAPSED_VIEW)[0];

this.expandButton = this.el.getElementsByClassName(EXPAND_BUTTON)[0];
this.expandedView = this.el.getElementsByClassName(EXPANDED_VIEW)[0];

this.collapseButton.addEventListener("click", (event) => {
event.stopPropagation();
this.updateStatus(COLLAPSED);
});

this.expandButton.addEventListener("click", (event) => {
event.stopPropagation();
this.updateStatus(EXPANDED);
});

var initialStatus = this.el.dataset.initialStatus
? this.el.dataset.initialTab
: COLLAPSED;

var savedStatus = this.loadStatus();
this.status = savedStatus ? savedStatus : initialStatus;
this.updateUI();
},

updated() {
this.updateUI();
},

loadStatus() {
const key = this.getStatusKey();
const status = window.localStorage.getItem(key);
if (typeof status === "string") {
return status;
}
return undefined;
},

saveStatus() {
console.info("saveStatus ", this.status);
window.localStorage.setItem(this.getStatusKey(), this.status);
},

getStatusKey() {
return "cell://" + this.el.id + "/status";
},

updateStatus(status) {
this.status = status;
this.saveStatus();
this.updateUI();
},

updateUI() {
if (this.status == EXPANDED) {
this.hide(this.collapsedView);
this.show(this.expandedView);
} else {
this.show(this.collapsedView);
this.hide(this.expandedView);
}
},
hide(element) {
if (!element.classList.contains("hidden")) {
element.classList.add("hidden");
}
},
show(element) {
element.classList.remove("hidden");
},
};
50 changes: 19 additions & 31 deletions core/assets/js/side_panel.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
const maxBottomMargin = 62;
const maxBottomMargin = 63;

export const SidePanel = {
mounted() {
this.mainContent = document.getElementById("main-content");
this.parent = document.getElementById(this.el.dataset.parent);
this.panel = this.el.getElementsByClassName("panel")[0];
this.panel.style = `height: 0px;`;
this.make_absolute();
this.panel.style = `position: fixed; height: 0px; top: 0px`;
this.updateFrame();

window.addEventListener("tab-activated", (event) => {
new ResizeObserver(() => {
this.updateFrame();
});
}).observe(this.parent);

window.addEventListener("scroll", (event) => {
this.mainContent.addEventListener("scroll", (event) => {
this.updateFrame();
});

window.addEventListener("resize", (event) => {
this.updateFrame();
});
},
make_absolute() {
this.el.classList.remove("relative");
this.el.classList.add("absolute");

window.addEventListener("tab-activated", (event) => {
this.updateFrame();
});
},
updated() {
this.make_absolute();
this.updateFrame();
},
updateFrame() {
this.updateHeight();
this.updatePosition();
},
updateHeight() {
const bottomMarginDelta = Math.min(
maxBottomMargin,
document.documentElement.scrollHeight -
window.scrollY -
window.innerHeight
);
const bottomMargin = maxBottomMargin - bottomMarginDelta;
const bottomDistance =
this.mainContent.scrollHeight -
this.mainContent.scrollTop -
window.innerHeight;
const bottomMargin =
maxBottomMargin - Math.min(maxBottomMargin, bottomDistance);
const topMargin = Math.max(0, this.parent.getBoundingClientRect().top);
const height = window.innerHeight - (topMargin + bottomMargin);

const height =
window.innerHeight -
(this.parent.getBoundingClientRect().top + bottomMargin);
this.panel.style = `height: ${height}px;`;
},
updatePosition() {
const top =
Math.max(0, this.parent.getBoundingClientRect().top) + window.scrollY;
this.el.style = `top: ${top}px; right: 0px`;
this.panel.style = `position: fixed; height: ${height}px; top: ${topMargin}px`;
},
};
2 changes: 1 addition & 1 deletion core/assets/js/tabbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Tabbar = {
var isVisible = tab.id === nextTabId;
setVisible(tab, isVisible);
if (isVisible) {
tab.dispatchEvent(new Event("tab-activated", { bubbles: true}));
tab.dispatchEvent(new Event("tab-activated", { bubbles: true }));
}
});

Expand Down
11 changes: 11 additions & 0 deletions core/assets/static/images/icons/ready.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion core/assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ module.exports = {
paddingBottom: "constant(safe-area-inset-bottom)",
paddingBottom: "env(safe-area-inset-bottom)",
},
".scrollbar-hide": {
".scrollbar-hidden": {
/* Firefox */
"scrollbar-width": "thin",

Expand Down
14 changes: 7 additions & 7 deletions core/bundles/link/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ student_count = 1500
researcher_count = 100
researchers_per_campaign = 5
lab_count = 200
survey_count = 600
questionnaire_count = 600
time_slots_per_lab = 20
seats_per_time_slot = 20

survey_url = "https://vuamsterdam.eu.qualtrics.com/jfe/form/SV_4Po8iTxbvcxtuaW"
questionnaire_url = "https://vuamsterdam.eu.qualtrics.com/jfe/form/SV_4Po8iTxbvcxtuaW"

images = [
"raw_url=https%3A%2F%2Fimages.unsplash.com%2Fphoto-1600614908054-57142d1eec2b%3Fixid%3DMnwyMTY0MzZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2Mjc4MDc5MzY%26ixlib%3Drb-1.2.1&username=seonghojang95&name=Seongho+Jang&blur_hash=LKLy%5B%2AMd0L%3FG%3B0XSE2xDyC%25f%24zI%3B",
Expand Down Expand Up @@ -184,9 +184,9 @@ researcher =

{:ok, surveys} =
Core.Repo.transaction(fn ->
for _ <- 1..survey_count do
for _ <- 1..questionnaire_count do
%{
type: :survey_tool,
type: :questionnaire_tool,
promotion: %{
title: Faker.Lorem.sentence() <> " (survey)",
subtitle: Faker.Lorem.sentence(),
Expand All @@ -195,8 +195,8 @@ researcher =
marks: ["vu"],
plugin: "survey"
},
survey_tool: %{
survey_url: Faker.Internet.url(),
questionnaire_tool: %{
questionnaire_url: Faker.Internet.url(),
# desktop_enabled: true,
# phone_enabled: true,
# tablet_enabled: true,
Expand Down Expand Up @@ -250,7 +250,7 @@ Core.Repo.transaction(
)
)

if tool_type == :survey_tool do
if tool_type == :questionnaire_tool do
participant_count = :random.uniform(tool.subject_count)

for student <- Enum.take_random(students, participant_count) do
Expand Down
1 change: 1 addition & 0 deletions core/frameworks/pixel/components/button.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule Frameworks.Pixel.Button do

defp action_function(type) do
case type do
:fake -> &Action.fake/1
:toggle -> &Action.toggle/1
:click -> &Action.click/1
:redirect -> &Action.redirect/1
Expand Down
10 changes: 10 additions & 0 deletions core/frameworks/pixel/components/button_action.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
defmodule Frameworks.Pixel.Button.Action do
use CoreWeb, :html

slot(:inner_block, required: true)

def fake(assigns) do
~H"""
<div class="cursor-pointer focus:outline-none">
<%= render_slot(@inner_block) %>
</div>
"""
end

attr(:code, :string, required: true)
slot(:inner_block, required: true)

Expand Down
4 changes: 2 additions & 2 deletions core/frameworks/pixel/components/side_panel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ defmodule Frameworks.Pixel.SidePanel do

def side_panel(assigns) do
~H"""
<div id={@id} data-parent={@parent} class={"relative top-0 right-0 w-side-panel #{@bg_color}"} phx-hook="SidePanel">
<div class="panel w-side-panel overflow-y-scroll">
<div id={@id} data-parent={@parent} class={"w-side-panel #{@bg_color}"} phx-hook="SidePanel">
<div class="panel w-side-panel scrollbar-hidden overflow-y-scroll bg-grey5">
<div class="mx-6 mb-6">
<%= render_slot(@inner_block) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion core/frameworks/pixel/components/square_container.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Frameworks.Pixel.Square do
def container(assigns) do
~H"""
<div class="relative rounded-lg bg-grey6 h-248px">
<div class="absolute top-0 left-0 w-full flex flex-row gap-6 p-6 overflow-scroll scrollbar-hide">
<div class="absolute top-0 left-0 w-full flex flex-row gap-6 p-6 overflow-scroll scrollbar-hidden">
<%= render_slot(@inner_block) %>
</div>
<div class="absolute top-0 right-0 h-full w-64px rounded-tr-lg rounded-br-lg bg-gradient-to-r from-white to-black opacity-5" />
Expand Down
1 change: 1 addition & 0 deletions core/frameworks/signal/_public.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule Frameworks.Signal.Public do
Core.WebPush.SignalHandlers,
Core.APNS.SignalHandlers,
Systems.Observatory.Switch,
Systems.Project.Switch,
Systems.Assignment.Switch,
Systems.Pool.Switch,
Systems.Student.Switch,
Expand Down
6 changes: 3 additions & 3 deletions core/lib/core/authorization.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Core.Authorization do

# Models
grant_access(Systems.Campaign.Model, [:visitor, :member])
grant_access(Systems.Survey.ToolModel, [:owner, :coordinator, :participant])
grant_access(Systems.Questionnaire.ToolModel, [:owner, :coordinator, :participant])
grant_access(Systems.Lab.ToolModel, [:owner, :coordinator, :participant])
grant_access(Systems.DataDonation.ToolModel, [:owner, :coordinator, :participant])
grant_access(Systems.Benchmark.SpotModel, [:owner])
Expand Down Expand Up @@ -71,9 +71,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.FakeSurvey, [:member])
grant_access(CoreWeb.FakeQuestionnaire, [:member])

grant_actions(CoreWeb.FakeSurveyController, %{
grant_actions(CoreWeb.FakeQuestionnaireController, %{
index: [:visitor, :member]
})

Expand Down
16 changes: 15 additions & 1 deletion core/lib/core/enums/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ defmodule Core.Enums.Base do
unquote(values)
end

def contains(atom) when is_atom(atom) do
contains(Atom.to_string(atom))
end

def contains(binary) when is_binary(binary) do
values()
|> Enum.map(&Atom.to_string/1)
|> Enum.member?(binary)
end

def translate(value) do
Gettext.dgettext(CoreWeb.Gettext, "eyra-enums", "#{unquote(name)}.#{value}")
if contains(value) do
Gettext.dgettext(CoreWeb.Gettext, "eyra-enums", "#{unquote(name)}.#{value}")
else
value
end
end

def labels() do
Expand Down
Loading

0 comments on commit 507a4fa

Please sign in to comment.