docs: configurando deploy via ssh para angular
This commit is contained in:
104
src/app/shared/kendo.module.ts
Normal file
104
src/app/shared/kendo.module.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { ChartModule, SparklineModule } from '@progress/kendo-angular-charts';
|
||||
import { LOCALE_ID, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
|
||||
import { FormFieldModule, InputsModule, NumericTextBoxModule } from '@progress/kendo-angular-inputs';
|
||||
import { LabelModule } from '@progress/kendo-angular-label';
|
||||
import { DateInputsModule } from '@progress/kendo-angular-dateinputs';
|
||||
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
||||
import { ExcelModule, GridModule } from '@progress/kendo-angular-grid';
|
||||
import { ScrollViewModule } from '@progress/kendo-angular-scrollview';
|
||||
import { IconsModule, SVGIconModule } from '@progress/kendo-angular-icons';
|
||||
import { DialogsModule } from '@progress/kendo-angular-dialog';
|
||||
import { ListViewModule } from '@progress/kendo-angular-listview';
|
||||
import { LayoutModule } from '@progress/kendo-angular-layout';
|
||||
import { NavigationModule } from '@progress/kendo-angular-navigation';
|
||||
import { IndicatorsModule } from '@progress/kendo-angular-indicators';
|
||||
import { MenusModule } from '@progress/kendo-angular-menu';
|
||||
import { PopupModule } from '@progress/kendo-angular-popup';
|
||||
import { TreeViewModule } from '@progress/kendo-angular-treeview';
|
||||
import { TooltipsModule } from '@progress/kendo-angular-tooltip';
|
||||
import { IntlModule } from '@progress/kendo-angular-intl';
|
||||
// Load all required data for the bg locale
|
||||
import '@progress/kendo-angular-intl/locales/bg/all';
|
||||
// Load the required calendar data for the de locale
|
||||
import '@progress/kendo-angular-intl/locales/pt/calendar';
|
||||
import { NotificationModule } from '@progress/kendo-angular-notification';
|
||||
import { BarcodeModule, QRCodeModule } from '@progress/kendo-angular-barcodes';
|
||||
import { ArcGaugeModule, CircularGaugeModule, LinearGaugeModule, RadialGaugeModule, } from '@progress/kendo-angular-gauges';
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
DropDownsModule,
|
||||
InputsModule,
|
||||
LabelModule,
|
||||
DateInputsModule,
|
||||
ButtonsModule,
|
||||
GridModule,
|
||||
ScrollViewModule,
|
||||
IconsModule,
|
||||
SVGIconModule,
|
||||
DialogsModule,
|
||||
ListViewModule,
|
||||
LayoutModule,
|
||||
NavigationModule,
|
||||
IndicatorsModule,
|
||||
MenusModule,
|
||||
PopupModule,
|
||||
TreeViewModule,
|
||||
TooltipsModule,
|
||||
IntlModule,
|
||||
NotificationModule,
|
||||
FormFieldModule,
|
||||
NumericTextBoxModule,
|
||||
ExcelModule,
|
||||
ChartModule,
|
||||
SparklineModule,
|
||||
BarcodeModule,
|
||||
QRCodeModule,
|
||||
ArcGaugeModule,
|
||||
CircularGaugeModule,
|
||||
LinearGaugeModule,
|
||||
RadialGaugeModule,
|
||||
|
||||
],
|
||||
exports: [DropDownsModule,
|
||||
InputsModule,
|
||||
LabelModule,
|
||||
DateInputsModule,
|
||||
ButtonsModule,
|
||||
GridModule,
|
||||
ScrollViewModule,
|
||||
IconsModule,
|
||||
SVGIconModule,
|
||||
DialogsModule,
|
||||
ListViewModule,
|
||||
LayoutModule,
|
||||
NavigationModule,
|
||||
IndicatorsModule,
|
||||
MenusModule,
|
||||
PopupModule,
|
||||
TreeViewModule,
|
||||
TooltipsModule,
|
||||
ExcelModule,
|
||||
ChartModule,
|
||||
SparklineModule,
|
||||
BarcodeModule,
|
||||
QRCodeModule,
|
||||
ArcGaugeModule,
|
||||
CircularGaugeModule,
|
||||
LinearGaugeModule,
|
||||
RadialGaugeModule,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
// Set default locale to bg-BG
|
||||
provide: LOCALE_ID,
|
||||
useValue: 'pt-BR',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
export class KendoModule { }
|
||||
@@ -0,0 +1,16 @@
|
||||
<kendo-dialog *ngIf="opened" (close)="onDialogClose()">
|
||||
<kendo-dialog-titlebar>
|
||||
<div style="font-size: 18px; line-height: 1.3em;">
|
||||
<span class="k-icon k-i-information"></span> {{title}}
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
<p style="margin: 30px; text-align: center;">
|
||||
{{menssage}}
|
||||
</p>
|
||||
|
||||
<kendo-dialog-actions [layout]="actionsLayout">
|
||||
<button kendoButton (click)="onDialogClose()" primary="true">
|
||||
Ok
|
||||
</button>
|
||||
</kendo-dialog-actions>
|
||||
</kendo-dialog>
|
||||
@@ -0,0 +1 @@
|
||||
.k-dialog-close { display: none; }
|
||||
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { MenssageInformationComponent } from './menssage-information.component';
|
||||
|
||||
describe('MenssageInformationComponent', () => {
|
||||
let component: MenssageInformationComponent;
|
||||
let fixture: ComponentFixture<MenssageInformationComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MenssageInformationComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MenssageInformationComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Component, Input, OnInit, TemplateRef } from '@angular/core';
|
||||
import { ActionsLayout, DialogService } from '@progress/kendo-angular-dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menssage-information',
|
||||
templateUrl: './menssage-information.component.html',
|
||||
styleUrls: ['./menssage-information.component.scss']
|
||||
})
|
||||
export class MenssageInformationComponent implements OnInit {
|
||||
|
||||
@Input() title: string;
|
||||
@Input() menssage: string;
|
||||
constructor(private dialogService: DialogService) { }
|
||||
|
||||
public opened = true;
|
||||
public actionsLayout: ActionsLayout = 'normal';
|
||||
|
||||
public onDialogClose() {
|
||||
this.opened = false;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<img src="assets/img/Error500.png" alt="Error 500">
|
||||
</div>
|
||||
<div class="col-12 text-center">
|
||||
{{status}}
|
||||
</div>
|
||||
<div class="col-12 text-center">
|
||||
{{message}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
img {
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MessageErrorComponent } from './message-error.component';
|
||||
|
||||
describe('MessageErrorComponent', () => {
|
||||
let component: MessageErrorComponent;
|
||||
let fixture: ComponentFixture<MessageErrorComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MessageErrorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MessageErrorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-message-error',
|
||||
templateUrl: './message-error.component.html',
|
||||
styleUrls: ['./message-error.component.scss']
|
||||
})
|
||||
export class MessageErrorComponent implements OnInit {
|
||||
@Input() public message: string;
|
||||
@Input() public status: number;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="container py-4">
|
||||
<div class="row">
|
||||
<!-- Ícone de erro -->
|
||||
<div class="col-12 text-center mb-3">
|
||||
<img src="assets/img/cancel.png" alt="Erro" class="error-icon">
|
||||
</div>
|
||||
<!-- Mensagem de erro -->
|
||||
<div class="col-12 text-center">
|
||||
<p class="error-message">{{ message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
img {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { MessageFailureComponent } from './message-failure.component';
|
||||
|
||||
describe('MessageFailureComponent', () => {
|
||||
let component: MessageFailureComponent;
|
||||
let fixture: ComponentFixture<MessageFailureComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MessageFailureComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MessageFailureComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-message-failure',
|
||||
templateUrl: './message-failure.component.html',
|
||||
styleUrls: ['./message-failure.component.scss']
|
||||
})
|
||||
export class MessageFailureComponent implements OnInit {
|
||||
@Input() public message: string = 'Ocorreu um erro inesperado.';
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
}
|
||||
84
src/app/shared/messages/auth-user/auth-user.component.html
Normal file
84
src/app/shared/messages/auth-user/auth-user.component.html
Normal file
@@ -0,0 +1,84 @@
|
||||
<kendo-dialog
|
||||
*ngIf="opened"
|
||||
(close)="onDialogClose()"
|
||||
[width]="400"
|
||||
[height]="300"
|
||||
>
|
||||
<kendo-dialog-titlebar
|
||||
style="background-color: rgb(34, 34, 61); color: white"
|
||||
>
|
||||
<div style="font-size: 18px; line-height: 1.3em; color: white">
|
||||
<span class="k-icon k-i-person"></span>Autorizar desconto
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
|
||||
<div class="container">
|
||||
<form [formGroup]="formAuth">
|
||||
<fieldset>
|
||||
<kendo-formfield>
|
||||
<kendo-label [for]="email" text="Email"></kendo-label>
|
||||
<kendo-textbox
|
||||
formControlName="email"
|
||||
[clearButton]="true"
|
||||
#email
|
||||
required
|
||||
></kendo-textbox>
|
||||
</kendo-formfield>
|
||||
|
||||
<kendo-formfield class="mt-2">
|
||||
<kendo-label [for]="password" text="Senha"></kendo-label>
|
||||
<input
|
||||
kendoTextBox
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
#password
|
||||
formControlName="password"
|
||||
/>
|
||||
|
||||
<kendo-formerror>Error: Password is required</kendo-formerror>
|
||||
</kendo-formfield>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<kendo-dialog-actions [layout]="actionsLayout">
|
||||
<button kendoButton (click)="onDialogClose()">Cancelar</button>
|
||||
<button
|
||||
kendoButton
|
||||
disable="!authForm.valid"
|
||||
[icon]="loadingIcon"
|
||||
(click)="login()"
|
||||
themeColor="primary"
|
||||
>
|
||||
Autorizar
|
||||
</button>
|
||||
</kendo-dialog-actions>
|
||||
</kendo-dialog>
|
||||
|
||||
<kendo-dialog *ngIf="openedDialog" (close)="closeDialog()">
|
||||
<kendo-dialog-titlebar
|
||||
style="background-color: rgb(34, 34, 61); color: white"
|
||||
>
|
||||
<div
|
||||
class="justify-content-center"
|
||||
style="font-size: 18px; line-height: 1.3em; color: white"
|
||||
>
|
||||
<span class="k-icon k-i-user d-inline"></span>
|
||||
<h5 class="d-inline ms-2">Autorização de desconto</h5>
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
<div style="text-align: center; margin: 30px">
|
||||
<h4>Ops! Houve falha na autenticação do usuário.</h4>
|
||||
<h6>Verifique o email e senha informados.</h6>
|
||||
<p class="mt-3">
|
||||
<button
|
||||
kendoButton
|
||||
themeColor="primary"
|
||||
[style.width.px]="300"
|
||||
(click)="closeDialog()"
|
||||
>
|
||||
OK
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</kendo-dialog>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthUserComponent } from './auth-user.component';
|
||||
|
||||
describe('AuthUserComponent', () => {
|
||||
let component: AuthUserComponent;
|
||||
let fixture: ComponentFixture<AuthUserComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AuthUserComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AuthUserComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
75
src/app/shared/messages/auth-user/auth-user.component.ts
Normal file
75
src/app/shared/messages/auth-user/auth-user.component.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActionsLayout, DialogService } from '@progress/kendo-angular-dialog';
|
||||
import { AuthService } from 'src/app/auth/services/auth.service';
|
||||
import { ResultApi } from 'src/app/models/result-api.model';
|
||||
import { User } from 'src/app/models/user.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-auth-user',
|
||||
templateUrl: './auth-user.component.html',
|
||||
styleUrls: ['./auth-user.component.scss']
|
||||
})
|
||||
export class AuthUserComponent implements OnInit {
|
||||
@Input() opened = false;
|
||||
@Output() resultEvent = new EventEmitter<User>();
|
||||
user: any;
|
||||
formAuth: FormGroup;
|
||||
openedDialog = false;
|
||||
public loadingIcon = '';
|
||||
|
||||
public actionsLayout: ActionsLayout = 'normal';
|
||||
|
||||
public onDialogClose(): void {
|
||||
this.resultEvent.emit(null);
|
||||
}
|
||||
|
||||
public onDeleteData(): void {
|
||||
this.opened = false;
|
||||
this.resultEvent.emit(this.user);
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
public closeDialog() {
|
||||
this.openedDialog = false;
|
||||
}
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private authService: AuthService,
|
||||
private dialogService: DialogService
|
||||
) {
|
||||
this.formAuth = this.fb.group({
|
||||
email: [''],
|
||||
password: [''],
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
login() {
|
||||
this.loadingIcon = 'loading';
|
||||
this.authService.login({
|
||||
email: this.formAuth.value.email,
|
||||
password: this.formAuth.value.password
|
||||
})
|
||||
.subscribe((res: ResultApi) => {
|
||||
if (res.success) {
|
||||
this.loadingIcon = '';
|
||||
this.opened = false;
|
||||
this.user = res.data;
|
||||
this.resultEvent.emit(this.user);
|
||||
} else {
|
||||
this.loadingIcon = '';
|
||||
this.openedDialog = true;
|
||||
}
|
||||
}, err => {
|
||||
this.openedDialog = true;
|
||||
this.loadingIcon = '';
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<!--kendo-dialog *ngIf="opened" (close)="onDialogClose()">
|
||||
<kendo-dialog-titlebar style="background-color: rgb(34, 34, 61); color: white">
|
||||
<div style="font-size: 18px; line-height: 1.3em; color: white">
|
||||
<span class="k-icon k-i-question"></span> {{title}}
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
<p style="margin: 30px; text-align: center; max-width: 450px;">
|
||||
{{message}}
|
||||
</p>
|
||||
|
||||
<kendo-dialog-actions [layout]="actionsLayout">
|
||||
<button kendoButton (click)="onDialogClose()">{{textButtonCancel}}</button>
|
||||
<button kendoButton (click)="onDeleteData()" themeColor="primary">
|
||||
{{textButtonConfirmation}}
|
||||
</button>
|
||||
</kendo-dialog-actions>
|
||||
</kendo-dialog-->
|
||||
|
||||
<kendo-dialog *ngIf="opened" (close)="onDialogClose()">
|
||||
<kendo-dialog-titlebar
|
||||
style="background-color: rgb(34, 34, 61); color: white"
|
||||
>
|
||||
<div
|
||||
class="justify-content-center"
|
||||
style="font-size: 18px; line-height: 1.3em; color: white"
|
||||
>
|
||||
<span class="k-icon k-i-user d-inline"></span>
|
||||
<h5 class="d-inline ms-2">{{title}}</h5>
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
<div style="text-align: center;">
|
||||
<span>{{detailMessage}}</span>
|
||||
<h5>{{message}}</h5>
|
||||
<kendo-dialog-actions class="mt-5" [layout]="actionsLayout">
|
||||
<button kendoButton (click)="onDialogClose()">{{textButtonCancel}}</button>
|
||||
<button kendoButton (click)="onDeleteData()" themeColor="primary">
|
||||
{{textButtonConfirmation}}
|
||||
</button>
|
||||
</kendo-dialog-actions>
|
||||
</div>
|
||||
</kendo-dialog>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
button {
|
||||
width: 120px;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { ConfirmationComponent } from './confirmation.component';
|
||||
|
||||
describe('ConfirmationComponent', () => {
|
||||
let component: ConfirmationComponent;
|
||||
let fixture: ComponentFixture<ConfirmationComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ConfirmationComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ConfirmationComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ActionsLayout } from '@progress/kendo-angular-dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirmation',
|
||||
templateUrl: './confirmation.component.html',
|
||||
styleUrls: ['./confirmation.component.scss']
|
||||
})
|
||||
export class ConfirmationComponent implements OnInit {
|
||||
@Input() opened = false;
|
||||
@Input() title = 'Confirma';
|
||||
@Input() message = 'Confirma processamento?';
|
||||
@Input() detailMessage = '';
|
||||
@Input() textButtonConfirmation = 'Ok';
|
||||
@Input() textButtonCancel = 'Cancelar';
|
||||
@Output() resultEvent = new EventEmitter<boolean>();
|
||||
public actionsLayout: ActionsLayout = 'normal';
|
||||
|
||||
public onDialogClose(): void {
|
||||
this.resultEvent.emit(false);
|
||||
}
|
||||
|
||||
public onDeleteData(): void {
|
||||
this.opened = false;
|
||||
this.resultEvent.emit(true);
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
18
src/app/shared/messages/loading/loading.component.html
Normal file
18
src/app/shared/messages/loading/loading.component.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="container">
|
||||
<ng-template>
|
||||
<ng-container>
|
||||
<div class="k-loading-panel">
|
||||
<div class="k-loading-panel-mask"></div>
|
||||
<div class="k-loading-panel-wrapper">
|
||||
<kendo-loader
|
||||
[type]="'infinite-spinner'"
|
||||
[themeColor]="'primary'"
|
||||
[size]="'large'"
|
||||
>
|
||||
</kendo-loader>
|
||||
<div class="k-loading-panel-text">{{message}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-template>
|
||||
</div>
|
||||
65
src/app/shared/messages/loading/loading.component.scss
Normal file
65
src/app/shared/messages/loading/loading.component.scss
Normal file
@@ -0,0 +1,65 @@
|
||||
.search {
|
||||
font-size: 1.3rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.example-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
.example-text {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.k-button {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Loader Panel Styles */
|
||||
.k-loading-panel {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
.k-loading-panel-mask {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: #000000;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.k-loading-panel-wrapper {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.k-loading-panel-text {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.customer-photo {
|
||||
display: inline-block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background-size: 32px 35px;
|
||||
background-position: center center;
|
||||
vertical-align: middle;
|
||||
line-height: 32px;
|
||||
box-shadow: inset 0 0 1px #999, inset 0 0 10px rgba(0, 0, 0, 0.2);
|
||||
margin-left: 5px;
|
||||
}
|
||||
25
src/app/shared/messages/loading/loading.component.spec.ts
Normal file
25
src/app/shared/messages/loading/loading.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoadingComponent } from './loading.component';
|
||||
|
||||
describe('LoadingComponent', () => {
|
||||
let component: LoadingComponent;
|
||||
let fixture: ComponentFixture<LoadingComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoadingComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoadingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
16
src/app/shared/messages/loading/loading.component.ts
Normal file
16
src/app/shared/messages/loading/loading.component.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-loading',
|
||||
templateUrl: './loading.component.html',
|
||||
styleUrls: ['./loading.component.scss']
|
||||
})
|
||||
export class LoadingComponent implements OnInit {
|
||||
|
||||
@Input() message: string;
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<kendo-dialog *ngIf="opened" (close)="closeDialog()">
|
||||
<kendo-dialog-titlebar
|
||||
style="background-color: rgb(34, 34, 61); color: white"
|
||||
>
|
||||
<div
|
||||
class="justify-content-center"
|
||||
style="font-size: 18px; line-height: 1.3em; color: white"
|
||||
>
|
||||
<span class="k-icon k-i-user d-inline"></span>
|
||||
<h5 class="d-inline ms-2">{{title}}</h5>
|
||||
</div>
|
||||
</kendo-dialog-titlebar>
|
||||
<div style="text-align: center; margin: 30px;">
|
||||
<h4>{{message}}</h4>
|
||||
<h6>{{information}}</h6>
|
||||
<p class="mt-3">
|
||||
<button
|
||||
kendoButton
|
||||
themeColor="primary"
|
||||
[style.width.px]="300"
|
||||
(click)="closeDialog()"
|
||||
>
|
||||
OK
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</kendo-dialog>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MessageInformationComponent } from './message-information.component';
|
||||
|
||||
describe('MessageInformationComponent', () => {
|
||||
let component: MessageInformationComponent;
|
||||
let fixture: ComponentFixture<MessageInformationComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MessageInformationComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MessageInformationComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ActionsLayout } from '@progress/kendo-angular-dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-message-information',
|
||||
templateUrl: './message-information.component.html',
|
||||
styleUrls: ['./message-information.component.scss']
|
||||
})
|
||||
export class MessageInformationComponent implements OnInit {
|
||||
|
||||
@Input() opened = false;
|
||||
@Input() title: string;
|
||||
@Input() message: string;
|
||||
@Input() information: string;
|
||||
|
||||
@Output() resultEvent = new EventEmitter<boolean>();
|
||||
openedDialog = false;
|
||||
public loadingIcon = '';
|
||||
|
||||
public actionsLayout: ActionsLayout = 'normal';
|
||||
|
||||
public onDialogClose(): void {
|
||||
this.resultEvent.emit(false);
|
||||
this.openedDialog = false;
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
public closeDialog() {
|
||||
this.openedDialog = false;
|
||||
this.resultEvent.emit(false);
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
16
src/app/shared/services/consulta-cep.service.spec.ts
Normal file
16
src/app/shared/services/consulta-cep.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { ConsultaCepService } from './consulta-cep.service';
|
||||
|
||||
describe('Service: ConsultaCep', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ConsultaCepService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should ...', inject([ConsultaCepService], (service: ConsultaCepService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
40
src/app/shared/services/consulta-cep.service.ts
Normal file
40
src/app/shared/services/consulta-cep.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ConsultaCepService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
consultaCep(cep: string){
|
||||
// retira todos os caracteres que não sejam números
|
||||
cep = cep.replace(/\D/g, '');
|
||||
if (cep !== ''){
|
||||
const validacep = /^[0-9]{8}$/;
|
||||
if (validacep.test(cep)) {
|
||||
const url = environment.url+`cep/find/viacep/${cep}`
|
||||
return this.http.get<any>(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
googleGeocode(address: string, addressNumber: string, neighborboard: string, city: string, state: string) {
|
||||
const url = environment.url+`cep/google`;
|
||||
const params = new HttpParams(
|
||||
{
|
||||
fromObject: {
|
||||
'address': address,
|
||||
'addressNumber': addressNumber,
|
||||
'neighborboard': neighborboard,
|
||||
'city': city,
|
||||
'state': state
|
||||
}
|
||||
});
|
||||
const response = this.http.get(url, {params});
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
23
src/app/shared/shared.module.ts
Normal file
23
src/app/shared/shared.module.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ConfirmationComponent } from './messages/confirmation/confirmation.component';
|
||||
import { KendoModule } from './kendo.module';
|
||||
import { MessageInformationComponent } from './messages/message-information/message-information.component';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
ConfirmationComponent,
|
||||
MessageInformationComponent,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
KendoModule,
|
||||
],
|
||||
exports: [
|
||||
ConfirmationComponent,
|
||||
MessageInformationComponent,
|
||||
]
|
||||
})
|
||||
export class SharedModule { }
|
||||
64
src/app/shared/styles/button-style.scss
Normal file
64
src/app/shared/styles/button-style.scss
Normal file
@@ -0,0 +1,64 @@
|
||||
.btn-fill-blue {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
position: static;
|
||||
width: 150px;
|
||||
height: 44px;
|
||||
|
||||
background: #2d2e83;
|
||||
border-radius: 5px;
|
||||
|
||||
/* Inside auto layout */
|
||||
|
||||
flex: none;
|
||||
order: 0;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.text-btn-white {
|
||||
font-family: "Open Sans";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
|
||||
color: #ffffff;
|
||||
|
||||
/* Inside auto layout */
|
||||
|
||||
flex: none;
|
||||
order: 0;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.btn-flat {
|
||||
background: #ffffff;
|
||||
border: 1px solid #2d2e83;
|
||||
box-sizing: border-box;
|
||||
border-radius: 5px;
|
||||
width: 150px;
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.text-btn-flat {
|
||||
font-family: "Open Sans";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
color: #2d2e83;
|
||||
|
||||
flex: none;
|
||||
order: 0;
|
||||
flex-grow: 0;
|
||||
margin: 0px 10px;
|
||||
}
|
||||
|
||||
|
||||
8
src/app/shared/styles/variables.scss
Normal file
8
src/app/shared/styles/variables.scss
Normal file
@@ -0,0 +1,8 @@
|
||||
$primary-color: #131d52;
|
||||
$secondary-color: #fe3b1f;
|
||||
$background-color: #bdbdbd;
|
||||
$confirm-color: #0e32c8;
|
||||
$cancel-color: #bdbdbd;
|
||||
$header-color: #131d52;
|
||||
$footer-color: #131d52;
|
||||
$dark-color: #303344;
|
||||
135
src/app/shared/validators/document-validator.ts
Normal file
135
src/app/shared/validators/document-validator.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import { AbstractControl, Validators } from '@angular/forms';
|
||||
|
||||
export class DocumentValidator {
|
||||
constructor() { }
|
||||
|
||||
|
||||
static isValidCpf() {
|
||||
return (control: AbstractControl): Validators => {
|
||||
const cpf = control.value;
|
||||
if (cpf.length > 11) {
|
||||
return null;
|
||||
}
|
||||
if (cpf) {
|
||||
let numbers;
|
||||
let digits;
|
||||
let sum;
|
||||
let i;
|
||||
let result;
|
||||
let equalDigits;
|
||||
equalDigits = 1;
|
||||
if (cpf.length < 11) {
|
||||
return null;
|
||||
}
|
||||
if (cpf.length > 11) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (i = 0; i < cpf.length - 1; i++) {
|
||||
if (cpf.charAt(i) !== cpf.charAt(i + 1)) {
|
||||
equalDigits = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!equalDigits) {
|
||||
numbers = cpf.substring(0, 9);
|
||||
digits = cpf.substring(9);
|
||||
sum = 0;
|
||||
for (i = 10; i > 1; i--) {
|
||||
sum += numbers.charAt(10 - i) * i;
|
||||
}
|
||||
|
||||
result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
|
||||
|
||||
if (result !== Number(digits.charAt(0))) {
|
||||
return { cpfNotValid: true };
|
||||
}
|
||||
numbers = cpf.substring(0, 10);
|
||||
sum = 0;
|
||||
|
||||
for (i = 11; i > 1; i--) {
|
||||
sum += numbers.charAt(11 - i) * i;
|
||||
}
|
||||
result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
|
||||
|
||||
if (result !== Number(digits.charAt(1))) {
|
||||
return { cpfNotValid: true };
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return { cpfNotValid: true };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
static isValidCNPJ() {
|
||||
return (control: AbstractControl): Validators => {
|
||||
const cnpj = control.value;
|
||||
console.log(cnpj);
|
||||
// Verifica se a variável cnpj é igua a "undefined", exibindo uma msg de erro
|
||||
if (cnpj === undefined) {
|
||||
return null;
|
||||
}
|
||||
if (cnpj.length < 14) {
|
||||
return null;
|
||||
}
|
||||
// Esta função retira os caracteres . / - da string do cnpj, deixando apenas os números
|
||||
const strCNPJ = cnpj.replace('.', '').replace('.', '').replace('/', '').replace('-', '');
|
||||
// Testa as sequencias que possuem todos os dígitos iguais e se o cnpj não tem 14 dígitos, retonando falso e exibindo uma msg de erro
|
||||
if (strCNPJ === '00000000000000' || strCNPJ === '11111111111111' || strCNPJ === '22222222222222' || strCNPJ === '33333333333333' ||
|
||||
strCNPJ === '44444444444444' || strCNPJ === '55555555555555' || strCNPJ === '66666666666666' || strCNPJ === '77777777777777' ||
|
||||
strCNPJ === '88888888888888' || strCNPJ === '99999999999999' || strCNPJ.length !== 14) {
|
||||
console.log('Processo 1');
|
||||
return { cnpjNotValid: true };
|
||||
}
|
||||
|
||||
// A variável numeros pega o bloco com os números sem o DV, a variavel
|
||||
// digitos pega apenas os dois ultimos numeros (Digito Verificador).
|
||||
let tamanho = strCNPJ.length - 2;
|
||||
let numeros = strCNPJ.substring(0, tamanho);
|
||||
const digitos = strCNPJ.substring(tamanho);
|
||||
let soma = 0;
|
||||
let pos = tamanho - 7;
|
||||
// Os quatro blocos seguintes de funções irá reaizar a validação do CNPJ propriamente
|
||||
// dito, conferindo se o DV bate. Caso alguma das funções não consiga verificar
|
||||
// o DV corretamente, mostrará uma mensagem de erro ao usuário e retornará falso,
|
||||
// para que o usário posso digitar novamente um número
|
||||
for (let i = tamanho; i >= 1; i--) {
|
||||
soma += numeros.charAt(tamanho - i) * pos--;
|
||||
if (pos < 2) {
|
||||
pos = 9;
|
||||
}
|
||||
}
|
||||
let resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
|
||||
if (resultado !== digitos.charAt(0)) {
|
||||
console.log('Processo 2');
|
||||
return { cnpjNotValid: true };
|
||||
}
|
||||
tamanho = tamanho + 1;
|
||||
numeros = strCNPJ.substring(0, tamanho);
|
||||
soma = 0;
|
||||
pos = tamanho - 7;
|
||||
for (let k = tamanho; k >= 1; k--) {
|
||||
soma += numeros.charAt(tamanho - k) * pos--;
|
||||
if (pos < 2) {
|
||||
pos = 9;
|
||||
}
|
||||
}
|
||||
resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
|
||||
if (resultado !== digitos.charAt(1)) {
|
||||
console.log('Processo 3');
|
||||
return { cnpjNotValid: true };
|
||||
}
|
||||
|
||||
console.log('cnpj valido');
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
24
src/app/shared/validators/form-validations.ts
Normal file
24
src/app/shared/validators/form-validations.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||
|
||||
export class FormValidations {
|
||||
|
||||
static maxDiscount(discountUser: number) {
|
||||
|
||||
const validator = (formControl: AbstractControl) => {
|
||||
|
||||
if (!formControl.root || (formControl.root as FormGroup).controls) {
|
||||
return null;
|
||||
}
|
||||
const mDiscount = formControl.value;
|
||||
console.log('Desconto informado: ' + mDiscount);
|
||||
console.log('desconto autorizado: ' + discountUser);
|
||||
if (mDiscount > discountUser) {
|
||||
console.log('controle invalido');
|
||||
return { maxDiscount : true };
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return validator;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user