graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 5.22 kB
JavaScript
export const __webpack_esm_id__=39874;export const __webpack_esm_ids__=[39874];export const __webpack_esm_modules__={39874:(e,i,t)=>{t.r(i),t.d(i,{onto_layout:()=>r});var a=t(87848),s=t(57154);const r=class{constructor(e){(0,a.r)(this,e),this.authenticationService=s.ServiceProvider.get(s.AuthenticationService),this.authorizationService=s.ServiceProvider.get(s.AuthorizationService),this.navigationContextService=s.ServiceProvider.get(s.NavigationContextService),this.isLowResolution=!1,this.showHeader=this.isAuthenticatedFully(),this.subscriptions=new s.SubscriptionList,this.isNavbarCollapsed=!1,this.windowResizeObserver=function(e,i=300){let t;return(...a)=>{clearTimeout(t),t=setTimeout(()=>e.apply(this,a),i)}}(()=>this.windowResizeHandler(),50),s.WindowService.getWindow().addEventListener("storage",this.handleStorageChange)}componentDidLoad(){this.windowResizeHandler()}connectedCallback(){this.subscribeToSecurityChanges(),this.updateVisibility(),this.subscribeToNavigationEnd()}disconnectedCallback(){this.subscriptions.unsubscribeAll()}render(){return(0,a.h)(a.a,{key:"43839b39292ee9e9cb0069d0fc7bf37d5349becc",class:"wb-layout"},(0,a.h)("div",{key:"81001d71c4d01825f83719cac61d34d1fc35b2b1",class:"default-slot-wrapper"},(0,a.h)("slot",{key:"5fe786622416da21561472f6da834c4c233d13fc",name:"default"})),(0,a.h)("header",{key:"b1b90981f77f98aad86b57be0d8dcb6abe541866",class:"wb-header"},this.showHeader&&(0,a.h)("onto-header",{key:"b1edea3608955812df1dd6de8e60df3e6138577a"})),(0,a.h)("nav",{key:"e633af3ed9c81dbb200ca6e212b5dba802a6db10",class:"wb-navbar"},(0,a.h)("onto-navbar",{key:"b5bf00eaed42a98be5b0e5e3becc20d0b30914b0",ref:this.assignNavbarRef(),"navbar-collapsed":this.isLowResolution})),(0,a.h)("div",{key:"bd8f85e4c5cdb36c7bd46855c1665d44bd73397e",class:"main-slot-wrapper"},(0,a.h)("slot",{key:"c2dbb842f63c92ea6f74a683860dcbfb49949be1",name:"main"})),(0,a.h)("footer",{key:"db49d5698c19ae3bfc3144e61226ff8e24830961",class:"wb-footer"},(0,a.h)("onto-footer",{key:"4b5c21c7ba8544c647d216f23aaef94fc8c47858"})),(0,a.h)("onto-tooltip",{key:"8af057e1dfe06c4268e2163f989730301aae443e"}),(0,a.h)("onto-toastr",{key:"037436b1c9bd88bc2fcae2fce8f0a99d943b0e43"}))}onNavbarToggled(e){this.isNavbarCollapsed=e.detail.payload,this.isNavbarCollapsed?this.hostElement.classList.add("expanded"):this.hostElement.classList.remove("expanded")}onResize(){this.windowResizeObserver()}windowResizeHandler(){this.isLowResolution=s.WindowService.getWindow().innerWidth<=768,this.isLowResolution||this.isNavbarCollapsed?this.hostElement.classList.add("expanded"):this.hostElement.classList.remove("expanded")}handleStorageChange(e){s.ServiceProvider.get(s.LocalStorageSubscriptionHandlerService).handleStorageChange(e)}subscribeToSecurityChanges(){const e=s.ServiceProvider.get(s.SecurityContextService);this.subscriptions.add(e.onAuthenticatedUserChanged(e=>{this.authenticatedUser=e,this.updateVisibility()})),this.subscriptions.add(e.onSecurityConfigChanged(e=>{this.securityConfig=e,this.updateVisibility()})),this.subscriptions.add(s.ServiceProvider.get(s.EventService).subscribe(s.EventName.LOGIN,()=>{this.setNavbarItemVisibility(),this.updateVisibility()})),this.subscriptions.add(s.ServiceProvider.get(s.EventService).subscribe(s.EventName.LOGOUT,()=>{this.setNavbarItemVisibility(),this.updateVisibility(),(0,s.navigate)("login")}))}updateVisibility(){this.authenticationService.isSecurityEnabled()?this.showHeader=this.authenticationService.isAuthenticated()||this.authorizationService.hasFreeAccess():this.showHeader=!0}isAuthenticatedFully(){return!this.authenticationService.isSecurityEnabled()||this.authenticationService.isAuthenticated()||this.authorizationService.hasFreeAccess()}shouldShowMenu(e){return this.isAuthenticatedFully()&&this.authorizationService.hasRole(e)}assignNavbarRef(){return e=>{this.navbarRef=e,this.navbarRef.menuItems=s.WindowService.getWindow().PluginRegistry.get("main.menu"),this.setNavbarItemVisibility()}}setNavbarItemVisibility(){var e,i,t;if(!(null===(e=this.navbarRef)||void 0===e?void 0:e.menuItems))return;const a=e=>{var i;e.shouldShow=this.shouldShowMenu(e.role),(null===(i=e.children)||void 0===i?void 0:i.length)&&e.children.forEach(a)};null===(t=null===(i=this.navbarRef)||void 0===i?void 0:i.menuItems)||void 0===t||t.forEach(e=>{e.items.forEach(a)}),this.navbarRef.menuItems=[...this.navbarRef.menuItems]}subscribeToNavigationEnd(){this.subscriptions.add(s.ServiceProvider.get(s.EventService).subscribe(s.EventName.NAVIGATION_END,e=>{this.navigationContextService.updatePreviousRoute(e.oldUrl)}))}get hostElement(){return(0,a.g)(this)}};r.style=':host{display:block;height:100%}.wb-layout{display:grid;grid-template-columns:15rem minmax(200px, 1fr);grid-template-rows:auto 1fr auto;grid-template-areas:"nav header" "nav main" "nav footer";min-height:100vh;margin:0}.wb-layout.expanded{grid-template-columns:4.375rem 1fr}.wb-layout nav{grid-area:nav}.wb-layout header{grid-area:header}.wb-layout main{grid-area:main}.wb-layout main .main-container{margin-left:0}.wb-layout .default-slot-wrapper{display:none}.wb-layout footer{grid-area:footer}.wb-header{position:sticky;top:0;z-index:999}'}};
//# sourceMappingURL=39874.825574a1ac25ff579cdc.bundle.js.map