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

fix: createTranslateLoader, encodeParam, update-guide #89

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion libs/portal-integration-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export * from './lib/model/person.model'
export * from './lib/model/page-info.model'
export * from './lib/model/portal'
export * from './lib/model/user-profile.model'
export * from './lib/model/user-profile.model'
export * from './lib/model/data-table-column.model'
export * from './lib/model/column-type.model'
export * from './lib/model/data-sort-direction'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import { HelpItemEditorComponent } from './components/help-item-editor/help-item
import { NoHelpItemComponent } from './components/no-help-item/no-help-item.component'
import { DataListGridComponent } from './components/data-list-grid/data-list-grid.component'
import { PrimeNgModule } from './primeng.module'
import { MockAuthService } from '../mock-auth/mock-auth.service'
import { ConfirmDialogModule } from 'primeng/confirmdialog'
import { DataTableComponent } from './components/data-table/data-table.component'
import de from '@angular/common/locales/de'
Expand Down Expand Up @@ -167,7 +166,6 @@ export class MyMissingTranslationHandler implements MissingTranslationHandler {
],
providers: [
ConfigurationService,
MockAuthService,
{
provide: LOCALE_ID,
useFactory: (translate: TranslateService) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Location } from '@angular/common'
import { HttpClient } from '@angular/common/http'
import { TranslateLoader } from '@ngx-translate/core'
import { TranslateHttpLoader } from '@ngx-translate/http-loader'
Expand All @@ -12,9 +13,16 @@ export function createTranslateLoader(http: HttpClient, appStateService: AppStat
filter(([, isLoading]) => !isLoading),
map(([currentMfe]) => {
return new TranslateCombinedLoader(
new TranslateHttpLoader(http, `${currentMfe.remoteBaseUrl}/assets/i18n/`, '.json'),
// translations of shell or of app in standalone mode
new TranslateHttpLoader(http, `./assets/i18n/`, '.json'),
new TranslateHttpLoader(http, `./onecx-portal-lib/assets/i18n/`, '.json')
// translations of portal-integration-angular of app
new TranslateHttpLoader(
http,
Location.joinWithSlash(currentMfe.remoteBaseUrl, `onecx-portal-lib/assets/i18n/`),
'.json'
),
// translations of the app
new TranslateHttpLoader(http, Location.joinWithSlash(currentMfe.remoteBaseUrl, `assets/i18n/`), '.json')
)
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ConfigurationService } from '../../services/configuration.service'

type Config = {
credentials: { [key: string]: string | (() => string | undefined) }
encodeParam: (param: unknown) => string
selectHeaderContentType(contentTypes: string[]): string | undefined
selectHeaderAccept(accepts: string[]): string | undefined
isJsonMime(mime: string): boolean
Expand All @@ -29,6 +30,13 @@ export class PortalApiConfiguration {
this.configuration.credentials = value
}

get encodeParam(): (param: unknown) => string {
return this.configuration.encodeParam
}
set encocdeParam(value: (param: unknown) => string) {
this.configuration.encodeParam = value
}

constructor(
private configurationClassOfGenerator: unknown,
private apiPrefix: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AppStateService } from './app-state.service'
import { ConfigurationService } from './configuration.service'
import { UserService } from './user.service'

@Injectable()
@Injectable({ providedIn: 'any' })
export class InitializeModuleGuard implements CanActivate {
private SUPPORTED_LANGS = ['en', 'de']
private DEFAULT_LANG = 'en'
Expand Down
9 changes: 7 additions & 2 deletions update-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
- .getCurrentUser(), .getUserRoles() and to get other user related data is now done with userService.profile$

## ConfigurationService
- lang and lang$ are now defined in UserService as lang$
- lang and lang$ are now defined in UserService as lang$: BehaviorSubject<string> and to get the value use:
```
userService.lang$.getValue()
or
userService.lang$.value
```
- to get the portal ID use:
```
configService.getProperty(CONFIG_KEY.TKIT_PORTAL_ID)
Expand Down Expand Up @@ -52,7 +57,7 @@ await appStateService.currentPortal$.publish(Portal)
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient, AppStateService, ConfigurationService],
deps: [HttpClient, AppStateService],
},
```

Expand Down
Loading