src/app/modules/shared/services/content-utils/content-utils.service.ts
constructor(configService: ConfigService)
|
getBase64Url |
getBase64Url(type: any, identifier: any)
|
getBase64Url
Returns:
void
|
getUnlistedShareUrl |
getUnlistedShareUrl(contentShare: any)
|
getUnlistedShareUrl
Returns:
void
|
getCoursePublicShareUrl |
getCoursePublicShareUrl(courseid: any)
|
Returns:
void
|
getContentRollup |
getContentRollup(content: any)
|
{content} is node which comes from collection tree for each content and returns rollup object upto 4 elements
Returns:
void
|
getPublicShareUrl |
getPublicShareUrl(identifier: any, type: any)
|
getPublicShareUrl
Returns:
void
|
Public baseUrl |
baseUrl: |
baseUrl; |
configService |
configService: |
contentShare |
contentShare: |
input for Sharelink; |
import { Injectable } from '@angular/core';
import { ISharelink } from './../../interfaces';
import { ConfigService } from './../config/config.service';
import * as _ from 'lodash-es';
@Injectable()
export class ContentUtilsServiceService {
/**
*baseUrl;
*/
public baseUrl: string;
/**
*input for Sharelink;
*/
contentShare: ISharelink;
constructor(public configService: ConfigService) {
this.baseUrl = document.location.origin + '/';
}
/**
* getBase64Url
* generate the base url to play unlisted content for public users.
* {object} identifier-content or course identifier
* returns {string} type - content or course type.
*/
getBase64Url(type, identifier) {
return btoa(type + '/' + identifier);
}
/**
* getUnlistedShareUrl
* generate the url to play unlisted content for other users.
* {object} cData - content data
* returns {string} url to share.
*/
getUnlistedShareUrl(contentShare) {
if (contentShare.mimeType === 'application/vnd.ekstep.content-collection') {
if (contentShare.contentType === 'Course') {
return `${this.baseUrl}learn/course/${contentShare.identifier}/Unlisted`;
} else {
return `${this.baseUrl}resources/play/collection/${contentShare.identifier}/Unlisted`;
}
} else {
return `${this.baseUrl}resources/play/content/${contentShare.identifier}/Unlisted`;
}
}
getCoursePublicShareUrl (courseid) {
return `${this.baseUrl}explore-course/course/${courseid}`;
}
/**
* {content} is node which comes from collection tree for each content and returns rollup object upto 4 elements
* this function is called from public and private modules of collection and course players
*/
getContentRollup (content) {
const objectRollUp = {};
let nodes = content.getPath();
nodes = _.slice(nodes, 0, 4).slice(0, -1);
nodes.forEach((eachnode, index) => objectRollUp['l' + (index + 1)] = eachnode.model.identifier);
return objectRollUp;
}
/**
* getPublicShareUrl
* {string} identifier - content or course identifier
* {string} type - content or course type
* returns {string} url to share
*/
getPublicShareUrl(identifier, type) {
let playertype: string;
if (type === this.configService.appConfig.PLAYER_CONFIG.MIME_TYPE.collection) {
playertype = 'collection';
} else {
playertype = 'content';
}
return this.baseUrl + 'play' + '/' + playertype + '/' + identifier;
}
}