QutEcoacoustics / baw-server

The acoustic workbench server for storing and managing ecoacoustic data. Manages the structure and audio data. Provides an API for clients access.
Apache License 2.0
9 stars 4 forks source link

Missing capability details #419

Closed Allcharles closed 2 years ago

Allcharles commented 4 years ago

Details

Baw API should expose a capabilities object either as a separate route or integrated into all of the current routes. This should detail the list of actions available to the user with the following options:

This will control the angular8 action menu system so that the list of possible actions is set according to the users permissions related to the page they are viewing. For example, when the user navigates to this page their list of capabilities should depend on whether they are: admin, owner of the project, have permissions to access project, unable to view project. By default, any actions which are not accessible to the user should be disabled with details on how enable the option. Hidden fields should be limited to features which may not be implemented, or are not a part of the website (eg. Ecosounds version vs Government version).

Possible Implementations

Implementation 1

Create a new capabilities route: Expected Route: https://staging.ecosounds.org/capabilities Expected Method: GET Expected Body:

Example Request Body:

{
    "route": "https://staging.ecosounds.org/projects/1"
}

Example Response Body:

{
    "meta": {
        "status": 200,
        "message": "OK"
    },
    "data": [
        {
            "action": "Explore audio",
            "state": "Enabled"
        },
        {
            "action": "Edit project",
            "state": "Disabled",
            "description: "Request elevated privileges to edit project"
        }
    ]
}

Implementation 2

Update existing routes to include a capabilities field

Example Response Body:

{
    "meta": {
        "status": 200,
        "message": "OK",
        "sorting": {
            "order_by": "name",
            "direction": "asc"
        },
        "paging": {
            "page": 1,
            "items": 25,
            "total": 1,
            "max_page": 1,
            "current": "http://staging.ecosounds.org/projects?direction=asc&items=25&order_by=name&page=1",
            "previous": null,
            "next": null
        },
        "capabilities": [
            {
                "action": "Explore audio",
                "state": "Enabled"
            },
            {
                "action": "Edit project",
                "state": "Disabled",
                "description: "Request elevated privileges to edit project"
            }
        ]
    },
    "data": [
        {
            "id": 1,
            "name": "Project",
            "description": "Test project description",
            "creator_id": 2,
            "site_ids": [
                1,
                2,
                3,
                5,
                6,
                18
            ],
            "description_html": "<p>Test project description</p>\n"
        }
    ]
}
atruskie commented 4 years ago

Previously written specification: https://github.com/QutEcoacoustics/baw-server/wiki/API:-Capabilties

Allcharles commented 4 years ago

Related comment: https://github.com/QutEcoacoustics/workbench-client/pull/155#pullrequestreview-374907169

atruskie commented 2 years ago

Closed by #552