docs: configurando deploy via ssh para angular

This commit is contained in:
2026-01-02 19:55:27 -05:00
parent a16d0f0701
commit b0beb50d59
544 changed files with 97696 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
.example {
display: flex;
justify-content: center;
}
.k-form kendo-label:not(:last-of-type) {
flex-direction: column;
margin-bottom: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthLoginComponent } from './auth-login.component';
describe('AuthLoginComponent', () => {
let component: AuthLoginComponent;
let fixture: ComponentFixture<AuthLoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AuthLoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AuthLoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,65 @@
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-auth-login',
templateUrl: './auth-login.component.html',
styleUrls: ['./auth-login.component.scss',
'./auth-login.component.css']
})
export class AuthLoginComponent implements OnInit {
public phoneNumberValue = '';
public phoneNumberMask = '(999) 000-00-00-00';
public form: FormGroup;
public data: any = {
fullName: '',
email: '',
phoneNumber: this.phoneNumberValue,
arrivalDate: null,
numberOfNights: null,
numberOfGuests: null,
terms: false,
comments: '',
};
constructor() {
this.form = new FormGroup({
fullName: new FormControl(this.data.fullName, [Validators.required]),
email: new FormControl(this.data.email, [
Validators.required,
Validators.email,
]),
phoneNumber: new FormControl(this.data.phoneNumber, [
Validators.required,
]),
arrivalDate: new FormControl(this.data.arrivalDate, [
Validators.required,
]),
numberOfNights: new FormControl(this.data.numberOfNights, [
Validators.required,
]),
numberOfGuests: new FormControl(this.data.numberOfGuests, [
Validators.required,
Validators.max(5),
]),
terms: new FormControl(this.data.terms, [Validators.requiredTrue]),
comments: new FormControl(this.data.comments),
});
}
ngOnInit(): void {
}
public submitForm(): void {
this.form.markAllAsTouched();
}
public clearForm(): void {
this.form.reset();
}
}

View File

@@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AuthLoginComponent } from './auth-login/auth-login.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { KendoModule } from '../shared/kendo.module';
import { LoginComponent } from './login/login.component';
import { RouterModule, Routes } from '@angular/router';
import { RegisterComponent } from './register/register.component';
import { AuthService } from './services/auth.service';
const routes: Routes = [{ path: '', component: LoginComponent },
{ path: 'register', component: RegisterComponent }];
@NgModule({
declarations: [AuthLoginComponent, LoginComponent, RegisterComponent],
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
KendoModule,
RouterModule.forChild(routes),
],
providers: [AuthService]
})
export class AuthModule { }

View File

@@ -0,0 +1,206 @@
.hs-login {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 32px 64px;
position: absolute;
background: #fcfcfc;
}
.logo {
width: 190px;
height: 51.54px;
}
.fs-login {
display: flex;
flex-direction: column;
align-items: flex-start;
/* width: 100%; */
}
.fs-label {
display: flex;
width: 100%;
}
.container-login {
background-image: url("../../../assets/img/Background.png");
background-size: cover;
height: 100vh;
}
.cs-login {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 60px 40px;
width: 100%;
max-width: 500px;
background: #fcfcfc;
border-radius: 5px;
}
/* Textos */
.ls-saudacao,
.ls-plataforma {
font-family: "Fira Sans", sans-serif;
text-align: center;
margin-bottom: 16px;
}
.ls-saudacao {
font-weight: 400;
font-size: 40px;
color: #ef7d00;
}
.ls-plataforma {
font-weight: 700;
font-size: 40px;
color: #2d2e83;
}
.ls-subtitle {
font-family: "Open Sans", sans-serif;
font-weight: 700;
font-size: 20px;
color: #ef7d00;
margin-bottom: 10px;
}
.ls-text {
position: static;
width: 87px;
height: 19px;
left: 0px;
top: 37px;
font-family: "Open Sans";
font-style: normal;
font-weight: 700;
font-size: 14px;
line-height: 19px;
/* identical to box height */
color: #848484;
/* Inside auto layout */
flex: none;
order: 1;
flex-grow: 0;
margin: 10px 0px;
}
.is-text {
/* Auto layout */
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 0px;
align-items: center;
position: static;
width: 408px;
height: 48px;
left: 0px;
top: 66px;
/* Inside auto layout */
flex: none;
order: 2;
align-self: stretch;
flex-grow: 0;
margin: 10px 0px;
}
.bs-default {
display: flex;
justify-content: center;
align-items: center;
color: white;
width: 100%;
height: 48px;
background: #2d2e83;
border-radius: 5px;
margin-top: 16px;
}
.ls-forgot-password {
text-align: center;
margin-top: 16px;
}
.ls-link-forgot-password {
text-decoration: underline;
color: #2d2e83;
}
/* Responsividade */
/* Smartphones */
@media (max-width: 575.98px) {
.cs-login {
padding: 40px 20px;
max-width: 300px;
}
.ls-saudacao {
font-size: 24px;
}
.ls-plataforma {
font-size: 20px;
}
.bs-default {
height: 56px;
}
.is-text {
width: 300px;
height: 40px;
}
.ls-forgot-password {
font-size: 12px;
}
.ls-link-forgot-password {
font-size: 12px;
}
}
/* Tablets */
@media (max-width: 991.98px) {
.cs-login {
max-width: 400px;
}
.ls-saudacao {
font-size: 28px;
}
.ls-plataforma {
font-size: 24px;
}
.is-text {
width: 250px;
height: 40px;
}
}
/* Desktops */
@media (min-width: 992px) {
.cs-login {
max-width: 500px;
}
}

View File

@@ -0,0 +1,56 @@
<div class="container-fluid container-login">
<div class="d-flex flex-column">
<div class="row justify-content-center align-items-center" style="height: 100vh;">
<div class="col-12 col-sm-8 col-md-6 col-xl-4">
<div class="cs-login">
<div class="text-center">
<span class="ls-saudacao">Bem-vindo(a),</span>
<span class="ls-plataforma">à plataforma SMART</span>
</div>
<form class="fs-login" [formGroup]="form" (keydown.enter)="submitForm()">
<span class="ls-subtitle">Acesse sua conta</span>
<kendo-formfield>
<label>
<span class="ls-text">Email</span>
<kendo-textbox class="is-text" formControlName="email" placeholder="Informe seu email de acesso" #email
required>
</kendo-textbox>
</label>
<!-- <kendo-formerror *ngIf="form.controls.email.errors?.required">
Erro: Email é obrigatório!
</kendo-formerror>
<kendo-formerror *ngIf="form.controls.email.errors?.email">
Error: Informe um email com formato válido.
</kendo-formerror> -->
</kendo-formfield>
<kendo-formfield>
<label>
<span class="ls-text">Senha</span>
<kendo-textbox class="k-textbox is-text" type="password" placeholder="Informe sua senha" #password
formControlName="password">
<ng-template kendoTextBoxSuffixTemplate>
<button
kendoButton
look="clear"
[icon]="passwordVisible ? 'eye-slash' : 'eye'"
(click)="toggleVisibility()"
type="button"
></button>
</ng-template>
</kendo-textbox>
</label>
<kendo-formerror>Erro: A senha é obrigatória!</kendo-formerror>
</kendo-formfield>
<span class="ls-forgot-password">
Esqueceu a senha? <a class="ls-link-forgot-password">Recupere o acesso</a>
</span>
<button kendoButton class="bs-default" [disabled]="isLoading" [icon]="loadingIcon" (click)="submitForm()">
ENTRAR
</button>
</form>
</div>
</div>
</div>
</div>
</div>
<div kendoDialogContainer></div>

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,151 @@
import { AfterViewInit, Component, NgZone, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { DialogService } from '@progress/kendo-angular-dialog';
import { TextBoxComponent } from '@progress/kendo-angular-inputs';
import { thumbnailsUpIcon } from '@progress/kendo-svg-icons';
import { ResultApi } from 'src/app/models/result-api.model';
import { MessageFailureComponent } from 'src/app/shared/menssages/message-failure/message-failure.component';
import { AuthService } from '../services/auth.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss',
'./login.component.css']
})
export class LoginComponent implements OnInit, AfterViewInit {
@ViewChild('password') public textbox: TextBoxComponent;
public initialPassword = true;
public passwordVisible = false;
public loadingIcon = '';
public form: FormGroup;
public data: any = {
email: '',
password: '',
};
constructor(private authService: AuthService,
private router: Router,
private dialogService: DialogService,
private ngZone: NgZone
) {
this.form = new FormGroup({
password: new FormControl(this.data.password, [Validators.required, Validators.minLength(3)]),
email: new FormControl(this.data.email, [
Validators.required,
]),
});
}
private dialog: any;
public onEnter(event: KeyboardEvent): void {
event.preventDefault(); // Evita o envio do formulário padrão
if (this.form.valid) {
this.submitForm(); // Apenas submete se o formulário for válido
}
}
public submitForm(): void {
this.form.markAllAsTouched();
if (this.form.valid) {
this.loadingIcon = 'loading';
const domain = '@jurunense.com.br';
let email = this.form.value.email;
// Remover domínio existente se já foi digitado
if (email.toLowerCase().endsWith(domain)) {
email = email.substring(0, email.length - domain.length);
}
const emailUpperCase = (email + domain).toUpperCase();
const passwordUpperCase = this.form.value.password.toUpperCase();
this.authService.login({
email: emailUpperCase,
password: passwordUpperCase
})
.subscribe((res: ResultApi) => {
if (res.success) {
this.loadingIcon = '';
console.log(JSON.stringify(res.data));
this.authService.setDataInLocalStorage('user', JSON.stringify(res.data));
this.authService.setDataInLocalStorage('token', res.data.token);
localStorage.removeItem('cart');
this.router.navigate(['/menu']);
} else {
this.loadingIcon = '';
this.showErrorMessage(res.message);
}
}, err => {
this.loadingIcon = '';
this.showErrorMessage(`${err.error.message}`);
});
}
}
public get isLoading(): boolean {
return this.loadingIcon !== '';
}
public clearForm(): void {
this.form.reset();
}
public togglePass(): void {
const inputEl = this.textbox.input.nativeElement;
if (this.initialPassword) {
inputEl.type = 'password';
this.initialPassword = false;
return;
}
if (inputEl.type === 'password') {
inputEl.type = 'text';
} else {
inputEl.type = 'password';
}
console.log(this.form.controls.password.value);
}
getUserName() {
return this.authService.getUserName();
}
showErrorMessage(message: string) {
console.log('mensagem de erro', message);
const dialogRef = this.dialogService
.open({
title: 'Error',
content: MessageFailureComponent,
actions: [{ text: 'OK', primary: true }],
width: 400,
height: 250,
minWidth: 250,
});
const messageInfo = dialogRef.content.instance;
messageInfo.message = message;
this.ngZone.run(() => {
dialogRef.result.subscribe();
});
}
ngOnInit(): void { }
public ngAfterViewInit(): void {
this.textbox.input.nativeElement.type = 'password';
}
public toggleVisibility(): void {
const inputEl = this.textbox.input.nativeElement;
this.passwordVisible = !this.passwordVisible;
inputEl.type = this.passwordVisible ? 'text' : 'password';
}
}

View File

@@ -0,0 +1,42 @@
<div class="example">
<form class="k-form" [formGroup]="form">
<h5 class="text-center">CADASTRO DE NOVO USUARIO</h5>
<kendo-formfield>
<kendo-label [for]="email" text="Email"></kendo-label>
<kendo-textbox
formControlName="email"
[clearButton]="true"
#email
required
></kendo-textbox>
<kendo-formerror *ngIf="form.controls.email.errors?.required"
>Error: Email is required</kendo-formerror
>
<kendo-formerror *ngIf="form.controls.email.errors?.email"
>Error: Not valid email format</kendo-formerror
>
</kendo-formfield>
<kendo-formfield>
<kendo-label [for]="password" text="Senha"></kendo-label>
<kendo-textbox
formControlName="password"
[clearButton]="true"
#password
required
></kendo-textbox>
<kendo-formerror>Error: Password is required</kendo-formerror>
</kendo-formfield>
<div class="k-form-buttons">
<button class="k-button k-primary" (click)="submitForm()">
Send Reservation Request
</button>
<button class="k-button" (click)="clearForm()">Clear</button>
</div>
</form>
</div>

View File

@@ -0,0 +1,10 @@
.example {
display: flex;
justify-content: center;
align-content: center;
}
.k-form kendo-label:not(:last-of-type) {
flex-direction: column;
margin-bottom: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RegisterComponent } from './register.component';
describe('RegisterComponent', () => {
let component: RegisterComponent;
let fixture: ComponentFixture<RegisterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RegisterComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RegisterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,60 @@
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { AuthService } from '../services/auth.service';
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
public form: FormGroup;
public errorMessage: string;
public successMessage: string;
public data: any = {
email: '',
password: '',
};
constructor(private authService: AuthService) {
this.form = new FormGroup({
password: new FormControl(this.data.password, [Validators.required, Validators.minLength(3)]),
email: new FormControl(this.data.email, [
Validators.required,
Validators.email,
]),
});
}
public submitForm(): void {
this.form.markAllAsTouched();
if (this.form.valid){
this.tryRegister({email: this.form.value.email, password: this.form.value.password});
}
}
public clearForm(): void {
this.form.reset();
}
tryRegister(value){
/*this.authService.doRegister(value)
.then(res => {
console.log(res);
this.errorMessage = '';
this.successMessage = 'Your account has been created';
console.log(this.successMessage);
}, err => {
console.log(err);
this.errorMessage = err.message;
this.successMessage = '';
console.log(err.code + ' - ' + this.errorMessage);
});*/
}
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,183 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { ResultApi } from 'src/app/models/result-api.model';
import { environment } from 'src/environments/environment';
import { AuthUser } from '../../models/auth.user.model';
import jwt_decode from 'jwt-decode';
import { ModuleSystem } from 'src/app/models/module.model';
import { PagesUser } from 'src/app/models/pages-user.model';
import { ActionsUser } from 'src/app/models/actions-user.model';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private UserAuthenticate = false;
public actionsUser: ActionsUser[];
constructor(public httpClient: HttpClient,
public router: Router) { }
/*doRegister(value){
return new Promise<any>((resolve, reject) => {
this.afAuth.createUserWithEmailAndPassword(value.email, value.password)
.then(res => {
resolve(res);
}, err => reject(err));
});
}
doEmailAndPasswordLogin(value){
return new Promise<any>((resolve, reject) => {
this.afAuth
.signInWithEmailAndPassword(value.email, value.password)
.then(res => {
console.log(res);
resolve(res);
}, err => reject(err));
});
} */
login(value: AuthUser): Observable<ResultApi> {
return this.httpClient.post<ResultApi>(`${environment.url}auth/login`, value);
}
logout() {
localStorage.removeItem('user');
localStorage.removeItem('token');
this.router.navigate(['login']);
}
authenticate(value: AuthUser): Observable<ResultApi> {
return this.httpClient.post<ResultApi>(`${environment.url}auth/authenticate`, value);
}
getDiscount(id: number = 0): Observable<ResultApi> {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
const token = this.getToken();
const headers = new HttpHeaders().set('Authorization', `Basic ${token}`);
let userId = user.id;
if (id > 0){
userId = id;
}
return this.httpClient.get<ResultApi>(`${environment.url}auth/discount-user/${userId}`);
}
getModules(id: number) {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
const token = this.getToken();
const headers = new HttpHeaders().set('Authorization', `Basic ${token}`);
let userId = user.id;
if (id > 0){
userId = id;
}
return this.httpClient.get<ModuleSystem[]>(`${environment.url}access-control/modules/${userId}`);
}
getPagesUser(moduleId: number) {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
const token = this.getToken();
const headers = new HttpHeaders().set('Authorization', `Basic ${token}`);
return this.httpClient.get<PagesUser[]>(`${environment.url}access-control/pages/${user.id}/${moduleId}`);
}
getActionsUser(moduleId: number) {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
const token = this.getToken();
const headers = new HttpHeaders().set('Authorization', `Basic ${token}`);
return this.httpClient.get<ActionsUser[]>(`${environment.url}access-control/actions/${user.id}/${moduleId}`);
}
setDataInLocalStorage(variableName: string, data: any) {
localStorage.setItem(variableName, data);
}
getToken() {
return localStorage.getItem('token');
}
getPayload() {
try {
return jwt_decode(this.getToken()) as any;
} catch (Error) {
return null;
}
}
isManager() {
const data = this.getPayload();
console.log(JSON.stringify(data));
return data.sectorId.toString() === data.sectorManagerId.toString();
}
getUserName() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.username;
}
getStoreName() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.name;
}
getUser() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.id;
}
getSeller() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.seller;
}
getSupervisor() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.supervisorId;
}
getStore() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.store;
}
getDeliveryTime() {
const data = localStorage.getItem('user');
const user = JSON.parse(data);
return user.deliveryTime;
}
deleteDataLocalStorage(variableName: string) {
localStorage.removeItem(variableName);
}
isAuthenticate(){
console.log(localStorage.getItem('token'));
return localStorage.getItem('token') != null;
}
userAction(processId: number, pageId: number, actionId: number) {
const actionUser = this.actionsUser
.find(action => action.moduleId == 2 &&
action.processId == processId &&
action.pageId == pageId &&
action.actionId == actionId &&
action.access == "S" );
console.log(this.actionsUser);
return actionUser !== undefined && actionUser!== null;
}
}