diff --git a/config/routes.php b/config/routes.php index fe313bee..25d3bc69 100644 --- a/config/routes.php +++ b/config/routes.php @@ -43,6 +43,8 @@ $route->addGroup( $route->get('/certificates', 'SettingsController@certificate'); $route->post('/certificates/ifsg', 'SettingsController@saveIfsgCertificate'); $route->post('/certificates/driving', 'SettingsController@saveDrivingLicense'); + $route->get('/api', 'SettingsController@api'); + $route->post('/api', 'SettingsController@apiKeyReset'); $route->get('/oauth', 'SettingsController@oauth'); $route->get('/sessions', 'SettingsController@sessions'); $route->post('/sessions', 'SettingsController@sessionsDelete'); diff --git a/resources/lang/de_DE/additional.po b/resources/lang/de_DE/additional.po index 870ccf6b..1975b54c 100644 --- a/resources/lang/de_DE/additional.po +++ b/resources/lang/de_DE/additional.po @@ -192,6 +192,9 @@ msgstr "Einstellungen gespeichert." msgid "settings.sessions.delete_success" msgstr "Sitzung erfolgreich gelöscht." +msgid "settings.api.key_reset_success" +msgstr "API Key erfolgreich zurückgesetzt." + msgid "faq.delete.success" msgstr "FAQ Eintrag erfolgreich gelöscht." diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index c9ca1961..104844cb 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1743,6 +1743,35 @@ msgstr "Hier kannst Du Deine Sprache ändern." msgid "settings.language.success" msgstr "Sprache wurde erfolgreich geändert." +msgid "settings.api" +msgstr "API" + +msgid "settings.api.about" +msgstr "" +"Die API erlaubt es dir, über externe Programme, mit dem Engelsystem zu interagieren. " +"Sie ist noch nicht vollständig, wir arbeiten aber daran sie zu erweitern.\n" +"Der API Einstiegspunkt befindet sich unter `%s` und ist in der [OpenAPI Spezifikation](%s) beschrieben.\n" +"Teile deinen persönlichen API Key mit niemandem, er erlaubt es deine persönlichen Daten einzusehen " +"und Änderungen in deinem Namen durch zu führen!" + +msgid "settings.api.shifts_json_show" +msgstr "JSON Schichten Export anzeigen" + +msgid "settings.api.ical_show" +msgstr "iCal export anzeigen" + +msgid "settings.api.news_show" +msgstr "News feeds anzeigen" + +msgid "settings.api.key_show" +msgstr "API Key anzeigen" + +msgid "settings.api.key_reset" +msgstr "API Key zurücksetzen" + +msgid "settings.api.key_reset_confirm" +msgstr "Wenn du den API Key zurücksetzt, musst ihn in allen deinen Anwendungen aktualisieren." + msgid "settings.oauth" msgstr "Single Sign-On" diff --git a/resources/lang/en_US/additional.po b/resources/lang/en_US/additional.po index 7bc4a8e2..3e7d1dc1 100644 --- a/resources/lang/en_US/additional.po +++ b/resources/lang/en_US/additional.po @@ -191,6 +191,9 @@ msgstr "Settings saved." msgid "settings.sessions.delete_success" msgstr "Session deleted successfully." +msgid "settings.api.key_reset_success" +msgstr "API key successfully reset." + msgid "faq.delete.success" msgstr "FAQ entry successfully deleted." diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index f7891cb1..cec17e52 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -456,6 +456,35 @@ msgstr "Here you can change your language." msgid "settings.language.success" msgstr "Language was changed successfully." +msgid "settings.api" +msgstr "API" + +msgid "settings.api.about" +msgstr "" +"The API allows you to interact with the Engelsystem by using external programs. " +"It's not complete but we are working on extending it.\n" +"The API endpoint is located at `%s` and described in the [OpenAPI specification](%s).\n" +"Don't share your personal API key with anyone as it can be used to view your personal data " +"and do changes your behalf!" + +msgid "settings.api.shifts_json_show" +msgstr "Show JSON shifts export" + +msgid "settings.api.ical_show" +msgstr "Show iCal export" + +msgid "settings.api.news_show" +msgstr "Show news feeds" + +msgid "settings.api.key_show" +msgstr "Show API key" + +msgid "settings.api.key_reset" +msgstr "Reset API key" + +msgid "settings.api.key_reset_confirm" +msgstr "If you reset the API key you have to update it in all your applications." + msgid "settings.oauth" msgstr "Single Sign-On" diff --git a/resources/views/macros/form.twig b/resources/views/macros/form.twig index 8d3dc8d9..c55b1c57 100644 --- a/resources/views/macros/form.twig +++ b/resources/views/macros/form.twig @@ -253,6 +253,7 @@ Renders a button. Must be a Bootstrap icon class without prefix, such as "info" or "check". @param {string} [opt.confirm_title] - Optional value for the confirmation title. @param {string} [opt.confirm_text] - Optional value for the confirmation text. +@param {dictionary} [opt.attr] - Optional value for additional attributes like data fields. #} {% macro button(label, opt) %} {%- set icon_left = opt.icon_left is defined ? '' : '' %} @@ -269,6 +270,7 @@ Renders a button. {%- if opt.confirm_button_text is defined %} data-confirm_button_text="{{ icon_left ~ ' ' ~ opt.confirm_button_text ~ ' ' ~ icon_right }}" {%- endif -%} + {%- for key, value in opt.attr|default({}) %} {{ key }}="{{ value }}"{% endfor -%} > {{ icon_left|raw }} {{ label }} diff --git a/resources/views/pages/settings/api.twig b/resources/views/pages/settings/api.twig new file mode 100644 index 00000000..0dd33487 --- /dev/null +++ b/resources/views/pages/settings/api.twig @@ -0,0 +1,95 @@ +{% extends 'pages/settings/settings.twig' %} +{% import 'macros/form.twig' as f %} + +{% block title %}{{ __('settings.api') }}{% endblock %} + +{% block row_content %} + +
+ {{ user.api_key }}
+
+ {{ url('/shifts-json-export', {'key': user.api_key}) }}
+
+ {{ url('/ical', {'key': user.api_key}) }}
+
+ {{ url('/atom', {'key': user.api_key}) }}
+ {{ url('/atom', {'meetings': 1, 'key': user.api_key}) }}
+ {{ url('/rss', {'key': user.api_key}) }}
+ {{ url('/rss', {'meetings': 1, 'key': user.api_key}) }}
+