Skip to content

Commit

Permalink
Merge pull request #2378 from venkykandagaddala/BM-Fixes
Browse files Browse the repository at this point in the history
Added fetchPlaylistReadData method in ATI/CTI show all page
  • Loading branch information
venkykandagaddala authored Jul 31, 2024
2 parents 85e5e22 + e1108d2 commit f02f41f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NsContentStripWithTabs } from '@sunbird-cb/consumption/lib/_common/cont

import { BrowseProviderService } from '../../services/browse-provider.service'
import { UtilityService } from '@sunbird-cb/utils-v2'
import { environment } from 'src/environments/environment'

@Component({
selector: 'ws-app-provider-content-all',
Expand Down Expand Up @@ -40,7 +41,6 @@ export class ProviderContentAllComponent implements OnInit {
this.activatedRoute.params.subscribe(params => {
this.providerName = params['provider']
this.providerId = params['orgId']

if (this.activatedRoute.snapshot.queryParams && this.activatedRoute.snapshot.queryParams.stripData) {
const data = JSON.parse(this.activatedRoute.snapshot.queryParams.stripData)
this.isMobile = this.utilitySvc.isMobile || false
Expand Down Expand Up @@ -78,6 +78,66 @@ export class ProviderContentAllComponent implements OnInit {
this.fetchAllTopContent(this.seeAllPageConfig, query)
} else if (this.seeAllPageConfig.request && this.seeAllPageConfig.request.featureContent) {
this.fetchAllFeaturedContent(this.seeAllPageConfig, query)
} else if (this.seeAllPageConfig.request && this.seeAllPageConfig.request.playlistRead) {
this.fetchPlaylistReadData(this.seeAllPageConfig, query)
}
}

getFullUrl(apiUrl: any, id: string) {
let formedUrl: string = apiUrl
if (apiUrl.indexOf('<bookmarkId>') >= 0) {
formedUrl = apiUrl.replace('<bookmarkId>', environment.mdoChannelsBookmarkId)
} else if (apiUrl.indexOf('<playlistKey>') >= 0 && apiUrl.indexOf('<orgID>') >= 0) {
formedUrl = apiUrl.replace('<playlistKey>', this.providerId + id)
formedUrl = formedUrl.replace('<orgID>', this.providerId)
}
return formedUrl
}

async getRequestMethod(strip: NsContentStripWithTabs.IContentStripUnit,
request: NsContentStripWithTabs.IContentStripUnit['request'],
apiUrl: string
): Promise<any> {
return new Promise<any>((resolve, reject) => {
if (request && request) {
this.contentSvc.getApiMethod(apiUrl).subscribe(results => {
const showViewMore = Boolean(
results.result.data && results.result.data.orgList.length > 5 && strip.stripConfig && strip.stripConfig.postCardForSearch,
)
const viewMoreUrl = showViewMore
? {
path: strip.viewMoreUrl && strip.viewMoreUrl.path || '',
}
: null
resolve({ results, viewMoreUrl })
}, (error: any) => {
reject(error)
},
)
}
})
}

async fetchPlaylistReadData(strip: NsContentStripWithTabs.IContentStripUnit, _querydata?: any) {
if (strip.request && strip.request.playlistRead && Object.keys(strip.request.playlistRead).length) {
if (strip.request &&
strip.request.playlistRead &&
strip.request.playlistRead.type) {
strip.request.apiUrl = this.getFullUrl(strip.request.apiUrl, strip.request.playlistRead.type)
}
try {
const response = await this.getRequestMethod(strip, strip.request.playlistRead, strip.request.apiUrl)
if (response && response.results.result.content) {
const content = response.results.result.content
this.originalContentlist = content
this.contentDataList = this.commonSvc.transformContentsToWidgets(content, strip)
} else {
this.contentDataList = []
}
} catch (error) {
// Handle errors
// console.error('Error:', error);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ export class BrowseProviderService {
return this.http.post<NsContent.IContent>(apiUrl, req)
}

getApiMethod(apiUrl: any): Observable<NsContent.IContent> {
// req.query = req.query || '';
return this.http.get<NsContent.IContent>(apiUrl)
}


}

0 comments on commit f02f41f

Please sign in to comment.