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

add CRUD module and API endpoints #100

Merged
merged 52 commits into from
Jun 3, 2022
Merged

add CRUD module and API endpoints #100

merged 52 commits into from
Jun 3, 2022

Conversation

peterstadler
Copy link
Member

This started with the broken "copy" button (closes #92) and resulted in a major rewrite of some basic CRUD functions.
There is still a lot that can be improved, but I think it's already an improvement as it is.

Changes so far:

  • add new module "crud.xqm" with public functions crud:read, crud:copy, crud:create, and crud:delete
  • add new endpoints "/data/read", "/data/delete", "/data/copy", "/data/rename", and "/data/create" that use these new functions. NB, these endpoints do not feature MerMEId specific authentication but rather rely on the standard eXist permissions. E.g., an admin user (with the dba role) might add and delete data, not only the mermeid user.
  • the new endpoint "/data/read" outputs unfiltered XML and is used for displaying the MEI files to the user on request (see broken round tripping via filter_get.xsl and filter_put.xsl #90). The old endpoints in "/data/controller.xql" for Orbeon have been retained so far.
  • add new module "common.xqm" to store common functions and queries.
  • align the markup of the "buttons" on the main list page. They are now all <button> elements within a <form> to facilitate consistent capturing of events, styling, etc.
  • remove the javascript prompt with more elaborate modal. The modal grabs all information from the original form on the main list page.

and add `$new_title` as parameter to copy operation
to capture permission issues
and add some comments
to use the new endpoints `/data/copy` and `/data/delete`
and copy over some common functions
rather than its own implementation
that gets sent by javascript
for copying and deleting files
as a simple chain of "copy" and a "delete"
especially add a button
and some reformatting, and addition of some HTML namespaces
so the look of the buttons stays the same as before
depending on login status
NB, we still need to check for published files when deleting and renaming. But this should already be suppressed in the main form, not in the modal.
and remove old "create-file"-XQuery
and align behaviour regarding login status
the endpoint "rename" is now available at /data/controller.xql" and functions have been moved to "modules/common.xql"
@peterstadler peterstadler added the enhancement New feature or request label Feb 21, 2022
@peterstadler peterstadler added this to the Release 2.0 milestone Feb 21, 2022
@daniel-jettka
Copy link

Questions:

  1. on "Copy" and "Rename" got following error with all users I know. Is it expected?
  • failed to create file: Write permission is not granted on the Collection. XMLDB reported an exception while storing documentorg.xmldb.api.base.XMLDBException: Write permission is not granted on the Collection.
  1. on "Edit", then changing main title and save, got following error. To do with above?
  • Submission response status: 500 Error type: resource-error URI: http://127.0.0.2:8080/apps/mermeid/data/incipit_demo.xml Headers: DateMon, 21 Feb 2022 19:33:44 GMT

@peterstadler
Copy link
Member Author

Questions:

  1. on "Copy" and "Rename" got following error with all users I know. Is it expected?
  • failed to create file: Write permission is not granted on the Collection. XMLDB reported an exception while storing documentorg.xmldb.api.base.XMLDBException: Write permission is not granted on the Collection.
  1. on "Edit", then changing main title and save, got following error. To do with above?
  • Submission response status: 500 Error type: resource-error URI: http://127.0.0.2:8080/apps/mermeid/data/incipit_demo.xml Headers: DateMon, 21 Feb 2022 19:33:44 GMT

Looks as if you're not logged in properly?
Can you try to

  1. login as mermeid
  2. click "copy" (on any entry) on the main "modules/list_files.xq" page

That should present you with a (new) modal where you can add a title and filename. Once you hit "copy" on that modal's submit button you are redirected to the list page again and your copy should show up.

@peterstadler
Copy link
Member Author

Another caveat: all endpoints (except "/data/read") only accept POST requests!

@daniel-jettka
Copy link

Looks as if you're not logged in properly? Can you try to

1. login  as mermeid

2. click "copy" (on any entry) on the main "modules/list_files.xq" page

That should present you with a (new) modal where you can add a title and filename. Once you hit "copy" on that modal's submit button you are redirected to the list page again and your copy should show up.

  • pulled all new changes from branch issue-92
  • built new docker, started and logged in as mermeid
  • clicked on Copy (also after triggering onfocus)

Screenshot_2022-02-22 All documents

@peterstadler
Copy link
Member Author

At least the error handling seems to work ;)

But I think I found the issue—it seems to be related to the login: checking "Remember me" is causing trouble. Once you uncheck it, it should work. We had that before (can't remember now) and it looks as if we should disable (or fix) this "Remember me" option.

@daniel-jettka
Copy link

daniel-jettka commented Feb 25, 2022

checking "Remember me" is causing trouble. Once you uncheck it, it should work.

Yes, it does work with "Remember me" unchecked. Can confirm the CRUD actions are successful, but different behaviours in browsers:

  • in Firefox 84.0.1: login not recognized anymore after performing an action
  • in Chrome 91.0.4472.114 everything's fine

Copy link

@daniel-jettka daniel-jettka left a comment

Choose a reason for hiding this comment

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

Tested the functionality and all buttons/options work like they're supposed to.

Only (separate) things:

  • the "Remember me" option in the login procedure does not work properly

peterstadler added a commit that referenced this pull request Apr 8, 2022
replace with Esc-event; CSS fixes will be included via #100
@AnastasiaWawilow AnastasiaWawilow merged commit fcc7fab into develop Jun 3, 2022
@AnastasiaWawilow AnastasiaWawilow deleted the issue-92 branch June 3, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy button does not work
3 participants