diff --git a/src/app/dashboard/partner-details/partner-details.component.html b/src/app/dashboard/partner-details/partner-details.component.html index cfb727d..0bbdb4a 100644 --- a/src/app/dashboard/partner-details/partner-details.component.html +++ b/src/app/dashboard/partner-details/partner-details.component.html @@ -514,7 +514,8 @@
-
+
+
Select Data Type
diff --git a/src/app/dashboard/partner-details/partner-details.component.ts b/src/app/dashboard/partner-details/partner-details.component.ts index 53c330f..6bf2331 100644 --- a/src/app/dashboard/partner-details/partner-details.component.ts +++ b/src/app/dashboard/partner-details/partner-details.component.ts @@ -65,6 +65,21 @@ export class PartnerDetailsComponent implements OnInit { let surveyCtoData: Array = []; + let areaOfWork: any = []; + let branchLocationCountries: any = []; + let communities: any = []; + let preferredLanguages: any = []; + let primaryAreasOfSupportOffered: any = []; + let primaryAreasOfSupportRequired: any = []; + + partnerData.strengthAndCapability.primaryAreasOfSupportOffered.forEach(x => { primaryAreasOfSupportOffered.push(x.name) }) + partnerData.strengthAndCapability.primaryAreasOfSupportRequired.forEach(x => { primaryAreasOfSupportRequired.push(x.name) }) + partnerData.detailedProfile.preferredLanguages.forEach(x => { preferredLanguages.push(x.name) }) + partnerData.detailedProfile.communities.forEach(x => { communities.push(x.name) }) + partnerData.detailedProfile.branchLocationCountries.forEach(x => { branchLocationCountries.push(x.name) }) + partnerData.organizationBasicInfo.areasOfWork.forEach(x => { areaOfWork.push(x.name) }) + + exportData = [{ "PortalID": partnerData.portalId ? partnerData.portalId : '-', @@ -77,7 +92,7 @@ export class PartnerDetailsComponent implements OnInit { // Basic Info - "Areas Of Work": partnerData.organizationBasicInfo.areasOfWork ? partnerData.organizationBasicInfo.areasOfWork.map(option => option.name).join(', ') : '', + "Areas Of Work": areaOfWork.toString(), "Name": partnerData.organizationBasicInfo.name, "Reason For Becoming Member": partnerData.organizationBasicInfo.reasonForBecomingMember, "Referral Name": partnerData.organizationBasicInfo.referralName, @@ -96,18 +111,18 @@ export class PartnerDetailsComponent implements OnInit { // Detailed Profile 'Bio': partnerData.detailedProfile.bio, - 'Branch Location Countries': partnerData.detailedProfile.branchLocationCountries ? partnerData.detailedProfile.branchLocationCountries.map(option => option.name).join(', ') : '', - "Communities": partnerData.detailedProfile.communities ? partnerData.detailedProfile.communities.map(option => option.name).join(', ') : '', + 'Branch Location Countries': branchLocationCountries.toString(), + "Communities": communities.toString(), "District": partnerData.detailedProfile.district, - "Districts": partnerData.detailedProfile.districts ? partnerData.detailedProfile.districts.map(option => option.name).join(', ') : '', + "Districts": partnerData.detailedProfile.districts ? partnerData.detailedProfile.districts.toString() : '', "Files": partnerData.detailedProfile.files, "Have Branches In Other Districts": partnerData.detailedProfile.haveBranchesInOtherDistricts, "Logo": partnerData.detailedProfile.logo, - "partnerData Location": partnerData.detailedProfile.partnerLocation, - "Preferred Languages": partnerData.detailedProfile.preferredLanguages ? partnerData.detailedProfile.preferredLanguages.map(option => option.name).join(', ') : '', - "Preferred Mode Of Communications": partnerData.detailedProfile.preferredModeOfCommunications ? partnerData.detailedProfile.preferredModeOfCommunications.map(option => option.name).join(', ') : '', + "partner Location": partnerData.detailedProfile.partnerLocation, + "Preferred Languages": preferredLanguages.toString(), + "Preferred Mode Of Communications": partnerData.detailedProfile.preferredModeOfCommunications ? partnerData.detailedProfile.preferredModeOfCommunications.toString() : '', "State": partnerData.detailedProfile.state, - "States": partnerData.detailedProfile.states ? partnerData.detailedProfile.states.map(option => option.name).join(', ') : '', + "States": partnerData.detailedProfile.states ? partnerData.detailedProfile.states.toString() : '', "Total Reach Of Organization": partnerData.detailedProfile.totalReachOfOrganization, "Year Of Establishment": partnerData.detailedProfile.yearOfEstablishment, @@ -115,10 +130,10 @@ export class PartnerDetailsComponent implements OnInit { "Other Specific Support Required": partnerData.strengthAndCapability.otherSpecificSupportRequired, "Primary Areas Of Support Offered": partnerData.strengthAndCapability.otherSpecificSupportRequired ? partnerData.strengthAndCapability.otherSpecificSupportRequired.toString() : '', - "Primary Areas Of Support Offered Description": partnerData.strengthAndCapability.primaryAreasOfSupportOffered.map(option => option.name).join(', '), + "Primary Areas Of Support Offered Description": primaryAreasOfSupportOffered.toString(), "Primary Areas Of Support Offered Other": partnerData.strengthAndCapability.primaryAreasOfSupportOfferedDescription, "Primary Areas Of Support Required": partnerData.strengthAndCapability.primaryAreasOfSupportOfferedOther ? partnerData.strengthAndCapability.primaryAreasOfSupportOfferedOther.toString() : '', - "Primary Areas Of Support Required Description": partnerData.strengthAndCapability.primaryAreasOfSupportRequired.map(option => option.name).join(', '), + "Primary Areas Of Support Required Description": primaryAreasOfSupportRequired.toString(), "Primary Areas Of Support Required Other": partnerData.strengthAndCapability.primaryAreasOfSupportRequiredOther, }] @@ -206,22 +221,30 @@ export class PartnerDetailsComponent implements OnInit { this.loadExportData(this.partnerDetails) + const fileTypeCSV = 'text/csv;charset=utf-8;', + element = document.createElement('a'); + let blob; const partnerData = XLSX.utils.json_to_sheet(this.exportData); const hiiData = XLSX.utils.json_to_sheet(this.exportSurveyCtoData[0]); const spData = XLSX.utils.json_to_sheet(this.exportSurveyCtoData[1]); const spSchema = XLSX.utils.json_to_sheet(this.exportSurveyCtoData[2]); const wb = XLSX.utils.book_new(); - + if (exportType === 'CSV') { if (this.isProfileData) { - this.exportJsonToCSV(this.exportData,['ProfileData']) + let csvData = Papa.unparse(this.exportData); + blob = new Blob([csvData], { type: fileTypeCSV }); + let url = URL.createObjectURL(blob); + element.href = url; + element.setAttribute('download', 'ProfileData' + '.csv'); + element.click(); } else if (this.isImplementationData) { this.exportJsonToCSV(this.exportSurveyCtoData, ['HiiData', 'SPData', 'SPSchemaData']) } else { let completeData = this.exportSurveyCtoData completeData.push(this.exportData) - this.exportJsonToCSV(completeData, ['ProfileData', 'HiiData', 'SPData', 'SPSchemaData']) + this.exportJsonToCSV(completeData, ['HiiData', 'SPData', 'SPSchemaData', 'ProfileData',]) } } else { if (this.isProfileData) { @@ -243,7 +266,6 @@ export class PartnerDetailsComponent implements OnInit { } exportJsonToCSV(csvData: any, fileName?: any) { - console.log(fileName) const fileTypeCSV = 'text/csv;charset=utf-8;', element = document.createElement('a'); let blob; diff --git a/src/app/dashboard/table/table.component.html b/src/app/dashboard/table/table.component.html index 313c5c9..aaf5fa5 100644 --- a/src/app/dashboard/table/table.component.html +++ b/src/app/dashboard/table/table.component.html @@ -23,11 +23,10 @@ -
-
-
Filters:
+
Filters:
+
diff --git a/src/app/dashboard/table/table.component.scss b/src/app/dashboard/table/table.component.scss index aedb9e4..afa931c 100644 --- a/src/app/dashboard/table/table.component.scss +++ b/src/app/dashboard/table/table.component.scss @@ -28,20 +28,18 @@ } .filter-row { - padding: 5px 15px; - display: flex; - align-items: center; - - .explainer { - flex-basis: 150px; - font-style: italic; - color: silver; - } + display: grid; + align-items: stretch; + grid-template-columns: 1fr 1fr 1fr 1fr; + justify-content: flex-end; + grid-gap: 10px; + margin: 0px 0px 20px 0px; +} - ng-select { - flex-grow: 1; - margin: 0 5px; - } +.explainer { + font-style: italic; + color: silver; + margin: 20px 0 10px; } .card { diff --git a/src/app/dashboard/table/table.component.ts b/src/app/dashboard/table/table.component.ts index 4193a1c..c8f6c20 100644 --- a/src/app/dashboard/table/table.component.ts +++ b/src/app/dashboard/table/table.component.ts @@ -140,6 +140,7 @@ export class TableComponent implements OnInit { this.partialLoad(this.userData.slice(0, 100)) }, (e) => console.log(e)); + this.selectedPartnerList = []; } partialLoad(data: Array) { @@ -171,6 +172,22 @@ export class TableComponent implements OnInit { let surveyCtoData: Array = []; for (const partner of this.selectedPartnerList) { + + let areaOfWork: any = []; + let branchLocationCountries: any = []; + let communities: any = []; + let preferredLanguages: any = []; + let primaryAreasOfSupportOffered: any = []; + let primaryAreasOfSupportRequired: any = []; + + partner.strengthAndCapability.primaryAreasOfSupportOffered.forEach(x => { primaryAreasOfSupportOffered.push(x.name)}) + partner.strengthAndCapability.primaryAreasOfSupportRequired.forEach(x => { primaryAreasOfSupportRequired.push(x.name)}) + partner.detailedProfile.preferredLanguages.forEach(x => { preferredLanguages.push(x.name)}) + partner.detailedProfile.communities.forEach(x => { communities.push(x.name)}) + partner.detailedProfile.branchLocationCountries.forEach(x => { branchLocationCountries.push(x.name)}) + partner.organizationBasicInfo.areasOfWork.forEach(x => { areaOfWork.push(x.name)}) + + let partnerDetails = { "PortalID": partner.portalId ? partner.portalId : '-', @@ -183,7 +200,7 @@ export class TableComponent implements OnInit { // Basic Info - "Areas Of Work": partner.organizationBasicInfo.areasOfWork ? partner.organizationBasicInfo.areasOfWork.toString() : '', + "Areas Of Work": areaOfWork.toString(), "Name": partner.organizationBasicInfo.name, "Reason For Becoming Member": partner.organizationBasicInfo.reasonForBecomingMember, "Referral Name": partner.organizationBasicInfo.referralName, @@ -202,15 +219,15 @@ export class TableComponent implements OnInit { // Detailed Profile 'Bio': partner.detailedProfile.bio, - 'Branch Location Countries': partner.detailedProfile.branchLocationCountries ? partner.detailedProfile.branchLocationCountries.toString() : '', - "Communities": partner.detailedProfile.communities ? partner.detailedProfile.communities.toString() : '', + 'Branch Location Countries': branchLocationCountries.toString(), + "Communities": communities.toString(), "District": partner.detailedProfile.district, "Districts": partner.detailedProfile.districts ? partner.detailedProfile.districts.toString() : '', "Files": partner.detailedProfile.files, "Have Branches In Other Districts": partner.detailedProfile.haveBranchesInOtherDistricts, "Logo": partner.detailedProfile.logo, "partner Location": partner.detailedProfile.partnerLocation, - "Preferred Languages": partner.detailedProfile.preferredLanguages ? partner.detailedProfile.preferredLanguages.toString() : '', + "Preferred Languages": preferredLanguages.toString(), "Preferred Mode Of Communications": partner.detailedProfile.preferredModeOfCommunications ? partner.detailedProfile.preferredModeOfCommunications.toString() : '', "State": partner.detailedProfile.state, "States": partner.detailedProfile.states ? partner.detailedProfile.states.toString() : '', @@ -221,13 +238,15 @@ export class TableComponent implements OnInit { "Other Specific Support Required": partner.strengthAndCapability.otherSpecificSupportRequired, "Primary Areas Of Support Offered": partner.strengthAndCapability.otherSpecificSupportRequired ? partner.strengthAndCapability.otherSpecificSupportRequired.toString() : '', - "Primary Areas Of Support Offered Description": partner.strengthAndCapability.primaryAreasOfSupportOffered, + "Primary Areas Of Support Offered Description": primaryAreasOfSupportOffered.toString(), "Primary Areas Of Support Offered Other": partner.strengthAndCapability.primaryAreasOfSupportOfferedDescription, "Primary Areas Of Support Required": partner.strengthAndCapability.primaryAreasOfSupportOfferedOther ? partner.strengthAndCapability.primaryAreasOfSupportOfferedOther.toString() : '', - "Primary Areas Of Support Required Description": partner.strengthAndCapability.primaryAreasOfSupportRequired, + "Primary Areas Of Support Required Description": primaryAreasOfSupportRequired.toString(), "Primary Areas Of Support Required Other": partner.strengthAndCapability.primaryAreasOfSupportRequiredOther, } + exportData.push(partnerDetails); + console.log(exportData) let surveyCtoHIIData = []; for (const hiidata of partner.surveyCtoData.hiiData) { @@ -308,6 +327,10 @@ export class TableComponent implements OnInit { exportProfileData(exportType: exportType) { this.loadExportData(); + const fileTypeCSV = 'text/csv;charset=utf-8;', + element = document.createElement('a'); + let blob; + const partnerData = XLSX.utils.json_to_sheet(this.exportData); const hiiData = XLSX.utils.json_to_sheet(this.exportSurveyCtoData[0]); const spData = XLSX.utils.json_to_sheet(this.exportSurveyCtoData[1]); @@ -317,13 +340,19 @@ export class TableComponent implements OnInit { if (exportType === 'CSV') { if (this.isProfileData) { - this.exportJsonToCSV(this.exportData,['ProfileData']) + let csvData = Papa.unparse(this.exportData); + blob = new Blob([csvData], { type: fileTypeCSV }); + let url = URL.createObjectURL(blob); + element.href = url; + element.setAttribute('download', 'ProfileData' + '.csv'); + element.click(); } else if (this.isImplementationData) { this.exportJsonToCSV(this.exportSurveyCtoData, ['HiiData', 'SPData', 'SPSchemaData']) } else { let completeData = this.exportSurveyCtoData completeData.push(this.exportData) - this.exportJsonToCSV(completeData, ['ProfileData', 'HiiData', 'SPData', 'SPSchemaData']) + + this.exportJsonToCSV(completeData, ['HiiData', 'SPData', 'SPSchemaData', 'ProfileData',]) } } else { if (this.isProfileData) {