Skip to content

Commit 13731ad

Browse files
authored
US-551354: Move to using standard MashupAPI to create case (#195)
* US-551354: Move to using standard MashupAPI to create case
1 parent b8ef310 commit 13731ad

File tree

12 files changed

+223
-187
lines changed

12 files changed

+223
-187
lines changed

sdk-config.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
"authConfig_comment": "Optional Full paths to Infinity server OAuth endpoints (Only needed if using custom OAuth service)",
55
"authConfig_comment2": "Optional attributes are: authorize, token, revoke, redirectUri, authService, silentTimeout, iframeLoginUI",
66
"authService": "pega",
7-
7+
88
"mashupClient_comment": "Client ID and Client secret from the OAuth 2.0 Client Registration record used for mashup use case",
99
"mashupClient_comment2": "See SDK Guide for instructions on how to generate and obtain the proper values for the following entries",
1010
"mashupClientId": "69184022781147469983",
1111
"mashupUserIdentifier": "customer@mediaco",
1212
"mashupClient_comment3": "Note: mashupPassword requires Base64 encoding",
1313
"mashupPassword": "",
14-
14+
1515
"portalClientId_comment": "Client ID from the OAuth 2.0 Client Registration record used for portal use case",
1616
"portalClientId": "69184022781147469983"
1717
},
1818
"serverConfig": {
1919
"comment_serverConfig": "serverConfig is the block for SDK Content Server config entries",
20-
20+
2121
"infinityRestServerUrl_comment": "Full path to Infinity REST server",
2222
"infinityRestServerUrl": "https://localhost:1080/prweb",
2323

@@ -26,11 +26,14 @@
2626

2727
"sdkContentServerUrl_comment": "If specified, the given URL will be used. If left blank, window.location.origin will be used.",
2828
"sdkContentServerUrl": "",
29-
29+
3030
"appPortal_comment": "If specified, the given appPortal will be loaded. If left blank, the operator's default Portal is used. Ignored for Mashup",
3131
"appPortal": "",
3232

33+
"appMashupCaseType_comment": "If specified, uses this case type for mashup. Otherwise, uses the first case type found for the app",
34+
"appMashupCaseType": "",
35+
3336
"excludePortals_comment": "Array of specific portals to avoid attempting to load with SDK",
34-
"excludePortals" : ["pxExpress", "Developer", "pxPredictionStudio", "pxAdminStudio", "pyCaseWorker", "pyCaseManager7"]
37+
"excludePortals": ["pxExpress", "Developer", "pxPredictionStudio", "pxAdminStudio", "pyCaseWorker", "pyCaseManager7"]
3538
}
36-
}
39+
}

src/app/_components/root-container/root-container.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
<div [ngSwitch]="componentName$">
77
<app-view *ngSwitchCase="'View'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-view>
88
<!-- <app-reference *ngSwitchCase="'reference'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-reference> -->
9-
<app-view-container *ngSwitchCase="'ViewContainer'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-view-container>
9+
<app-view-container
10+
*ngSwitchCase="'ViewContainer'"
11+
[pConn$]="displayOnlyFA$ ? viewContainerPConn$ : pConn$"
12+
[displayOnlyFA$]="displayOnlyFA$"
13+
></app-view-container>
1014
<app-hybrid-view-container *ngSwitchCase="'HybridViewContainer'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-hybrid-view-container>
1115
<app-modal-view-container
1216
*ngSwitchCase="'ModalViewContainer'"

src/app/_components/root-container/root-container.component.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { ReferenceComponent } from '../reference/reference.component';
1010
* is totally at your own risk.
1111
*/
1212

13+
const options = { context: 'app' };
14+
1315
@Component({
1416
selector: 'app-root-container',
1517
templateUrl: './root-container.component.html',
@@ -20,7 +22,6 @@ export class RootContainerComponent implements OnInit {
2022
@Input() props$: any;
2123
@Input() PCore$: any;
2224
@Input() displayOnlyFA$: boolean;
23-
@Input() isMashup$: boolean;
2425

2526
// For interaction with AngularPConnect
2627
angularPConnectData: any = {};
@@ -36,16 +37,12 @@ export class RootContainerComponent implements OnInit {
3637

3738
progressSpinnerSubscription: Subscription;
3839
spinnerTimer: any = null;
40+
viewContainerPConn$: any = null;
3941

4042
constructor(private angularPConnect: AngularPConnectService, private psService: ProgressSpinnerService, private ngZone: NgZone) {}
4143

4244
ngOnInit(): void {
4345
let myContext = 'app';
44-
if (this.isMashup$) {
45-
myContext = 'root';
46-
}
47-
48-
const options = { context: myContext };
4946

5047
if (!this.PCore$) {
5148
this.PCore$ = window.PCore;
@@ -132,13 +129,7 @@ export class RootContainerComponent implements OnInit {
132129
const renderingModes = ['portal', 'view'];
133130
const noPortalMode = 'noPortal';
134131

135-
let myContext = 'app';
136-
if (this.isMashup$) {
137-
myContext = 'root';
138-
}
139-
140-
const options = { context: myContext };
141-
const { renderingMode, children, skeleton, httpMessages, routingInfo } = myProps;
132+
const { renderingMode, children, skeleton, routingInfo } = myProps;
142133

143134
if (routingInfo && renderingModes.includes(renderingMode)) {
144135
const { accessedOrder, items } = routingInfo;
@@ -185,6 +176,19 @@ export class RootContainerComponent implements OnInit {
185176
this.ngZone.run(() => {
186177
let localPConn = arChildren[0].getPConnect();
187178
this.componentName$ = localPConn.getComponentName();
179+
180+
if (this.componentName$ === 'ViewContainer') {
181+
const configProps = this.pConn$.getConfigProps();
182+
const viewContConfig = {
183+
meta: {
184+
type: 'ViewContainer',
185+
config: configProps,
186+
},
187+
options,
188+
};
189+
190+
this.viewContainerPConn$ = this.PCore$.createPConnect(viewContConfig).getPConnect();
191+
}
188192
this.bShowRoot$ = true;
189193
});
190194
});

src/app/_samples/full-portal/top-app-mashup/top-app-mashup.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class TopAppMashupComponent implements OnInit {
6666
) {}
6767

6868
ngOnInit() {
69-
this.scservice.getServerConfig().then(() => {
69+
this.scservice.readSdkConfig().then(() => {
7070
this.initialize();
7171
});
7272
}
@@ -144,9 +144,8 @@ export class TopAppMashupComponent implements OnInit {
144144
});
145145
});
146146

147-
const thePortal = this.scservice.getAppPortal();
147+
const { appPortal: thePortal, excludePortals } = this.scservice.getSdkConfigServer();
148148
const defaultPortal = window.PCore?.getEnvironmentInfo?.().getDefaultPortal?.();
149-
const excludePortals = this.scservice.getSdkConfigServer().excludePortals;
150149

151150
// Note: myLoadPortal and myLoadDefaultPortal are set when bootstrapWithAuthHeader is invoked
152151
if (thePortal) {

src/app/_samples/mashup/main-screen/main-screen.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<app-bundle-swatch [swatchConfig$]="thirdConfig$" (ShopNowButtonClick)="onShopNow($event)"></app-bundle-swatch>
99
</div>
1010
</div>
11-
<div *ngIf="showPega$">
11+
<div [hidden]="!showPega$">
1212
<div class="mc-info">
1313
<div class="mc-info-pega">
14-
<app-root-container [pConn$]="pConn$" [displayOnlyFA$]="true" [isMashup$]="true"></app-root-container>
14+
<app-root-container [pConn$]="pConn$" [displayOnlyFA$]="true"></app-root-container>
1515
<div style="padding-left: 50px">* - required fields</div>
1616
</div>
1717
<div class="mc-info-banner">

src/app/_samples/mashup/main-screen/main-screen.component.ts

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit, Input } from '@angular/core';
22
import { ProgressSpinnerService } from '../../../_messages/progress-spinner.service';
3+
import { ServerConfigService } from 'src/app/_services/server-config.service';
34

45
declare function loadMashup(targetDom, preLoadComponents);
56

@@ -20,7 +21,7 @@ export class MainScreenComponent implements OnInit {
2021
showPega$: boolean = false;
2122
showResolution$: boolean = false;
2223

23-
constructor(private psservice: ProgressSpinnerService) {}
24+
constructor(private psservice: ProgressSpinnerService, private serverConfigService: ServerConfigService) {}
2425

2526
ngOnInit(): void {
2627
if (!this.PCore$) {
@@ -102,48 +103,28 @@ export class MainScreenComponent implements OnInit {
102103
this.showTriplePlayOptions$ = false;
103104
this.showPega$ = true;
104105

105-
let actionsApi = this.pConn$.getActionsApi();
106-
let createWork = actionsApi.createWork.bind(actionsApi);
107-
let sFlowType = 'pyStartCase';
108-
109-
this.psservice.sendMessage(true);
110-
111-
let actionInfo;
112-
const accessGroup = sessionStorage.getItem('userAccessGroup');
113-
114-
let portalName = accessGroup;
115-
let pCore: any;
116-
if (window.PCore) {
117-
pCore = window.PCore;
118-
119-
portalName = pCore.getEnvironmentInfo().getApplicationLabel();
120-
}
121-
122-
if (portalName.toLowerCase().includes('cableco')) {
123-
actionInfo = {
124-
containerName: 'primary',
125-
flowType: sFlowType ? sFlowType : 'pyStartCase',
126-
caseInfo: {
127-
content: {
128-
Package: sLevel,
129-
},
130-
},
131-
};
132-
133-
createWork('CableC-CableCon-Work-Service', actionInfo);
134-
} else if (portalName.toLowerCase().includes('mediaco')) {
135-
actionInfo = {
136-
containerName: 'primary',
137-
flowType: sFlowType ? sFlowType : 'pyStartCase',
138-
caseInfo: {
139-
content: {
140-
Package: sLevel,
141-
},
142-
},
106+
this.serverConfigService.getSdkConfig().then((sdkConfig) => {
107+
let mashupCaseType = sdkConfig.serverConfig.appMashupCaseType;
108+
if (!mashupCaseType) {
109+
const caseTypes = this.PCore$.getEnvironmentInfo().environmentInfoObject.pyCaseTypeList;
110+
mashupCaseType = caseTypes[0].pyWorkTypeImplementationClassName;
111+
}
112+
113+
const options = {
114+
pageName: 'pyEmbedAssignment',
115+
startingFields:
116+
mashupCaseType === 'DIXL-MediaCo-Work-NewService'
117+
? {
118+
Package: sLevel,
119+
}
120+
: {},
143121
};
144-
145-
createWork('DIXL-MediaCo-Work-NewService', actionInfo);
146-
}
122+
this.PCore$.getMashupApi()
123+
.createCase(mashupCaseType, this.PCore$.getConstants().APP.APP, options)
124+
.then(() => {
125+
console.log('createCase rendering is complete');
126+
});
127+
});
147128
}
148129

149130
onShopNow(sLevel: string) {

src/app/_samples/mashup/mc-nav/mc-nav.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<mat-toolbar color="primary" class="mc-toolbar">
66
<mat-toolbar-row class="mc-toolbar-row">
7-
MediaCo
7+
{{ applicationLabel }}
88
<mat-icon class="mc-icon">router</mat-icon>
99

1010
<span class="toolbar-spacer"> </span>

src/app/_samples/mashup/mc-nav/mc-nav.component.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class MCNavComponent implements OnInit {
2828
PCore$: any;
2929
pConn$: any;
3030

31+
applicationLabel: string = '';
3132
bLoggedIn$: boolean = false;
3233
bPConnectLoaded$: boolean = false;
3334
bHasPConnect$: boolean = false;
@@ -49,7 +50,7 @@ export class MCNavComponent implements OnInit {
4950
) {}
5051

5152
ngOnInit() {
52-
this.scservice.getServerConfig().then(() => {
53+
this.scservice.readSdkConfig().then(() => {
5354
this.initialize();
5455
});
5556
}
@@ -59,13 +60,11 @@ export class MCNavComponent implements OnInit {
5960
this.resetPConnectSubscription.unsubscribe();
6061
}
6162

62-
initialize() {
63+
async initialize() {
6364
if (!this.PCore$) {
6465
this.PCore$ = window.PCore;
6566
}
6667

67-
this.titleService.setTitle('Media Co');
68-
6968
sessionStorage.clear();
7069

7170
// handle showing and hiding the progress spinner
@@ -103,7 +102,7 @@ export class MCNavComponent implements OnInit {
103102
this.bLoggedIn$ = false;
104103
});
105104

106-
const sdkConfigAuth = this.scservice.getSdkConfigAuth();
105+
const sdkConfigAuth = await this.scservice.getSdkConfigAuth();
107106

108107
if (!sdkConfigAuth.mashupClientId && sdkConfigAuth.customAuthType === 'Basic') {
109108
// Service package to use custom auth with Basic
@@ -133,8 +132,12 @@ export class MCNavComponent implements OnInit {
133132
}
134133

135134
this.PCore$.onPCoreReady((renderObj) => {
135+
console.log('PCore ready!');
136136
// Check that we're seeing the PCore version we expect
137137
compareSdkPCoreVersions();
138+
this.applicationLabel = this.PCore$.getEnvironmentInfo().getApplicationLabel();
139+
140+
this.titleService.setTitle(this.applicationLabel);
138141

139142
// Need to register the callback function for PCore.registerComponentCreator
140143
// This callback is invoked if/when you call a PConnect createComponent

src/app/_samples/simple-portal/main-content/main-content.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
</div>
55

66
<div *ngIf="sComponentName$ == 'RootContainer'">
7-
<app-root-container [pConn$]="pConn$" [PCore$]="PCore$" [props$]="props$" [isMashup$]="true" [displayOnlyFA$]="false"></app-root-container>
7+
<app-root-container [pConn$]="pConn$" [PCore$]="PCore$" [props$]="props$" [displayOnlyFA$]="false"></app-root-container>
88
</div>

src/app/_samples/simple-portal/navigation/navigation.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class NavigationComponent implements OnInit {
3737
) {}
3838

3939
ngOnInit() {
40-
this.scservice.getServerConfig().then(() => {
40+
this.scservice.readSdkConfig().then(() => {
4141
this.initialize();
4242
});
4343
}

0 commit comments

Comments
 (0)