File

src/app/manage-learn/project/learning-resources/learning-resources.page.ts

Metadata

Index

Properties
Methods

Constructor

constructor(routerparam: ActivatedRoute, headerService: AppHeaderService, translate: TranslateService, utils: UtilsService, loader: LoaderService, toast: ToastService, db: DbService, navigateService: NavigationService, platform: Platform, location: Location, contentService: ContentService, commonUtilService: CommonUtilService)
Parameters :
Name Type Optional
routerparam ActivatedRoute No
headerService AppHeaderService No
translate TranslateService No
utils UtilsService No
loader LoaderService No
toast ToastService No
db DbService No
navigateService NavigationService No
platform Platform No
location Location No
contentService ContentService No
commonUtilService CommonUtilService No

Methods

getProjectFromLocal
getProjectFromLocal(projectId)
Parameters :
Name Optional
projectId No
Returns : void
Private handleBackButton
handleBackButton()
Returns : void
ionViewWillEnter
ionViewWillEnter()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
openBodh
openBodh(resource)
Parameters :
Name Optional
resource No
Returns : void

Properties

Private _headerConfig
Type : object
Default value : { showHeader: true, showBurgerMenu: false, pageTitle: '', actionButtons: [] as string[] }
Private _networkSubscription
Type : Subscription
Private backButtonFunc
Type : Subscription
list
networkFlag
Type : boolean
projectId
taskId
Type : any
import { Component, Inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppHeaderService, CommonUtilService } from '@app/services';
import { TranslateService } from '@ngx-translate/core';
import { LoaderService, ToastService } from '../../core';
import { DbService } from '../../core/services/db.service';
import { UtilsService } from '../../core/services/utils.service';
import { ContentDetailRequest, Content, ContentService } from 'sunbird-sdk';
import { NavigationService } from '@app/services/navigation-handler.service';
import { Location } from '@angular/common';
import { Subscription } from 'rxjs';
import { Platform } from '@ionic/angular';

var environment = {
  db: {
    projects: 'project.db',
    categories: 'categories.db'
  },
  deepLinkAppsUrl: ''
};

@Component({
  selector: 'app-learning-resources',
  templateUrl: './learning-resources.page.html',
  styleUrls: ['./learning-resources.page.scss']
})
export class LearningResourcesPage {
  projectId;
  taskId: any;
  list;
  networkFlag: boolean;
  private backButtonFunc: Subscription;
  private _networkSubscription: Subscription;

  private _headerConfig = {
    showHeader: true,
    showBurgerMenu: false,
    pageTitle: '',
    actionButtons: [] as string[]
  };

  constructor(
    private routerparam: ActivatedRoute,
    private headerService: AppHeaderService,
    private translate: TranslateService,
    private utils: UtilsService,
    private loader: LoaderService,
    private toast: ToastService,
    private db: DbService,
    private navigateService: NavigationService,
    private platform: Platform,
    private location: Location,
    @Inject('CONTENT_SERVICE') private contentService: ContentService,
    private commonUtilService: CommonUtilService
  ) // private openResources: OpenResourcesService
  {
    let data;
    routerparam.params.subscribe((param) => {
      this.projectId = param.id;
      this.taskId = param.taskId;
      this.getProjectFromLocal(this.projectId);
    });
    this.networkFlag = this.commonUtilService.networkInfo.isNetworkAvailable;
    this._networkSubscription = this.commonUtilService.networkAvailability$.subscribe(async (available: boolean) => {
        this.networkFlag = available;
      })
  }

  ngOnDestroy() {
    if(this._networkSubscription){
      this._networkSubscription.unsubscribe();
    }
  }

  ionViewWillEnter() {
    let data;
    this.translate
      .get(['FRMELEMNTS_LBL_LEARNING_RESOURCES']).subscribe((text) => {
        data = text;
      });
    this._headerConfig = this.headerService.getDefaultPageConfig();
    this._headerConfig.actionButtons = [];
    this._headerConfig.showHeader = true;
    this._headerConfig.showBurgerMenu = false;
    this._headerConfig.pageTitle = data['FRMELEMNTS_LBL_LEARNING_RESOURCES'];
    this.headerService.updatePageConfig(this._headerConfig);
    this.handleBackButton();
  }

  private handleBackButton() {
    this.backButtonFunc = this.platform.backButton.subscribeWithPriority(10,() => {
        this.location.back();
        this.backButtonFunc.unsubscribe();
      }
    );
  }
  getProjectFromLocal(projectId) {
    this.db.query({ _id: projectId }).then(
      (success) => {
        this.list = success.docs.length ? success.docs[0] : [];
        if (this.taskId) {
          this.list = this.list.tasks.filter((t) => t._id == this.taskId)[0];
        }
      },
      error => {}
    );
  }
  openBodh(resource) {
    let id
    if (resource.id) {
      id = resource.id;
    } else {
      id = resource.link.split('/').pop()
    }
    
    if (!this.networkFlag) {
      this.toast.showMessage('FRMELEMNTS_MSG_PLEASE_GO_ONLINE', 'danger');
      return;
    }
    const req: ContentDetailRequest = {
      contentId: id,
      attachFeedback: false,
      attachContentAccess: false,
      emitUpdateIfAny: false
    };

    this.contentService
      .getContentDetails(req)
      .toPromise()
      .then(async (data: Content) => {
        this.navigateService.navigateToDetailPage(data, { content: data });
      });
  }
}
<ion-content *ngIf="list">
  <app-item-list-card *ngFor="let resource of list.learningResources" [title]="resource?.name"
    (cardSelect)="openBodh(resource)">
    <div arrow class="d-flex flex-dc">
      <ion-icon class="mg-popup-btn-icon" name="arrow-forward" arrow></ion-icon>
    </div>
  </app-item-list-card>
  <app-no-data *ngIf="!list?.learningResources?.length"></app-no-data>
</ion-content>

./learning-resources.page.scss

.resource-card{
    padding:5px;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""