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

Feat(Views): Manage data presentation of tables by views #426

Merged
merged 108 commits into from
Aug 11, 2023
Merged

Conversation

Hephi2
Copy link
Contributor

@Hephi2 Hephi2 commented Jul 21, 2023

Views are tables that contain and display certain data of the underlying data table. Views allow you to select the columns to display and their order, filter and sort the rows. Combined with functions such as sharing with specific permissions and more, this enables the creation of workflows.

View related

Unrelated but still solved

@Hephi2 Hephi2 self-assigned this Jul 21, 2023
Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some early comments on the first batch of files I went over. Overall this looks super nice already :)

appinfo/info.xml Outdated Show resolved Hide resolved
['name' => 'api1#getColumn', 'url' => '/api/1/columns/{columnId}', 'verb' => 'GET'],
['name' => 'api1#deleteColumn', 'url' => '/api/1/columns/{columnId}', 'verb' => 'DELETE'],
['name' => 'api1#updateColumn', 'url' => '/api/1/columns/{columnId}', 'verb' => 'PUT'],
// -> rows -> table
['name' => 'api1#indexTableRowsSimple', 'url' => '/api/1/tables/{tableId}/rows/simple', 'verb' => 'GET'],
['name' => 'api1#indexTableRows', 'url' => '/api/1/tables/{tableId}/rows', 'verb' => 'GET'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we may need to keep a compatibility endpoint (for this and other dropped ones) to just point to the base view then, as I know @stefan-niedermann is already using this API for an Android client in the works ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliushaertl if you can give me a list of dropped endpoints I can tell you which one are problematic for the Tables Android App 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APIs used by the Tables Android App 1.1.2:

GET    /tables
POST   /tables
DELETE /tables/{tableId}
PUT    /tables/{tableId}
GET    /tables/{tableId}/columns
POST   /tables/{tableId}/columns
PUT    /columns/{columnId}
DELETE /columns/{columnId}
GET    /tables/{tableId}/rows    <-- Dropped?
POST   /tables/{tableId}/rows
PUT    /rows/{rowId}
DELETE /rows/{rowId}

If one of them needs to get dropped, it would be awesome to maintain backward compatibility for at least one major version of the Tables server app while announcing deprecations for the APIs that shall be dropped, so 3rd party users have some time to adapt the changes.

Looking forward to a list of APIs that will be dropped and which replacements will be there 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the PR has been merged, I assume that there are breaking changes in the API? Are the differences documented or announced somewhere?

@juliushaertl @datenangebot

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, all routes are back and should work as before, no breaking changes.
(Some new routes are not yet documented: #452)

Comment on lines 190 to 199
if ($keyword) {
return $this->handleError(function () use ($keyword, $limit, $offset) {
return $this->viewService->search($keyword, $limit, $offset);
});
} else {
return $this->handleError(function () use ($tableId) {
return $this->viewService->findAll($this->tableService->find($tableId));
});
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be personal preference but I feel something like this would be easier to read and saves the extra else branch:

Suggested change
if ($keyword) {
return $this->handleError(function () use ($keyword, $limit, $offset) {
return $this->viewService->search($keyword, $limit, $offset);
});
} else {
return $this->handleError(function () use ($tableId) {
return $this->viewService->findAll($this->tableService->find($tableId));
});
}
return $this->handleError(function () use ($keyword, $limit, $offset) use (keyword, $limit, $offset) {
if ($keyword !== null) {
return $this->viewService->search($keyword, $limit, $offset);
}
return $this->viewService->findAll($this->tableService->find($tableId));
});

Null check would also be safer to do a strict comparison as it allows to use the limit/offset with an empty search term. In gerneral findAll and search could probably be combined in one method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually looking at it again, i find it odd that search ignores the tableId

lib/Controller/ColumnController.php Outdated Show resolved Hide resolved
lib/Controller/ColumnController.php Outdated Show resolved Hide resolved
lib/Db/ColumnTypes/DatetimeColumnQB.php Outdated Show resolved Hide resolved
lib/Migration/Version000603Date20230703000000.php Outdated Show resolved Hide resolved
lib/Migration/Version000603Date20230703000000.php Outdated Show resolved Hide resolved
$table->addColumn('filter', \Doctrine\DBAL\Types\Types::JSON, [
'notnull' => false,
]);
$table->setPrimaryKey(['id']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should carefully review the queries at some point and see where it would make sense to add indices to the tables

lib/Reference/ReferenceHelper.php Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2023

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the reviewing process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR reviewing process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

@kesselb
Copy link

kesselb commented Aug 8, 2023

Great job, thank you 👍

interface IColumnTypeQB {
public const DB_PLATFORM_MYSQL = 0;
public const DB_PLATFORM_PGSQL = 1;
public const DB_PLATFORM_SQLITE = 2;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add another constant for Oracle DB, usually called oci in our code.

Currently, because MySQL is the else in formatCellValue, it would use the MySQL dialect, which is not going to work 😞

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oracle is not yet supported. No plans for it yet.
Install shouln't be possible on oci db backends...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lucky you 😃

Florian Steffens and others added 15 commits August 11, 2023 12:41
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Florian Steffens and others added 23 commits August 11, 2023 12:41
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
Signed-off-by: Philipp Hempel <Philipp.Hempel1@web.de>
remove from dashboard view

Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
fix
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
@datenangebot datenangebot marked this pull request as ready for review August 11, 2023 10:52
Copy link
Collaborator

@datenangebot datenangebot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes, need some refactorings later on, but fine for now.

Florian Steffens added 2 commits August 11, 2023 13:07
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
@datenangebot datenangebot merged commit 5def698 into main Aug 11, 2023
15 of 16 checks passed
@datenangebot datenangebot deleted the enh/views branch August 11, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment