Skip to content

Commit

Permalink
Merge pull request #632 from sunbird-cb/nic-fixes
Browse files Browse the repository at this point in the history
Nic fixes
  • Loading branch information
aAmitSengar authored Dec 21, 2022
2 parents 9615ff4 + b06f3f1 commit e58a5b3
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export namespace NSSearch {
sort_by: { lastUpdatedOn: string },
fields: string[],
facets: string[],
fuzzy?: true
fuzzy?: false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ng-container *ngSwitchCase="'card-discussion'" [ngTemplateOutlet]="cardDiscussion"></ng-container>
<ng-container *ngSwitchCase="'card-wide'" [ngTemplateOutlet]="cardWide"></ng-container>
<ng-container *ngSwitchDefault [ngTemplateOutlet]="cardStandard"></ng-container>
<ng-container *ngSwitchCase="'cardCurated'" [ngTemplateOutlet]="cardCurated"></ng-container>
</ng-container>

<ng-template #cardMinimal>
Expand Down Expand Up @@ -1203,6 +1204,141 @@ <h2 class="mat-subheading-2 flex-1 min-w-0 margin-remove-bottom" i18n>Reason</h2
</mat-card>
</ng-template>


<!-- curated collection cards -->
<ng-template #cardCurated>
<mat-card class="card-standard-container mr-6 curated" [ngClass]="{
greyOut:
widgetData.deletedMode === 'greyOut' && !isLiveOrMarkForDeletion
? true
: widgetData?.intranetMode === 'greyOut' && showIntranetContent
}" (click)="(showIntranetContent || !isLiveOrMarkForDeletion) && showSnackbar()">
<div class="display-contents" [ngClass]="{
disableClick:
widgetData.deletedMode === 'greyOut' && !isLiveOrMarkForDeletion
? true
: widgetData?.intranetMode === 'greyOut' && showIntranetContent
}">
<a (click)="raiseTelemetry(); $event.stopPropagation()" [routerLink]="widgetData?.content?.linkUrl" [state]="widgetData?.stateData"
role="link" i18n-aria-label>
<ng-container *ngIf="!isCardFlipped">
<div class="status-danger" role="note" i18n-aria-label aria-label="Content expired or deleted" i18n-matTooltip
matTooltip="Content may be expired or deleted" *ngIf="!isLiveOrMarkForDeletion"></div>
<div class="status-danger" role="note" i18n-aria-label aria-label="Intranet content" i18n-matTooltip
matTooltip="Available only in Company's network"
*ngIf="widgetData?.intranetMode === 'greyOut' && showIntranetContent"></div>
<div style="position: relative; z-index: 1;">
<ng-container *ngIf="widgetData.content.posterImage">
<img mat-card-image [src]="widgetData.content.posterImage | pipePublicURL" loading="lazy" style="position: absolute; z-index: 2;"
class="card-img ws-mat-primary-lite-background"
[alt]="widgetData.content.name" />
</ng-container>
<ng-container *ngIf="!widgetData.content.posterImage">
<ng-container *ngIf="widgetData.content.appIcon; else defaultImg">
<img mat-card-image [src]="widgetData.content.appIcon | pipePublicURL" loading="lazy" style="position: absolute; z-index: 2;"
class="card-img ws-mat-primary-lite-background" [wsUtilsDefaultThumbnail]="defaultThumbnail"
[alt]="widgetData.content.name" />
</ng-container>
<ng-template #defaultImg>
<img mat-card-image [src]="defaultThumbnail" loading="lazy" style="position: absolute; z-index: 2;"
class="card-img ws-mat-primary-lite-background"
[alt]="widgetData.content.name" />
</ng-template>
</ng-container>
<div class="source-div" style="display: none;">
<img [src]="widgetData.content.creatorLogo" class="source-icon" [wsUtilsDefaultThumbnail]="defaultSLogo"
[alt]="(widgetData.content.sourceName + '_' + widgetData.content.identifier)" />
</div>
</div>
<button *ngIf="showFlip" class="detail-button ws-mat-primary-lite-background-op30" mat-icon-button
(click)="isCardFlipped = true" aria-label="Details" i18n-aria-label="Details | Click to see details">
<mat-icon>flip_to_back</mat-icon>
</button>
<mat-card-content class="min-top">
<a (click)="raiseTelemetry(); $event.stopPropagation()" [routerLink]="widgetData?.content?.linkUrl" [state]="widgetData?.stateData"
role="link" i18n-aria-label>
<div class="text-gray-time complexity flex-between flex-center">
<div *ngIf="showIsMode" i18n i18n-title title="Newly Added"
class="mode-tag px-2 ws-mat-accent-background">
Newly Added
</div>
</div>

<div class="course_logo_box">
<img [src]="widgetData.content.creatorLogo | pipePublicURL " class="source-icon" [wsUtilsDefaultThumbnail]="defaultSLogo"
[alt]="(widgetData.content.sourceName + '_' + widgetData.content.identifier)" />
</div>

<div class="course_widget">
<mat-icon class="mat-icon main_icon ws-mat-default-text margin-right-xs">video_library</mat-icon>
<ws-widget-display-content-type i18n-title title="Content Type" *ngIf="widgetData.content?.primaryCategory"
class="ws-mat-black60-text font-normal mat-caption text-uppercase" [displayContentType]="widgetData.content?.primaryCategory === 'CuratedCollections'
? 'Curated collection'
: widgetData.content?.primaryCategory">

</ws-widget-display-content-type>
</div>

<div [id]="'m-c-'+ widgetData.content?.identifier"
class="mat-subheading-1 title-text ws-mat-text-block-fade-gradient">
{{ widgetData.content.name }}
</div>
<div class="mat-body-2 ws-mat-primary-text description-text ws-mat-text-block-fade-gradient mb-2">
{{ widgetData.content.description | pipeHtmlTagRemoval }}
</div>
<div class="mat-body-2 mb-5" *ngIf="widgetData?.content?.batch?.endDate">
Deadline : {{ widgetData?.content?.batch?.endDate | date: "d MMM yyyy" }}
</div>
</a>
<div class="mt-4 mb-2 flex justify-between items-center absolute bottom-0 left-0 right-0 px-3 py-2">

<div class="flex flex-row justify-between w-full">
<div *ngIf="widgetData.content.duration" class="duration flex ">
<span class="time-text ws-mat-black60-text">{{ widgetData.content.duration | pipeDurationTransform: 'hms' }}</span>
</div>

<div *ngIf="widgetData.content?.completionStatus == 2" class="flex">
<p class="margin-remove-bottom">100%</p>
</div>
<div *ngIf="widgetData.content?.completionStatus < 2" class="flex">
<p class="margin-remove-bottom"> {{ widgetData.content?.completionPercentage }} %</p>
</div>

</div>
<div class="flex items-center">
</div>
</div>
<ng-container *ngIf="widgetData.content?.completionStatus == 2">
<ws-widget-content-progress class="progress-bar" *ngIf="widgetData.content?.identifier"
[contentId]="widgetData.content?.identifier" [progress]="100"
[progressType]="'percentage'">
</ws-widget-content-progress>
</ng-container>
<ng-container *ngIf="widgetData.content?.completionStatus < 2">
<ws-widget-content-progress class="progress-bar" *ngIf="widgetData.content?.identifier"
[contentId]="widgetData.content?.identifier" [progress]="widgetData.content?.completionPercentage"
[progressType]="'percentage'">
</ws-widget-content-progress>
</ng-container>

</mat-card-content>
</ng-container>
<ng-container *ngIf="isCardFlipped">
<div class="flex items-center">
<h2 class="mat-subheading-2 flex-1 min-w-0 margin-remove-bottom" i18n>Reason</h2>
<button mat-icon-button (click)="isCardFlipped = false">
<mat-icon>close</mat-icon>
</button>
</div>
<p class="text-justify mat-body-1">
{{ widgetData.content.reason }}
</p>
</ng-container>
</a>
</div>
</mat-card>
</ng-template>

<!-- <ng-template #cardWithUserDetails>
<mat-card [attr.name]="'widget-card-content ' + widgetData?.content?.name"
class="card-with-user-details-container mr-6" [ngClass]="{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class CardContentComponent extends WidgetBaseComponent
}

if (this.widgetData) {
if (this.widgetData.context && this.widgetData.context.pageSection === 'curatedCollections') {
this.widgetData.content.linkUrl = '/app/curatedCollections/'+ this.widgetData.content.identifier
}
this.btnPlaylistConfig = {
contentId: this.widgetData.content.identifier,
contentName: this.widgetData.content.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class ContentStripMultipleComponent extends WidgetBaseComponent
this.fetchMicrosoftCourses(strip, calculateParentStatus)
this.fetchDAKSHTACourses(strip, calculateParentStatus)
this.fetchprarambhCourse(strip, calculateParentStatus)
this.fetchCuratedCollections(strip, calculateParentStatus)
}
fetchFromApi(strip: NsContentStripMultiple.IContentStripUnit, calculateParentStatus = true) {
if (strip.request && strip.request.api && Object.keys(strip.request.api).length) {
Expand Down Expand Up @@ -541,6 +542,36 @@ export class ContentStripMultipleComponent extends WidgetBaseComponent
}
}

// curated collection
fetchCuratedCollections(strip: any, calculateParentStatus = true) {
if (strip.request && strip.request.curatedCollections && Object.keys(strip.request.curatedCollections).length) {
const searchRequest = strip.request.curatedCollections
this.contentSvc.searchRelatedCBPV6(searchRequest).subscribe(
results => {
const showViewMore = Boolean(
results.result.content.length > 5 && strip.stripConfig && strip.stripConfig.postCardForSearch,
)
const viewMoreUrl = showViewMore
? {
path: '/app/curatedCollections/home',
queryParams: {},
}
: null
this.processStrip(
strip,
this.transformContentsToWidgets(results.result.content, strip),
'done',
calculateParentStatus,
viewMoreUrl,
)
},
() => {
this.processStrip(strip, [], 'error', calculateParentStatus, null)
},
)
}
}

fetchBasedOnInterest(strip: NsContentStripMultiple.IContentStripUnit, calculateParentStatus = true) {
// topics based recommendations start
if (strip.request && strip.request.basedOnInterest && Object.keys(strip.request.basedOnInterest).length) {
Expand Down Expand Up @@ -1039,7 +1070,8 @@ export class ContentStripMultipleComponent extends WidgetBaseComponent
(strip.request.basedOnInterest && Object.keys(strip.request.basedOnInterest).length) ||
(strip.request.microsoftCourses && Object.keys(strip.request.microsoftCourses).length) ||
(strip.request.DAKSHTACourses && Object.keys(strip.request.DAKSHTACourses).length) ||
(strip.request.prarambhCourse && Object.keys(strip.request.prarambhCourse).length)
(strip.request.prarambhCourse && Object.keys(strip.request.prarambhCourse).length) ||
(strip.request.curatedCollections && Object.keys(strip.request.curatedCollections).length)
)
) {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export namespace NsContentStripMultiple {
basedOnInterest?: any
microsoftCourses?: any,
DAKSHTACourses?: any,
prarambhCourse?: any
prarambhCourse?: any,
curatedCollections?: any
}
searchV6Type?: 'KB' | 'Collections' | 'searchQuery' | null
stripBackground?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ProviderAllCbpComponent implements OnInit, OnDestroy {
offset: 0,
fields: [],
facets: ['primaryCategory', 'mimeType', 'source'],
fuzzy: true,
fuzzy: false,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class CuratedHomeComponent implements OnInit {
offset: 0,
fields: [],
facets: ['primaryCategory', 'mimeType'],
fuzzy: true,
fuzzy: false,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class CuratedexplorerComponent implements OnInit, OnDestroy {
offset: 0,
fields: [],
facets: ['primaryCategory', 'mimeType'],
fuzzy: true,
fuzzy: false,
},
}
stateData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class LearnSearchComponent implements OnInit, OnChanges, OnDestroy {
facets: ['primaryCategory', 'mimeType', 'source', 'competencies_v3.name', 'topics'],
limit: 100,
offset: 0,
fuzzy: true,
fuzzy: false,
},
}
totalResults: any
Expand Down Expand Up @@ -167,7 +167,7 @@ export class LearnSearchComponent implements OnInit, OnChanges, OnDestroy {
facets: ['primaryCategory', 'mimeType', 'source'],
limit: 100,
offset: 0,
fuzzy: true,
fuzzy: false,
},
}
this.newQueryParam = queryparam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class SearchServService {
},
facets: Object.keys(this.searchConfig.search.visibleFiltersV2),
fields: request.request.fields,
fuzzy: true,
fuzzy: false,
},
}
return this.searchApi.getSearchV6Results(v6Request, this.searchConfig.defaultsearch)
Expand Down

0 comments on commit e58a5b3

Please sign in to comment.