-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #495 from rahulramakrishnan3/release-3.0.0
bulk upload story 1173
- Loading branch information
Showing
12 changed files
with
184 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,7 @@ | |
color: #6da6f2; | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
.normal-case { | ||
text-transform: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/app/shared/components/bulk-upload/bulk-upload.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ion-grid> | ||
<ion-row class="d-flex flex-justify-center"> | ||
<div class="ion-margin ion-padding"> | ||
<ion-button class="btn-width-200" | ||
(click)="downloadCSV()">{{"DOWNLOAD_SAMPLE_CSV"|translate}}</ion-button> | ||
</div> | ||
<div class="ion-margin ion-padding"> | ||
<ion-button class="btn-width-200" | ||
(click)="upload.click()">{{"UPLOAD_CSV"|translate}}</ion-button> | ||
<input type="file" accept=".csv" (change)="uploadCSV($event)" hidden #upload /> | ||
</div> | ||
</ion-row> | ||
</ion-grid> |
Empty file.
24 changes: 24 additions & 0 deletions
24
src/app/shared/components/bulk-upload/bulk-upload.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { BulkUploadComponent } from './bulk-upload.component'; | ||
|
||
describe('BulkUploadComponent', () => { | ||
let component: BulkUploadComponent; | ||
let fixture: ComponentFixture<BulkUploadComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ BulkUploadComponent ], | ||
imports: [IonicModule.forRoot()] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(BulkUploadComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
src/app/shared/components/bulk-upload/bulk-upload.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { ToastService } from 'src/app/core/services'; | ||
import { OrganisationService } from 'src/app/core/services/organisation/organisation.service'; | ||
import { SessionService } from 'src/app/core/services/session/session.service'; | ||
|
||
@Component({ | ||
selector: 'app-bulk-upload', | ||
templateUrl: './bulk-upload.component.html', | ||
styleUrls: ['./bulk-upload.component.scss'], | ||
}) | ||
export class BulkUploadComponent implements OnInit { | ||
|
||
@Input() data: any; | ||
uploadData: any; | ||
|
||
constructor( | ||
private toast: ToastService, | ||
private organisation: OrganisationService, | ||
private sessionService:SessionService | ||
) { } | ||
|
||
ngOnInit() {} | ||
|
||
async downloadCSV(){ | ||
if(this.data){ | ||
let response = await this.organisation.downloadCsv(this.data?.downloadCsvApiUrl); | ||
if(response){this.sessionService.openBrowser(response,"_blank")} | ||
} | ||
} | ||
|
||
async uploadCSV(event){ | ||
let file= event.target.files[0]; | ||
if(file.type != 'text/csv'){ | ||
this.toast.showToast('PLEASE_UPLOAD_CSV_FILE', 'danger') | ||
event.target.value=''; | ||
}else{ | ||
let signedUrl = await this.organisation.getSignedUrl(event.target.files[0].name); | ||
this.organisation.upload(event.target.files[0], signedUrl).subscribe(async () => { | ||
let data = await this.organisation.bulkUpload(signedUrl.filePath,this.data?.uploadCsvApiUrl); | ||
if(data){ | ||
this.toast.showToast(data.message, 'success'); | ||
event.target.value=''; | ||
} | ||
(error) => event.target.value=''; | ||
}) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters