From 841ef7e16fc1fcc016bccdef3a7c2be44782a5dd Mon Sep 17 00:00:00 2001 From: Diego Carlito Date: Thu, 2 Nov 2023 00:54:30 -0300 Subject: [PATCH 01/17] Corrige docker para o windows Co-authored-by: Ricardo Loureiro Co-authored-by: Geraldo Victor --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 709082f9..ba3d1d7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,4 +11,4 @@ services: volumes: - .:/unb-tv-web - /unb-tv-web/node_modules - command: ng serve --host 0 --port 4200 + command: ng serve --host 0 --port 4200 --poll 2000 From 64e0b3b0fa949ea88286ca554d4fc5fe0019e443 Mon Sep 17 00:00:00 2001 From: Diego Carlito Date: Thu, 2 Nov 2023 00:55:33 -0300 Subject: [PATCH 02/17] =?UTF-8?q?Adiciona=20componente=20de=20sugest=C3=A3?= =?UTF-8?q?o=20de=20pauta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ricardo Loureiro Co-authored-by: Geraldo Victor --- src/app/app-routing.module.ts | 2 ++ src/app/app.module.ts | 2 ++ .../suggest-agenda.component.css | 4 ++++ .../suggest-agenda.component.html | 5 ++++ .../suggest-agenda.component.spec.ts | 23 +++++++++++++++++++ .../suggest-agenda.component.ts | 10 ++++++++ 6 files changed, 46 insertions(+) create mode 100644 src/app/pages/suggest-agenda/suggest-agenda.component.css create mode 100644 src/app/pages/suggest-agenda/suggest-agenda.component.html create mode 100644 src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts create mode 100644 src/app/pages/suggest-agenda/suggest-agenda.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 31eca30f..caff5ca9 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -12,6 +12,7 @@ import { CheckCodeRestPasswordComponent } from './pages/check-code-rest-password import { ResetPasswordComponent } from './pages/reset-password/reset-password.component'; import { AuthGuard } from './services/auth.guard'; import { EditUserComponent } from './pages/edit-user/edit-user.component'; +import { SuggestAgendaComponent } from './pages/suggest-agenda/suggest-agenda.component'; const routes: Routes = [ { path: 'login', component: LoginComponent }, @@ -22,6 +23,7 @@ const routes: Routes = [ { path: 'activeAccount', component: ActiveAccountComponent }, { path: 'sendCodeResetPassword', component: CheckCodeRestPasswordComponent }, { path: 'changePassword', component: ResetPasswordComponent }, + { path: 'suggestAgenda', component: SuggestAgendaComponent }, { path: 'profile', component: ProfileComponent, canActivate: [AuthGuard], }, { path: 'editUser/:id', component: EditUserComponent, canActivate: [AuthGuard], }, { path: '', component: HomePageComponent, canActivate: [AuthGuard], } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3d7a5c4e..6a602fb8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,6 +22,7 @@ import { CheckCodeRestPasswordComponent } from './pages/check-code-rest-password import { AuthGuard } from './services/auth.guard'; import { AuthService } from './services/auth.service'; import { EditUserComponent } from './pages/edit-user/edit-user.component'; +import { SuggestAgendaComponent } from './pages/suggest-agenda/suggest-agenda.component'; @NgModule({ declarations: [ @@ -40,6 +41,7 @@ import { EditUserComponent } from './pages/edit-user/edit-user.component'; ResetPasswordComponent, CheckCodeRestPasswordComponent, EditUserComponent, + SuggestAgendaComponent, ], imports: [ BrowserModule, diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.css b/src/app/pages/suggest-agenda/suggest-agenda.component.css new file mode 100644 index 00000000..ad488dd6 --- /dev/null +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.css @@ -0,0 +1,4 @@ +.width-suggest-agend { + width: 866px; + +} \ No newline at end of file diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html new file mode 100644 index 00000000..e31e9eb5 --- /dev/null +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -0,0 +1,5 @@ +
+
+

Sugestão de Pautas

+
+
diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts new file mode 100644 index 00000000..529d591d --- /dev/null +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SuggestAgendaComponent } from './suggest-agenda.component'; + +describe('SuggestAgendaComponent', () => { + let component: SuggestAgendaComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ SuggestAgendaComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SuggestAgendaComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.ts new file mode 100644 index 00000000..0316e6b0 --- /dev/null +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-suggest-agenda', + templateUrl: './suggest-agenda.component.html', + styleUrls: ['./suggest-agenda.component.css'] +}) +export class SuggestAgendaComponent { + +} From 1e8190c15cb0725cae75b6cbd9c28044e8dc96e1 Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Thu, 2 Nov 2023 13:49:43 -0300 Subject: [PATCH 03/17] Tela Sugestao de pauta Co-authored-by: VitoriaAquere Co-authored-by: Diego-Carlito --- .../login-social/login-social.component.css | 3 +- .../suggest-agenda.component.css | 65 ++++++++++++++++++- .../suggest-agenda.component.html | 14 +++- 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/src/app/pages/login-social/login-social.component.css b/src/app/pages/login-social/login-social.component.css index fcca13ed..807ed9e3 100644 --- a/src/app/pages/login-social/login-social.component.css +++ b/src/app/pages/login-social/login-social.component.css @@ -104,4 +104,5 @@ color: #0087C8; margin-left: -140px; margin-top: 18.5px -} \ No newline at end of file +} + diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.css b/src/app/pages/suggest-agenda/suggest-agenda.component.css index ad488dd6..d4015d8c 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.css +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.css @@ -1,4 +1,63 @@ -.width-suggest-agend { - width: 866px; + +.containner { + width: 360px; + margin-left: auto; + margin-right: auto; + text-align: center; + height: -300px; +} + +.containner h1 { + color: #0087C8; + font-size: 13px; + font-family: "unb-pro", sans-serif; + font-style: normal; + font-weight: 700; + line-height: 12.35px; + margin-left: 29px; + margin-top: 45px; + margin-bottom: 40px; + text-align: start; +} + +.first { + border: 0.15px solid #3C3C3B; + margin-left: 29px; + width: 330px; + border-radius: 9px; + height: 30px; -} \ No newline at end of file +} + +form ::placeholder { + font-size: 13px; + font-family: "unb-pro", sans-serif; + padding: 9px 0 10px 28px; + +} + +.descricao { + border: 0.15px solid #3C3C3B; + margin-left: 29px; + width: 330px; + border-radius: 9px; + height: 100px; +} + +.descricao::placeholder { + top: -35px; + +} + +button { + background-color: #0087C8; + padding: 3px 33px 3px 33px; + border-radius: 9px; + margin-top: 7px; +} + +span { + color: white; + font-family: "unb-pro", sans-serif; + font-size: 13px; +} diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index e31e9eb5..d042db9a 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -1,5 +1,15 @@ -
-
+
+

Sugestão de Pautas

+
+

+

+

+

+

+

+

+ +
From d2aade926fde78f164d0a3ac91bd81f022f1e997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vit=C3=B3ria=20Aquere=20Matos?= Date: Thu, 2 Nov 2023 14:49:52 -0300 Subject: [PATCH 04/17] Adiciona service de e-mail Co-authored-by: Geraldo Victor Co-authored-by: Diego-Carlito --- src/app/services/email.service.spec.ts | 16 ++++++++++++++++ src/app/services/email.service.ts | 17 +++++++++++++++++ src/shared/model/email.model.ts | 12 ++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/app/services/email.service.spec.ts create mode 100644 src/app/services/email.service.ts create mode 100644 src/shared/model/email.model.ts diff --git a/src/app/services/email.service.spec.ts b/src/app/services/email.service.spec.ts new file mode 100644 index 00000000..1d765b40 --- /dev/null +++ b/src/app/services/email.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { EmailService } from './email.service'; + +describe('EmailService', () => { + let service: EmailService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(EmailService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/email.service.ts b/src/app/services/email.service.ts new file mode 100644 index 00000000..d8803f5f --- /dev/null +++ b/src/app/services/email.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { IEmailData } from 'src/shared/model/email.model'; + +@Injectable({ + providedIn: 'root' +}) +export class EmailService { + private apiUrl = 'http://localhost:8000/pauta/email'; // Ajuste conforme necessário + + constructor(private http: HttpClient) {} + + sendEmail(emailData: IEmailData): Observable { + return this.http.post(this.apiUrl, emailData); + } +} \ No newline at end of file diff --git a/src/shared/model/email.model.ts b/src/shared/model/email.model.ts new file mode 100644 index 00000000..cc8c61ed --- /dev/null +++ b/src/shared/model/email.model.ts @@ -0,0 +1,12 @@ + +export interface IEmailData { + email?: string; + message?: string; +} + +export class EmailData implements IEmailData { + constructor( + public email?: string, + public message?: string + ) { } +} \ No newline at end of file From fb13f0cc14a744e4ff6a5e0e746dc1b605d585cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vit=C3=B3ria=20Aquere=20Matos?= Date: Thu, 2 Nov 2023 20:37:24 -0300 Subject: [PATCH 05/17] =?UTF-8?q?Integra=C3=A7=C3=A3o=20do=20frontend=20co?= =?UTF-8?q?m=20o=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Geraldo Victor Co-authored-by: Diego-Carlito --- src/app/pages/profile/profile.component.ts | 6 +-- .../suggest-agenda.component.html | 18 +++---- .../suggest-agenda.component.ts | 50 ++++++++++++++++++- src/app/services/email.service.ts | 6 +-- src/shared/model/email.model.ts | 22 +++++--- 5 files changed, 79 insertions(+), 23 deletions(-) diff --git a/src/app/pages/profile/profile.component.ts b/src/app/pages/profile/profile.component.ts index c858274e..d62bd099 100644 --- a/src/app/pages/profile/profile.component.ts +++ b/src/app/pages/profile/profile.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { NavigationExtras, Router } from '@angular/router'; import { UserService } from 'src/app/services/user.service'; -import jwt_decode from 'jwt-decode'; +//import jwt_decode from 'jwt-decode'; @Component({ selector: 'app-profile', @@ -25,8 +25,8 @@ export class ProfileComponent { } setUserIdFromToken(token: string) { - const decodedToken: any = jwt_decode(token); - this.userId = decodedToken.id; + //const decodedToken: any = jwt_decode(token); + //this.userId = decodedToken.id; } getUser() { diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index d042db9a..98af5690 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -1,15 +1,15 @@

Sugestão de Pautas

-
-

-

-

-

-

-

-

- + +

+

+

+

+

+

+

+
diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.ts index 0316e6b0..3f24685d 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.ts @@ -1,10 +1,56 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { EmailService } from 'src/app/services/email.service'; @Component({ selector: 'app-suggest-agenda', templateUrl: './suggest-agenda.component.html', styleUrls: ['./suggest-agenda.component.css'] }) -export class SuggestAgendaComponent { +export class SuggestAgendaComponent implements OnInit{ + + suggestAgendaForm!: FormGroup; + + constructor( + private fb: FormBuilder, + private emailService: EmailService + ){} + + ngOnInit(): void { + this.suggestAgendaForm = this.fb.group({ + tema: ['', [Validators.required]], + descricao: ['', [Validators.required]], + quando: ['', [Validators.required]], + local: ['', [Validators.required]], + responsavel: ['', [Validators.required]], + telefoneResponsavel: ['', [Validators.required]], + emailContato: ['', [Validators.required]], + }, + ); + } + + sendSuggestAgenda(): void{ + console.log('this.suggestAgendaForm', this.suggestAgendaForm.tema); + if (this.suggestAgendaForm.valid) { + const email = new EmailData(); + email.tema = this.suggestAgendaForm.tema; + email.descricao = this.suggestAgendaForm.descricao; + email.local = this.suggestAgendaForm.local; + email.quando = this.suggestAgendaForm.quando; + email.responsavel = this.suggestAgendaForm.responsavel; + email.telefone_responsavel = this.suggestAgendaForm.telefoneResponsavel; + email.email_contato = this.suggestAgendaForm.emailContato; + const emailUnB = 'geraldovictor@outlook.com'; + emailData.email = emailUnB; + this.emailService.sendEmail(emailData).subscribe((res: HttpResponse) => { + console.log('email enviado com sucesso'); + }, + (error: HttpResponseError) => { + console.log('error', error.message); + }); + } else { + alert('Preencha todos os campos corretamente!'); + } + } } diff --git a/src/app/services/email.service.ts b/src/app/services/email.service.ts index d8803f5f..dfaeecc2 100644 --- a/src/app/services/email.service.ts +++ b/src/app/services/email.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { IEmailData } from 'src/shared/model/email.model'; +import { IEmail } from 'src/shared/model/email.model'; @Injectable({ providedIn: 'root' @@ -11,7 +11,7 @@ export class EmailService { constructor(private http: HttpClient) {} - sendEmail(emailData: IEmailData): Observable { - return this.http.post(this.apiUrl, emailData); + sendEmail(email: IEmail): Observable { + return this.http.post(this.apiUrl, email); } } \ No newline at end of file diff --git a/src/shared/model/email.model.ts b/src/shared/model/email.model.ts index cc8c61ed..81534ce0 100644 --- a/src/shared/model/email.model.ts +++ b/src/shared/model/email.model.ts @@ -1,12 +1,22 @@ -export interface IEmailData { - email?: string; - message?: string; +export interface IEmail { + tema?: string; + descricao?: string; + quando?: string; + local?: string; + responsavel?: string; + telefone_responsavel?: string; + email_contato?: string; } -export class EmailData implements IEmailData { +export class Email implements IEmail { constructor( - public email?: string, - public message?: string + public tema?: string, + public descricao?: string, + public quando?: string, + public local?: string, + public responsavel?: string, + public telefone_responsavel?: string, + public email_contato?: string ) { } } \ No newline at end of file From a7ba678fb61a2bdbf055786c302fe2037174b056 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Fri, 3 Nov 2023 14:29:16 -0300 Subject: [PATCH 06/17] =?UTF-8?q?Descomenta=20c=C3=B3digo=20commitado=20po?= =?UTF-8?q?r=20engano?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/profile/profile.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/pages/profile/profile.component.ts b/src/app/pages/profile/profile.component.ts index d62bd099..c858274e 100644 --- a/src/app/pages/profile/profile.component.ts +++ b/src/app/pages/profile/profile.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { NavigationExtras, Router } from '@angular/router'; import { UserService } from 'src/app/services/user.service'; -//import jwt_decode from 'jwt-decode'; +import jwt_decode from 'jwt-decode'; @Component({ selector: 'app-profile', @@ -25,8 +25,8 @@ export class ProfileComponent { } setUserIdFromToken(token: string) { - //const decodedToken: any = jwt_decode(token); - //this.userId = decodedToken.id; + const decodedToken: any = jwt_decode(token); + this.userId = decodedToken.id; } getUser() { From afb3930a511f7c45fc38479c09098fbb67bbb636 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Fri, 3 Nov 2023 17:23:16 -0300 Subject: [PATCH 07/17] =?UTF-8?q?Ajusta=20formata=C3=A7=C3=A3o=20e=20corri?= =?UTF-8?q?ge=20requisi=C3=A7=C3=A3o=20para=20endpoint=20do=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../suggest-agenda.component.css | 13 ++++--- .../suggest-agenda.component.html | 20 ++++++----- .../suggest-agenda.component.ts | 35 ++++++++++--------- src/app/services/email.service.ts | 6 ++-- src/shared/model/email.model.ts | 8 +++-- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.css b/src/app/pages/suggest-agenda/suggest-agenda.component.css index d4015d8c..db87a650 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.css +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.css @@ -26,14 +26,12 @@ width: 330px; border-radius: 9px; height: 30px; - + padding: 9px 0 10px 28px; } form ::placeholder { font-size: 13px; - font-family: "unb-pro", sans-serif; - padding: 9px 0 10px 28px; - + font-family: "unb-pro", sans-serif; } .descricao { @@ -42,11 +40,11 @@ form ::placeholder { width: 330px; border-radius: 9px; height: 100px; + padding: 9px 0 10px 28px; } .descricao::placeholder { top: -35px; - } button { @@ -61,3 +59,8 @@ span { font-family: "unb-pro", sans-serif; font-size: 13px; } + +.input:focus { + outline: none !important; + border: 0.25px solid #00A550; + } \ No newline at end of file diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index 98af5690..32326691 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -1,15 +1,17 @@

Sugestão de Pautas

-
-

-

-

-

-

-

-

- + + + + + + + + +
+ +
diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.ts index 3f24685d..7d9b057f 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { EmailService } from 'src/app/services/email.service'; +import { EmailData } from 'src/shared/model/email.model'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'app-suggest-agenda', @@ -18,35 +20,34 @@ export class SuggestAgendaComponent implements OnInit{ ngOnInit(): void { this.suggestAgendaForm = this.fb.group({ - tema: ['', [Validators.required]], + tema: [''], descricao: ['', [Validators.required]], - quando: ['', [Validators.required]], - local: ['', [Validators.required]], + quando: [''], + local: [''], responsavel: ['', [Validators.required]], telefoneResponsavel: ['', [Validators.required]], - emailContato: ['', [Validators.required]], + emailContato: [''], }, ); } sendSuggestAgenda(): void{ - console.log('this.suggestAgendaForm', this.suggestAgendaForm.tema); if (this.suggestAgendaForm.valid) { - const email = new EmailData(); - email.tema = this.suggestAgendaForm.tema; - email.descricao = this.suggestAgendaForm.descricao; - email.local = this.suggestAgendaForm.local; - email.quando = this.suggestAgendaForm.quando; - email.responsavel = this.suggestAgendaForm.responsavel; - email.telefone_responsavel = this.suggestAgendaForm.telefoneResponsavel; - email.email_contato = this.suggestAgendaForm.emailContato; + const emailData = new EmailData(); + emailData.tema = this.suggestAgendaForm.value.tema; + emailData.descricao = this.suggestAgendaForm.value.descricao; + emailData.local = this.suggestAgendaForm.value.local; + emailData.quando = this.suggestAgendaForm.value.quando; + emailData.responsavel = this.suggestAgendaForm.value.responsavel; + emailData.telefone_responsavel = this.suggestAgendaForm.value.telefoneResponsavel; + emailData.email_contato = this.suggestAgendaForm.value.emailContato; const emailUnB = 'geraldovictor@outlook.com'; - emailData.email = emailUnB; + emailData.recipients = [emailUnB]; this.emailService.sendEmail(emailData).subscribe((res: HttpResponse) => { - console.log('email enviado com sucesso'); + alert('Sugestão enviada com sucesso'); }, - (error: HttpResponseError) => { - console.log('error', error.message); + (error: HttpErrorResponse) => { + alert('error: ' + error.message); }); } else { alert('Preencha todos os campos corretamente!'); diff --git a/src/app/services/email.service.ts b/src/app/services/email.service.ts index dfaeecc2..cbe6b773 100644 --- a/src/app/services/email.service.ts +++ b/src/app/services/email.service.ts @@ -1,17 +1,17 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { IEmail } from 'src/shared/model/email.model'; +import { IEmailData } from 'src/shared/model/email.model'; @Injectable({ providedIn: 'root' }) export class EmailService { - private apiUrl = 'http://localhost:8000/pauta/email'; // Ajuste conforme necessário + private apiUrl = 'http://localhost:8080/api/pauta/email'; // Ajuste conforme necessário constructor(private http: HttpClient) {} - sendEmail(email: IEmail): Observable { + sendEmail(email: IEmailData): Observable { return this.http.post(this.apiUrl, email); } } \ No newline at end of file diff --git a/src/shared/model/email.model.ts b/src/shared/model/email.model.ts index 81534ce0..fa930695 100644 --- a/src/shared/model/email.model.ts +++ b/src/shared/model/email.model.ts @@ -1,5 +1,5 @@ -export interface IEmail { +export interface IEmailData { tema?: string; descricao?: string; quando?: string; @@ -7,9 +7,10 @@ export interface IEmail { responsavel?: string; telefone_responsavel?: string; email_contato?: string; + recipients?: string[]; } -export class Email implements IEmail { +export class EmailData implements IEmailData { constructor( public tema?: string, public descricao?: string, @@ -17,6 +18,7 @@ export class Email implements IEmail { public local?: string, public responsavel?: string, public telefone_responsavel?: string, - public email_contato?: string + public email_contato?: string, + public recipients?: string[], ) { } } \ No newline at end of file From 70e669d599e18fad5e2ec229601c26c46dd15c9a Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Fri, 3 Nov 2023 17:52:51 -0300 Subject: [PATCH 08/17] =?UTF-8?q?Corrige=20testes=20iniciais=20de=20cria?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20componentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: VitoriaAquere --- .../suggest-agenda/suggest-agenda.component.spec.ts | 10 ++++++++-- .../pages/video-viewer/video-viewer.component.spec.ts | 2 +- src/app/pages/video/video.component.spec.ts | 2 +- src/app/services/email.service.spec.ts | 7 +++++-- src/app/services/video.service.spec.ts | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts index 529d591d..dd1dea71 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { SuggestAgendaComponent } from './suggest-agenda.component'; +import { EmailService } from 'src/app/services/email.service'; +import { FormBuilder } from '@angular/forms'; +import { ReactiveFormsModule } from '@angular/forms'; describe('SuggestAgendaComponent', () => { let component: SuggestAgendaComponent; @@ -8,7 +11,10 @@ describe('SuggestAgendaComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ SuggestAgendaComponent ] + declarations: [ SuggestAgendaComponent ], + imports: [HttpClientTestingModule, + ReactiveFormsModule], + providers: [{ provide: EmailService, FormBuilder}] }) .compileComponents(); diff --git a/src/app/pages/video-viewer/video-viewer.component.spec.ts b/src/app/pages/video-viewer/video-viewer.component.spec.ts index feaf9281..e682490b 100644 --- a/src/app/pages/video-viewer/video-viewer.component.spec.ts +++ b/src/app/pages/video-viewer/video-viewer.component.spec.ts @@ -2,8 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from "@angular/router/testing"; import { VideoViewerComponent } from './video-viewer.component'; -import { VideoService } from './video.service'; import { SafePipe } from 'src/app/pipes/safe.pipe'; +import { VideoService } from 'src/app/services/video.service'; describe('VideoViewerComponent', () => { let component: VideoViewerComponent; diff --git a/src/app/pages/video/video.component.spec.ts b/src/app/pages/video/video.component.spec.ts index 79fd12db..5e94afc2 100644 --- a/src/app/pages/video/video.component.spec.ts +++ b/src/app/pages/video/video.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { VideoComponent } from './video.component'; -import { VideoService } from './video.service'; +import { VideoService } from 'src/app/services/video.service'; describe('VideoComponent', () => { let component: VideoComponent; diff --git a/src/app/services/email.service.spec.ts b/src/app/services/email.service.spec.ts index 1d765b40..a47083aa 100644 --- a/src/app/services/email.service.spec.ts +++ b/src/app/services/email.service.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; - +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { EmailService } from './email.service'; describe('EmailService', () => { let service: EmailService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [EmailService] + }); service = TestBed.inject(EmailService); }); diff --git a/src/app/services/video.service.spec.ts b/src/app/services/video.service.spec.ts index 3378e3ce..84e13dd8 100644 --- a/src/app/services/video.service.spec.ts +++ b/src/app/services/video.service.spec.ts @@ -1,8 +1,8 @@ import { TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { VideoService } from './video.service'; import { EDUPLAY_API_URL, UNB_ID } from 'src/app/app.constant'; -import { EDUPLAY_CLIENT_KEY } from 'src/app/secret/eduplay.credentials'; +import { EDUPLAY_CLIENT_KEY } from '../environment/environment'; +import { VideoService } from './video.service'; describe('VideoService', () => { let service: VideoService; From 1fc574de5f6c87b128e6fab1bbcacebe99ff1df0 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 16:03:55 -0300 Subject: [PATCH 09/17] =?UTF-8?q?Adiciona=20componente=20de=20participa?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app-routing.module.ts | 2 ++ src/app/app.module.ts | 2 ++ .../participate/participate.component.css | 0 .../participate/participate.component.html | 1 + .../participate/participate.component.spec.ts | 23 +++++++++++++++++++ .../participate/participate.component.ts | 10 ++++++++ 6 files changed, 38 insertions(+) create mode 100644 src/app/pages/participate/participate.component.css create mode 100644 src/app/pages/participate/participate.component.html create mode 100644 src/app/pages/participate/participate.component.spec.ts create mode 100644 src/app/pages/participate/participate.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index caff5ca9..b1f37e8b 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -13,6 +13,7 @@ import { ResetPasswordComponent } from './pages/reset-password/reset-password.co import { AuthGuard } from './services/auth.guard'; import { EditUserComponent } from './pages/edit-user/edit-user.component'; import { SuggestAgendaComponent } from './pages/suggest-agenda/suggest-agenda.component'; +import { ParticipateComponent } from './pages/participate/participate.component'; const routes: Routes = [ { path: 'login', component: LoginComponent }, @@ -24,6 +25,7 @@ const routes: Routes = [ { path: 'sendCodeResetPassword', component: CheckCodeRestPasswordComponent }, { path: 'changePassword', component: ResetPasswordComponent }, { path: 'suggestAgenda', component: SuggestAgendaComponent }, + { path: 'participate', component: ParticipateComponent }, { path: 'profile', component: ProfileComponent, canActivate: [AuthGuard], }, { path: 'editUser/:id', component: EditUserComponent, canActivate: [AuthGuard], }, { path: '', component: HomePageComponent, canActivate: [AuthGuard], } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6a602fb8..85123e85 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,6 +23,7 @@ import { AuthGuard } from './services/auth.guard'; import { AuthService } from './services/auth.service'; import { EditUserComponent } from './pages/edit-user/edit-user.component'; import { SuggestAgendaComponent } from './pages/suggest-agenda/suggest-agenda.component'; +import { ParticipateComponent } from './pages/participate/participate.component'; @NgModule({ declarations: [ @@ -42,6 +43,7 @@ import { SuggestAgendaComponent } from './pages/suggest-agenda/suggest-agenda.co CheckCodeRestPasswordComponent, EditUserComponent, SuggestAgendaComponent, + ParticipateComponent, ], imports: [ BrowserModule, diff --git a/src/app/pages/participate/participate.component.css b/src/app/pages/participate/participate.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/pages/participate/participate.component.html b/src/app/pages/participate/participate.component.html new file mode 100644 index 00000000..f11d5ea1 --- /dev/null +++ b/src/app/pages/participate/participate.component.html @@ -0,0 +1 @@ +

participate works!

diff --git a/src/app/pages/participate/participate.component.spec.ts b/src/app/pages/participate/participate.component.spec.ts new file mode 100644 index 00000000..21150e1c --- /dev/null +++ b/src/app/pages/participate/participate.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ParticipateComponent } from './participate.component'; + +describe('ParticipateComponent', () => { + let component: ParticipateComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ParticipateComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ParticipateComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/participate/participate.component.ts b/src/app/pages/participate/participate.component.ts new file mode 100644 index 00000000..4632bd98 --- /dev/null +++ b/src/app/pages/participate/participate.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-participate', + templateUrl: './participate.component.html', + styleUrls: ['./participate.component.css'] +}) +export class ParticipateComponent { + +} From 875f4090c5e64142869f06290c534a5c1f606a2c Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 16:48:39 -0300 Subject: [PATCH 10/17] =?UTF-8?q?Adiciona=20rota=20para=20a=20p=C3=A1gina?= =?UTF-8?q?=20de=20participa=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/background/background.component.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/components/background/background.component.html b/src/app/components/background/background.component.html index ef83a777..1ba674e2 100644 --- a/src/app/components/background/background.component.html +++ b/src/app/components/background/background.component.html @@ -8,7 +8,8 @@
Início
|
Agora na TV
|
Programação
| -
Transmissões
+
Transmissões
| +
Participe
hamburguer
From da6c9ced2019903b70a72b1cf390d8475b336a95 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 16:50:38 -0300 Subject: [PATCH 11/17] =?UTF-8?q?Ajustes=20de=20formata=C3=A7=C3=A3o=20e?= =?UTF-8?q?=20valida=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../participate/participate.component.css | 25 ++++++++++++++++ .../participate/participate.component.html | 10 ++++++- .../suggest-agenda.component.css | 7 ++++- .../suggest-agenda.component.html | 12 ++++---- .../suggest-agenda.component.ts | 29 ++++++++++++------- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/app/pages/participate/participate.component.css b/src/app/pages/participate/participate.component.css index e69de29b..2fe148f9 100644 --- a/src/app/pages/participate/participate.component.css +++ b/src/app/pages/participate/participate.component.css @@ -0,0 +1,25 @@ +.font-unb { + font-size: 13px; + font-family: "unb-pro", sans-serif; +} + +.containner h1 { + color: #0087C8; + font-size: 13px; + font-family: "unb-pro", sans-serif; + font-style: normal; + font-weight: 700; + line-height: 12.35px; + margin-left: 29px; + margin-top: 45px; + margin-bottom: 40px; + text-align: start; +} + +.containner { + width: 360px; + margin-left: auto; + margin-right: auto; + text-align: center; + height: -300px; +} \ No newline at end of file diff --git a/src/app/pages/participate/participate.component.html b/src/app/pages/participate/participate.component.html index f11d5ea1..480da1f1 100644 --- a/src/app/pages/participate/participate.component.html +++ b/src/app/pages/participate/participate.component.html @@ -1 +1,9 @@ -

participate works!

+
+

+ Sugira uma pauta +

+

+ Solicite uma transmissão +

+
+ diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.css b/src/app/pages/suggest-agenda/suggest-agenda.component.css index db87a650..a1836637 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.css +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.css @@ -63,4 +63,9 @@ span { .input:focus { outline: none !important; border: 0.25px solid #00A550; - } \ No newline at end of file +} + +.required-field { + outline: none !important; + border: 2px solid red; +} \ No newline at end of file diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index 32326691..92301de6 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -1,16 +1,16 @@
-
+

Sugestão de Pautas

- + - - + + -
- +
+
diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.ts index 7d9b057f..53681cd1 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.ts @@ -9,14 +9,17 @@ import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; templateUrl: './suggest-agenda.component.html', styleUrls: ['./suggest-agenda.component.css'] }) -export class SuggestAgendaComponent implements OnInit{ +export class SuggestAgendaComponent implements OnInit { suggestAgendaForm!: FormGroup; + isDescricaoFilled = false; + isResponsavelFilled = false; + isTelefoneFilled = false; constructor( private fb: FormBuilder, private emailService: EmailService - ){} + ) { } ngOnInit(): void { this.suggestAgendaForm = this.fb.group({ @@ -28,10 +31,10 @@ export class SuggestAgendaComponent implements OnInit{ telefoneResponsavel: ['', [Validators.required]], emailContato: [''], }, - ); + ); } - sendSuggestAgenda(): void{ + sendSuggestAgenda(): void { if (this.suggestAgendaForm.valid) { const emailData = new EmailData(); emailData.tema = this.suggestAgendaForm.value.tema; @@ -41,17 +44,23 @@ export class SuggestAgendaComponent implements OnInit{ emailData.responsavel = this.suggestAgendaForm.value.responsavel; emailData.telefone_responsavel = this.suggestAgendaForm.value.telefoneResponsavel; emailData.email_contato = this.suggestAgendaForm.value.emailContato; - const emailUnB = 'geraldovictor@outlook.com'; + const emailUnB = 'unbtv@unb.br'; emailData.recipients = [emailUnB]; this.emailService.sendEmail(emailData).subscribe((res: HttpResponse) => { alert('Sugestão enviada com sucesso'); - }, - (error: HttpErrorResponse) => { - alert('error: ' + error.message); - }); + }, + (error: HttpErrorResponse) => { + alert('error: ' + error.message); + }); } else { - alert('Preencha todos os campos corretamente!'); + alert('Preencha os campos obrigatórios!'); } } + onRequiredFieldsChange(): void { + this.isDescricaoFilled = !!this.suggestAgendaForm.value.descricao; + this.isResponsavelFilled = !!this.suggestAgendaForm.value.responsavel; + this.isTelefoneFilled = !!this.suggestAgendaForm.value.telefoneResponsavel; + } + } From 394953d87d02ef7b641bedf1fabbb0645cbcd9d6 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 16:54:10 -0300 Subject: [PATCH 12/17] =?UTF-8?q?Adiciona=20indica=C3=A7=C3=A3o=20de=20que?= =?UTF-8?q?=20o=20email=20est=C3=A1=20sendo=20enviado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/suggest-agenda/suggest-agenda.component.html | 5 ++++- src/app/pages/suggest-agenda/suggest-agenda.component.ts | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index 92301de6..ba9ed8ed 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -10,7 +10,10 @@

Sugestão de Pautas

- +
diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.ts index 53681cd1..e53faaf3 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.ts @@ -15,6 +15,7 @@ export class SuggestAgendaComponent implements OnInit { isDescricaoFilled = false; isResponsavelFilled = false; isTelefoneFilled = false; + isSendingEmail = false; constructor( private fb: FormBuilder, @@ -46,11 +47,15 @@ export class SuggestAgendaComponent implements OnInit { emailData.email_contato = this.suggestAgendaForm.value.emailContato; const emailUnB = 'unbtv@unb.br'; emailData.recipients = [emailUnB]; + this.isSendingEmail = true; this.emailService.sendEmail(emailData).subscribe((res: HttpResponse) => { alert('Sugestão enviada com sucesso'); }, (error: HttpErrorResponse) => { alert('error: ' + error.message); + }, + () => { + this.isSendingEmail = false; }); } else { alert('Preencha os campos obrigatórios!'); From ec6ad25f8df7fa4b19ab71ba98b882ccb4d00b1a Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 17:10:53 -0300 Subject: [PATCH 13/17] Adiciona modulo de rotas nos testes --- src/app/components/background/background.component.spec.ts | 4 +++- src/app/pages/participate/participate.component.spec.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/background/background.component.spec.ts b/src/app/components/background/background.component.spec.ts index c7ae10a4..53021daf 100644 --- a/src/app/components/background/background.component.spec.ts +++ b/src/app/components/background/background.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BackgroundComponent } from './background.component'; +import { RouterTestingModule } from '@angular/router/testing'; describe('BackgroundComponent', () => { let component: BackgroundComponent; @@ -8,7 +9,8 @@ describe('BackgroundComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ BackgroundComponent ] + declarations: [ BackgroundComponent ], + imports: [RouterTestingModule] }) .compileComponents(); diff --git a/src/app/pages/participate/participate.component.spec.ts b/src/app/pages/participate/participate.component.spec.ts index 21150e1c..4f87ffae 100644 --- a/src/app/pages/participate/participate.component.spec.ts +++ b/src/app/pages/participate/participate.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ParticipateComponent } from './participate.component'; +import { RouterTestingModule } from '@angular/router/testing'; describe('ParticipateComponent', () => { let component: ParticipateComponent; @@ -8,7 +9,8 @@ describe('ParticipateComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ParticipateComponent ] + declarations: [ ParticipateComponent ], + imports: [ RouterTestingModule ] }) .compileComponents(); From 38edbab73700eb563424e7ea0007b337d4902949 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sat, 11 Nov 2023 18:48:52 -0300 Subject: [PATCH 14/17] Adiciona teste ao frontend --- .../suggest-agenda.component.html | 4 +-- .../suggest-agenda.component.spec.ts | 36 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.html b/src/app/pages/suggest-agenda/suggest-agenda.component.html index ba9ed8ed..53e492f6 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.html +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.html @@ -9,8 +9,8 @@

Sugestão de Pautas

-
- diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts index dd1dea71..9e1e8493 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts @@ -4,26 +4,58 @@ import { SuggestAgendaComponent } from './suggest-agenda.component'; import { EmailService } from 'src/app/services/email.service'; import { FormBuilder } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms'; +import { of, throwError } from 'rxjs'; + + +const mockData = "email has been sent" +class EmailServiceMock { + constructor() { } + findAll() { + return of(mockData); + } +} + describe('SuggestAgendaComponent', () => { let component: SuggestAgendaComponent; let fixture: ComponentFixture; + let emailService: EmailService; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ SuggestAgendaComponent ], imports: [HttpClientTestingModule, ReactiveFormsModule], - providers: [{ provide: EmailService, FormBuilder}] + providers: [{ provide: EmailService, useValue: new EmailServiceMock, FormBuilder}] }) .compileComponents(); fixture = TestBed.createComponent(SuggestAgendaComponent); component = fixture.componentInstance; - fixture.detectChanges(); + emailService = TestBed.inject(EmailService); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should have a valid form on initialization', () => { + fixture.detectChanges(); + expect(component.suggestAgendaForm).toBeTruthy(); + }); + + it('should call suggestAgendaComponent method when the form is submitted', () => { + fixture.detectChanges(); + spyOn(component, 'sendSuggestAgenda').and.callThrough(); + const form = component.suggestAgendaForm; + form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: ''}); + + const submitButton = fixture.nativeElement.querySelector( + 'button[type="submit"]' + ); + submitButton.click(); + + expect(component.sendSuggestAgenda).toHaveBeenCalled(); + }); + }); From 6886671ec6ffc39ed39d05e387311b8b34b38fdf Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Sun, 12 Nov 2023 12:32:22 -0300 Subject: [PATCH 15/17] =?UTF-8?q?Adiciona=20e=20corrige=20testes=20ao=20co?= =?UTF-8?q?mponente=20de=20sugest=C3=A3o=20de=20agenda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../suggest-agenda.component.spec.ts | 52 +++++++++++++++---- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts index 9e1e8493..bae66b05 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts @@ -1,16 +1,16 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { SuggestAgendaComponent } from './suggest-agenda.component'; -import { EmailService } from 'src/app/services/email.service'; -import { FormBuilder } from '@angular/forms'; -import { ReactiveFormsModule } from '@angular/forms'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; +import { By } from '@angular/platform-browser'; import { of, throwError } from 'rxjs'; +import { EmailService } from 'src/app/services/email.service'; +import { SuggestAgendaComponent } from './suggest-agenda.component'; const mockData = "email has been sent" class EmailServiceMock { constructor() { } - findAll() { + sendEmail() { return of(mockData); } } @@ -20,15 +20,17 @@ describe('SuggestAgendaComponent', () => { let component: SuggestAgendaComponent; let fixture: ComponentFixture; let emailService: EmailService; + let emailServiceMock: jasmine.SpyObj; beforeEach(async () => { + emailServiceMock = jasmine.createSpyObj('EmailService', ['sendEmail']); await TestBed.configureTestingModule({ - declarations: [ SuggestAgendaComponent ], + declarations: [SuggestAgendaComponent], imports: [HttpClientTestingModule, ReactiveFormsModule], - providers: [{ provide: EmailService, useValue: new EmailServiceMock, FormBuilder}] + providers: [FormBuilder, { provide: EmailService, useValue: new EmailServiceMock() }] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(SuggestAgendaComponent); component = fixture.componentInstance; @@ -48,7 +50,7 @@ describe('SuggestAgendaComponent', () => { fixture.detectChanges(); spyOn(component, 'sendSuggestAgenda').and.callThrough(); const form = component.suggestAgendaForm; - form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: ''}); + form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: '' }); const submitButton = fixture.nativeElement.querySelector( 'button[type="submit"]' @@ -58,4 +60,34 @@ describe('SuggestAgendaComponent', () => { expect(component.sendSuggestAgenda).toHaveBeenCalled(); }); + it('should call onRequiredFieldsChange when responsavel input value changes', () => { + fixture.detectChanges(); + spyOn(component, 'onRequiredFieldsChange'); + + const input = fixture.debugElement.query(By.css('input[name="responsavel"]')).nativeElement; + input.value = 'novo valor'; + input.dispatchEvent(new Event('change')); + + expect(component.onRequiredFieldsChange).toHaveBeenCalled(); + }); + + it('should call sendEmail', () => { + fixture.detectChanges(); + const mySpy = spyOn(emailService, 'sendEmail').and.callThrough(); + // spyOn(component, 'sendSuggestAgenda').and.callThrough(); + const form = component.suggestAgendaForm; + form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: '' }) + component.sendSuggestAgenda(); + expect(mySpy).toHaveBeenCalled(); + }); + + it('should call sendEmail and return an error', () => { + fixture.detectChanges(); + const mySpy = spyOn(emailService, 'sendEmail').and.returnValue(throwError(() => new Error('Erro'))); + const form = component.suggestAgendaForm; + form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: '' }) + component.sendSuggestAgenda(); + expect(mySpy).toHaveBeenCalled(); + }); + }); From bc00922fea630bbb787d3572af1694a783f46399 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Mon, 13 Nov 2023 11:39:56 -0300 Subject: [PATCH 16/17] Corrige code smells --- src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts index bae66b05..5c50eef8 100644 --- a/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts +++ b/src/app/pages/suggest-agenda/suggest-agenda.component.spec.ts @@ -9,7 +9,6 @@ import { SuggestAgendaComponent } from './suggest-agenda.component'; const mockData = "email has been sent" class EmailServiceMock { - constructor() { } sendEmail() { return of(mockData); } @@ -20,10 +19,8 @@ describe('SuggestAgendaComponent', () => { let component: SuggestAgendaComponent; let fixture: ComponentFixture; let emailService: EmailService; - let emailServiceMock: jasmine.SpyObj; beforeEach(async () => { - emailServiceMock = jasmine.createSpyObj('EmailService', ['sendEmail']); await TestBed.configureTestingModule({ declarations: [SuggestAgendaComponent], imports: [HttpClientTestingModule, @@ -74,7 +71,6 @@ describe('SuggestAgendaComponent', () => { it('should call sendEmail', () => { fixture.detectChanges(); const mySpy = spyOn(emailService, 'sendEmail').and.callThrough(); - // spyOn(component, 'sendSuggestAgenda').and.callThrough(); const form = component.suggestAgendaForm; form.setValue({ descricao: 'Descrição', responsavel: 'Usuário Teste', telefoneResponsavel: '999999999', tema: '', quando: '', local: '', emailContato: '' }) component.sendSuggestAgenda(); From 9aa79cb6d83c05997136966e0412d66bf79533c5 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Mon, 13 Nov 2023 23:06:04 -0300 Subject: [PATCH 17/17] =?UTF-8?q?Corrige=20url=20e=20nome=20de=20vari?= =?UTF-8?q?=C3=A1vel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/environment/environment.ts | 3 ++- src/app/services/auth.service.spec.ts | 14 +++++++------- src/app/services/auth.service.ts | 16 ++++++++-------- src/app/services/email.service.ts | 7 ++++--- .../user-token-interceptor.service.spec.ts | 2 +- src/app/services/user.service.spec.ts | 8 ++++---- src/app/services/user.service.ts | 10 +++++----- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/app/environment/environment.ts b/src/app/environment/environment.ts index e21e43da..6ed41a3c 100644 --- a/src/app/environment/environment.ts +++ b/src/app/environment/environment.ts @@ -1,4 +1,5 @@ export const EDUPLAY_CLIENT_KEY = "a1cdba06226408fcda63b49c50223c68d56005d234cc98bcdc1ae787d2b4de1d"; export const environment = { - apiURL: 'https://unb-tv-backend-2be1ed3a0485.herokuapp.com/api', + usersAPIURL: 'https://unb-tv-backend-2be1ed3a0485.herokuapp.com/api', + adminAPIURL: 'https://admin-unb-tv-2023-2-dc0dd53d3aca.herokuapp.com/api' }; diff --git a/src/app/services/auth.service.spec.ts b/src/app/services/auth.service.spec.ts index d4bec24a..cd99307a 100644 --- a/src/app/services/auth.service.spec.ts +++ b/src/app/services/auth.service.spec.ts @@ -30,7 +30,7 @@ describe('AuthService', () => { service.registerUser(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/register`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/register`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -44,7 +44,7 @@ describe('AuthService', () => { service.loginUser(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/login`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/login`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -57,7 +57,7 @@ describe('AuthService', () => { service.activeAccount(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/activate-account`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/activate-account`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); }); @@ -69,7 +69,7 @@ describe('AuthService', () => { service.resendCode(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/resend-code`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/resend-code`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -81,7 +81,7 @@ describe('AuthService', () => { service.sendEmailPassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/request`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/request`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -94,7 +94,7 @@ describe('AuthService', () => { service.verifyCodePassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/verify`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/verify`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -108,7 +108,7 @@ describe('AuthService', () => { service.updatePassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/change`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/change`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); }); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index b94bb0cc..7f4a6a3a 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -8,36 +8,36 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class AuthService { - public apiURL = environment.apiURL; + public usersAPIURL = environment.usersAPIURL; constructor(private http: HttpClient) { } registerUser(user: any): Observable { - return this.http.post(`${this.apiURL}/auth/register`, user); + return this.http.post(`${this.usersAPIURL}/auth/register`, user); } loginUser(user: any): Observable { - return this.http.post(`${this.apiURL}/auth/login`, user); + return this.http.post(`${this.usersAPIURL}/auth/login`, user); } activeAccount(emailCode: any): Observable { - return this.http.patch(`${this.apiURL}/auth/activate-account`, emailCode); + return this.http.patch(`${this.usersAPIURL}/auth/activate-account`, emailCode); } resendCode(email: any): Observable { - return this.http.post(`${this.apiURL}/auth/resend-code`, email); + return this.http.post(`${this.usersAPIURL}/auth/resend-code`, email); } sendEmailPassword(email: any): Observable { - return this.http.post(`${this.apiURL}/auth/reset-password/request`, email); + return this.http.post(`${this.usersAPIURL}/auth/reset-password/request`, email); } verifyCodePassword(info: any): Observable { - return this.http.post(`${this.apiURL}/auth/reset-password/verify`, info); + return this.http.post(`${this.usersAPIURL}/auth/reset-password/verify`, info); } updatePassword(user: any): Observable { - return this.http.patch(`${this.apiURL}/auth/reset-password/change`, user); + return this.http.patch(`${this.usersAPIURL}/auth/reset-password/change`, user); } isAuthenticated(): boolean { diff --git a/src/app/services/email.service.ts b/src/app/services/email.service.ts index cbe6b773..fa91d33b 100644 --- a/src/app/services/email.service.ts +++ b/src/app/services/email.service.ts @@ -2,16 +2,17 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { IEmailData } from 'src/shared/model/email.model'; +import { environment } from '../environment/environment'; @Injectable({ providedIn: 'root' }) export class EmailService { - private apiUrl = 'http://localhost:8080/api/pauta/email'; // Ajuste conforme necessário + private adminAPIUrl = environment.adminAPIURL + '/pauta/email'; // Ajuste conforme necessário - constructor(private http: HttpClient) {} + constructor(private http: HttpClient) { } sendEmail(email: IEmailData): Observable { - return this.http.post(this.apiUrl, email); + return this.http.post(this.adminAPIUrl, email); } } \ No newline at end of file diff --git a/src/app/services/user-token-interceptor.service.spec.ts b/src/app/services/user-token-interceptor.service.spec.ts index 085d5581..3f520648 100644 --- a/src/app/services/user-token-interceptor.service.spec.ts +++ b/src/app/services/user-token-interceptor.service.spec.ts @@ -33,7 +33,7 @@ describe('TokenInterceptorService', () => { userService.getAllUsers().subscribe((res) => { expect(res).toBeTruthy(); }); - const req = httpMock.expectOne(`${userService.apiURL}/users`); + const req = httpMock.expectOne(`${userService.usersAPIURL}/users`); expect(req.request.headers.has('Authorization')).toEqual(true); }); }); diff --git a/src/app/services/user.service.spec.ts b/src/app/services/user.service.spec.ts index cc2d4167..9950ac52 100644 --- a/src/app/services/user.service.spec.ts +++ b/src/app/services/user.service.spec.ts @@ -30,7 +30,7 @@ describe('UserService', () => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('GET'); req.flush(userResponse); }); @@ -56,7 +56,7 @@ describe('UserService', () => { service.getAllUsers().subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users`); expect(req.request.method).toBe('GET'); req.flush(userResponse); } @@ -74,7 +74,7 @@ describe('UserService', () => { service.updateUser(1, { "name": "Mario", "connection": "PROFESSOR", "email": "mario@gmail.com" }).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); } @@ -92,7 +92,7 @@ describe('UserService', () => { service.deleteUser(1).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('DELETE'); req.flush(userResponse); } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index bb9279f9..4677ad41 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -7,23 +7,23 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class UserService { - public apiURL = environment.apiURL; + public usersAPIURL = environment.usersAPIURL; constructor(private http: HttpClient) { } getUser(id: any): Observable { - return this.http.get(`${this.apiURL}/users/${id}`); + return this.http.get(`${this.usersAPIURL}/users/${id}`); } getAllUsers(): Observable { - return this.http.get(`${this.apiURL}/users`); + return this.http.get(`${this.usersAPIURL}/users`); } updateUser(id: any, body: any): Observable { - return this.http.patch(`${this.apiURL}/users/${id}`, body); + return this.http.patch(`${this.usersAPIURL}/users/${id}`, body); } deleteUser(id: any): Observable { - return this.http.delete(`${this.apiURL}/users/${id}`); + return this.http.delete(`${this.usersAPIURL}/users/${id}`); } }