forked from openMF/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add identities-tab component - add upload-document-dialog component - remove content-type header from authentication interceptor fixes: openMF#261
- Loading branch information
Showing
15 changed files
with
376 additions
and
7 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
62 changes: 62 additions & 0 deletions
62
src/app/clients/clients-view/identities-tab/identities-tab.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,62 @@ | ||
<div class="tab-container mat-typography"> | ||
|
||
<!-- Identities Table --> | ||
|
||
<h3>Identities</h3> | ||
|
||
<button mat-raised-button class="f-right" color="primary"> | ||
<fa-icon icon="plus"></fa-icon> Add | ||
</button> | ||
|
||
<table mat-table #identifiersTable [dataSource]="clientIdentities" class="mat-elevation-z1"> | ||
|
||
<ng-container matColumnDef="id"> | ||
<th mat-header-cell *matHeaderCellDef> Id </th> | ||
<td mat-cell *matCellDef="let identity"> | ||
{{identity.id}} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="description"> | ||
<th mat-header-cell *matHeaderCellDef> Description </th> | ||
<td mat-cell *matCellDef="let identity"> {{identity.description}} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="type"> | ||
<th mat-header-cell *matHeaderCellDef> type </th> | ||
<td mat-cell *matCellDef="let identity"> {{identity.documentType.name}} | ||
</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="documents"> | ||
<th mat-header-cell *matHeaderCellDef>Identity Documents </th> | ||
<td mat-cell *matCellDef="let identity"> | ||
<div *ngFor="let document of identity.documents"> | ||
{{document.name}} | ||
<fa-icon icon="cloud-download-alt" (click)="download(document.parentEntityId,document.id)"></fa-icon> | ||
</div> | ||
</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="status"> | ||
<th mat-header-cell *matHeaderCellDef> Status </th> | ||
<td mat-cell *matCellDef="let identity"> | ||
{{(identity.status==='clientIdentifierStatusType.active')?'active':'inactive'}} </td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="actions"> | ||
<th mat-header-cell *matHeaderCellDef> Actions </th> | ||
<td mat-cell *matCellDef="let identity; let i = index"> | ||
<button class="identity-action-button" mat-raised-button color="primary" (click)="uploadDocument(i,identity.id)"> | ||
<fa-icon icon="cloud-upload-alt"></fa-icon> | ||
</button> | ||
<button class="identity-action-button" mat-raised-button color="warn" (click)="deleteIdentifier(identity.clientId,identity.id,index)"> | ||
<fa-icon icon="times"></fa-icon> | ||
</button> | ||
</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="identitiesColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: identitiesColumns;"></tr> | ||
</table> | ||
|
||
</div> |
18 changes: 18 additions & 0 deletions
18
src/app/clients/clients-view/identities-tab/identities-tab.component.scss
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,18 @@ | ||
.tab-container { | ||
padding: 1%; | ||
margin: 1%; | ||
|
||
h3{ | ||
margin:1% auto; | ||
} | ||
table { | ||
width: 100%; | ||
.identity-action-button{ | ||
min-width: 26px; | ||
padding: 0 6px; | ||
margin: 4px; | ||
line-height: 25px; | ||
} | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/app/clients/clients-view/identities-tab/identities-tab.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { IdentitiesTabComponent } from './identities-tab.component'; | ||
|
||
describe('IdentitiesTabComponent', () => { | ||
let component: IdentitiesTabComponent; | ||
let fixture: ComponentFixture<IdentitiesTabComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ IdentitiesTabComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(IdentitiesTabComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
75 changes: 75 additions & 0 deletions
75
src/app/clients/clients-view/identities-tab/identities-tab.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,75 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { MatTable } from '@angular/material/table'; | ||
import { MatDialog } from '@angular/material'; | ||
|
||
/** Custom Components */ | ||
import { UploadDocumentDialogComponent } from '../upload-document-dialog/upload-document-dialog.component'; | ||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component'; | ||
|
||
/** Custom Services */ | ||
import { ClientsService } from '../../clients.service'; | ||
|
||
@Component({ | ||
selector: 'mifosx-identities-tab', | ||
templateUrl: './identities-tab.component.html', | ||
styleUrls: ['./identities-tab.component.scss'] | ||
}) | ||
export class IdentitiesTabComponent implements OnInit { | ||
@ViewChild('identifiersTable') identifiersTable: MatTable<Element>; | ||
identitiesColumns: string[] = ['id', 'description', 'type', 'documents', 'status', 'actions']; | ||
clientIdentities: any; | ||
|
||
constructor(private route: ActivatedRoute, | ||
public dialog: MatDialog, | ||
private clientService: ClientsService) { | ||
this.route.data.subscribe((data: { clientIdentities: any }) => { | ||
this.clientIdentities = data.clientIdentities; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
download(parentEntityId: string, documentId: string) { | ||
this.clientService.downloadClientIdentificationDocument(parentEntityId, documentId).subscribe(res => { | ||
const url = window.URL.createObjectURL(res); | ||
window.open(url); | ||
}); | ||
} | ||
|
||
deleteIdentifier(clientId: string, identifierId: string, index: number) { | ||
const deleteFamilyMemberDialogRef = this.dialog.open(DeleteDialogComponent, { | ||
data: { deleteContext: `identifier id:${identifierId}` } | ||
}); | ||
deleteFamilyMemberDialogRef.afterClosed().subscribe((response: any) => { | ||
if (response.delete) { | ||
this.clientService.deleteClientIdentifier(clientId, identifierId).subscribe(res => { | ||
this.clientIdentities.splice(index, 1); | ||
this.identifiersTable.renderRows(); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
uploadDocument(index: number, identifierId: string) { | ||
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent); | ||
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => { | ||
if (dialogResponse) { | ||
const formData: FormData = new FormData; | ||
formData.append('name', dialogResponse.fileName); | ||
formData.append('file', dialogResponse.file); | ||
this.clientService.uploadClientIdentifierDocument(identifierId, formData).subscribe((res: any) => { | ||
this.clientIdentities[index].documents.push({ | ||
id: res.resourceId, | ||
parentEntityType: 'client_identifiers', | ||
parentEntityId: identifierId, | ||
name: dialogResponse.fileName, | ||
fileName: dialogResponse.file.fileName | ||
}); | ||
this.identifiersTable.renderRows(); | ||
}); | ||
} | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/app/clients/clients-view/upload-document-dialog/upload-document-dialog.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,22 @@ | ||
<h1 mat-dialog-title>Upload Client Documents</h1> | ||
<div> | ||
<form [formGroup]="uploadDocumentForm" fxLayout="column"> | ||
|
||
<mat-form-field fxFlex> | ||
<mat-label>File Name</mat-label> | ||
<input formControlName="fileName" required matInput /> | ||
<mat-error *ngIf="uploadDocumentForm.controls.fileName.hasError('required')"> | ||
File Name is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
|
||
<input type="file" name="file" (change)="onFileSelect($event)" /> | ||
|
||
<mat-dialog-actions align="end"> | ||
<button mat-raised-button mat-dialog-close>Cancel</button> | ||
<button mat-raised-button color="primary" [disabled]="!uploadDocumentForm.valid" | ||
[mat-dialog-close]="uploadDocumentForm.value">Confirm</button> | ||
</mat-dialog-actions> | ||
|
||
</form> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/clients/clients-view/upload-document-dialog/upload-document-dialog.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { UploadDocumentDialogComponent } from './upload-document-dialog.component'; | ||
|
||
describe('UploadDocumentDialogComponent', () => { | ||
let component: UploadDocumentDialogComponent; | ||
let fixture: ComponentFixture<UploadDocumentDialogComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ UploadDocumentDialogComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(UploadDocumentDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
src/app/clients/clients-view/upload-document-dialog/upload-document-dialog.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,41 @@ | ||
import { Component, OnInit, Inject } from '@angular/core'; | ||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; | ||
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'mifosx-upload-document-dialog', | ||
templateUrl: './upload-document-dialog.component.html', | ||
styleUrls: ['./upload-document-dialog.component.scss'] | ||
}) | ||
export class UploadDocumentDialogComponent implements OnInit { | ||
/** Upload Document form. */ | ||
uploadDocumentForm: FormGroup; | ||
file: any; | ||
uploadDocumentData: any = []; | ||
|
||
constructor(public dialogRef: MatDialogRef<UploadDocumentDialogComponent>, | ||
private formBuilder: FormBuilder, | ||
@Inject(MAT_DIALOG_DATA) public data: any) { } | ||
|
||
ngOnInit() { | ||
this.createUploadDocumentForm(); | ||
} | ||
|
||
/** | ||
* Creates the upload Document form. | ||
*/ | ||
createUploadDocumentForm() { | ||
this.uploadDocumentForm = this.formBuilder.group({ | ||
'fileName': ['', Validators.required], | ||
'file': [''] | ||
}); | ||
} | ||
onFileSelect(event: any) { | ||
if (event.target.files.length > 0) { | ||
const file = event.target.files[0]; | ||
this.uploadDocumentForm.get('file').setValue(file); | ||
} | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.