File
Methods
Public
Async
getPGPUrl
|
getPGPUrl(tableID)
|
|
Given a Product family group table ID, return a canonical URL for the family group page.
Returns : Promise<string>
|
Public
getPGPUrlWithPath
|
getPGPUrlWithPath(tableID, publicationPath, publicationId)
|
|
Parameters :
Name |
Optional |
tableID |
No
|
publicationPath |
No
|
publicationId |
No
|
|
Private
Readonly
PGP_URL_LOOKUP
|
Default value : `getProductTablePageURL`
|
|
pubId
|
Type : string
|
Default value : ''
|
|
pubPath
|
Type : string
|
Default value : ''
|
|
import { Injectable } from '@angular/core';
import { PublicationService } from '../publication-service/publication.service';
import { ClientSideCacheService } from '../../client-side-cache/client-side-cache.service';
@Injectable()
export class OpcService {
private readonly PGP_URL_LOOKUP = `getProductTablePageURL`;
pubPath = '';
pubId = '';
constructor(
private pubService: PublicationService,
private cacheService: ClientSideCacheService
) {}
/** Given a Product family group table ID, return a canonical URL for the family group page. */
public async getPGPUrl(tableID): Promise<string> {
this.pubId = this.pubService.getPublicationId();
this.pubPath = this.pubService.getPublicationPath();
const lookupUrl = `/content${this.pubPath}/${this.PGP_URL_LOOKUP}/${this.pubId}/${tableID}`;
const promise = new Promise<string>((resolve, reject) => {
this.cacheService.getValue(`${this.pubPath}-${tableID}`, lookupUrl).toPromise().then(res => {
if (res) {
resolve(res['productTablePageURL']);
} else {
console.error('PGP error');
}
},
err => {
console.error('No PGP found');
});
});
return promise;
}
public getPGPUrlWithPath(tableID, publicationPath, publicationId) {
const lookupUrl = `/content${publicationPath}/${this.PGP_URL_LOOKUP}/${publicationId}/${tableID}`;
const promise = new Promise<string>((resolve, reject) => {
this.cacheService.getValue(`${publicationPath}-${tableID}`, lookupUrl).toPromise().then(res => {
if (res) {
resolve(res['productTablePageURL']);
} else {
reject(undefined);
}
},
err => {
console.error('No PGP found');
});
});
return promise;
}
}