# Frontend API

Authentication is handled by session cookie, which means that the user has to login first.
Testing can done by using the browser, e.g. via 
[Firefox RESTClient addon](https://addons.mozilla.org/de/firefox/addon/restclient/).

Requests that need a request body require JSON format.

Response bodies are defined in the request
header (accept: application/json).

The default response body is delivered in JSON format.

[GET] requests result in a list of resources.

For [PUT] and [POST] requests the response body contains a link to a newly 
created or edited resource.

Please have a look at:
[Swagger FE](/doc/swagger-fe.html)


[See Miro Board for a visualization of all entities and endpoints.](https://miro.com/app/board/uXjVNQzRbKo=/)

Get a list of all **available** portlets

Example Response:
```
[{
  "name": "Dynprojectgroup creator",
  "portlet_id": "Dynprojectgroup_creator",
  "is_purchased": false,
  "main_title": "Projekte",
  "title": "portlet_dynprojectgroup_creator",
  "col_preset": 6,
  "title_lang": "Dynamische Projektgruppen erstellen",
  "keywords": ["dynamische projektgruppen erstellen", "projekte"],
  "min_height": 300
}, {
  "name": "Delegated read opentasks",
  ...
  "min_height": 300
}]
```

Get a list of all **installed** portlets

Example Response:
```
[{
  "id": "1",
  "position_id": 0,
  "portlet_id": "Sysinfo_portlet",
  "unique_id": "a18887b6ef7c41",
  "staff_id": "1",
  "col": "0",
  "row": "0",
  "tab": "1",
  "page_id": "1",
  "title": "Portlet_Sysinfo_Portlet",
  "tab_name": "Start",
  "tab_sort": "1",
  "page_name": "Butler"
}, {
  "id": "2",
  ...
  "tab_sort": "1",
  "page_name": "Butler"
}]
```

Get a list of all portlets under a specific tab by `portlets_tabs.id`
Create a new portlet

Example Request:
```
{
   "title": "Some Liqui Portlet",
   "portlet_id": "com_untermstrich_liqui",
   "tab_id": 1,
   "sort": 1,
   "width": 2,
   "height": 1,
   "min_height": 150,
   "auto_refresh": 10
}
```

Example Response:
```
{
  "url": "http:\/\/untermstrich.local:8080\/fe\/portlets\/index\/ab58348058719b"
}
```
Get a specific portlet by `portlets.unique_id`
Update a specific portlet by `portlets.unique_id`
Delete a specific portlet by `portlets.unique_id`
Set sort attribute by a given array of portlets.ids.

Example Request:
```
{
  "portlets": [
    5,
    3,
    4,
    2,
    1
  ]
}
```
Example Response:
```
["OK"]
```

**Caution:** As it is possible that widgets are temporarily not visible, it is possible that sort numbers (`tab_sort`) 
can be duplicated in the response of `/fe/portlets/portlets` call.

Get a list of all tabs
Create a new tab
Update a specific tab by id
Delete a specific tab by id

**Caution:** At the moment, deleting a tab will not delete the portlets that are assigned to it. Also, no check is done 
for ownership. This might change in later versions.
Set sort attribute by a given array of portlets_tabs.ids.

Get a list of all sections
Create a new section
Update a specific section by id
Delete a specific section by id

**Caution:** At the moment, deleting a section will not delete the tabs (and portlets) that are assigned to it. Also, 
no check is done for ownership. This might change in later versions.

Set sort attribute by a given array of portlets_sections.ids.

Get a list of all groups
Create a new group
Update a specific group by id
Delete a specific group by id

**Caution:** At the moment, deleting a group will not delete the sections (and tabs and portlets) that are assigned to 
it. This might change in later versions.

Set sort attribute by a given array of portlets_groups.ids.

Get the user settings for the active user.
Set user settings for the active user.

Example Request:

This example shows all possible settings, it is possible to just set some of them though.
```
{
  "settings": {
    "language": "german",
    "datelocale": "de",
    "datesetting": "eur",
    "numberlocale": "de",
    "defaultproject": null,
    "delete_eml": false,
    "mailto_outlook": true,
    "addresses_search_similar": true,
    "use_last_to_time": true,
    "holidayadmin_show_vac_print": true,
    "file_manager": 2,
    "connector_ip": "127.0.0.1",
    "connector_port": 17342,
    "ignore_connector4vx_for_doc": false,
    "use_pdf_to_send": false,
    "zip_drawings_email": false,
    "project_start_view": false,
    "filter_favourite_list": false,
    "filter_proj_my_cost_centre": false,
    "nodblclck": false,
    "savefilter": true,
    "keeptimespan": false,
    "hideinactiveaddresses": true,
    "browserreminder": false,
    "ical_tokens_allow_others": true,
    "timelogging_start_view": false,
    "timelogging_auto_purpose": false,
    "timelogging_auto_times": false,
    "timelogging_start_project_id": null,
    "timelogging_start_work_package_id": null,
    "change_menu_style": null,
    "ical_days_back": null,
    "beep_volume": 80,
    "dav_event_name": "untermStrich Termine",
    "dav_task_name": "untermStrich Aufgaben",
    "dav_address_name": "untermStrich Adressen"
  }
}
```



Example Response:
`["OK"]`

Set user settings for **all** users. Request and response are equivalent to the above endpoint `[POST] /fe/user_settings/user_settings`.
