Skip to content

Commit

Permalink
Merge pull request #18 from ConductionNL/development
Browse files Browse the repository at this point in the history
Development to main
  • Loading branch information
remko48 authored Oct 16, 2024
2 parents 8007a0e + 948b786 commit 95c06b4
Show file tree
Hide file tree
Showing 82 changed files with 4,652 additions and 996 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {
rules: {
'jsdoc/require-jsdoc': 'off',
'vue/first-attribute-linebreak': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
}
26 changes: 26 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"files.autoSave": "afterDelay",
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"eslint.format.enable": true,
"cSpell.words": [
"depubliceren",
"Depubliceren",
"gedepubliceerd",
"Matadata",
"nextcloud",
"opencatalogi",
"organisation",
"Organisation",
"organisations",
"Organisations",
"pinia",
"Toegangs"
],
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
4 changes: 3 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
'Registers' => ['url' => 'api/registers'],
'Schemas' => ['url' => 'api/schemas'],
'Sources' => ['url' => 'api/sources'],
'Objects' => ['url' => 'api/objects'],
],
'routes' => [
['name' => 'dashboard#page', 'url' => '/', 'verb' => 'GET'],
['name' => 'dashboard#page', 'url' => '/', 'verb' => 'GET'],
['name' => 'registers#objects', 'url' => '/api/registers-objects/{register}/{schema}', 'verb' => 'GET'],
],
];
23 changes: 16 additions & 7 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:root {
--OC-margin-10: 10px;
--OC-margin-20: 20px;
--OC-margin-50: 50px;
--OR-margin-10: 10px;
--OR-margin-20: 20px;
--OR-margin-50: 50px;
}

/* Pages */
Expand All @@ -18,11 +18,15 @@
/* Lists */

.listHeader {
display: flex;

position: sticky;
top: 0;
z-index: 1000;
background-color: var(--color-main-background);
border-bottom: 1px solid var(--color-border);
flex-direction: row;
align-items: center;
}

.searchField {
Expand All @@ -39,9 +43,9 @@
/* Detail pages */

.detailContainer {
margin-block-start: var(--OC-margin-20);
margin-inline-start: var(--OC-margin-20);
margin-inline-end: var(--OC-margin-20);
margin-block-start: var(--OR-margin-20);
margin-inline-start: var(--OR-margin-20);
margin-inline-end: var(--OR-margin-20);
}

.tabContainer > * ul > li {
Expand Down Expand Up @@ -79,7 +83,7 @@
}

.tabContainer > * div[role="tabpanel"] {
margin-block-start: var(--OC-margin-10);
margin-block-start: var(--OR-margin-10);
}

.tabPanel {
Expand Down Expand Up @@ -107,6 +111,11 @@
}

/* Modals */
.modalContent {
margin: var(--OR-margin-50);
text-align: center;
}

.form-group > * {
margin-block-end: 10px;
}
Expand Down
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.5"
volumes:
nextcloud:
apps:
db:
config:

services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD='!ChangeMe!'
- MYSQL_PASSWORD='!ChangeMe!'
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud

init-ubuntu:
image: ubuntu
command: sh /home/ubuntu/docker/init-ubuntu.sh
volumes:
- ./docker:/home/ubuntu/docker
- .:/home/ubuntu/app

nextcloud:
user: root
container_name: nextcloud
# entrypoint: occ app:enable openregister
image: nextcloud
restart: always
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html:rw
- ./custom_apps:/var/www/html/custom_apps
- .:/var/www/html/custom_apps/openregister
environment:
- MYSQL_PASSWORD='!ChangeMe!'
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=db
- TZ=Europe/Amsterdam
- NEXTCLOUD_ADMIN_USER=admin
- NEXTCLOUD_ADMIN_PASSWORD=admin
8 changes: 8 additions & 0 deletions docker/init-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apt update;
apt install npm composer php-gd php-zip -y

cd /home/ubuntu/app
npm i
npm run dev

composer install
165 changes: 165 additions & 0 deletions lib/Controller/ObjectsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php

namespace OCA\OpenRegister\Controller;

use OCA\OpenRegister\Service\ObjectService;
use OCA\OpenRegister\Service\SearchService;
use OCA\OpenRegister\Db\ObjectEntity;
use OCA\OpenRegister\Db\ObjectEntityMapper;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
use OCP\IRequest;

class ObjectsController extends Controller
{
/**
* Constructor for the ObjectsController
*
* @param string $appName The name of the app
* @param IRequest $request The request object
* @param IAppConfig $config The app configuration object
*/
public function __construct(
$appName,
IRequest $request,
private readonly IAppConfig $config,
private readonly ObjectEntityMapper $objectEntityMapper
)
{
parent::__construct($appName, $request);
}

/**
* Returns the template of the main app's page
*
* This method renders the main page of the application, adding any necessary data to the template.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return TemplateResponse The rendered template response
*/
public function page(): TemplateResponse
{
return new TemplateResponse(
'openconnector',
'index',
[]
);
}

/**
* Retrieves a list of all objects
*
* This method returns a JSON response containing an array of all objects in the system.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse A JSON response containing the list of objects
*/
public function index(ObjectService $objectService, SearchService $searchService): JSONResponse
{
$filters = $this->request->getParams();
$fieldsToSearch = ['uuid', 'register', 'schema'];

$searchParams = $searchService->createMySQLSearchParams(filters: $filters);
$searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch);
$filters = $searchService->unsetSpecialQueryParams(filters: $filters);

return new JSONResponse(['results' => $this->objectEntityMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]);
}

/**
* Retrieves a single object by its ID
*
* This method returns a JSON response containing the details of a specific object.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $id The ID of the object to retrieve
* @return JSONResponse A JSON response containing the object details
*/
public function show(string $id): JSONResponse
{
try {
return new JSONResponse($this->objectEntityMapper->find(id: (int) $id));
} catch (DoesNotExistException $exception) {
return new JSONResponse(data: ['error' => 'Not Found'], statusCode: 404);
}
}

/**
* Creates a new object
*
* This method creates a new object based on POST data.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse A JSON response containing the created object
*/
public function create(): JSONResponse
{
$data = $this->request->getParams();

foreach ($data as $key => $value) {
if (str_starts_with($key, '_')) {
unset($data[$key]);
}
}

if (isset($data['id'])) {
unset($data['id']);
}

return new JSONResponse($this->objectEntityMapper->createFromArray(object: $data));
}

/**
* Updates an existing object
*
* This method updates an existing object based on its ID.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $id The ID of the object to update
* @return JSONResponse A JSON response containing the updated object details
*/
public function update(int $id): JSONResponse
{
$data = $this->request->getParams();

foreach ($data as $key => $value) {
if (str_starts_with($key, '_')) {
unset($data[$key]);
}
}
if (isset($data['id'])) {
unset($data['id']);
}
return new JSONResponse($this->objectEntityMapper->updateFromArray(id: (int) $id, object: $data));
}

/**
* Deletes an object
*
* This method deletes an object based on its ID.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $id The ID of the object to delete
* @return JSONResponse An empty JSON response
*/
public function destroy(int $id): JSONResponse
{
$this->objectEntityMapper->delete($this->objectEntityMapper->find((int) $id));

return new JSONResponse([]);
}
}
Loading

0 comments on commit 95c06b4

Please sign in to comment.