Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: angular integration interface init #178

Merged
merged 7 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export * from './lib/model/diagram-type'
export * from './lib/model/search-config-info'

// core
export * from './lib/api/iauth.service'
export * from './lib/api/injection-tokens'
export * from './lib/angular-accelerator.module'
export * from './lib/angular-accelerator-primeng.module'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommonModule } from '@angular/common'
import { APP_INITIALIZER, NgModule } from '@angular/core'
import { AUTH_SERVICE } from '../api/injection-tokens'
import { AUTH_SERVICE } from '@onecx/angular-integration-interface'
import { MockAuthService } from './mock-auth.service'

function initializer(authService: MockAuthService): () => Promise<any> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { BehaviorSubject } from 'rxjs'
import { UserProfile } from '@onecx/integration-interface'
import { IAuthService } from '../api/iauth.service'
import { IAuthService } from '@onecx/angular-integration-interface'

@Injectable()
export class MockAuthService implements IAuthService {
Expand Down
14 changes: 14 additions & 0 deletions libs/angular-integration-interface/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// services
export * from './lib/services/app-state.service'
export * from './lib/services/configuration.service'
export * from './lib/services/user.service'
export * from './lib/services/portal-message.service'
export * from './lib/services/theme.service'

// models
export * from './lib/model/config-key.model'

// core
export * from './lib/api/iauth.service'
export * from './lib/api/injection-tokens'

// utils

export { MfeInfo, Theme } from '@onecx/integration-interface'
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export const AUTH_SERVICE = new InjectionToken<IAuthService>('AUTH_SERVICE')

export const SANITY_CHECK = new InjectionToken<string>('OCXSANITY_CHECK')

export const APPLICATION_NAME = new InjectionToken<string>('APPLICATION_NAME')
export const APPLICATION_NAME = new InjectionToken<string>('APPLICATION_NAME')
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpClient } from '@angular/common/http'
import { Inject, Injectable, OnDestroy, Optional } from '@angular/core'
import { Config, ConfigurationTopic } from '@onecx/integration-interface'
import { firstValueFrom } from 'rxjs'
import { APP_CONFIG } from '@onecx/angular-accelerator'
import { Config, ConfigurationTopic } from '@onecx/integration-interface'
import { APP_CONFIG } from '../api/injection-tokens'
import { CONFIG_KEY } from '../model/config-key.model'

@Injectable({ providedIn: 'root' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestBed, fakeAsync } from '@angular/core/testing'
import { PortalMessageService } from './portal-message.service'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { Message } from '@onecx/integration-interface'
import { PortalMessageService } from './portal-message.service'

describe('PortalMessageService', () => {
const origAddEventListener = window.addEventListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { MessageTopic } from '@onecx/integration-interface'
import { combineLatest, of } from 'rxjs'
import { MessageTopic } from '@onecx/integration-interface'

export type Message = {
summaryKey?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { HttpClient } from '@angular/common/http'
import { Injectable, OnDestroy } from '@angular/core'
import { CurrentThemeTopic } from '@onecx/integration-interface'
import { from, map, mergeMap } from 'rxjs'
import { CONFIG_KEY } from '../model/config-key.model'
import { Theme } from '../model/theme'
import { CurrentThemeTopic, Theme } from '@onecx/integration-interface'
import { ConfigurationService } from './configuration.service'
import { CONFIG_KEY } from '../model/config-key.model'

const defaultThemeServerUrl = 'http://portal-theme-management:8080'

Expand All @@ -13,12 +12,11 @@ export class ThemeService implements OnDestroy {
baseUrlV1 = './portal-api'
currentTheme$ = new CurrentThemeTopic()

constructor(private configService: ConfigurationService, private http: HttpClient) {
}
constructor(private configService: ConfigurationService, private http: HttpClient) {}

getThemeHref(themeId: string): string {
const themeServerUrl =
this.configService.getProperty(CONFIG_KEY.TKIT_PORTAL_THEME_SERVER_URL) || defaultThemeServerUrl
this.configService.getProperty(CONFIG_KEY.TKIT_PORTAL_THEME_SERVER_URL) || defaultThemeServerUrl
return `${themeServerUrl}/themes/${themeId}/${themeId}.min.css`
}

Expand Down
1 change: 0 additions & 1 deletion libs/keycloak-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"peerDependencies": {
"@angular/common": ">=15.2.7",
"@angular/core": ">=15.2.7",
"@onecx/portal-integration-angular": "~4",
"@onecx/angular-integration-interface": "~4",
"keycloak-angular": "^13.0.0",
"keycloak-js": "^18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions libs/keycloak-auth/src/lib/keycloak-auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { NgModule, ModuleWithProviders } from '@angular/core'
import { CommonModule } from '@angular/common'
import { AUTH_SERVICE } from '@onecx/portal-integration-angular'
import { HTTP_INTERCEPTORS } from '@angular/common/http'
import { AUTH_SERVICE } from '@onecx/angular-integration-interface'
import { KeycloakAuthService } from './keycloak-auth.service'
import { KeycloakAngularModule } from 'keycloak-angular'
import { HTTP_INTERCEPTORS } from '@angular/common/http'
import { TokenInterceptor } from './token.interceptor'
import { KEYCLOAK_AUTH_CONFIG } from './keycloak-injection-token'

export interface KeycloakAuthModuleConfig {
tokenInterceptorWhitelist?: string[]
}
/**
* Authentication module for keycloak. Requires @onecx/portal-integration-angular and keycloak-js to work.
* Authentication module for keycloak. Requires @onecx/angular-integration-interfacer and keycloak-js to work.
*/
@NgModule({
imports: [CommonModule, KeycloakAngularModule],
Expand Down
3 changes: 1 addition & 2 deletions libs/keycloak-auth/src/lib/keycloak-auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable } from '@angular/core'
import { ConfigurationService, CONFIG_KEY, IAuthService } from '@onecx/portal-integration-angular'
import { AppStateService } from '@onecx/angular-integration-interface'
import { AppStateService, ConfigurationService, CONFIG_KEY, IAuthService } from '@onecx/angular-integration-interface'
import { KeycloakEventType, KeycloakOptions, KeycloakService } from 'keycloak-angular'
import { KeycloakConfig } from 'keycloak-js'

Expand Down
2 changes: 1 addition & 1 deletion libs/keycloak-auth/src/lib/token.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, Optional } from '@angular/core'
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'
import { AUTH_SERVICE, IAuthService } from '@onecx/angular-integration-interface'
import { Observable } from 'rxjs'
import { AUTH_SERVICE, IAuthService } from '@onecx/portal-integration-angular'
import { KeycloakAuthModuleConfig } from './keycloak-auth.module'
import { KEYCLOAK_AUTH_CONFIG } from './keycloak-injection-token'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Injectable, Optional } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { combineLatest, of } from 'rxjs'
// eslint-disable-next-line
import { Message, PortalMessageService } from '@onecx/portal-integration-angular'
import { FakeTopic } from './fake-topic'
import { Message, PortalMessageService } from '@onecx/angular-integration-interface'
import { Message as TopicMessage } from '@onecx/integration-interface'
import { FakeTopic } from './fake-topic'

export function providePortalMessageServiceMock() {
return [
Expand Down
7 changes: 0 additions & 7 deletions libs/portal-integration-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ export * from './lib/core/components/lifecycle/lifecycle.component'

// services
export * from './lib/services/app.menu.service'
export * from './lib/services/configuration.service'
export * from './lib/services/menu-api.service'
export * from './lib/services/portal-api.service'
export * from './lib/services/portal-message.service'
export * from './lib/services/theme.service'
export * from './lib/services/initialize-module-guard.service'
export * from './lib/services/userprofile-api.service'
export * from './lib/services/portal-dialog.service'
Expand All @@ -63,7 +60,6 @@ export * from './lib/mock-auth/mock-auth.module'
export * from './lib/model/avatar-info.model'
export * from './lib/model/microfrontend'
export * from './lib/model/portal-wrapper'
export * from './lib/model/theme'
export * from './lib/model/column'
export * from './lib/model/column-view-template'
export * from './lib/model/menu-item.model'
Expand All @@ -73,7 +69,6 @@ export * from './lib/model/page-info.model'
export * from './lib/model/portal'
export * from './lib/model/user-profile.model'
export * from './lib/model/button-dialog'
export * from './lib/model/config-key.model'

// core
export * from './lib/api/constants'
Expand All @@ -88,7 +83,5 @@ export * from './lib/core/utils/add-initialize-module-guard.utils'
export * from './lib/core/utils/translate-service-initializer.utils'
export * from './lib/core/utils/portal-api-configuration.utils'

export { MfeInfo } from '@onecx/integration-interface'

export * from '@onecx/angular-accelerator'
export * from '@onecx/angular-integration-interface'
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* tslint:disable:no-unused-variable */
import { ComponentFixture, TestBed, getTestBed } from '@angular/core/testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { Subject } from 'rxjs'

import { AppStateService, ConfigurationService } from '@onecx/angular-integration-interface'
import { AnnouncementBannerComponent } from './announcement-banner.component'
import { ConfigurationService } from '../../../services/configuration.service'
import { AppStateService } from '@onecx/angular-integration-interface'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { AnnouncementsApiService } from '../../../services/announcements-api.service'
import { Subject } from 'rxjs'
import { AnnouncementItem, AnnouncementPriorityType } from '../../../model/announcement-item'

describe('AnnouncementBannerComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component } from '@angular/core'
import { catchError, map, Observable, of, switchMap, tap, throwError, EMPTY, mergeMap } from 'rxjs'
import { AppStateService, ConfigurationService } from '@onecx/angular-integration-interface'
import { AnnouncementItem, AnnouncementPriorityType } from '../../../model/announcement-item'
import { AnnouncementsApiService } from '../../../services/announcements-api.service'
import { AppStateService } from '@onecx/angular-integration-interface'
import { ConfigurationService } from '../../../services/configuration.service'

@Component({
selector: 'ocx-announcement-banner',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { HelpItemEditorComponent } from './help-item-editor.component'
import { ConfigurationService } from '../../../services/configuration.service'
import { DialogModule } from 'primeng/dialog'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { PortalMessageService } from '../../../services/portal-message.service'
import { DialogModule } from 'primeng/dialog'

import { ConfigurationService, PortalMessageService } from '@onecx/angular-integration-interface'
import { HelpItemEditorComponent } from './help-item-editor.component'

describe('HelpItemEditorComponent', () => {
let component: HelpItemEditorComponent
Expand All @@ -16,7 +15,13 @@ describe('HelpItemEditorComponent', () => {
await TestBed.configureTestingModule({
declarations: [HelpItemEditorComponent],
providers: [ConfigurationService, PortalMessageService],
imports: [DialogModule, FormsModule, ReactiveFormsModule, NoopAnimationsModule, TranslateTestingModule.withTranslations({}),],
imports: [
DialogModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule,
TranslateTestingModule.withTranslations({}),
],
}).compileComponents()

fixture = TestBed.createComponent(HelpItemEditorComponent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { PortalMessageService } from '@onecx/angular-integration-interface'
import { HelpData } from '../../../model/help-data'
import { PortalMessageService } from '../../../services/portal-message.service'

@Component({
selector: 'ocx-help-item-editor',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { animate, state, style, transition, trigger } from '@angular/animations'
import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'
import { AUTH_SERVICE, IAuthService } from '@onecx/angular-accelerator'
import { MenuService } from '../../../services/app.menu.service'
import { MenuItem } from 'primeng/api'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { UserService } from '@onecx/angular-integration-interface'
import { map, Observable } from 'rxjs'
import { MenuItem } from 'primeng/api'
import { UserService, AUTH_SERVICE, IAuthService } from '@onecx/angular-integration-interface'
import { MenuService } from '../../../services/app.menu.service'
import { UserProfile } from '../../../model/user-profile.model'

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ComponentFixture, TestBed, getTestBed, waitForAsync } from '@angular/core/testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { AppStateService, ConfigurationService } from '@onecx/angular-integration-interface'
import { PortalFooterComponent } from './portal-footer.component'
import { ConfigurationService } from '../../../services/configuration.service'
import { AppStateService } from '@onecx/angular-integration-interface'

describe('PortalFooterComponent', () => {
const origAddEventListener = window.addEventListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'
import { ConfigurationService } from '../../../services/configuration.service'
import { Router } from '@angular/router'
import { combineLatest, concat, map, Observable, of, withLatestFrom } from 'rxjs'
import { MenuItem } from 'primeng/api'
import { AppStateService, ConfigurationService, ThemeService, CONFIG_KEY } from '@onecx/angular-integration-interface'
import { MenuService } from '../../../services/app.menu.service'
import { AppStateService } from '@onecx/angular-integration-interface'
import { combineLatest, concat, map, Observable, of, withLatestFrom } from 'rxjs'
import { ThemeService } from '../../../services/theme.service'
import { API_PREFIX } from '../../../api/constants'
import { CONFIG_KEY } from '../../../model/config-key.model'
import { ImageLogoUrlUtils } from '../../utils/image-logo-url.utils'
@Component({
selector: 'ocx-footer',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { HeaderComponent } from './header.component'
import { AUTH_SERVICE } from '@onecx/angular-accelerator'
import { MockAuthService } from '../../../mock-auth/mock-auth.service'
import { ConfigurationService } from '../../../services/configuration.service'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { UserAvatarComponent } from '../user-avatar/user-avatar.component'
import { ActivatedRoute, RouterModule } from '@angular/router'
import { IfBreakpointDirective } from '../../directives/if-breakpoint.directive'
import { TooltipModule } from 'primeng/tooltip'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { ConfigurationService, AUTH_SERVICE } from '@onecx/angular-integration-interface'
import { HeaderComponent } from './header.component'
import { MockAuthService } from '../../../mock-auth/mock-auth.service'
import { UserAvatarComponent } from '../user-avatar/user-avatar.component'
import { IfBreakpointDirective } from '../../directives/if-breakpoint.directive'

describe('HeaderComponent', () => {
let component: HeaderComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { animate, style, transition, trigger } from '@angular/animations'
import { Component, ElementRef, EventEmitter, Inject, Input, OnInit, Output, ViewChild } from '@angular/core'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { combineLatest, filter, map, Observable } from 'rxjs'
import { MenuItem } from 'primeng/api/menuitem'
import { PrimeIcons } from 'primeng/api'

import {
AppStateService,
UserService,
ThemeService,
AUTH_SERVICE,
ConfigurationService,
CONFIG_KEY,
IAuthService,
} from '@onecx/angular-integration-interface'

import { AUTH_SERVICE, IAuthService } from '@onecx/angular-accelerator'
import { UserProfile } from '../../../model/user-profile.model'
import { ConfigurationService } from '../../../services/configuration.service'
import { MenuService } from '../../../services/app.menu.service'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { CONFIG_KEY } from '../../../model/config-key.model'
import { ThemeService } from '../../../services/theme.service'
import { ImageLogoUrlUtils } from '../../utils/image-logo-url.utils'
import { UserService } from '@onecx/angular-integration-interface'
import { AppStateService } from '@onecx/angular-integration-interface'
import { PrimeIcons } from 'primeng/api'

type MenuItemPerm = MenuItem & { permission: string }
@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { PortalMenuHorizontalComponent } from './portal-menu-horizontal.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { ConfigurationService } from '../../../services/configuration.service'
import { MenubarModule } from 'primeng/menubar'
import { ConfigurationService } from '@onecx/angular-integration-interface'
import { PortalMenuHorizontalComponent } from './portal-menu-horizontal.component'

describe('PortalMenuHorizontalComponent', () => {
let component: PortalMenuHorizontalComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { PortalMenuComponent } from './portal-menu.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { ConfigurationService } from '../../../services/configuration.service'
import { ConfigurationService } from '@onecx/angular-integration-interface'
import { PortalMenuComponent } from './portal-menu.component'

describe('PortalMenuComponent', () => {
let component: PortalMenuComponent
Expand Down
Loading
Loading