diff --git a/src/app/claim-mgt/claim/claim.component.html b/src/app/claim-mgt/claim/claim.component.html index 5c970be8..a3432c98 100644 --- a/src/app/claim-mgt/claim/claim.component.html +++ b/src/app/claim-mgt/claim/claim.component.html @@ -1 +1,3 @@ -Claim + + + diff --git a/src/app/claim-mgt/claim/claim.component.ts b/src/app/claim-mgt/claim/claim.component.ts index e52aa701..f15391bf 100644 --- a/src/app/claim-mgt/claim/claim.component.ts +++ b/src/app/claim-mgt/claim/claim.component.ts @@ -1,6 +1,19 @@ import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ClaimService } from './claim.service'; @Component({ - templateUrl: 'claim.component.html' + templateUrl: 'claim.component.html', + providers: [ClaimService] }) -export class ClaimComponent {} +export class ClaimComponent { + claim$ = this.claimService.claim$; + + constructor(private route: ActivatedRoute, private claimService: ClaimService) { + this.route.params.subscribe(params => { + const { party_id, claim_id } = params; + this.claimService.getClaim(party_id, Number(claim_id)); + }); + } +} diff --git a/src/app/claim-mgt/claim/claim.module.ts b/src/app/claim-mgt/claim/claim.module.ts index d1fe3d30..a6e36cd6 100644 --- a/src/app/claim-mgt/claim/claim.module.ts +++ b/src/app/claim-mgt/claim/claim.module.ts @@ -1,9 +1,17 @@ import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MatCardModule } from '@angular/material'; +import { FlexModule } from '@angular/flex-layout'; + import { ClaimComponent } from './claim.component'; import { ClaimRoutingModule } from './claim-routing.module'; +import { SharedModule } from '../../shared/shared.module'; +import { ClaimManagementService } from '../../thrift/claim-management.service'; +import { DetailsComponent } from './details/details.component'; @NgModule({ - imports: [ClaimRoutingModule], - declarations: [ClaimComponent] + imports: [ClaimRoutingModule, SharedModule, CommonModule, MatCardModule, FlexModule], + declarations: [ClaimComponent, DetailsComponent], + providers: [ClaimManagementService] }) export class ClaimModule {} diff --git a/src/app/claim-mgt/claim/claim.service.ts b/src/app/claim-mgt/claim/claim.service.ts new file mode 100644 index 00000000..211e6f6d --- /dev/null +++ b/src/app/claim-mgt/claim/claim.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; +import { MatSnackBar } from '@angular/material'; + +import { ClaimManagementService } from '../../thrift/claim-management.service'; +import { Claim } from '../../gen-damsel/claim_management'; + +@Injectable() +export class ClaimService { + claim$: Subject = new Subject(); + + constructor( + private claimManagementService: ClaimManagementService, + private snackBar: MatSnackBar + ) {} + + getClaim(partyID: string, claimID: number) { + this.claimManagementService.getClaim(partyID, claimID).subscribe( + claim => this.claim$.next(claim), + e => { + console.error(e); + this.snackBar.open('An error occurred while claim accepting', 'OK'); + } + ); + } +} diff --git a/src/app/claim-mgt/claim/details/details.component.html b/src/app/claim-mgt/claim/details/details.component.html new file mode 100644 index 00000000..c8606326 --- /dev/null +++ b/src/app/claim-mgt/claim/details/details.component.html @@ -0,0 +1,33 @@ + + Claim details + + + + Claim ID: + {{ claim.id }} + + + Status: + {{ extractClaimStatus(claim.status) }} + + + Revision: + {{ claim.revision }} + + + + + Party ID: + {{ claim.party_id }} + + + Created At: + {{ claim.created_at | date: 'dd.MM.yyyy HH:mm:ss' }} + + + Updated At: + {{ claim.updated_at | date: 'dd.MM.yyyy HH:mm:ss' }} + + + + diff --git a/src/app/claim-mgt/claim/details/details.component.ts b/src/app/claim-mgt/claim/details/details.component.ts new file mode 100644 index 00000000..74a59347 --- /dev/null +++ b/src/app/claim-mgt/claim/details/details.component.ts @@ -0,0 +1,16 @@ +import { Component, Input } from '@angular/core'; + +import { Claim, ClaimStatus } from '../../../gen-damsel/claim_management'; +import { extractClaimStatus } from '../../../shared/extract-claim-status'; + +@Component({ + selector: 'cc-claim-details', + templateUrl: 'details.component.html' +}) +export class DetailsComponent { + @Input() claim: Claim; + + extractClaimStatus(status: ClaimStatus) { + return extractClaimStatus(status); + } +} diff --git a/src/app/thrift/claim-management.service.ts b/src/app/thrift/claim-management.service.ts index 60206c81..9f1aff12 100644 --- a/src/app/thrift/claim-management.service.ts +++ b/src/app/thrift/claim-management.service.ts @@ -1,11 +1,11 @@ import { Injectable, NgZone } from '@angular/core'; import { Observable } from 'rxjs'; +import { KeycloakService } from 'keycloak-angular'; import { ThriftService } from '../thrift'; import * as ClaimManagement from './gen-nodejs/ClaimManagement'; -import { ClaimSearchQuery, ClaimSearchResponse } from '../gen-damsel/claim_management'; +import { Claim, ClaimSearchQuery, ClaimSearchResponse } from '../gen-damsel/claim_management'; import { ClaimSearchQuery as ClaimSearchQueryType } from './gen-nodejs/claim_management_types'; -import { KeycloakService } from 'keycloak-angular'; @Injectable() export class ClaimManagementService extends ThriftService { @@ -15,4 +15,8 @@ export class ClaimManagementService extends ThriftService { searchClaims = (query: ClaimSearchQuery): Observable => this.toObservableAction('SearchClaims')(new ClaimSearchQueryType(query)); + + getClaim = (partyID: string, claimID: number): Observable => { + return this.toObservableAction('GetClaim')(partyID, claimID); + }; }