-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Mashup code cleanup changes --------- Co-authored-by: mashm <[email protected]> Co-authored-by: Siva Rama Krishna <[email protected]>
- Loading branch information
1 parent
8f0ac6d
commit 1789ceb
Showing
27 changed files
with
322 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
projects/angular-test-app/src/app/_samples/embedded/bundle-swatch/bundle-swatch.component.ts
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
projects/angular-test-app/src/app/_samples/embedded/embedded.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="progress-box" *ngIf="isProgress$"> | ||
<mat-spinner class="progress-spinner"></mat-spinner> | ||
</div> | ||
|
||
<div *ngIf="bLoggedIn$; else loading"> | ||
<app-header></app-header> | ||
<app-main-screen *ngIf="bHasPConnect$" [pConn$]="pConn$"></app-main-screen> | ||
</div> | ||
|
||
<ng-template #loading> | ||
<div>Loading...</div> | ||
</ng-template> |
18 changes: 18 additions & 0 deletions
18
projects/angular-test-app/src/app/_samples/embedded/embedded.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.progress-box { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
width: 100%; | ||
background-color: var(--app-background-color); | ||
position: fixed; | ||
z-index: 99999; | ||
top: 0px; | ||
left: 0px; | ||
opacity: 0.5; | ||
} | ||
|
||
.progress-spinner { | ||
text-align: center; | ||
} |
12 changes: 6 additions & 6 deletions
12
...p-mashup/top-app-mashup.component.spec.ts → ...mples/embedded/embedded.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
projects/angular-test-app/src/app/_samples/embedded/embedded.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatToolbarModule } from '@angular/material/toolbar'; | ||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; | ||
import { Subscription } from 'rxjs'; | ||
import { getSdkConfig, loginIfNecessary } from '@pega/auth/lib/sdk-auth-manager'; | ||
|
||
import { ProgressSpinnerService } from 'packages/angular-sdk-components/src/lib/_messages/progress-spinner.service'; | ||
import { Utils } from 'packages/angular-sdk-components/src/lib/_helpers/utils'; | ||
import { compareSdkPCoreVersions } from 'packages/angular-sdk-components/src/lib/_helpers/versionHelpers'; | ||
import { HeaderComponent } from './header/header.component'; | ||
import { MainScreenComponent } from './main-screen/main-screen.component'; | ||
|
||
import { getSdkComponentMap } from 'packages/angular-sdk-components/src/lib/_bridge/helpers/sdk_component_map'; | ||
import localSdkComponentMap from 'packages/angular-sdk-components/src/sdk-local-component-map'; | ||
import { initializeAuthentication } from './utils'; | ||
|
||
declare global { | ||
interface Window { | ||
myLoadMashup: Function; | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'app-embedded', | ||
templateUrl: './embedded.component.html', | ||
styleUrls: ['./embedded.component.scss'], | ||
providers: [Utils], | ||
standalone: true, | ||
imports: [CommonModule, MatProgressSpinnerModule, MatToolbarModule, MatIconModule, MatButtonModule, HeaderComponent, MainScreenComponent] | ||
}) | ||
export class EmbeddedComponent implements OnInit, OnDestroy { | ||
pConn$: typeof PConnect; | ||
|
||
bLoggedIn$ = false; | ||
bHasPConnect$ = false; | ||
isProgress$ = false; | ||
|
||
progressSpinnerSubscription: Subscription; | ||
|
||
bootstrapShell: any; | ||
|
||
constructor(private psservice: ProgressSpinnerService) {} | ||
|
||
ngOnInit() { | ||
this.initialize(); | ||
|
||
// handle showing and hiding the progress spinner | ||
this.progressSpinnerSubscription = this.psservice.getMessage().subscribe(message => { | ||
this.showHideProgress(message.show); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.progressSpinnerSubscription.unsubscribe(); | ||
} | ||
|
||
async initialize() { | ||
// Add event listener for when logged in and constellation bootstrap is loaded | ||
document.addEventListener('SdkConstellationReady', () => this.handleSdkConstellationReady()); | ||
|
||
const { authConfig } = await getSdkConfig(); | ||
|
||
initializeAuthentication(authConfig); | ||
|
||
// Login if needed, without doing an initial main window redirect | ||
const sAppName = window.location.pathname.substring(window.location.pathname.indexOf('/') + 1); | ||
loginIfNecessary({ appName: sAppName, mainRedirect: false }); | ||
} | ||
|
||
handleSdkConstellationReady() { | ||
this.bLoggedIn$ = true; | ||
// start the portal | ||
this.startMashup(); | ||
} | ||
|
||
startMashup() { | ||
PCore.onPCoreReady(async renderObj => { | ||
console.log('PCore ready!'); | ||
|
||
// Check that we're seeing the PCore version we expect | ||
compareSdkPCoreVersions(); | ||
|
||
// Initialize the SdkComponentMap (local and pega-provided) | ||
await getSdkComponentMap(localSdkComponentMap); | ||
console.log(`SdkComponentMap initialized`); | ||
|
||
// Don't call initialRender until SdkComponentMap is fully initialized | ||
this.initialRender(renderObj); | ||
}); | ||
|
||
window.myLoadMashup('app-root', false); // this is defined in bootstrap shell that's been loaded already | ||
} | ||
|
||
initialRender(renderObj) { | ||
// Need to register the callback function for PCore.registerComponentCreator | ||
// This callback is invoked if/when you call a PConnect createComponent | ||
PCore.registerComponentCreator(c11nEnv => { | ||
return c11nEnv; | ||
}); | ||
|
||
// Change to reflect new use of arg in the callback: | ||
const { props } = renderObj; | ||
|
||
this.pConn$ = props.getPConnect(); | ||
|
||
this.bHasPConnect$ = true; | ||
|
||
this.showHideProgress(false); | ||
} | ||
|
||
showHideProgress(bShow: boolean) { | ||
this.isProgress$ = bShow; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
projects/angular-test-app/src/app/_samples/embedded/header/header.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<mat-toolbar color="primary" class="mc-toolbar"> | ||
<mat-toolbar-row class="mc-toolbar-row"> | ||
{{ applicationLabel }} | ||
<mat-icon class="mc-icon">router</mat-icon> | ||
|
||
<span class="toolbar-spacer"> </span> | ||
</mat-toolbar-row> | ||
</mat-toolbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
.../embedded/mc-nav/mc-nav.component.spec.ts → .../embedded/header/header.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
projects/angular-test-app/src/app/_samples/embedded/header/header.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatToolbarModule } from '@angular/material/toolbar'; | ||
|
||
@Component({ | ||
selector: 'app-header', | ||
templateUrl: './header.component.html', | ||
styleUrls: ['./header.component.scss'], | ||
standalone: true, | ||
imports: [CommonModule, MatToolbarModule, MatIconModule, MatButtonModule] | ||
}) | ||
export class HeaderComponent implements OnInit { | ||
applicationLabel: string | undefined; | ||
|
||
ngOnInit() { | ||
this.applicationLabel = PCore.getEnvironmentInfo().getApplicationLabel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.