docs: configurando deploy via ssh para angular
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
<div class="d-flex flex-column wrapper">
|
||||
<div class="filter">
|
||||
<form class="k-form shadow bg-body rounded" [formGroup]="formFilter">
|
||||
<h4>FILTRO DE CATEGORIAS</h4>
|
||||
|
||||
<label class="mt-2">
|
||||
<span>Descrição</span>
|
||||
<kendo-textbox
|
||||
formControlName="description"
|
||||
placeholder="Informe o nome do parceiro"
|
||||
></kendo-textbox>
|
||||
</label>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-12">
|
||||
<span>Tipo de parceiro</span>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 col-lg-2">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="type"
|
||||
value="B"
|
||||
#other
|
||||
formControlName="type"
|
||||
kendoRadioButton
|
||||
/>
|
||||
<span class="in-line"> Bella Obra</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 col-lg-2">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="type"
|
||||
value="P"
|
||||
#other
|
||||
formControlName="type"
|
||||
kendoRadioButton
|
||||
/>
|
||||
<span class="in-line"> Parceiros</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 col-lg-3">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="type"
|
||||
value="M"
|
||||
#other
|
||||
formControlName="type"
|
||||
kendoRadioButton
|
||||
/>
|
||||
<span class="in-line"> Mestre Jurunense</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 col-lg-2">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
name="type"
|
||||
value="T"
|
||||
#other
|
||||
formControlName="type"
|
||||
kendoRadioButton
|
||||
/>
|
||||
<span class="in-line"> Todos</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 row-buttons">
|
||||
<button
|
||||
kendoButton
|
||||
rounded="medium"
|
||||
themeColor="primary"
|
||||
(click)="getPartnerCategory()"
|
||||
>
|
||||
Pesquisar
|
||||
</button>
|
||||
<button
|
||||
kendoButton
|
||||
rounded="medium"
|
||||
themeColor="waring"
|
||||
(click)="open(null)"
|
||||
>
|
||||
Incluir
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<main class="flex-fill mt-3">
|
||||
<kendo-grid
|
||||
[kendoGridBinding]="gridView"
|
||||
class="gridPartnerCategory"
|
||||
(edit)="open($event)"
|
||||
[sortable]="true"
|
||||
[reorderable]="true"
|
||||
[resizable]="true"
|
||||
[columnMenu]="{ filter: true }"
|
||||
>
|
||||
<kendo-grid-column title="Código" field="id" width="80">
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-column
|
||||
title="Tipo Parceiro"
|
||||
field="descriptionType"
|
||||
width="100"
|
||||
>
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-column
|
||||
title="Forma de Pagamento"
|
||||
field="descriptionPayment"
|
||||
width="100"
|
||||
>
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-column title="Descrição" field="name" width="250">
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-column title="Ações" [width]="60">
|
||||
<ng-template kendoGridCellTemplate let-dataItem>
|
||||
<div class="row g-2 justify-content-start">
|
||||
<div class="col-3 me-2" kendoGridEditCommand>
|
||||
<i class="bi bi-pencil text-success"></i>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</kendo-grid-column>
|
||||
<ng-template kendoGridNoRecordsTemplate>
|
||||
<div>
|
||||
<kendo-badge-container>
|
||||
<kendo-icon name="user" size="large"></kendo-icon>
|
||||
<kendo-badge position="inside" themeColor="error">
|
||||
<kendo-icon name="close"></kendo-icon>
|
||||
</kendo-badge>
|
||||
</kendo-badge-container>
|
||||
</div>
|
||||
<p>
|
||||
Não foram localizadas categorias com os filtros inforamdos, verifique
|
||||
a pesquisa.
|
||||
</p>
|
||||
</ng-template>
|
||||
</kendo-grid>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<kendo-window
|
||||
*ngIf="opened"
|
||||
autoFocusedElement="#firstName"
|
||||
title="CADASTRO DE CATEGORIA"
|
||||
(close)="close()"
|
||||
[minWidth]="250"
|
||||
[width]="450"
|
||||
>
|
||||
<form class="k-form" [formGroup]="formPartner">
|
||||
<kendo-formfield>
|
||||
<label>
|
||||
<span>Nome</span>
|
||||
<kendo-textbox
|
||||
formControlName="name"
|
||||
[clearButton]="true"
|
||||
#fullName
|
||||
required
|
||||
></kendo-textbox>
|
||||
</label>
|
||||
<kendo-formerror>Error: Nome é obrigatório</kendo-formerror>
|
||||
</kendo-formfield>
|
||||
|
||||
<kendo-formfield showHints="initial">
|
||||
<label class="k-label">Tipo de parceiro</label>
|
||||
<ul class="k-radio-list">
|
||||
<li class="k-radio-item">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
#mestre
|
||||
value="B"
|
||||
kendoRadioButton
|
||||
formControlName="partnerType"
|
||||
/>
|
||||
<span> Bella Obra</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="k-radio-item">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
#mestre
|
||||
value="P"
|
||||
kendoRadioButton
|
||||
formControlName="partnerType"
|
||||
/>
|
||||
<span> Parceiro</span>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<li class="k-radio-item">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
#parceiro
|
||||
kendoRadioButton
|
||||
value="M"
|
||||
formControlName="partnerType"
|
||||
/>
|
||||
<span>Mestre Jurunense</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<kendo-formerror *ngIf="formPartner.controls.partnerType.errors?.required"
|
||||
>Error: O tipo do parceiro é obrigatório</kendo-formerror
|
||||
>
|
||||
</kendo-formfield>
|
||||
|
||||
|
||||
<kendo-formfield showHints="initial">
|
||||
<label class="k-label">Tipo de Pagamento</label>
|
||||
<ul class="k-radio-list">
|
||||
<li class="k-radio-item">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
#mestre
|
||||
value="C"
|
||||
kendoRadioButton
|
||||
formControlName="paymentType"
|
||||
/>
|
||||
<span>Crédito</span>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<li class="k-radio-item">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
#parceiro
|
||||
kendoRadioButton
|
||||
value="P"
|
||||
formControlName="paymentType"
|
||||
/>
|
||||
<span>Contas a pagar</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<kendo-formerror *ngIf="formPartner.controls.paymentType.errors?.required"
|
||||
>Error: O tipo do parceiro é obrigatório</kendo-formerror
|
||||
>
|
||||
</kendo-formfield>
|
||||
|
||||
<div class="k-form-buttons">
|
||||
<button kendoButton themeColor="primary" (click)="submitForm()">
|
||||
Salvar
|
||||
</button>
|
||||
<button kendoButton (click)="clearForm()">Cancelar</button>
|
||||
</div>
|
||||
</form>
|
||||
</kendo-window>
|
||||
@@ -0,0 +1,37 @@
|
||||
.wrapper {
|
||||
min-height: calc(100vh - 80px);
|
||||
}
|
||||
.gridPartnerCatetgory {
|
||||
max-height: calc(100vh - 410px);
|
||||
}
|
||||
|
||||
.form-partner {
|
||||
display: flex;
|
||||
justify-content: start;
|
||||
}
|
||||
.wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.wrap .arrival-date {
|
||||
width: 90%;
|
||||
margin-right: 18px;
|
||||
}
|
||||
.k-form {
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
label {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.row-buttons {
|
||||
display: flex;
|
||||
justify-content: start space-between;
|
||||
}
|
||||
|
||||
.row-buttons button {
|
||||
margin-right: 10px;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ParnterCategoryHomeComponent } from './parnter-category-home.component';
|
||||
|
||||
describe('ParnterCategoryHomeComponent', () => {
|
||||
let component: ParnterCategoryHomeComponent;
|
||||
let fixture: ComponentFixture<ParnterCategoryHomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ParnterCategoryHomeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ParnterCategoryHomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,155 @@
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DataBindingDirective } from '@progress/kendo-angular-grid';
|
||||
import { Observable, of, Subscription } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { CategoryPartner } from 'src/app/models/category-partner.model';
|
||||
import { PartnerCategory } from 'src/app/models/partner-category.model';
|
||||
import { PartnerCategoryService } from 'src/app/services/partner-category.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-parnter-category-home',
|
||||
templateUrl: './parnter-category-home.component.html',
|
||||
styleUrls: ['./parnter-category-home.component.scss']
|
||||
})
|
||||
export class ParnterCategoryHomeComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
|
||||
public gridView: unknown[];
|
||||
formFilter: FormGroup;
|
||||
formPartner: FormGroup;
|
||||
partnerCategory$: Observable<PartnerCategory[]>;
|
||||
partnerCategories: PartnerCategory[] = [];
|
||||
subscriptionCategory: Subscription;
|
||||
isloading = false;
|
||||
|
||||
public opened = false;
|
||||
|
||||
|
||||
constructor(
|
||||
private readonly partnerCategoryService: PartnerCategoryService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
) {
|
||||
this.formFilter = new FormGroup({
|
||||
description: new FormControl(null),
|
||||
type: new FormControl(null),
|
||||
});
|
||||
this.formPartner = new FormGroup({
|
||||
id: new FormControl(),
|
||||
name: new FormControl('', [Validators.required, Validators.minLength(10)]),
|
||||
partnerType: new FormControl('', [Validators.required]),
|
||||
paymentType: new FormControl('', [Validators.required]),
|
||||
descriptionType: new FormControl(''),
|
||||
descriptionPayment: new FormControl('')
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if ( this.subscriptionCategory ) {
|
||||
this.subscriptionCategory.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
getPartnerCategory() {
|
||||
const description = this.formFilter.get('description').value;
|
||||
const type = this.formFilter.get('type').value;
|
||||
|
||||
this.partnerCategory$ = this.partnerCategoryService.getPartnerCategory(description, type);
|
||||
this.subscriptionCategory = this.partnerCategory$.subscribe(partnerCategory => {
|
||||
this.partnerCategories = partnerCategory;
|
||||
this.gridView = this.partnerCategories;
|
||||
});
|
||||
}
|
||||
|
||||
editPartner(data) {
|
||||
console.log(data);
|
||||
this.router.navigate([`/partner/category/edit/category/${data.dataItem.id}`]);
|
||||
}
|
||||
|
||||
createPartnerCategory() {
|
||||
this.router.navigate([`/partner/category/create/category`]);
|
||||
}
|
||||
|
||||
public submitForm(): void {
|
||||
this.formPartner.markAllAsTouched();
|
||||
console.log(this.formPartner.valid);
|
||||
console.log(this.formPartner.errors);
|
||||
// if (this.formPartner.valid) {
|
||||
const data = JSON.stringify(this.formPartner.value);
|
||||
const partnerCategory: PartnerCategory = JSON.parse(data);
|
||||
|
||||
console.log(JSON.stringify(partnerCategory));
|
||||
this.partnerCategoryService.createOrReplace(this.formPartner.value).pipe(
|
||||
tap((resultData: PartnerCategory) => {
|
||||
this.isloading = false;
|
||||
// TODO: INCLUIR MENSAGEM
|
||||
this.opened = false;
|
||||
const categoryBD = this.partnerCategories.find(p => p.id === resultData.id);
|
||||
console.log('CategoryBD: ' + JSON.stringify(categoryBD));
|
||||
const index = this.partnerCategories.indexOf(categoryBD);
|
||||
console.log('Index ' + index);
|
||||
|
||||
const categoryData = new PartnerCategory();
|
||||
categoryData.id = resultData.id;
|
||||
categoryData.name = resultData.name;
|
||||
categoryData.partnerType = resultData.partnerType;
|
||||
categoryData.paymentType = resultData.paymentType;
|
||||
categoryData.descriptionType = ( resultData.partnerType === 'P') ? 'PARCEIRO' :
|
||||
( resultData.partnerType === 'B') ? 'BELLA OBRA' : 'MESTRE JURUNENSE';
|
||||
categoryData.descriptionPayment = (resultData.paymentType === 'C') ? 'Crédito' : 'Contas a Pagar';
|
||||
|
||||
|
||||
if ( index === -1) {
|
||||
this.partnerCategories.push(categoryData);
|
||||
} else {
|
||||
this.partnerCategories[index] = categoryData;
|
||||
}
|
||||
}),
|
||||
catchError((error) => {
|
||||
this.isloading = false;
|
||||
// TODO: INCLUIR MENSAGEM
|
||||
console.log(error);
|
||||
return of(error);
|
||||
})
|
||||
).subscribe();
|
||||
|
||||
console.log(JSON.stringify(this.formPartner.value));
|
||||
}
|
||||
|
||||
public clearForm(): void {
|
||||
this.formPartner.reset();
|
||||
this.opened = false;
|
||||
}
|
||||
|
||||
|
||||
populatePartnerCategory(data: PartnerCategory) {
|
||||
this.formPartner.patchValue({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
partnerType: data.partnerType,
|
||||
paymentType: data.paymentType,
|
||||
descriptionType: data.descriptionType,
|
||||
descriptionPayment: data.descriptionPayment,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public close(): void {
|
||||
this.opened = false;
|
||||
}
|
||||
|
||||
public open(data: any): void {
|
||||
this.formPartner.reset();
|
||||
if ( data != null) {
|
||||
const categoryPartner = data.dataItem as PartnerCategory;
|
||||
this.populatePartnerCategory(categoryPartner);
|
||||
}
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user