graphdb-workbench
Version:
The web application for GraphDB APIs
1 lines • 2.47 kB
JavaScript
import{h}from"@stencil/core";import{AuthenticationService,navigateTo,ServiceProvider}from"../../../../../api/dist/ontotext-workbench-api";export class OntoUserMenu{constructor(){this.logout=()=>{ServiceProvider.get(AuthenticationService).logout()},this.toggleDropdown=()=>{this.isOpen=!this.isOpen},this.handleOutsideClick=e=>{this.isOpen&&!this.hostElement.contains(e.target)&&(this.isOpen=!1)}}connectedCallback(){document.addEventListener("click",this.handleOutsideClick)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}render(){var e;return h("section",{key:"9af009c793910f1b3e649e8dc8caa5ee0ef453f4",class:"onto-user-menu"},h("div",{key:"57d6117855907c7448e2c11ea42c226ef15d218a",class:"dropdown-toggle-wrapper",onClick:this.toggleDropdown},h("button",{key:"30e36c837726d768dbf62d564a6307df3e2244eb",class:this.isOpen?"open":""},h("i",{key:"a8c1de5c3aa4ef5e018710ed26e2bab25701400e",class:"fa-solid fa-user"}),h("span",{key:"0be9deb90e4a63116d0464fef29a8d0ec1b9fbcf",class:"username"},this.user.username),h("i",{key:"7e18b21b67075714cf636d113683bcc3dbdb0daa",class:"fa-light fa-angle-down "+(this.isOpen?"fa-rotate-180":"")})),this.isOpen?h("section",{class:"onto-user-menu-dropdown"},h("translate-label",{onClick:navigateTo("settings"),labelKey:"user_menu.my_settings"}),(null===(e=this.securityConfig)||void 0===e?void 0:e.hasExternalAuthUser)?"":h("translate-label",{onClick:this.logout,labelKey:"user_menu.logout"})):""))}static get is(){return"onto-user-menu"}static get originalStyleUrls(){return{$:["onto-user-menu.scss"]}}static get styleUrls(){return{$:["onto-user-menu.css"]}}static get properties(){return{user:{type:"unknown",attribute:"user",mutable:!1,complexType:{original:"AuthenticatedUser",resolved:"AuthenticatedUser",references:{AuthenticatedUser:{location:"import",path:"@ontotext/workbench-api",id:"../api/dist/ontotext-workbench-api.d.ts::AuthenticatedUser"}}},required:!1,optional:!1,docs:{tags:[],text:"Currently authenticated user"},getter:!1,setter:!1},securityConfig:{type:"unknown",attribute:"security-config",mutable:!1,complexType:{original:"SecurityConfig",resolved:"SecurityConfig",references:{SecurityConfig:{location:"import",path:"@ontotext/workbench-api",id:"../api/dist/ontotext-workbench-api.d.ts::SecurityConfig"}}},required:!1,optional:!1,docs:{tags:[],text:"Current security config"},getter:!1,setter:!1}}}static get states(){return{isOpen:{}}}static get elementRef(){return"hostElement"}}