diff --git a/source/base.ts b/source/base.ts index 5f3aa65..3dd2bb3 100644 --- a/source/base.ts +++ b/source/base.ts @@ -3,7 +3,7 @@ namespace _dali /** */ - let _actions_login : Array<(() => Promise)> = []; + let _actions_login : Array<((name ?: (null | string)) => Promise)> = []; /** @@ -19,7 +19,7 @@ namespace _dali /** */ export function listen_login( - action : (() => Promise) + action : ((name ?: (null | string)) => Promise) ) : void { @@ -41,13 +41,14 @@ namespace _dali /** */ export async function notify_login( + name : (null | string) ) : Promise { _is_logged_in = true; for (const action of _actions_login) { - await action(); + await action(name); } } @@ -76,6 +77,20 @@ namespace _dali } + /** + */ + export async function oidc_finish( + session_key : string + ) + : Promise + { + await _dali.backend.set_session_key(session_key); + const status = await _dali.backend.status(); + await _dali.notify_login(status.name); + return Promise.resolve(undefined); + } + + /** */ export async function logout( diff --git a/source/main.ts b/source/main.ts index c316c10..73e60f9 100644 --- a/source/main.ts +++ b/source/main.ts @@ -98,8 +98,9 @@ namespace _dali _dali.overlay.clear(); _dali.overlay.toggle({"mode": false}); }, - "action_success": () => { - _dali.notify_login(); + "action_success": async () => { + const status = await _dali.backend.status(); + _dali.notify_login(status.name); _dali.overlay.clear(); _dali.overlay.toggle({"mode": false}); }, @@ -145,13 +146,15 @@ namespace _dali ); await widget_menu.load(document.querySelector("header")); _dali.listen_login( - async () => { + async (name) => { widget_menu.set_groups(["logged_in"]); + widget_menu.set_label(name); } ); _dali.listen_logout( async () => { widget_menu.set_groups(["logged_out"]); + widget_menu.set_label(null); } ); } @@ -175,7 +178,7 @@ namespace _dali ); if (status.logged_in) { - _dali.notify_login(); + _dali.notify_login(status.name); } else { diff --git a/source/pages/oidc_finish/logic.ts b/source/pages/oidc_finish/logic.ts index d6a3838..1c3f42a 100644 --- a/source/pages/oidc_finish/logic.ts +++ b/source/pages/oidc_finish/logic.ts @@ -7,8 +7,7 @@ namespace _dali.pages "oidc_finish", async (parameters, target_element) => { target_element.innerHTML = ""; - await _dali.backend.set_session_key(parameters["session_key"]); - await _dali.notify_login(); + await _dali.oidc_finish(parameters["session_key"]); lib_plankton.zoo_page.set( { "name": "overview", diff --git a/source/resources/backend.ts b/source/resources/backend.ts index bb5cef7..3fc73d1 100644 --- a/source/resources/backend.ts +++ b/source/resources/backend.ts @@ -334,6 +334,7 @@ namespace _dali.backend : Promise< { logged_in : boolean; + name : (null | string); } > { diff --git a/source/style/widget-menu.css b/source/style/widget-menu.css index 501f1d4..d8b4b40 100644 --- a/source/style/widget-menu.css +++ b/source/style/widget-menu.css @@ -2,7 +2,7 @@ { margin-left: auto; margin-right: 8px; - max-width: 40px; + width: fit-content; } .widget-menu.widget-menu-collapsed > .widget-menu-platform @@ -12,6 +12,7 @@ .widget-menu-button { + text-transform: initial; } .widget-menu-entry diff --git a/source/widgets/menu/logic.ts b/source/widgets/menu/logic.ts index da48fe4..68c486a 100644 --- a/source/widgets/menu/logic.ts +++ b/source/widgets/menu/logic.ts @@ -30,6 +30,11 @@ namespace _dali.widgets.menu private initial_groups : Array; + /** + */ + private label : (null | string); + + /** */ private container : (null | HTMLElement); @@ -41,10 +46,12 @@ namespace _dali.widgets.menu entry_data_list : Array, { "initial_groups": initial_groups = [], + "initial_label": initial_label = "=", } : { initial_groups ?: Array; + initial_label ?: string; } = { @@ -60,6 +67,7 @@ namespace _dali.widgets.menu ) ); this.initial_groups = initial_groups; + this.label = initial_label; this.container = null; } @@ -79,6 +87,23 @@ namespace _dali.widgets.menu ); } + /** + */ + public set_label( + label ?: string + ) + : void + { + this.label = label; + this.container.querySelector(".widget-menu-button").textContent = ( + (this.label === null) + ? + "[=]" + : + ("[" + this.label + "]") + ); + } + /** */ @@ -115,7 +140,7 @@ namespace _dali.widgets.menu // button { const dom_button : HTMLElement = document.createElement("button"); - dom_button.textContent = "[=]"; + dom_button.textContent = "[" + this.label + "]"; dom_button.classList.add("widget-menu-button"); dom_button.addEventListener( "click",