Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.
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
27 changes: 14 additions & 13 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
: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 */

.pageHeader {
margin-block-start: var(--app-navigation-padding);
margin-inline-start: calc(
Expand All @@ -15,13 +16,16 @@
}

/* Lists */

.listHeader {
display: flex;

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

Expand All @@ -37,15 +41,11 @@
}

/* Detail pages */
.detailHeader {
display: flex;
justify-content: space-between;
}

.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 @@ -83,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 @@ -112,7 +112,7 @@

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

Expand All @@ -136,6 +136,7 @@
}

/* File drag and drop */

.filesListDragDropNotice {
width: 100%;
min-height: 113px;
Expand Down
54 changes: 27 additions & 27 deletions lib/Controller/RegistersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use OCA\OpenRegister\Service\ObjectService;
use OCA\OpenRegister\Service\SearchService;
use OCA\OpenRegister\Db\Source;
use OCA\OpenRegister\Db\SourceMapper;
use OCA\OpenRegister\Db\Register;
use OCA\OpenRegister\Db\RegisterMapper;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
Expand All @@ -15,7 +15,7 @@
class RegistersController extends Controller
{
/**
* Constructor for the SourcesController
* Constructor for the RegistersController
*
* @param string $appName The name of the app
* @param IRequest $request The request object
Expand All @@ -25,7 +25,7 @@ public function __construct(
$appName,
IRequest $request,
private readonly IAppConfig $config,
private readonly SourceMapper $sourceMapper
private readonly RegisterMapper $registerMapper
)
{
parent::__construct($appName, $request);
Expand All @@ -51,56 +51,56 @@ public function page(): TemplateResponse
}

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

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

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

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

/**
* Creates a new source
* Creates a new register
*
* This method creates a new source based on POST data.
* This method creates a new register based on POST data.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse A JSON response containing the created source
* @return JSONResponse A JSON response containing the created register
*/
public function create(): JSONResponse
{
Expand All @@ -116,19 +116,19 @@ public function create(): JSONResponse
unset($data['id']);
}

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

/**
* Updates an existing source
* Updates an existing register
*
* This method updates an existing source based on its ID.
* This method updates an existing register based on its ID.
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $id The ID of the source to update
* @return JSONResponse A JSON response containing the updated source details
* @param string $id The ID of the register to update
* @return JSONResponse A JSON response containing the updated register details
*/
public function update(int $id): JSONResponse
{
Expand All @@ -142,23 +142,23 @@ public function update(int $id): JSONResponse
if (isset($data['id'])) {
unset($data['id']);
}
return new JSONResponse($this->sourceMapper->updateFromArray(id: (int) $id, object: $data));
return new JSONResponse($this->registerMapper->updateFromArray(id: (int) $id, object: $data));
}

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

return new JSONResponse([]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SchemasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function page(): TemplateResponse
public function index(ObjectService $objectService, SearchService $searchService): JSONResponse
{
$filters = $this->request->getParams();
$fieldsToSearch = ['name', 'description'];
$fieldsToSearch = ['title', 'description'];

$searchParams = $searchService->createMySQLSearchParams(filters: $filters);
$searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch);
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SourcesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function page(): TemplateResponse
public function index(ObjectService $objectService, SearchService $searchService): JSONResponse
{
$filters = $this->request->getParams();
$fieldsToSearch = ['name', 'description'];
$fieldsToSearch = ['title', 'description'];

$searchParams = $searchService->createMySQLSearchParams(filters: $filters);
$searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch);
Expand Down
43 changes: 30 additions & 13 deletions lib/Db/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,58 @@

class Register extends Entity implements JsonSerializable
{
protected ?string $id = null;
protected ?string $title = null;
protected ?string $description = null;
protected ?array $schemas = null;
protected ?array $schemas = [];
protected ?string $source = null;
protected ?string $tablePrefix = null;
protected ?DateTime $updated = null;
protected ?DateTime $created = null;

public function __construct() {
$this->addType('id', 'string');
$this->addType('title', 'title');
$this->addType('description', 'string');
$this->addType('schemas', 'array');
$this->addType('source', 'string');
$this->addType('tablePrefix', 'string');
$this->addType('updated', 'datetime');
$this->addType('created', 'datetime');
$this->addType(fieldName: 'title', type: 'string');
$this->addType(fieldName: 'description', type: 'string');
$this->addType(fieldName: 'schemas', type: 'json');
$this->addType(fieldName: 'source', type: 'string');
$this->addType(fieldName: 'tablePrefix', type: 'string');
$this->addType(fieldName:'updated', type: 'datetime');
$this->addType(fieldName:'created', type: 'datetime');
}

public function getJsonFields(): array
{
return array_keys(
array_filter($this->getFieldTypes(), function ($field) {
return $field === 'json';
})
);
}

public function hydrate(array $object): self
{
$jsonFields = $this->getJsonFields();

if(isset($object['metadata']) === false) {
$object['metadata'] = [];
}

foreach($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
$value = null;
}

$method = 'set'.ucfirst($key);

try {
$this->$method($value);
} catch (\Exception $exception) {
// Error handling can be added here
}
}

return $this;
}


public function jsonSerialize(): array
{
return [
Expand All @@ -52,8 +69,8 @@ public function jsonSerialize(): array
'schemas' => $this->schemas,
'source' => $this->source,
'tablePrefix' => $this->tablePrefix,
'updated' => $this->updated,
'created' => $this->created
'updated' => isset($this->updated) ? $this->updated->format('c') : null,
'created' => isset($this->created) ? $this->created->format('c') : null
];
}
}
8 changes: 6 additions & 2 deletions lib/Db/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class Schema extends Entity implements JsonSerializable
{
protected ?string $title = null;
protected ?string $version = null;
protected ?string $description = null;
protected ?string $summary = null;
Expand All @@ -20,13 +19,13 @@ class Schema extends Entity implements JsonSerializable
protected ?DateTime $created = null;

public function __construct() {
$this->addType(fieldName: 'archive', type: 'json');
$this->addType(fieldName: 'title', type: 'string');
$this->addType(fieldName: 'version', type: 'string');
$this->addType(fieldName: 'description', type: 'string');
$this->addType(fieldName: 'summary', type: 'string');
$this->addType(fieldName: 'required', type: 'json');
$this->addType(fieldName: 'properties', type: 'json');
$this->addType(fieldName: 'archive', type: 'json');
$this->addType(fieldName: 'source', type: 'string');
$this->addType(fieldName:'updated', type: 'datetime');
$this->addType(fieldName:'created', type: 'datetime');
Expand All @@ -45,6 +44,10 @@ public function hydrate(array $object): self
{
$jsonFields = $this->getJsonFields();

if(isset($object['metadata']) === false) {
$object['metadata'] = [];
}

foreach($object as $key => $value) {
if (in_array($key, $jsonFields) === true && $value === []) {
$value = null;
Expand All @@ -61,6 +64,7 @@ public function hydrate(array $object): self
return $this;
}


public function jsonSerialize(): array
{
$properties = [];
Expand Down
Loading