Skip to content

Commit

Permalink
Merge branch 'release-7.0.0' of https://github.com/Sunbird-Ed/Sunbird…
Browse files Browse the repository at this point in the history
…Ed-mobile-app into release-7.0.0_ED-4197
  • Loading branch information
sujithsojan committed May 3, 2024
2 parents e461cc2 + 1c0c45f commit 587db38
Show file tree
Hide file tree
Showing 32 changed files with 4,753 additions and 4,430 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ jobs:
path: coverage
- run:
name: install sonar scanner
command: sudo npm install -g [email protected]
command: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
unzip || sudo apt install unzip -y
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
- run:
name: Run SonarScan
command: sonar-scanner
command: sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner
2 changes: 1 addition & 1 deletion build_config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cordova-plugin=https://github.com/swayangjit/cordova-plugin-document-viewer.git
cordova-plugin=com-sarriaroman-photoviewer
cordova-plugin=https://github.com/shikshalokam/cordova-plugin-filepath.git
cordova-plugin=https://github.com/greybax/cordova-plugin-proguard.git
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-utility/tree/release-6.0.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-6.0.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-downloadmanager.git
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-4.6.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs#release-5.0.2 --variable URL_SCHEME=@string/custom_scheme_url --variable URL_HOST=mobile
Expand Down
8,651 changes: 4,417 additions & 4,234 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@awesome-cordova-plugins/chooser": "6.3.0",
"@awesome-cordova-plugins/core": "6.3.0",
"@awesome-cordova-plugins/device": "6.3.0",
"@awesome-cordova-plugins/diagnostic": "6.3.0",
"@awesome-cordova-plugins/diagnostic": "6.5.0",
"@awesome-cordova-plugins/fcm": "^6.3.0",
"@awesome-cordova-plugins/file": "6.3.0",
"@awesome-cordova-plugins/file-chooser": "6.3.0",
Expand Down Expand Up @@ -67,7 +67,7 @@
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@project-sunbird/client-services": "7.0.4",
"@project-sunbird/common-consumption": "6.0.1",
"@project-sunbird/common-consumption": "7.0.6",
"@project-sunbird/common-form-elements": "6.0.0",
"@project-sunbird/content-player": "5.1.0",
"@project-sunbird/discussions-ui": "5.3.0-beta.0",
Expand Down Expand Up @@ -206,7 +206,7 @@
"cordova-plugin-zip": "^3.1.0",
"cordova-sqlite-storage": "^6.0.0",
"cordova-zip-plugin": "git+https://github.com/Sunbird-Ed/jjdltc-cordova-plugin-zip.git",
"cordova.plugins.diagnostic": "^5.0.2",
"cordova.plugins.diagnostic": "^7.1.4",
"es6-promise-plugin": "^4.2.2",
"fs-extra": "^8.1.0",
"ionic-plugin-keyboard": "^2.2.1",
Expand All @@ -217,7 +217,7 @@
"sb-cordova-plugin-db": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-4.6.0",
"sb-cordova-plugin-sync": "git+https://github.com/project-sunbird/sb-cordova-plugin-sync.git",
"sb-cordova-plugin-utility": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-6.0.0",
"sonarqube-scanner": "^2.5.0",
"sonarqube-scanner": "2.9.0",
"tiny-glob": "^0.2.9",
"ts-node": "^10.9.1",
"tslint": "~6.1.0",
Expand Down Expand Up @@ -260,9 +260,6 @@
"ANDROID_SUPPORT_V4_VERSION": "26.+"
},
"cordova-plugin-code-push": {},
"cordova.plugins.diagnostic": {
"ANDROID_SUPPORT_VERSION": "28.+"
},
"cordova-plugin-openrap": {},
"cordova-plugin-webview-checker": {},
"sb-cordova-plugin-utility": {},
Expand Down Expand Up @@ -294,7 +291,11 @@
"uk.co.workingedge.phonegap.plugin.istablet": {},
"cordova-plugin-console": {},
"cordova-plugin-sunbirdsplash": {},
"cordova-plugin-document-viewer": {}
"cordova-plugin-document-viewer": {},
"cordova.plugins.diagnostic": {
"ANDROIDX_VERSION": "1.0.0",
"ANDROIDX_APPCOMPAT_VERSION": "1.3.1"
}
},
"platforms": [
"ios"
Expand Down Expand Up @@ -384,4 +385,4 @@
"<rootDir>/src/app/manage-learn/"
]
}
}
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sonar.projectKey=Sunbird-Ed_SunbirdEd-mobile-app
sonar.host.url=https://sonarcloud.io
sonar.organization=sunbird-ed
sonar.projectVersion=1.0
sonar.coverage.exclusions=**/*.module.ts, src/app/animations/*.ts
sonar.coverage.exclusions=**/*.module.ts, src/app/animations/*.ts
3 changes: 2 additions & 1 deletion src/__tests__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ global.cordova = {
open: () => ({
executeScript: () => { },
addEventListener: () => { },
close: () => { }
close: () => { },
insertCSS: () => {}
})
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/category-list/category-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class CategoryListPage implements OnInit, OnDestroy {
this.primaryFacetFiltersFormGroup.patchValue(
this.primaryFacetFilters.reduce((acc, p) => {
if (p) {
this.displayFacetFilters[p.code].sort((a, b) => a.name > b.name && 1 || -1);
this.displayFacetFilters[p.code]?.sort((a, b) => a.name > b.name && 1 || -1);
}
acc[p.code] = this.facetFilters[p.code] ? this.facetFilters[p.code]
.filter(v => v.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[showDownloadBtn]="showDownloadBtn"
[isDepthChild]='isDepthChild'
[defaultAppIcon]="defaultAppIcon"
[trackDownloads]="trackDownloads$">
[trackDownloads]="trackDownloads$"
[frameworkCategories]="categories">
</app-detail-card>
<!-- End of the Parent Card -->

Expand Down
30 changes: 20 additions & 10 deletions src/app/components/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<div class="dashlet-table-container">
<sb-dashlet [type]="'table'" [data]="DashletRowData" [config]="columnConfig" #lib>
<ng-template sbTemplateRef="header" let-config>
<div>
<span (click)="exportCsv()" class="ad-csv-btn float-end">
<span class="ad-dw">{{'DOWNLOAD_CSV' | translate}}</span>
<img src="assets/imgs/download-icon.svg" alt="download" aria-hidden="true">
</span>
</div>
</ng-template>
</sb-dashlet>
<div>
<span (click)="exportCsv()" class="ad-csv-btn float-end">
<span class="ad-dw">{{'DOWNLOAD_CSV' | translate}}</span>
<img src="assets/imgs/download-icon.svg" alt="download" aria-hidden="true">
</span>
</div>
<div style="padding-top: 1rem;">
<table class="dataTable">
<thead>
<tr role="row">
<th class="sorting" *ngFor="let clmn of columnConfig?.columnConfig; let i = index" (click)="handleSort(i)">{{clmn.title}}</th>
</tr>
</thead>
<tbody>
<tr role="row" *ngFor="let data of DashletRowData?.values">
<td *ngFor="let clmn of columnConfig?.columnConfig">{{data[clmn.data]}}</td>
</tr>
</tbody>
</table>
</div>
</div>
29 changes: 28 additions & 1 deletion src/app/components/dashboard/dashboard.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,31 @@
.ad-csv-btn{
position: relative;
bottom: 0.625rem;
}
}

table {
font-family: arial, sans-serif;
border-radius: var(--sbt-bradius-24);
display: table;
overflow: hidden;
width: 100% !important;
margin: 0 auto 1rem;
clear: both;
border-collapse: separate;
border-spacing: 0;
font-size: .875rem;
box-shadow: 0.375rem 0.375rem 0.125rem #0000001a;
border-bottom: 0px !important;
background: var(--white);
border: .0625rem solid var(--rc-dddddd);
cursor: pointer;
}

td, th {
text-align: left;
padding: 8px;
}

table tbody tr:nth-child(odd) {
background-color: var(--gray-0) !important;
}
109 changes: 91 additions & 18 deletions src/app/components/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { Environment, ID, InteractType, PageId } from '../../../services/telemetry-constants';
import { CommonUtilService } from '../../../services/common-util.service';
import { TelemetryGeneratorService } from '../../../services/telemetry-generator.service';
Expand All @@ -13,7 +13,7 @@ import 'datatables.net-fixedcolumns';
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss'],
})
export class DashboardComponent implements OnInit {
export class DashboardComponent implements OnInit, AfterViewInit {
@Input() dashletData: any;
@Input() collectionName: string;
DashletRowData = { values: [] };
Expand Down Expand Up @@ -41,6 +41,62 @@ export class DashboardComponent implements OnInit {
this.columnConfig.columnConfig = this.dashletData.columns;
}

ngAfterViewInit() {
let ele = document.querySelectorAll('th')
if(ele) {
ele.forEach((th, i) => {
th.className = ""
if(i == 0) {
th.className = "sorting_asc"
} else {
th.className = "sorting"
}
});
}
}

handleSort(i) {
let sortClmn = this.columnConfig.columnConfig[i].data
let ele = document.querySelectorAll('th')
if(ele) {
ele.forEach((th, indx) => {
if(i == indx && th.className == "sorting") {
this.sortAscDesc(sortClmn, "asc");
th.className = ""
th.className = "sorting_asc"
} else if(i == indx && th.className == "sorting_asc") {
this.sortAscDesc(sortClmn, "desc");
th.className = ""
th.className = "sorting_desc"
} else if(i == indx && th.className == "sorting_desc") {
this.sortAscDesc(sortClmn, "asc");
th.className = ""
th.className = "sorting_asc"
} else {
th.className = ""
th.className = "sorting"
}
});
}
}

sortAscDesc(sortClmn, type) {
this.DashletRowData.values.sort((a, b) => {
if (typeof(a[sortClmn]) == 'string') {
const strA = a[sortClmn].toUpperCase();
const strB = b[sortClmn].toUpperCase();
if (strA < strB) {
return type == "asc" ? -1 : 1;
}
if (strA > strB) {
return type == "asc" ? 1 : -1;
}
return 0;
} else {
return type == "asc" ? a[sortClmn] - b[sortClmn] : b[sortClmn] - a[sortClmn]
}
});
}

async exportCsv() {
this.telemetryGeneratorService.generateInteractTelemetry(
Expand Down Expand Up @@ -75,22 +131,39 @@ export class DashboardComponent implements OnInit {
const filename = this.collectionName.trim() + '_' + expTime + '.csv';
const downloadDirectory = this.platform.is('ios') ? `${cordova.file.documentsDirectory}Download/` : cordova.file.externalDataDirectory

this.lib.instance.exportCsv({ 'strict': true }).then((csvData) => {
console.log('exportCSVdata', csvData);
this.file.writeFile(downloadDirectory, filename, csvData, { replace: true })
.then((res) => {
console.log('rs write file', res);
this.openCsv(res.nativeURL);
this.commonUtilService.showToast(
this.commonUtilService.translateMessage('DOWNLOAD_COMPLETED', filename), false, 'custom-toast');
})
.catch((err) => {
this.writeFile(downloadDirectory, csvData);
console.log('writeFile err', err);
});
}).catch((err) => {
console.log('export csv err', err);
});
let csvData = this.convertJsonToCsv()
console.log('exportCSVdata', csvData);
this.file.writeFile(downloadDirectory, filename, csvData, { replace: true })
.then((res) => {
console.log('rs write file', res);
this.openCsv(res.nativeURL);
this.commonUtilService.showToast(
this.commonUtilService.translateMessage('DOWNLOAD_COMPLETED', filename), false, 'custom-toast');
})
.catch((err) => {
this.writeFile(downloadDirectory, csvData);
console.log('writeFile err', err);
});
}

convertJsonToCsv(): string {
let oftionData = this.columnConfig?.columnConfig?.map(function (obj) {
return obj.title;
});;
const header = oftionData ? (oftionData).join(",") + "\n" : Object.keys(this.DashletRowData?.values[0]).join(",") + "\n"; // TO Generate the CSV header
let csvData = header;
for (const row of this.DashletRowData?.values) {
const values = Object.values(row).map((value: any) => {
// Check if the value contains commas
if (typeof value === 'string' && value.includes(',')) {
// Escape the value by wrapping it in double quotes and replacing any double quotes within the value
return `"${value.replace(/"/g, '""')}"`;
}
return value;
});
csvData += values.join(",") + "\n";
}
return csvData;
}

openCsv(path) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/detail-card/detail-card.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="sb-dt-card">
<app-toc-header [contentData]="contentDetail?.contentData"></app-toc-header>
<app-toc-header [contentData]="contentDetail?.contentData" [frameworkCategories]="frameworkCategories"></app-toc-header>
<div class="sb-dt-content pt-0">
<div class="left">
</div>
Expand Down
1 change: 1 addition & 0 deletions src/app/components/detail-card/detail-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class DetailCardComponent {
@Input() showDownloadBtn: boolean;
@Input() isDepthChild: boolean;
@Input() trackDownloads: Observable<DownloadTracking>;
@Input() frameworkCategories: any;

@Output() downloadAllContent = new EventEmitter();
@Output() showOverflowMenuEvent = new EventEmitter();
Expand Down
17 changes: 4 additions & 13 deletions src/app/components/toc-header/toc-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@
<span class="sb-by">{{ 'CONTENT_CREATED_BY' | translate }}</span>
<span class="sb-user">{{ contentData?.owner || contentData?.creator}}</span>
</div>
<div class="sb-dt-class-info" *ngIf="contentData?.gradeLevel || contentData?.subject">
<span *ngIf="contentData?.board">
<span class="sb-dt-label sb-dt-subject">{{contentData?.board}}</span>
<span class="sb-separator-dot"></span>
<div class="sb-dt-class-info">
<span *ngFor="let category of frameworkCategories; let i = index">
<span class="sb-dt-label sb-dt-subject" *ngIf="contentData?.[category.code] || contentData?.[category.alterNativeCode]">{{contentData[category.code] || contentData[category.alterNativeCode]}}</span>
<span class="sb-separator-dot" *ngIf="i < frameworkCategories.length-1 && (contentData?.[category.code] || contentData?.[category.alterNativeCode])"></span>
</span>
<span *ngIf="contentData?.medium">
<span class="sb-dt-label sb-dt-subject">{{contentData?.medium}}</span>
<span class="sb-separator-dot"></span>
</span>
<span *ngIf="contentData?.gradeLevel">
<span class="sb-dt-label sb-dt-subject">{{contentData?.gradeLevel}}</span>
<span class="sb-separator-dot"></span>
</span>
<span class="sb-dt-label sb-dt-subject">{{contentData?.subject | csa}}</span>
</div>
</div>
<div class="right">
Expand Down
1 change: 1 addition & 0 deletions src/app/components/toc-header/toc-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CommonUtilService } from '../../../services/common-util.service';
})
export class TocHeaderComponent {
@Input() contentData: ContentData;
@Input() frameworkCategories: any;

// defaultIcon
defaultAppIcon: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-content>
<div class="p-8" *ngIf="!showOfflineSection">
<ion-card class="sb-dt-card">
<app-toc-header [contentData]="course || courseCardData?.content"></app-toc-header>
<app-toc-header [contentData]="course || courseCardData?.content" [frameworkCategories]="categories"></app-toc-header>
<div class="hr-border-bottom"></div>
<ion-card-content class="sb-content-info">
<div *ngIf="isFromGroupFlow">
Expand Down
Loading

0 comments on commit 587db38

Please sign in to comment.