Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"papaparse": "^5.4.1",
"rxjs": "~6.6.0",
"rxjs-compat": "^6.6.7",
"sl-generic-table": "^1.3.1",
"sl-generic-table": "^1.3.11",
"tslib": "^2.2.0",
"yargs": "^17.7.2",
"zone.js": "~0.11.4"
Expand Down
10 changes: 10 additions & 0 deletions src/app/core/services/util/util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,15 @@ export class UtilService {
subscribeCriteriaChip(criteriaChip: string) {
this.criteriaChipSource.next(criteriaChip);
}

downloadCSVFile(rawCsvUrl: string, fileName: string): void {
const link = document.createElement('a');
link.href = rawCsvUrl;
link.download = fileName.endsWith('.csv') ? fileName : `${fileName}.csv`;

document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

}
34 changes: 23 additions & 11 deletions src/app/pages/mentor-details/mentor-details.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,32 @@ export class MentorDetailsPage implements OnInit {
this.detailData.data = this.mentorProfileData?.result;
this.detailData.data.organizationName = this.mentorProfileData?.result?.organization.name;
}
async getUpcomingSessions() {
async getUpcomingSessions(isLoadMore: boolean = false) {
const config = {
url: urlConstants.API_URLS.UPCOMING_SESSIONS + this.mentorId + "?page="+this.page + '&limit='+this.limit,
payload: {}
};
try {
let data = await this.httpService.get(config);
this.upcomingSessions = this.upcomingSessions.concat(data.result.data);
this.totalCount = data.result.count;
this.infiniteScroll.disabled = (this.upcomingSessions.length === this.totalCount) ? true : false;
const newSessions = data?.result?.data || [];

if (isLoadMore) {
this.upcomingSessions = [...this.upcomingSessions, ...newSessions];
} else {
this.upcomingSessions = newSessions;
}

this.totalCount = data?.result?.count || 0;

if (this.infiniteScroll) {
this.infiniteScroll.disabled = this.upcomingSessions.length >= this.totalCount;
}
}
catch (error) {
console.error('Error fetching upcoming sessions:', error);
if (this.infiniteScroll) {
this.infiniteScroll.disabled = true;
}
}
}

Expand Down Expand Up @@ -175,11 +189,9 @@ export class MentorDetailsPage implements OnInit {
}
}

loadMore(event){
setTimeout(() => {
this.page += 1;
this.getUpcomingSessions();
event.target.complete();
}, 1000);
async loadMore(event){
this.page += 1;
await this.getUpcomingSessions(true);
event.target.complete();
}
}
}
2 changes: 1 addition & 1 deletion src/app/pages/tabs/dashboard/dashboard.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1 style="text-align: center; color: var(--ion-color-primary);" class="my-0">
<div class="tables inner-div-style" *ngIf="selectedRole !=='org_admin'">
<ion-grid>
<ion-row *ngIf="chartBody?.tableUrl">
<lib-table [url]="chartBody?.tableUrl" [headers]="chartBody?.headers" [showDownload]="true" [title]="chartBody?.tableTitle | translate" style="width: 100%;" [metaKeys]="metaKeys"></lib-table>
<lib-table [url]="chartBody?.tableUrl" [headers]="chartBody?.headers" [showDownload]="true" [title]="chartBody?.tableTitle | translate" style="width: 100%;" [metaKeys]="metaKeys" (downloadEvent)="downloadCSV($event)"></lib-table>
</ion-row>
</ion-grid>
</div>
Expand Down
10 changes: 8 additions & 2 deletions src/app/pages/tabs/dashboard/dashboard.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import { BIG_NUMBER_DASHBOARD_FORM , DASHBOARD_TABLE_META_KEYS} from 'src/app/core/constants/formConstant';
import { HttpService } from 'src/app/core/services';
import { HttpService, UtilService } from 'src/app/core/services';
import { FormService } from 'src/app/core/services/form/form.service';
import * as moment from 'moment';
import { urlConstants } from 'src/app/core/constants/urlConstants';
Expand Down Expand Up @@ -54,7 +54,9 @@ export class DashboardPage implements OnInit {
private profile: ProfileService,
private apiService: HttpService,
private form: FormService,
private translate : TranslateService) { }
private translate : TranslateService,
private utilService: UtilService
) { }


ionViewWillEnter() {
Expand Down Expand Up @@ -333,5 +335,9 @@ export class DashboardPage implements OnInit {
}, 10);
this.chartBody.headers = await this.apiService.setHeaders();
}

downloadCSV(data: { url: string; fileName: string }) {
this.utilService.downloadCSVFile(data.url, data.fileName);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div *ngIf="!mentorsCount && isLoaded">
<app-no-data-found [messageHeader]="'NO_MENTORS_AVAILABLE'"> </app-no-data-found>
</div>
<ion-infinite-scroll #infinitescroll (ionInfinite)="loadMore($event)" >
<ion-infinite-scroll #infinitescroll [disabled]="isInfiniteScrollDisabled" (ionInfinite)="loadMore($event)" >
<ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="{{'LOADING' | translate}}">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
Expand Down
42 changes: 22 additions & 20 deletions src/app/pages/tabs/mentor-directory/mentor-directory.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { IonContent, IonInfiniteScroll } from '@ionic/angular';
import { IonContent } from '@ionic/angular';
import { urlConstants } from 'src/app/core/constants/urlConstants';
import {
HttpService,
Expand All @@ -14,8 +14,7 @@ import { CommonRoutes } from 'src/global.routes';
styleUrls: ['./mentor-directory.page.scss'],
})
export class MentorDirectoryPage implements OnInit {
@ViewChild(IonContent) content: IonContent;
@ViewChild(IonInfiniteScroll) infinitescroll: IonInfiniteScroll;
@ViewChild(IonContent) content: IonContent

page = 1; //todo: Enable pagenation
limit = 50;
Expand Down Expand Up @@ -43,6 +42,7 @@ export class MentorDirectoryPage implements OnInit {
directory: boolean = true;
selectedChips: boolean = false;
data: any;
isInfiniteScrollDisabled: boolean = false;

constructor(
private router: Router,
Expand All @@ -54,41 +54,43 @@ export class MentorDirectoryPage implements OnInit {
ngOnInit() {}

async ionViewWillEnter() {
this.isLoaded = false;
this.page = 1;
this.mentors = [];
this.getMentors();
this.isInfiniteScrollDisabled = false;
this.gotToTop();
}

gotToTop() {
this.content.scrollToTop(1000);
}

async getMentors(showLoader = true) {

async getMentors(showLoader = true ,isLoadMore: boolean =false) {
showLoader ? await this.loaderService.startLoader() : '';
const config = {
const config = {
url: urlConstants.API_URLS.MENTORS_DIRECTORY_LIST + this.page + '&limit=' + this.limit + '&search=' + btoa(this.searchText) + '&directory=' + this.directory + '&search_on=' + (this.selectedChipName? this.selectedChipName : '') + '&' + (this.urlFilterData ? this.urlFilterData: ''),
payload: {}
};
try {
let data: any = await this.httpService.get(config);
this.data = data.result.data;
this.isLoaded = true
this.isLoaded = true;
showLoader ? await this.loaderService.stopLoader() : '';
if (this.mentors.length && this.mentors[this.mentors.length - 1].key == data.result.data[0]?.key) {
this.mentors[this.mentors.length - 1].values = this.mentors[this.mentors.length - 1].values.concat(data.result.data[0].values)
data.result.data.shift();
this.mentors = this.mentors.concat(data.result.data);

if (isLoadMore) {
this.mentors = [...this.mentors, ...data.result.data];
} else {
this.mentors = this.mentors.concat(data.result.data);
this.mentors = data.result.data;
this.mentorsCount = data.result.count;
}
let totalValues = this.mentors.reduce((acc, mentor) => acc + (mentor.values?.length || 0), 0);
this.infinitescroll.disabled = this.mentorsCount == totalValues ? true : false;
}
catch (error) {
this.isLoaded = true
this.isInfiniteScrollDisabled = (totalValues >= this.mentorsCount) ;


} catch (error) {
this.isLoaded = true;
this.isInfiniteScrollDisabled = true;
showLoader ? await this.loaderService.stopLoader() : '';
}
}
Expand All @@ -99,10 +101,10 @@ export class MentorDirectoryPage implements OnInit {
break;
}
}
async loadMore(event) {
if(this.data){
this.page = this.directory ? this.page + 1 : this.page;
await this.getMentors(false);
async loadMore(event) {
if (this.data && !this.isInfiniteScrollDisabled) {
this.page = this.page + 1;
await this.getMentors(false, true);
}
event.target.complete();
}
Expand Down