Skip to content

Commit

Permalink
fix: styles imports, log permission directive, set favicon, menu stay…
Browse files Browse the repository at this point in the history
…s open (#235)

* fix: styles imports and added style for layout topbar items

* fix: log if no permission in permission directive

* fix: set favicon url, menu stays open when clicking menu item while mobile mode

* fix: path typo

* fix: token is also sent in local env

* fix: remove style class

---------

Co-authored-by: kim.tran <[email protected]>
  • Loading branch information
KimFFVII and kim.tran authored May 6, 2024
1 parent 72f289c commit e02b9ec
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion libs/accelerator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './lib/topic/topic'
export * from './lib/topic/syncable-topic'
export * from './lib/topic/topic-publisher'
export * from './lib/utils/path.uitls'
export * from './lib/utils/path.utils'
9 changes: 4 additions & 5 deletions libs/angular-accelerator/assets/styles.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* You can add global styles to this file, and also import other style files */
/* You can add global styles to this file, and also import other style files */
/* You can add global styles to this file, and also import other style files */
@import '../../../node_modules/primeflex/primeflex.scss';

@import '../../../libs/portal-layout-styles/src/styles/shell/shell.scss';
@import 'node_modules/primeflex/primeflex.scss';

@import 'node_modules/@onecx/portal-layout-styles/src/styles/shell/shell.scss';

@import '../../../libs/portal-layout-styles/src/styles/primeng/theme-light.scss';
@import 'node_modules/@onecx/portal-layout-styles/src/styles/primeng/theme-light.scss';
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export class IfPermissionDirective implements OnInit {
this.permission = value
this.negate = true
}

@Input() onMissingPermission: 'hide' | 'disable' = 'hide'

@Input() ocxIfPermissionPermissions: string[] | undefined
@Input()
@Input()
set ocxIfNotPermissionPermissions(value: string[] | undefined) {
this.ocxIfPermissionPermissions = value
}

negate = false

constructor(
Expand Down Expand Up @@ -45,7 +45,11 @@ export class IfPermissionDirective implements OnInit {

hasPermission(permission: string) {
if (this.ocxIfPermissionPermissions) {
return this.ocxIfPermissionPermissions.includes(permission)
const result = this.ocxIfPermissionPermissions.includes(permission)
if (!result) {
console.log('👮‍♀️ No permission in overwrites for: `', permission)
}
return result
}
return this.userService.hasPermission(permission)
}
Expand Down
11 changes: 4 additions & 7 deletions libs/portal-integration-angular/assets/styles.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* You can add global styles to this file, and also import other style files */
/* You can add global styles to this file, and also import other style files */
/* You can add global styles to this file, and also import other style files */
// @import '../../../node_modules/primeng/resources/primeng.min';
@import '../../../node_modules/primeflex/primeflex.scss';
@import 'node_modules/primeflex/primeflex.scss';
// @import '../../../node_modules/primeicons/primeicons';

@import '../../../libs/portal-layout-styles/src/styles/shell/shell.scss';
@import 'node_modules/@onecx/portal-layout-styles/src/styles/shell/shell.scss';

@import '../../../libs/portal-layout-styles/src/styles/primeng/theme-light.scss';
@import 'node_modules/@onecx/portal-layout-styles/src/styles/primeng/theme-light.scss';

@import '../../../libs/portal-integration-angular/src/lib/core/directives/loading-indicator.directive.scss';
@import 'node_modules/@onecx/portal-integration-angular/assets/loading-indicator.directive.scss';
12 changes: 10 additions & 2 deletions libs/portal-integration-angular/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
"lib": {
"entryFile": "src/index.ts"
},
"assets": ["CHANGELOG.md", "./assets/**"]
}
"assets": [
"CHANGELOG.md",
"./assets/**",
{
"input": "src/lib/core/directives",
"glob": "**/*.scss",
"output": "assets"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { HttpClient } from '@angular/common/http'
import {
AfterViewInit,
Component,
HostListener,
Inject,
InjectionToken,
OnDestroy,
OnInit,
Optional,
Renderer2,
} from '@angular/core'
import { Component, HostListener, Inject, InjectionToken, OnDestroy, OnInit, Optional, Renderer2 } from '@angular/core'
import { Router } from '@angular/router'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import {
Expand All @@ -34,7 +24,7 @@ export interface ShowContentProvider {
styleUrls: ['./portal-viewport.component.scss'],
})
@UntilDestroy()
export class PortalViewportComponent implements OnInit, AfterViewInit, OnDestroy {
export class PortalViewportComponent implements OnInit, OnDestroy {
menuButtonTitle = ''
menuActive = true
activeTopbarItem: string | undefined
Expand Down Expand Up @@ -76,6 +66,18 @@ export class PortalViewportComponent implements OnInit, AfterViewInit, OnDestroy
| undefined) || this.colorScheme
})

this.themeService.currentTheme$.pipe(
first(),
mergeMap((theme) => {
const prefix = theme.faviconUrl && theme.faviconUrl.startsWith('/') ? '/shell-bff' : ''
return theme.faviconUrl
? this.httpClient
.get(prefix + theme.faviconUrl, { responseType: 'blob' })
.pipe(map((blob) => URL.createObjectURL(blob)))
: of('')
})
)

this.themeService.currentTheme$
.pipe(
first(),
Expand Down Expand Up @@ -114,14 +116,6 @@ export class PortalViewportComponent implements OnInit, AfterViewInit, OnDestroy
this.onResize()
}

ngAfterViewInit() {
// hides the horizontal submenus or top menu if outside is clicked
this.removeDocumentClickListener = this.renderer.listen('body', 'click', () => {
this.activeTopbarItem = undefined
if (this.isMobile) this.menuActive = false
})
}

ngOnDestroy() {
this.removeDocumentClickListener?.()
}
Expand Down

0 comments on commit e02b9ec

Please sign in to comment.