Skip to content

Commit

Permalink
Update PoC to Pilot version
Browse files Browse the repository at this point in the history
  • Loading branch information
jschram committed Dec 11, 2024
1 parent b430563 commit 1640ab2
Show file tree
Hide file tree
Showing 634 changed files with 43,522 additions and 7,283 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@ SURFCONEXT_TEST=true
SURFCONEXT_ROLE_TEACHER=urn:collab:group:test.surfconext.nl:nl:surfnet:diensten:edutools_test_docent
SURFCONEXT_ROLE_INFORMATION_MANAGER=urn:collab:group:test.surfconext.nl:nl:surfnet:diensten:edutools_test_informatiemanager
SURFCONEXT_ROLE_CONTENT_MANAGER=urn:collab:group:test.surfconext.nl:nl:surfnet:diensten:edutools_test_contentmanager

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET_PUBLIC=
AWS_URL=
AWS_ENDPOINT=
AWS_USE_PATH_STYLE_ENDPOINT=true

PIWIK_KEY=
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# PEA
# PEA - Platform Educational Applications (Pilot Phase)

## Setting up the application

### Requirements

- PHP 8.0
- Composer 2
- NVM with Node 14
- NVM with Node 20
- PNPM >=8.7.6 && <9
- Run `curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=8.15.8 sh -` to install pnpm
- Run `pnpm add -g pnpm@8` if you need to update to a newer version of pnpm 8 for some reason
- MySQL 5.7
- S3 (or compatible) storage

### Set up

#### Production
- Create a database
- Copy the `.env.example` to `.env`
- Copy the `.env.example` to `.env` and configure the variables
- Install dependencies: `composer install --no-dev`
- Set up a new key for the application: `artisan key:generate`
- Properly fill in the `.env` file
Expand All @@ -26,7 +30,7 @@

#### Development
- Create a database
- Copy the `.env.example` to `.env`
- Copy the `.env.example` to `.env` and configure the variables
- Install dependencies: `composer install`
- Set up a new key for the application: `artisan key:generate`
- Properly fill in the `.env` file
Expand All @@ -35,9 +39,18 @@
- Export the translations for Javascript: `artisan w2w:export-translations`

## Storage
Storage is assumed to run from a S3 service, or anything that's compatible with S3 (like Minio, Wasabisys, etc.).
A public bucket is required from which images are served, and an Access Key + Secret should be entered into the .env file:

If running in a Docker environment, always ensure that the symbolic links are created from Docker and not the host OS.
Otherwise the path will not be correct and files can not be found by nginx.
```dotenv
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET_PUBLIC=
AWS_URL=
AWS_ENDPOINT=
AWS_USE_PATH_STYLE_ENDPOINT=true
```

## SURFconext authentication
To be able to login with SURFconext you need to configure valid oAuth credentials in your .env file:
Expand Down Expand Up @@ -68,4 +81,3 @@ Perform the following steps to login with SURFconext:
* Choose the EduID provider
* Log in with an existing EduID account, or [create your own free account](https://wiki.surfnet.nl/display/conextsupport/eduID+gasttoegang)
* After the login, you are redirect back into the application and a user account is either created, or updated with the latest information from SURFconext

19 changes: 19 additions & 0 deletions app/Actions/ContentPage/CreateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Actions\ContentPage;

use App\Models\ContentPage;
use Spatie\QueueableAction\QueueableAction;

class CreateAction
{
use QueueableAction;

public function execute(array $data): void
{
$contentPage = new ContentPage($data);
$contentPage->save();
}
}
18 changes: 18 additions & 0 deletions app/Actions/ContentPage/DeleteAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions\ContentPage;

use App\Models\ContentPage;
use Spatie\QueueableAction\QueueableAction;

class DeleteAction
{
use QueueableAction;

public function execute(ContentPage $contentPage): void
{
$contentPage->delete();
}
}
18 changes: 18 additions & 0 deletions app/Actions/ContentPage/UpdateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions\ContentPage;

use App\Models\ContentPage;
use Spatie\QueueableAction\QueueableAction;

class UpdateAction
{
use QueueableAction;

public function execute(array $data, ContentPage $contentPage): void
{
$contentPage->update($data);
}
}
31 changes: 31 additions & 0 deletions app/Actions/CustomField/CreateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Actions\CustomField;

use App\Models\CustomField;
use App\Models\Institute;
use Spatie\QueueableAction\QueueableAction;

class CreateAction
{
use QueueableAction;

public function execute(array $data, Institute $institute): void
{
if (!isset($data['sortkey'])) {
$data['sortkey'] = $this->getHighestSortkey($institute) + 1;
}

$customField = new CustomField($data);

$customField->institute()->associate($institute);
$customField->save();
}

private function getHighestSortkey(Institute $institute): int
{
return $institute->customFields()->max('sortkey') ?? 0;
}
}
18 changes: 18 additions & 0 deletions app/Actions/CustomField/DeleteAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions\CustomField;

use App\Models\CustomField;
use Spatie\QueueableAction\QueueableAction;

class DeleteAction
{
use QueueableAction;

public function execute(CustomField $customField): void
{
$customField->delete();
}
}
18 changes: 18 additions & 0 deletions app/Actions/CustomField/UpdateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions\CustomField;

use App\Models\CustomField;
use Spatie\QueueableAction\QueueableAction;

class UpdateAction
{
use QueueableAction;

public function execute(CustomField $customField, array $data): void
{
$customField->update($data);
}
}
24 changes: 24 additions & 0 deletions app/Actions/HomepageInformation/EditHomepageInformationAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Actions\HomepageInformation;

use App\Helpers\WYSIWYG;
use App\Models\Institute;
use Spatie\QueueableAction\QueueableAction;

class EditHomepageInformationAction
{
use QueueableAction;

public function execute(array $data, Institute $institute): void
{
$institute->update([
'homepage_title_en' => $data['homepage_title_en'],
'homepage_body_en' => WYSIWYG::isEmpty($data['homepage_body_en']) ? null : $data['homepage_body_en'],
'homepage_title_nl' => $data['homepage_title_nl'],
'homepage_body_nl' => WYSIWYG::isEmpty($data['homepage_body_nl']) ? null : $data['homepage_body_nl'],
]);
}
}
17 changes: 17 additions & 0 deletions app/Actions/Institute/ImpersonateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace App\Actions\Institute;

use App\Models\Institute;
use App\Models\User;

class ImpersonateAction
{
public function execute(User $user, Institute $institute): void
{
$user->impersonatedInstitute()->associate($institute);
$user->save();
}
}
16 changes: 16 additions & 0 deletions app/Actions/Institute/StopImpersonatingAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace App\Actions\Institute;

use App\Models\User;

class StopImpersonatingAction
{
public function execute(User $user): void
{
$user->impersonatedInstitute()->disassociate();
$user->save();
}
}
26 changes: 26 additions & 0 deletions app/Actions/Institute/Tag/CreateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\Actions\Institute\Tag;

use App\Models\Institute;
use App\Models\Tag;
use Spatie\QueueableAction\QueueableAction;

class CreateAction
{
use QueueableAction;

public function execute(array $data, Institute $institute): void
{
$tag = Tag::create(['name' => $data['name'], 'type' => $data['type']]);
$tag->institute()->associate($institute);

if (isset($data['description']['en']) || isset($data['description']['nl'])) {
$tag->setTranslations('description', $data['description']);
}

$tag->save();
}
}
18 changes: 18 additions & 0 deletions app/Actions/Institute/Tag/DeleteAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions\Institute\Tag;

use App\Models\Tag;
use Spatie\QueueableAction\QueueableAction;

class DeleteAction
{
use QueueableAction;

public function execute(Tag $tag): void
{
$tag->delete();
}
}
26 changes: 26 additions & 0 deletions app/Actions/Institute/Tag/UpdateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\Actions\Institute\Tag;

use App\Models\Tag;
use Spatie\QueueableAction\QueueableAction;

class UpdateAction
{
use QueueableAction;

public function execute(Tag $tag, array $data): void
{
$tag->setTranslations('name', $data['name']);

if (isset($data['description'])) {
$tag->setTranslations('description', $data['description']);
}

$tag->type = $data['type'];

$tag->save();
}
}
29 changes: 27 additions & 2 deletions app/Actions/Institute/Tool/AddAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,42 @@
namespace App\Actions\Institute\Tool;

use App\Models\Institute;
use App\Models\InstituteTool;
use App\Models\Tool;
use App\Models\User;
use Spatie\QueueableAction\QueueableAction;

class AddAction
{
use QueueableAction;

public function execute(Tool $tool, Institute $institute, array $data): void
public function execute(Tool $tool, Institute $institute, array $data, User $user): void
{
$tool->institutes()->attach($institute);

(new UpdateAction())->execute($tool, $institute, $data);
(new UpdateAction())->execute($tool, $institute, $data, $user);

$this->setCustomFields($tool, $institute, $data);
}

private function setCustomFields(Tool $tool, Institute $institute, array $data): void
{
if (!isset($data['custom_fields'])) {
return;
}

$instituteTool = InstituteTool::forTool($tool)->forInstitute($institute)->firstOrFail();

$instituteTool->customFields()->sync([]);
foreach ($data['custom_fields'] as $customField) {
if ($customField['value_en'] === null) {
continue;
}

$instituteTool->customFields()->attach($customField['id'], [
'value_en' => $customField['value_en'],
'value_nl' => $customField['value_nl'],
]);
}
}
}
Loading

0 comments on commit 1640ab2

Please sign in to comment.