UNPKG

graphdb-workbench

Version:
2 lines 9.62 kB
export const __webpack_esm_id__=39874;export const __webpack_esm_ids__=[39874];export const __webpack_esm_modules__={39874(e,t,i){i.r(t),i.d(t,{onto_layout:()=>r});var a=i(55508),s=i(57154),n=i(79939);const r=class{constructor(e){(0,a.r)(this,e),this.authenticationService=(0,s.service)(s.AuthenticationService),this.authorizationService=(0,s.service)(s.AuthorizationService),this.navigationContextService=(0,s.service)(s.NavigationContextService),this.authStorageService=(0,s.service)(s.AuthenticationStorageService),this.runtimeConfigurationContextService=(0,s.service)(s.RuntimeConfigurationContextService),this.eventService=(0,s.service)(s.EventService),this.applicationLifecycleContextService=(0,s.service)(s.ApplicationLifecycleContextService),this.fullJwtKey=`${s.StorageKey.GLOBAL_NAMESPACE}.${this.authStorageService.NAMESPACE}.${this.authStorageService.jwtKey}`,this.fullAuthenticatedKey=`${s.StorageKey.GLOBAL_NAMESPACE}.${this.authStorageService.NAMESPACE}.${this.authStorageService.authenticatedKey}`,this.authEvents=[this.fullJwtKey,this.fullAuthenticatedKey],this.isLowResolution=!1,this.showHeader=this.isAuthenticatedFully(),this.showNavbar=!1,this.isEmbedded=!1,this.loading=!0,this.subscriptions=new s.SubscriptionList,this.isNavbarCollapsed=!1,this.handleStorageChange=e=>{(0,s.service)(s.LocalStorageSubscriptionHandlerService).handleStorageChange(e),this.handleAuthChange(e.key)},this.windowResizeObserver=function(e,t=300){let i;return(...a)=>{clearTimeout(i),i=setTimeout(()=>e.apply(this,a),t)}}(()=>this.windowResizeHandler(),50),s.WindowService.getWindow().addEventListener("storage",this.handleStorageChange)}componentDidLoad(){this.windowResizeHandler()}connectedCallback(){this.subscribeToSecurityChanges(),this.updateVisibility(),this.subscribeToNavigationEnd(),this.subscribeToRuntimeConfigurationChanges(),this.subscribeToApplicationChange()}disconnectedCallback(){this.subscriptions.unsubscribeAll()}render(){return(0,a.h)(a.a,{key:"b8cbbca1f12bf6af844e18397d2a725d6ab4e1fc",class:{"wb-layout":!0,"is-embedded":this.isEmbedded,"hide-navbar":!this.showNavbar}},(0,a.h)("div",{key:"f2e3b7a238b82536bd7605196966bd758330c521",class:"default-slot-wrapper"},(0,a.h)("slot",{key:"5d391e2f612d9aead6c07b2ef3641b961eddc504",name:"default"})),!this.isEmbedded&&(0,a.h)("header",{key:"e43c5b68d590e12b2b3e95d4c414505f1fc82abb",class:"wb-header"},this.showHeader&&(0,a.h)("onto-header",{key:"21102b279bed2dd3ee857b399683d14c5f3eaf57"})),!this.isEmbedded&&this.showNavbar&&(0,a.h)("nav",{key:"67dcbf444a30ac933ba83f86ae9f8d08fe5f995f",class:"wb-navbar"},(0,a.h)("onto-navbar",{key:"a9816369cbbac4d5b58f607be61277d6074556bd",ref:this.assignNavbarRef(),"navbar-collapsed":this.isLowResolution})),(0,a.h)("div",{key:"f3ff0e1734eecc433dc20717e0b9f2871ea40dae",class:{"main-slot-wrapper":!0,loading:this.loading}},this.loading&&(0,a.h)("div",{key:"17d9a8024d280f70ad8684e5d114c38b184b529d",class:"loader-wrapper"},(0,a.h)("onto-loader",{key:"534a5d8f89b92051822d1d7750ca56894013c142",size:96,messageText:n.T.translate("common.loading")})),(0,a.h)("slot",{key:"bcd21d932551dc6f9b9365ccbbafae690f8b7245",name:"main"})),!this.isEmbedded&&(0,a.h)("footer",{key:"9fcd224439dbb7fd35bb4c277dc343eccab40087",class:"wb-footer"},(0,a.h)("onto-footer",{key:"39d5d1c8275c527ca16aa74f6f15dc3f0cc3686c"})),(0,a.h)("onto-tooltip",{key:"6a70e6d2d67e8a9aa6b8eda66b6768735c0f6dcd"}))}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")}handleAuthChange(e){var t;e&&this.authEvents.includes(e)&&(this.authStorageService.isAuthenticated()?(0,s.navigate)(null!==(t=this.navigationContextService.getPreviousRoute())&&void 0!==t?t:"./"):(0,s.navigate)("login"),s.WindowService.getWindow().location.reload())}subscribeToSecurityChanges(){const e=(0,s.service)(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(this.eventService.subscribe(s.EventName.LOGIN,()=>{this.setNavbarItemVisibility(),this.updateVisibility()})),this.subscriptions.add(this.eventService.subscribe(s.EventName.LOGOUT,()=>{this.setNavbarItemVisibility(),this.updateVisibility(),(0,s.navigate)("login")}))}subscribeToRuntimeConfigurationChanges(){this.subscriptions.add(this.runtimeConfigurationContextService.onRuntimeConfigurationChanged(e=>{var t;this.isEmbedded=null!==(t=null==e?void 0:e.isEmbedded)&&void 0!==t&&t}))}updateVisibility(){this.authenticationService.isSecurityEnabled()?(this.showHeader=this.authenticationService.isAuthenticated()||this.authorizationService.hasFreeAccess(),this.showNavbar=this.authenticationService.isAuthenticated()||this.authorizationService.hasFreeAccess()):(this.showNavbar=!0,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&&(this.navbarRef.menuItems=s.WindowService.getWindow().PluginRegistry.get("main.menu"),this.setNavbarItemVisibility())}}setNavbarItemVisibility(){var e,t,i;if(!(null===(e=this.navbarRef)||void 0===e?void 0:e.menuItems))return;const a=e=>{var t;e.shouldShow=this.shouldShowMenu(e.role),(null===(t=e.children)||void 0===t?void 0:t.length)&&e.children.forEach(a)};null===(i=null===(t=this.navbarRef)||void 0===t?void 0:t.menuItems)||void 0===i||i.forEach(e=>{e.items.forEach(a)}),this.navbarRef.menuItems=[...this.navbarRef.menuItems]}subscribeToNavigationEnd(){this.subscriptions.add(this.eventService.subscribe(s.EventName.NAVIGATION_END,e=>{this.navigationContextService.updatePreviousRoute(e.oldUrl)}))}subscribeToApplicationChange(){this.subscriptions.add(this.applicationLifecycleContextService.onApplicationStateBeforeChange(e=>{e&&(this.loading=!0)})),this.subscriptions.add(this.applicationLifecycleContextService.onApplicationStateChange(e=>{e&&(this.loading=!1)}))}get hostElement(){return(0,a.g)(this)}};r.style=':host{display:block;height:100%}.wb-layout{display:grid;grid-template:"header header" auto "nav main" 1fr "nav footer" auto/15rem minmax(200px, 1fr);min-height:100vh;margin:0}.wb-layout.is-embedded{grid-template-columns:1fr;grid-template-areas:"main";padding-top:1rem}.wb-layout.hide-navbar{grid-template:"header" auto "main" 1fr "footer" auto/1fr;}.wb-layout.hide-navbar.expanded{grid-template-columns:1fr}.wb-layout.expanded{grid-template-columns:4.375rem 1fr}.wb-layout main .main-container{margin-left:0}.wb-layout .main-slot-wrapper .loader-wrapper{flex-grow:1;display:flex;align-items:center;justify-content:center}.wb-layout .main-slot-wrapper.loading{display:flex;flex-direction:column}.wb-layout .main-slot-wrapper.loading .page-content{visibility:hidden}.wb-layout .default-slot-wrapper{display:none}.wb-layout .wb-header{position:sticky;top:0;z-index:999}.wb-layout nav{grid-area:nav}.wb-layout header{grid-area:header}.wb-layout main{grid-area:main}.wb-layout footer{grid-area:footer}'},79939(e,t,i){i.d(t,{L:()=>n,T:()=>o,s:()=>s});var a=i(57154);function s(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}class n{static get logger(){return a.Loggers.getLoggerInstance("SharedComponents")}}class r{constructor(){this.languageContextService=a.ServiceProvider.get(a.LanguageContextService),this.translationChangedObservers={},this.logger=n.logger,this.defaultBundle=this.languageContextService.getDefaultBundle(),this.subscribeToBundleChange()}onTranslate(e,t=[],i=()=>{}){this.translationChangedObservers[e]=this.translationChangedObservers[e]||[];const a={parameters:t,callback:i};return this.translationChangedObservers[e].push(a),i(this.translate(e,t)),()=>{const t=this.translationChangedObservers[e].indexOf(a);-1!==t&&this.translationChangedObservers[e].splice(t,1)}}translate(e,t){return this.translateInLocale(e,t)}translateInLocale(e,t){let i=this.translateFromBundle(this.currentBundle,e);return i||(i=this.translateFromBundle(this.defaultBundle,e)),i?(i=this.applyParameters(i,t),s(i)):(this.logger.warn(`Missing translation for key: [${e}]`),e)}translateFromBundle(e,t){if(!e)return;let i=e[t];return"string"!=typeof i&&(i=this.translateAsJsonObject(e,t)),i}translateAsJsonObject(e,t){let i=t.split(".");return this.getTranslation(e,i)}getTranslation(e,t){if(!t||!e)return;const i=e[t.splice(0,1)[0]];return 0===t.length?i:"string"!=typeof i?t.length>0?this.getTranslation(i,t):i:void 0}applyParameters(e,t){return t?t.reduce((e,t)=>r.replaceAll(e,t),e):e}static replaceAll(e,t){return t?e.split(`{{${t.key}}}`).join(t.value):e}notifyTranslationsChanged(){Object.keys(this.translationChangedObservers).forEach(e=>{(this.translationChangedObservers[e]||[]).forEach(t=>t.callback(this.translate(e,t.parameters)))})}subscribeToBundleChange(){this.languageChangeSubscription=this.languageContextService.onLanguageBundleChanged(e=>{e&&(this.currentBundle=e,this.notifyTranslationsChanged())})}destroy(){this.languageChangeSubscription&&this.languageChangeSubscription()}}const o=new r}}; //# sourceMappingURL=39874.2adb676df18d7f3c1f9c.bundle.js.map