Skip to content

Commit

Permalink
Issue #SB-000 merge: Merge pull request #3500 from swayangjit/release…
Browse files Browse the repository at this point in the history
…-5.2.0.1

Issue #SB-000 merge: Merge branch 'release-5.1.0.10' into release-5.2…
  • Loading branch information
swayangjit authored Oct 5, 2023
2 parents 5e6b8e8 + 159ace1 commit 0d4edb3
Show file tree
Hide file tree
Showing 25 changed files with 1,519 additions and 1,065 deletions.
1,130 changes: 584 additions & 546 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,20 @@
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-appavailability": "^0.4.2",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^6.0.0",
"cordova-plugin-chooser": "^1.3.2",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-document-viewer": "^0.9.13",
"cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer.git",
"cordova-plugin-file": "^7.0.0",
"cordova-plugin-file-transfer": "git+https://github.com/vishwanath1004/cordova-plugin-file-transfer.git",
"cordova-plugin-file": "^8.0.0",
"cordova-plugin-file-opener2": "^2.2.1",
"cordova-plugin-filechooser": "^1.2.0",
"cordova-plugin-filepath": "^1.5.8",
"cordova-plugin-filepicker": "^1.1.6",
"cordova-plugin-googleplus": "^8.5.2",
"cordova-plugin-inappbrowser": "^5.0.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-media": "^6.1.0",
"cordova-plugin-media": "^7.0.0",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-printer": "^0.8.0",
"cordova-plugin-secure-storage-echo": "^5.1.1",
Expand Down Expand Up @@ -190,9 +188,14 @@
"cordova-plugin-android-downloadmanager": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-downloadmanager.git",
"cordova-plugin-app-version": "^0.1.12",
"cordova-plugin-awesome-shared-preferences": "git+https://github.com/adriano-di-giovanni/cordova-plugin-shared-preferences.git",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-fcm-with-dependecy-updated": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-fcm.git#release-5.1.2",
"cordova-plugin-file": "^7.0.0",
"cordova-plugin-badge-fix": "^0.8.10",
"cordova-plugin-camera": "git+https://github.com/vishwanath1004/cordova-plugin-camera.git",
"cordova-plugin-code-push": "git+https://github.com/swayangjit/cordova-plugin-code-push.git",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-file-transfer": "git+https://github.com/vishwanath1004/cordova-plugin-file-transfer.git",
"cordova-plugin-filepath": "git+https://github.com/vishwanath1004/cordova-plugin-filepath.git",
"cordova-plugin-inappupdatemanager": "git+https://github.com/subranil/cordova-plugin-inappupdatemanager.git#release-3.7.0",
"cordova-plugin-local-notification": "git+https://github.com/fquirin/cordova-plugin-local-notifications.git",
"cordova-plugin-openrap": "git+https://github.com/project-sunbird/cordova-plugin-openrap.git",
Expand Down Expand Up @@ -359,4 +362,4 @@
"<rootDir>/src/app/manage-learn/"
]
}
}
}
5 changes: 3 additions & 2 deletions src/app/components/dashboard/dashboard.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('DashboardComponent', () => {
const mockCommonUtilService: Partial<CommonUtilService> = {
showToast: jest.fn(),
translateMessage: jest.fn(),
showSettingsPageToast: jest.fn()
showSettingsPageToast: jest.fn(),
isAndroidVer13: jest.fn()
};
const mockStoragePermissionHandlerService: Partial<StoragePermissionHandlerService> = {};
const mockAppVersion: Partial<AppVersion> = {
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('DashboardComponent', () => {
dashboardComponent.exportCsv()
// assert
setTimeout(() => {
expect(mockStoragePermissionHandlerService.checkForPermissions).toHaveBeenCalled();
// expect(mockStoragePermissionHandlerService.checkForPermissions).toHaveBeenCalled();
done()
});
})
Expand Down
57 changes: 33 additions & 24 deletions src/app/components/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,41 @@ export class DashboardComponent implements OnInit {
ID.DOWNLOAD_CLICKED
);
const appName = await this.appVersion.getAppName();
await this.storagePermissionHandlerService.checkForPermissions(PageId.ACTIVITY_DASHBOARD).then(async (result) => {
if (result) {
const expTime = new Date().getTime();
const filename = this.collectionName.trim() + '_' + expTime + '.csv';
const downloadDirectory = this.platform.is('ios') ? `${cordova.file.documentsDirectory}Download/` : cordova.file.externalDataDirectory
if(this.commonUtilService.isAndroidVer13()) {
this.handleExportCsv();
} else {
await this.storagePermissionHandlerService.checkForPermissions(PageId.ACTIVITY_DASHBOARD).then(async (result) => {
if (result) {
this.handleExportCsv();
} else {
await this.commonUtilService.showSettingsPageToast('FILE_MANAGER_PERMISSION_DESCRIPTION', appName, PageId.ACTIVITY_DASHBOARD, true);
}
}).catch((err) => {
console.log('checkForPermissions err', err);
});
}
}

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('checkForPermissions err', err);
});
handleExportCsv() {
const expTime = new Date().getTime();
const filename = this.collectionName.trim() + '_' + expTime + '.csv';
const downloadDirectory = this.platform.is('ios') ? `${cordova.file.documentsDirectory}Download/` : cordova.file.externalDataDirectory

} else {
this.commonUtilService.showSettingsPageToast('FILE_MANAGER_PERMISSION_DESCRIPTION', appName, PageId.ACTIVITY_DASHBOARD, true);
}
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);
});
}

Expand Down
Loading

0 comments on commit 0d4edb3

Please sign in to comment.