diff --git a/source/data/localization/deu.loc.json b/source/data/localization/deu.loc.json index 5245331..9b32317 100644 --- a/source/data/localization/deu.loc.json +++ b/source/data/localization/deu.loc.json @@ -54,6 +54,17 @@ "page.login.internal.do": "Anmelden", "page.login.oidc.via": "via {{title}}", "page.logout.title": "Abmelden", + "page.caldav.title": "CalDAV", + "page.caldav.unavailable": "CalDAV nicht verfügbar", + "page.caldav.conf.title": "Zugangsdaten", + "page.caldav.conf.address": "Adresse (URL)", + "page.caldav.conf.username": "Nutzername", + "page.caldav.conf.password": "Kennwort", + "page.caldav.conf.setup_hints": "Einrichtungs-Hinweise", + "page.caldav.conf.token_unset": "es muss zunächst ein Token gesetzt werden", + "page.caldav.set_token.title": "Token setzen", + "page.caldav.set_token.action.set": "setzen", + "page.caldav.set_token.action.overwrite": "überschreiben", "page.calendar_add.title": "Kalendar anlegen", "page.calendar_add.actions.do": "anlegen", "page.calendar_edit.title.regular": "Kalendar bearbeiten", diff --git a/source/data/localization/eng.loc.json b/source/data/localization/eng.loc.json index 87012f1..721a41c 100644 --- a/source/data/localization/eng.loc.json +++ b/source/data/localization/eng.loc.json @@ -54,6 +54,17 @@ "page.login.internal.do": "login", "page.login.oidc.via": "via {{title}}", "page.logout.title": "Logout", + "page.caldav.title": "CalDAV", + "page.caldav.unavailable": "CalDAV not available", + "page.caldav.conf.title": "credentials", + "page.caldav.conf.address": "address (URL)", + "page.caldav.conf.username": "username", + "page.caldav.conf.password": "password", + "page.caldav.conf.setup_hints": "setup hints", + "page.caldav.conf.token_unset": "a token has to be set", + "page.caldav.set_token.title": "set token", + "page.caldav.set_token.action.set": "set", + "page.caldav.set_token.action.overwrite": "overwrite", "page.calendar_add.title": "Add calendar", "page.calendar_add.actions.do": "anlegen", "page.event_add.title": "Add event", diff --git a/source/logic/backend.ts b/source/logic/backend.ts index 4ba763a..2706011 100644 --- a/source/logic/backend.ts +++ b/source/logic/backend.ts @@ -231,7 +231,7 @@ namespace _zeitbild.frontend_web.backend /** */ - export async function user_list( + export function user_list( ) : Promise< Array< { @@ -249,6 +249,49 @@ namespace _zeitbild.frontend_web.backend } + /** + */ + export function user_dav_conf( + ) : Promise< + ( + null + | + { + address : string; + username : string; + password : string; + setup_hints : Array< + { + label : string; + link : string; + remark : (null | string); + } + >; + } + ) + > + { + return call( + lib_plankton.http.enum_method.get, + "/user_dav_conf", + null + ); + } + + + /** + */ + export function user_dav_token( + ) : Promise + { + return call( + lib_plankton.http.enum_method.patch, + "/user_dav_token", + null + ); + } + + /** */ export async function calendar_list( diff --git a/source/logic/main.ts b/source/logic/main.ts index e123e0c..4c8a2ff 100644 --- a/source/logic/main.ts +++ b/source/logic/main.ts @@ -15,9 +15,9 @@ namespace _zeitbild.frontend_web ); // init - lib_plankton.log.conf_push( + lib_plankton.log.set_main_logger( [ - lib_plankton.log.channel_make({"kind": "console", "data": {"threshold": "info"}}), + {"kind": "console", "data": {"threshold": "info"}}, ] ); await _zeitbild.frontend_web.backend.init( @@ -54,6 +54,10 @@ namespace _zeitbild.frontend_web {"name": "calendar_add", "parameters": {}}, {"label": lib_plankton.translate.get("page.calendar_add.title")} ); + lib_plankton.zoo_page.add_nav_entry( + {"name": "caldav", "parameters": {}}, + {"label": lib_plankton.translate.get("page.caldav.title")} + ); /* lib_plankton.zoo_page.add_nav_entry( {"name": "event_add", "parameters": {}}, diff --git a/source/pages/caldav/logic.ts b/source/pages/caldav/logic.ts new file mode 100644 index 0000000..7646644 --- /dev/null +++ b/source/pages/caldav/logic.ts @@ -0,0 +1,119 @@ +namespace _zeitbild.frontend_web.pages +{ + + /** + */ + lib_plankton.zoo_page.register( + "caldav", + async (parameters, target_element) => { + target_element.innerHTML = ""; + const conf = await _zeitbild.frontend_web.backend.user_dav_conf(); + target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "main", + { + "label": lib_plankton.translate.get("page.caldav.title"), + "content": ( + (conf === null) + ? + await _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "unavailable", + { + "text": lib_plankton.translate.get("page.caldav.unavailable"), + } + ) + : + await _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "available", + { + "conf_title": lib_plankton.translate.get("page.caldav.conf.title"), + "conf_content": ( + (conf.password === null) + ? + await _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "conf-token_unset", + { + "text": lib_plankton.translate.get("page.caldav.conf.token_unset") + } + ) + : + await _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "conf-token_set", + { + "address_label": lib_plankton.translate.get("page.caldav.conf.address"), + "address_value": conf.address, + "username_label": lib_plankton.translate.get("page.caldav.conf.username"), + "username_value": conf.username, + "password_label": lib_plankton.translate.get("page.caldav.conf.password"), + "password_value": conf.password, + "setup_hints_label": lib_plankton.translate.get("page.caldav.conf.setup_hints"), + "setup_hint_entries": ( + await lib_plankton.call.promise_condense( + conf.setup_hints + .map( + entry => () => _zeitbild.frontend_web.helpers.template_coin( + "caldav", + "conf-setup_hint_entry", + { + "text": entry.label, + "href": entry.link, + "remark": ( + (entry.remark === null) + ? + "" + : + lib_plankton.string.coin( + " — {{content}}", + { + "content": entry.remark, + } + ) + ) + } + ) + ) + ) + ).join("") + } + ) + ), + "set_token_title": lib_plankton.translate.get("page.caldav.set_token.title"), + "set_token_action": ( + (conf.password === null) + ? + lib_plankton.translate.get("page.caldav.set_token.action.set") + : + lib_plankton.translate.get("page.caldav.set_token.action.overwrite") + ), + } + ) + ) + } + ); + + /** + * logic: set token + */ + { + if (conf !== null) + { + document.querySelector("#caldav-set_token > button").addEventListener( + "click", + async () => { + await _zeitbild.frontend_web.backend.user_dav_token(); + lib_plankton.zoo_page.reload(); + } + ); + } + } + + return Promise.resolve(undefined); + } + ); + +} + diff --git a/source/pages/caldav/templates/available.html.tpl b/source/pages/caldav/templates/available.html.tpl new file mode 100644 index 0000000..c8bb50b --- /dev/null +++ b/source/pages/caldav/templates/available.html.tpl @@ -0,0 +1,8 @@ +
+

{{conf_title}}

+ {{conf_content}} +
+
+

{{set_token_title}}

+ +
diff --git a/source/pages/caldav/templates/conf-setup_hint_entry.html.tpl b/source/pages/caldav/templates/conf-setup_hint_entry.html.tpl new file mode 100644 index 0000000..d4338e6 --- /dev/null +++ b/source/pages/caldav/templates/conf-setup_hint_entry.html.tpl @@ -0,0 +1,3 @@ +
  • + {{text}}{{remark}} +
  • diff --git a/source/pages/caldav/templates/conf-token_set.html.tpl b/source/pages/caldav/templates/conf-token_set.html.tpl new file mode 100644 index 0000000..0a8b003 --- /dev/null +++ b/source/pages/caldav/templates/conf-token_set.html.tpl @@ -0,0 +1,18 @@ +
    + + {{address_value}} +
    +
    + + {{username_value}} +
    +
    + + {{password_value}} +
    +
    + +
      +{{setup_hint_entries}} +
    +
    diff --git a/source/pages/caldav/templates/conf-token_unset.html.tpl b/source/pages/caldav/templates/conf-token_unset.html.tpl new file mode 100644 index 0000000..1d78bf3 --- /dev/null +++ b/source/pages/caldav/templates/conf-token_unset.html.tpl @@ -0,0 +1,4 @@ +
    + ({{text}}) +
    + diff --git a/source/pages/caldav/templates/main.html.tpl b/source/pages/caldav/templates/main.html.tpl new file mode 100644 index 0000000..da98a2b --- /dev/null +++ b/source/pages/caldav/templates/main.html.tpl @@ -0,0 +1,6 @@ +
    +

    {{label}}

    +
    +{{content}} +
    +
    diff --git a/source/pages/caldav/templates/unavailable.html.tpl b/source/pages/caldav/templates/unavailable.html.tpl new file mode 100644 index 0000000..d6d75fb --- /dev/null +++ b/source/pages/caldav/templates/unavailable.html.tpl @@ -0,0 +1,3 @@ +
    + {{text}} +
    diff --git a/source/style/main.css b/source/style/main.css index a91b626..1cf4e9b 100644 --- a/source/style/main.css +++ b/source/style/main.css @@ -1,3 +1,8 @@ +:root +{ + --hue: 150; +} + html { background-color: hsl(0, 0%, 12.5%); @@ -29,18 +34,29 @@ nav > ul > li padding: 8px; } -a +nav a { padding: 8px; text-decoration: none; - color: hsl(0, 0%, 87.5%); + color: hsl(var(--hue), 0%, 87.5%); +} + +nav a:hover +{ + color: hsl(var(--hue), 0%, 100%); + border-bottom: 2px solid hsl(0, 0%, 100%); + transition: 1s ease color; +} + +a +{ + text-decoration: none; + color: hsl(var(--hue), 50%, 50%); } a:hover { - color: hsl(0, 0%, 100%); - border-bottom: 2px solid hsl(0, 0%, 100%); - transition: 1s ease color; + color: hsl(var(--hue), 50%, 75%); } input,select,textarea diff --git a/source/style/page-caldav.css b/source/style/page-caldav.css new file mode 100644 index 0000000..47e293b --- /dev/null +++ b/source/style/page-caldav.css @@ -0,0 +1,22 @@ +.caldav-conf-section +{ + margin-bottom: 16px; +} + +.caldav-conf-section-label +{ + margin-left: 16px; + display: block; + font-weight: bold; + text-transform: capitalize; +} + +.caldav-conf-section-value +{ + margin-left: 32px; +} + +.caldav-conf-section-value-regular +{ + font-family: monospace; +} diff --git a/tools/makefile b/tools/makefile index d0b9b93..78c8687 100644 --- a/tools/makefile +++ b/tools/makefile @@ -35,6 +35,7 @@ templates: \ templates-widgets-sources \ templates-widgets-listview \ templates-widgets-weekview \ + templates-pages-caldav \ templates-pages-calendar_add \ templates-pages-calendar_edit \ templates-pages-event_add \ @@ -63,6 +64,13 @@ templates-widgets-weekview: \ @ ${cmd_mkdir} ${dir_build}/templates/widget-weekview @ ${cmd_cp} -r -u -v ${dir_source}/widgets/weekview/templates/* ${dir_build}/templates/widget-weekview/ +.PHONY: templates-pages-caldav +templates-pages-caldav: \ + $(wildcard ${dir_source}/pages/caldav/templates/*) + @ ${cmd_log} "templates:caldav …" + @ ${cmd_mkdir} ${dir_build}/templates/caldav + @ ${cmd_cp} -r -u -v ${dir_source}/pages/caldav/templates/* ${dir_build}/templates/caldav/ + .PHONY: templates-pages-calendar_add templates-pages-calendar_add: \ $(wildcard ${dir_source}/pages/calendar_add/templates/*) @@ -127,6 +135,7 @@ ${dir_temp}/logic-unlinked.js: \ ${dir_source}/widgets/weekview/logic.ts \ ${dir_source}/pages/login/logic.ts \ ${dir_source}/pages/logout/logic.ts \ + ${dir_source}/pages/caldav/logic.ts \ ${dir_source}/pages/oidc_finish/logic.ts \ ${dir_source}/pages/calendar_add/logic.ts \ ${dir_source}/pages/calendar_edit/logic.ts \