Skip to content

Commit

Permalink
Merge pull request #65 from analytics-ufcg/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JoaquimCMH authored Oct 1, 2020
2 parents dd3f95d + db8a70a commit 52de31b
Show file tree
Hide file tree
Showing 42 changed files with 723 additions and 270 deletions.
17 changes: 17 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Router, NavigationEnd } from '@angular/router';
import { Component } from '@angular/core';

import { filter } from 'rxjs/operators';

declare var gtag;

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand All @@ -8,4 +13,16 @@ import { Component } from '@angular/core';
export class AppComponent {
title = 'client';

constructor(private router: Router){
const navEndEvents$ = this.router.events
.pipe(
filter(event => event instanceof NavigationEnd)
);

navEndEvents$.subscribe((event: NavigationEnd) => {
gtag('config', 'UA-178653936-1', {
'page_path': event.urlAfterRedirects
});
});
}
}
43 changes: 32 additions & 11 deletions src/app/contratos/info-contrato/info-contrato.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<div class="d-flex justify-content-center">
<loading-spinner class="mt-2" *ngIf="isLoading"></loading-spinner>
</div>

<div *ngIf="!isLoading">
<div class="secao-inicial view-container">
<div class="container pt-5">
<nav aria-label="breadcrumb">
Expand Down Expand Up @@ -51,14 +56,27 @@ <h5 class="ml-3 col-sm-1 mt-1">
<div class="container mt-4">
<div class="row">
<div class="col-sm-4">
<strong><span class="text-warning">Valor do Contrato</span></strong>
<div class="col-sm-7 mb-1">
<strong><span class="text-warning">Custo</span></strong>
<!-- <div class="col-sm-7 mb-1">
<div class="progress">
<div class="progress-bar progress-bar-striped bg-secondary progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar progress-bar-striped bg-secondary progress-bar-animated" role="progressbar" [style.width.%]="getPorcentagemPago (contrato)" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<p class="text-warning">{{ contrato?.vl_total_contrato | currency: "R$" }} </p>

</div> -->
<br>
<span class="text-secondary"><small> valor contratado de {{ contrato?.vl_total_contrato | currency: "R$" }} </small></span>
<p *ngIf="getPorcentagemDiff(contrato)!= -1 && contrato.pagamentosContrato?.length > 0" class="text-warning"> foi pago {{getTotalPago(contrato) | currency: "R$"}}
<span [ngClass]="{
'text-success' : getPorcentagemDiff (contrato) <= 0,
'text-warnning' : getPorcentagemDiff (contrato) > 0,
'text-danger' : getPorcentagemDiff (contrato) > 20
}">
<small>({{getPorcentagemDiff(contrato) > 0 ? '+' : ''}}{{getPorcentagemDiff(contrato)}}%)</small>

</span>
</p>
<p *ngIf="getPorcentagemDiff(contrato)!= -1 && contrato.pagamentosContrato?.length == 0" class="text-warning">
nenhum pagamento foi registrado.
</p>
</div>
<div class="col-sm-4">
<strong><span class="text-warning">Vigência</span></strong>
Expand Down Expand Up @@ -115,20 +133,23 @@ <h6 class="text-warning text-capitalize mt-1">
aria-valuemax="100"></div>
</div>
</div>
<span *ngIf="contrato?.previsaoContrato" class="text-secondary"><small>{{getRisco (contrato)}}% de chances de rescisão.</small></span>
<span *ngIf="!contrato?.previsaoContrato" class="text-secondary"><small>Nenhum risco associado.</small></span>
<span *ngIf="contrato?.previsao" class="text-secondary"><small>{{getRisco (contrato)}}% de chances de rompimento</small></span>
<span *ngIf="!contrato?.previsao" class="text-secondary"><small>Nenhum risco associado.</small></span>
</div>
</div>
</div>

<div class="container mb-4 pb-5">
<div class="row">
<div class="col-sm-12">
<h6 class="text-warning"><strong>Eventos</strong></h6>
<h6 class="text-warning mb-4 pt-4"><strong>Eventos</strong></h6>
</div>
<div class="col-sm-8 mt-4">
<app-timeline [eventosTimeline]="getEventosTimeline ()"></app-timeline>
<div class="container-timeline">
<div class="col-sm-8 mt-4">
<app-timeline [eventosTimeline]="getEventosTimeline ()"></app-timeline>
</div>
</div>
</div>
</div>

</div>
20 changes: 20 additions & 0 deletions src/app/contratos/info-contrato/info-contrato.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@
background-color: #ffffff00;
border-radius: 0;
}
// SCROLLBAR TIMELINE
.container-timeline {
width: 100%;
overflow-x: auto;
white-space: nowrap;
}

::-webkit-scrollbar {
height: 6px;
}

::-webkit-scrollbar-track {
background: #edf0f4;
border-radius: 10px;
}

::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #4c4c6a;
}

.progress {
border-radius: 13px;
Expand Down
123 changes: 71 additions & 52 deletions src/app/contratos/info-contrato/info-contrato.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Contrato } from './../../shared/models/contrato.model';
import { ContratoService } from './../../shared/services/contrato.service';
import { RegiaoService } from './../../shared/services/regiao.service';
import { UserService } from './../../shared/services/user.service';

import { ActivatedRoute } from '@angular/router';

import { Contrato } from './../../shared/models/contrato.model';
import { Evento } from './../../shared/models/evento.model';
import { debounceTime, takeUntil, map } from 'rxjs/operators';
import { Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
import { Municipio } from './../../shared/models/municipio.model';
import { Location } from '@angular/common';
Expand All @@ -17,22 +16,20 @@ import { Location } from '@angular/common';
templateUrl: './info-contrato.component.html',
styleUrls: ['./info-contrato.component.scss']
})
export class InfoContratoComponent implements OnInit {
export class InfoContratoComponent implements OnInit, OnDestroy {

public contrato: any;

public isLoading = true;
private unsubscribe = new Subject();
public municipioEscolhido: Municipio;

constructor(private userService: UserService,
constructor(
private regiaoService: RegiaoService,
private contratoService: ContratoService,
private activatedroute: ActivatedRoute,
private location: Location) { }

ngOnInit(): void {
this.getMunicipio();

const id = this.activatedroute.snapshot.paramMap.get('id');
this.getContratoByID(id);
}
Expand All @@ -42,69 +39,91 @@ export class InfoContratoComponent implements OnInit {
.pipe(takeUntil(this.unsubscribe))
.subscribe(contrato => {
this.contrato = contrato;
this.isLoading = false;
this.getMunicipioById(contrato.cd_municipio);
});
}

getMunicipio() {
this.userService
.getMunicipioEscolhido()
.pipe(
debounceTime(300),
takeUntil(this.unsubscribe))
.subscribe(municipio => {
this.municipioEscolhido = municipio;
this.getMunicipioIfUnfined ()
getMunicipioById( cdMunicipio: string) {
this.regiaoService.getMunicipiosbyId(cdMunicipio)
.subscribe(municipio => {
municipio.map (result => {
this.municipioEscolhido = result;
});
});
}

/**
* Verifica se o municipio já está salvo no userservice,
* caso contrário é realizada a busca pelo código.
*/
getMunicipioIfUnfined () {
if (!this.municipioEscolhido?.cd_municipio ||
this.municipioEscolhido?.cd_municipio != this.contrato?.cd_municipio){
this.regiaoService.getMunicipiosbyId(this.contrato?.cd_municipio)
.subscribe(municipio => {
municipio.map (result => {
this.userService.setMunicipioEscolhido (result);
this.municipioEscolhido = result;
})
})
}
}

getPorcentagemContrato (start, end) {
getPorcentagemContrato(start, end) {
let percentage;

if (start && end) {
let startDate = new Date(start).getTime();
let endDate = new Date(end).getTime();
let todayDate = new Date().getTime();
const startDate = new Date(start).getTime();
const endDate = new Date(end).getTime();
const todayDate = new Date().getTime();

let total = endDate - startDate;
let current = todayDate - startDate;
const total = endDate - startDate;
const current = todayDate - startDate;
percentage = (current / total) * 100;

return Math.min(Math.max(parseInt((percentage).toFixed(2)), 0), 100);
return Math.min(Math.max(parseInt((percentage).toFixed(2), 10), 0), 100);
}

return -1
return -1;
}

getEventosTimeline () {
getEventosTimeline() {
if (this.contrato) {
let eventosTimeline: Array<Evento> = []
eventosTimeline.push (new Evento("Assinatura", this.contrato.dt_assinatura))
eventosTimeline.push (new Evento("Fim da vigência", this.contrato.pr_vigencia))

return eventosTimeline;
const eventosTimeline: Array<Evento> = [];
eventosTimeline.push (new Evento('Assinatura', this.contrato.dt_assinatura));
if (this.contrato.empenhosContrato){
for (let empenho of this.contrato.empenhosContrato){
eventosTimeline.push(new Evento('Empenho', empenho.dt_empenho, empenho.vl_empenho));
}
}
if (this.contrato.pagamentosContrato) {
for (let pagamento of this.contrato.pagamentosContrato){
eventosTimeline.push(new Evento('Pagamento', pagamento.dt_pagamento, pagamento.vl_pagamento));
}
}
eventosTimeline.push (new Evento('Fim da vigência', this.contrato.pr_vigencia));

return eventosTimeline.sort((b, a) => new Date(b.data).getTime() - new Date(a.data).getTime());
}
}

getRisco (risco) {
if (!risco?.previsaoContrato) return 0;
return (risco?.previsaoContrato?.vig_prob_1 * 100).toFixed(0);
getRisco(contrato: Contrato) {
if (!contrato?.previsao) {
return 0;
}
return (contrato?.previsao.risco * 100).toFixed(0);
}

getPorcentagemPago(contrato: Contrato) {
if (!contrato || !contrato.pagamentosContrato) {
return -1;
}
return (this. getTotalPago(contrato) / contrato.vl_total_contrato * 100).toFixed(0);
}

getTotalPago(contrato: Contrato) {
if (!contrato || !contrato.pagamentosContrato) {
return -1;
}
let totalPago = 0;
for (let pagamento of contrato.pagamentosContrato){
totalPago += +pagamento.vl_pagamento;
}
return totalPago;
}

getPorcentagemDiff(contrato: Contrato){
if (!contrato || !contrato.pagamentosContrato) {
return -1;
}
const diferenca = this.getTotalPago(contrato) - contrato.vl_total_contrato;
return ( diferenca / contrato.vl_total_contrato * 100).toFixed(0);


}

ngOnDestroy() {
Expand All @@ -113,7 +132,7 @@ export class InfoContratoComponent implements OnInit {
}

lastPage() {
this.location.back();
this.location.back();
}

}
50 changes: 45 additions & 5 deletions src/app/contratos/lista-contratos/lista-contratos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,41 @@ <h5 class="mt-5 pt-5 text-secondary" [hidden]="contratos?.length > 0 || isLoadin


<div class="row">

<div>

<div *ngIf="termoBuscado == contrato.nu_contrato && termoBuscado == contrato.nu_licitacao">
<div class="mx-auto pl-3">
<small class="text-secondary"> Nº Licitação:</small>
<p app:Highlight>{{contrato.nu_licitacao}}</p>
<small class="text-secondary"> Nº Contrato:</small>
<p app:Highlight>{{contrato.nu_contrato}}</p>
</div>
</div>

<div *ngIf="termoBuscado == contrato.nu_contrato && termoBuscado != contrato.nu_licitacao">
<div class="mx-auto pl-3">
<small class="text-secondary"> Nº Contrato:</small>
<p app:Highlight>{{contrato.nu_contrato}}</p>
</div>
</div>

<div *ngIf="termoBuscado == contrato.nu_licitacao && termoBuscado != contrato.nu_contrato">
<div class="mx-auto pl-3">
<small class="text-secondary"> Nº Licitação:</small>
<p app:Highlight>{{contrato.nu_licitacao}}</p>
</div>
</div>


</div>




<div class="col-sm-6 mx-auto">


<div class="col-sm-4 mx-auto">
<strong class="text-warning">Descrição: </strong>
<div class="mb-3 text-warning text-justify" [innerHTML]="contrato.de_obs | formatFirstLetterCapitalize | highlight: termoBuscado">
</div>
Expand All @@ -66,17 +99,24 @@ <h5 class="text-warning text-capitalize mt-3 mt-sm-0"><strong class="custom-valu
<div class="progress custom-progress text-left mt-1">
<div class="progress-bar progress-bar-striped progress-bar-animated"
role="progressbar"
[style.width.%]="getRisco (contrato?.vig_prob_1)"
[style.width.%]="getRisco (contrato)"
[ngClass]="{
'bg-danger' : getRisco (contrato?.vig_prob_1) >= 75,
'bg-warnning' : getRisco (contrato?.vig_prob_1) >= 50,
'bg-success' : getRisco (contrato?.vig_prob_1) < 50
'bg-danger' : getRisco (contrato) >= 75,
'bg-warnning' : getRisco (contrato) >= 50,
'bg-success' : getRisco (contrato) < 50
}"
aria-valuenow="0"
aria-valuemin="0"
aria-valuemax="100"></div>
</div>
<span class="text-secondary">Risco</span>

<i *ngIf="getRisco(contrato) != -1; else elseBlock" class="text-secondary fa fa-info-circle ml-1" data-toggle="tooltip" data-placement="top" title="{{ getRisco(contrato)}}% de chances de rompimento"></i>

<ng-template #elseBlock>
<i class="text-secondary fa fa-info-circle ml-1" data-toggle="tooltip" data-placement="top" title="Não há risco associado"></i>
</ng-template>

</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 52de31b

Please sign in to comment.