-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Mashup code cleanup changes (#412)
- Loading branch information
1 parent
f7d9f4a
commit e9a7006
Showing
24 changed files
with
334 additions
and
380 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
src/app/_samples/embedded/bundle-swatch/bundle-swatch.component.ts
This file was deleted.
Oops, something went wrong.
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> |
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
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,114 @@ | ||
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, Utils, compareSdkPCoreVersions, getSdkComponentMap } from '@pega/angular-sdk-components'; | ||
|
||
import { HeaderComponent } from './header/header.component'; | ||
import { MainScreenComponent } from './main-screen/main-screen.component'; | ||
import localSdkComponentMap from '../../../../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; | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -60,7 +60,7 @@ | |
} | ||
|
||
.mc-info-image { | ||
width: 700px; | ||
width: calc(100% - 40px); | ||
margin: 20px; | ||
border-radius: 10px; | ||
} |
Oops, something went wrong.