From 431ece756bb270692216a98d2011f5695665798d Mon Sep 17 00:00:00 2001 From: byronkamal Date: Mon, 11 Jun 2018 23:40:58 -0300 Subject: [PATCH 01/39] Creating admin page Co-authored-by: gitgabiru --- .../admin-page/admin-page.component.css | 0 .../admin-page/admin-page.component.html | 3 +++ .../admin-page/admin-page.component.spec.ts | 25 +++++++++++++++++++ .../admin-page/admin-page.component.ts | 15 +++++++++++ 4 files changed, 43 insertions(+) create mode 100644 src/app/profile/admin-page/admin-page.component.css create mode 100644 src/app/profile/admin-page/admin-page.component.html create mode 100644 src/app/profile/admin-page/admin-page.component.spec.ts create mode 100644 src/app/profile/admin-page/admin-page.component.ts diff --git a/src/app/profile/admin-page/admin-page.component.css b/src/app/profile/admin-page/admin-page.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/profile/admin-page/admin-page.component.html b/src/app/profile/admin-page/admin-page.component.html new file mode 100644 index 0000000..68f8411 --- /dev/null +++ b/src/app/profile/admin-page/admin-page.component.html @@ -0,0 +1,3 @@ +

+ admin-page works! +

diff --git a/src/app/profile/admin-page/admin-page.component.spec.ts b/src/app/profile/admin-page/admin-page.component.spec.ts new file mode 100644 index 0000000..3c12c01 --- /dev/null +++ b/src/app/profile/admin-page/admin-page.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AdminPageComponent } from './admin-page.component'; + +describe('AdminPageComponent', () => { + let component: AdminPageComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AdminPageComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AdminPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/profile/admin-page/admin-page.component.ts b/src/app/profile/admin-page/admin-page.component.ts new file mode 100644 index 0000000..109ad13 --- /dev/null +++ b/src/app/profile/admin-page/admin-page.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-admin-page', + templateUrl: './admin-page.component.html', + styleUrls: ['./admin-page.component.css'] +}) +export class AdminPageComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} From 8f37c016f755fedd69b92aa92ee2cbd5d326b6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Arag=C3=A3o?= Date: Tue, 12 Jun 2018 20:50:33 -0300 Subject: [PATCH 02/39] Fixing StudentPanel's EditMode --- .../student-panel/student-panel.component.css | 4 + .../student-panel.component.html | 288 ++++++------------ .../student-panel/student-panel.component.ts | 9 +- 3 files changed, 98 insertions(+), 203 deletions(-) diff --git a/src/app/students/student-panel/student-panel.component.css b/src/app/students/student-panel/student-panel.component.css index de5f662..b768b1e 100644 --- a/src/app/students/student-panel/student-panel.component.css +++ b/src/app/students/student-panel/student-panel.component.css @@ -7,3 +7,7 @@ text-align: center; color: #fff; } + +.panel-btn { + +} diff --git a/src/app/students/student-panel/student-panel.component.html b/src/app/students/student-panel/student-panel.component.html index c14018c..d8f53f9 100644 --- a/src/app/students/student-panel/student-panel.component.html +++ b/src/app/students/student-panel/student-panel.component.html @@ -1,205 +1,97 @@ -
- -
- -
-
-
-
Painel do Aluno
-
-
+
+
+
+
Painel do Aluno
+
+
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- - - - -
-
+
+
+
+
+ +
-
- -
-
-
-
-
-
Gerar Registro Diário
-
-
-
-
-
-
-
Gerar encaminhamento
-
-
-
-
-
-
-
Gerar Relatório
-
-
-
-
-
-
-
Enviar recomendações
-
-
-
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + +
+ +
-
+ diff --git a/src/app/students/student-panel/student-panel.component.ts b/src/app/students/student-panel/student-panel.component.ts index 815da94..3ce1559 100644 --- a/src/app/students/student-panel/student-panel.component.ts +++ b/src/app/students/student-panel/student-panel.component.ts @@ -38,15 +38,14 @@ export class StudentPanelComponent implements OnInit { deleteStudent(student) { if (confirm("Você tem certeza que quer deletar o estudante " + student.name + "?")) { - this.studentService.deleteStudent(student.id).subscribe(null); + this.studentService.deleteStudent(student.id) + .subscribe(data => this.router.navigate(['/students'])); } } updateStudent(student){ - var result; - result = this.studentService.updateStudent(this.student); - - result.subscribe(data => this.router.navigate(['/students'])); + this.studentService.updateStudent(this.student) + .subscribe(data => this.router.navigate(['/students'])); } } From ff93b85b80f2998877bebf4d913081a103b11259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Arag=C3=A3o?= Date: Tue, 12 Jun 2018 21:16:52 -0300 Subject: [PATCH 03/39] Centralizing Exported Models at models.ts --- src/app/shared/models.ts | 16 +++++++++++++++ .../recommendation-panel.component.ts | 6 ++++-- .../referral-form/referral-form.component.ts | 6 ++---- .../referral-panel.component.ts | 9 +++------ .../students/referral/referral.component.ts | 20 +++++++++---------- src/app/students/shared/recommendationData.ts | 7 ------- src/app/students/shared/referral.ts | 7 ------- 7 files changed, 35 insertions(+), 36 deletions(-) delete mode 100644 src/app/students/shared/recommendationData.ts delete mode 100644 src/app/students/shared/referral.ts diff --git a/src/app/shared/models.ts b/src/app/shared/models.ts index a2a5bbc..e375c24 100644 --- a/src/app/shared/models.ts +++ b/src/app/shared/models.ts @@ -59,3 +59,19 @@ export class Report { possibly_adequation: boolean; student_id: any; } + +export class Referral { + id: number; + title: any; + body: any; + student: any; + student_id: any; +} + +export class RecommendationData { + id: number; + title: any; + body: any; + student: any; + student_id: any; +} diff --git a/src/app/students/recommendation-panel/recommendation-panel.component.ts b/src/app/students/recommendation-panel/recommendation-panel.component.ts index 8005e3f..c72b3f8 100644 --- a/src/app/students/recommendation-panel/recommendation-panel.component.ts +++ b/src/app/students/recommendation-panel/recommendation-panel.component.ts @@ -1,9 +1,11 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; -import { RecommendationData } from "../shared/recommendationData"; import { Router, ActivatedRoute } from '@angular/router'; -import { RecommendationService } from '../shared/recommendation.service'; + import * as jsPDF from 'jspdf'; +import { RecommendationData } from "../../shared/models"; +import { RecommendationService } from '../shared/recommendation.service'; + @Component({ selector: 'app-recommendation-panel', templateUrl: './recommendation-panel.component.html', diff --git a/src/app/students/referral-form/referral-form.component.ts b/src/app/students/referral-form/referral-form.component.ts index faf30b5..461f690 100644 --- a/src/app/students/referral-form/referral-form.component.ts +++ b/src/app/students/referral-form/referral-form.component.ts @@ -1,11 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import { Referral } from "../../shared/models"; import { ReferralService } from '../shared/referral.service'; -import { Referral } from "../shared/referral"; - -import { Router, ActivatedRoute } from '@angular/router'; - @Component({ selector: 'app-referral-form', templateUrl: './referral-form.component.html', diff --git a/src/app/students/referral-panel/referral-panel.component.ts b/src/app/students/referral-panel/referral-panel.component.ts index 9d3ef94..004d7dd 100644 --- a/src/app/students/referral-panel/referral-panel.component.ts +++ b/src/app/students/referral-panel/referral-panel.component.ts @@ -1,13 +1,11 @@ import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; - -import { ReferralService } from '../shared/referral.service'; - -import {Referral} from "../shared/referral"; - import { Router, ActivatedRoute } from '@angular/router'; import * as jsPDF from 'jspdf'; +import { Referral } from "../../shared/models"; +import { ReferralService } from '../shared/referral.service'; + @Component({ selector: 'app-referral-panel', templateUrl: './referral-panel.component.html', @@ -21,7 +19,6 @@ export class ReferralPanelComponent implements OnInit { referral: Referral = new Referral(); constructor( - private referralService: ReferralService, private router: Router, private route: ActivatedRoute diff --git a/src/app/students/referral/referral.component.ts b/src/app/students/referral/referral.component.ts index 25af024..b2eb198 100644 --- a/src/app/students/referral/referral.component.ts +++ b/src/app/students/referral/referral.component.ts @@ -1,16 +1,16 @@ -import { Component, OnInit } from '@angular/core'; -import { ReferralService } from '../shared/referral.service'; -import { Referral } from "../shared/referral"; +import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; +import { Referral } from "../../shared/models"; +import { ReferralService } from '../shared/referral.service'; + @Component({ selector: 'app-referral', templateUrl: './referral.component.html', styleUrls: ['./referral.component.css'] }) export class ReferralComponent implements OnInit { - - private referrals: Referral[] = []; + private referrals: Referral[] = []; constructor( private referralService: ReferralService, @@ -20,10 +20,10 @@ export class ReferralComponent implements OnInit { ngOnInit() { this.referralService.getReferrals() - .subscribe( - data => this.referrals = data, - response => {} - ); + .subscribe( + data => this.referrals = data, + response => {} + ); } getReferrals() { @@ -35,7 +35,7 @@ export class ReferralComponent implements OnInit { var index = this.referrals.indexOf(referrals); this.referrals.splice(index, 1); this.referralService.deleteReferral(referrals.id) - .subscribe(null); + .subscribe(null); } } diff --git a/src/app/students/shared/recommendationData.ts b/src/app/students/shared/recommendationData.ts deleted file mode 100644 index dc146e7..0000000 --- a/src/app/students/shared/recommendationData.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class RecommendationData { - id: number; - title: any; - body: any; - student: any; - student_id: any; -} diff --git a/src/app/students/shared/referral.ts b/src/app/students/shared/referral.ts deleted file mode 100644 index 1f8835a..0000000 --- a/src/app/students/shared/referral.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class Referral { - id: number; - title: any; - body: any; - student: any; - student_id: any; -} From 0d7bddc344c923d2d874579919a05c295589f8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Arag=C3=A3o?= Date: Tue, 12 Jun 2018 21:59:17 -0300 Subject: [PATCH 04/39] Centralizing StudentServices --- src/app/app.module.ts | 10 +-- src/app/services/students.service.ts | 79 +++++++++++++++---- .../recommendation-panel.component.spec.ts | 11 +-- .../recommendation-panel.component.ts | 6 +- .../referral-form.component.spec.ts | 13 +-- .../referral-form/referral-form.component.ts | 8 +- .../referral-panel.component.spec.ts | 13 +-- .../referral-panel.component.ts | 10 +-- .../referral/referral.component.spec.ts | 6 +- .../students/referral/referral.component.ts | 4 +- .../students/shared/recommendation.service.ts | 31 -------- src/app/students/shared/referral.service.ts | 42 ---------- 12 files changed, 105 insertions(+), 128 deletions(-) delete mode 100644 src/app/students/shared/recommendation.service.ts delete mode 100644 src/app/students/shared/referral.service.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 51deb1b..5d73117 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,10 +14,10 @@ import { AuthService } from "./services/auth.service"; import { LoginComponent } from './login/login.component'; import { RegisterFormComponent } from './register/register-form/register-form.component'; import { ProfileComponent } from './profile/profile.component'; -import { StudentsService } from './services/students.service'; +import { StudentsService } from './services/students.service'; import { StudentsComponent } from './students/students.component'; import { StudentFormComponent } from './students/student-form/student-form.component'; -import { FilterClassPipe } from './students/shared/filter-class.pipe'; +import { FilterClassPipe } from './students/shared/filter-class.pipe'; import { SidenavComponent } from './sidenav/sidenav.component'; import { NavbarComponent } from './navbar/navbar.component'; import { StudentPanelComponent } from './students/student-panel/student-panel.component'; @@ -25,13 +25,11 @@ import { DailyLogComponent } from './students/daily-log/daily-log import { DailyLogFormComponent } from './students/daily-log-form/daily-log-form.component'; import { ReportComponent } from './students/report/report.component'; import { ReportFormComponent } from './students/report-form/report-form.component'; -import { ReferralService } from './students/shared/referral.service'; import { ReferralComponent } from './students/referral/referral.component'; import { ReferralFormComponent } from './students/referral-form/referral-form.component'; import { ReferralPanelComponent } from './students/referral-panel/referral-panel.component'; import { DailyLogPanelComponent } from './students/daily-log-panel/daily-log-panel.component'; import { RecommendationPanelComponent } from './students/recommendation-panel/recommendation-panel.component'; -import { RecommendationService } from './students/shared/recommendation.service'; @NgModule({ declarations: [ @@ -68,9 +66,7 @@ import { RecommendationService } from './students/shared/recommendati AuthGuard, AuthService, Angular2TokenService, - StudentsService, - ReferralService, - RecommendationService + StudentsService ], bootstrap: [ AppComponent ] }) diff --git a/src/app/services/students.service.ts b/src/app/services/students.service.ts index 0bfef7b..fba14ac 100644 --- a/src/app/services/students.service.ts +++ b/src/app/services/students.service.ts @@ -12,85 +12,134 @@ export class StudentsService { private studentsUrl: string = "http://localhost:3000/students"; private dailyLogsUrl: string = "http://localhost:3000/daily_logs"; private reportsUrl: string = "http://localhost:3000/reports"; + private referralsUrl: string = "http://localhost:3000/referrals"; + private recommendationsUrl: string = "http://localhost:3000/recommendations"; constructor(private http: Http) { } //Students Service + getStudents(){ return this.http.get(this.studentsUrl) - .map(res => res.json()); + .map(res => res.json()); } getStudent(id){ return this.http.get(this.studentsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); } addStudent(student){ return this.http.post(this.studentsUrl, {'student': student}) - .map(res => res.json()); + .map(res => res.json()); } updateStudent(student){ return this.http.put(this.studentsUrl + '/' + student.id, {'student': student}) - .map(res => res.json()); + .map(res => res.json()); } deleteStudent(id){ return this.http.delete(this.studentsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); } //DailyLogService + getDailyLogs(){ return this.http.get(this.dailyLogsUrl) - .map(res => res.json()); + .map(res => res.json()); } getDailyLog(id){ return this.http.get(this.dailyLogsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); } addDailyLog(daily_log){ return this.http.post(this.dailyLogsUrl, {'daily_log': daily_log}) - .map(res => res.json()); + .map(res => res.json()); } updateDailyLog(daily_log){ return this.http.put(this.dailyLogsUrl + '/' + daily_log.id, {'daily_log': daily_log}) - .map(res => res.json()); + .map(res => res.json()); } deleteDailyLog(id){ return this.http.delete(this.dailyLogsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); } //ReportsService + getReports(){ return this.http.get(this.reportsUrl) - .map(res => res.json()); + .map(res => res.json()); } getReport(id){ return this.http.get(this.reportsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); } addReport(report){ return this.http.post(this.reportsUrl, {'report': report}) - .map(res => res.json()); + .map(res => res.json()); } updateReport(report){ return this.http.put(this.reportsUrl + '/' + report.id, {'report': report}) - .map(res => res.json()); + .map(res => res.json()); } deleteReport(id){ return this.http.delete(this.reportsUrl + '/' + id) - .map(res => res.json()); + .map(res => res.json()); + } + + //ReferralsService + + getReferrals(){ + return this.http.get(this.referralsUrl) + .map(res => res.json()); + } + + getReferral(id){ + return this.http.get(this.referralsUrl + '/' + id) + .map(res => res.json()); + } + + addReferral(referral){ + return this.http.post(this.referralsUrl, {'referral': referral}) + .map(res => res.json()); + } + + updateReferral(referral){ + return this.http.put(this.referralsUrl + '/' + referral.id, {'referral': referral}) + .map(res => res.json()); + } + + deleteReferral(id){ + return this.http.delete(this.referralsUrl + '/' + id) + .map(res => res.json()); + } + + //RecommendationsService + + getRecommendation(id){ + return this.http.get(this.recommendationsUrl + '/' + id) + .map(res => res.json()); + } + + updateRecommendation(recommendation){ + return this.http.put(this.recommendationsUrl + '/' + recommendation.id, {'recommendation': recommendation}) + .map(res => res.json()); + } + + createRecommendation(recommendation){ + return this.http.post(this.recommendationsUrl, {recommendation}) + .map(res => res.json()); } } diff --git a/src/app/students/recommendation-panel/recommendation-panel.component.spec.ts b/src/app/students/recommendation-panel/recommendation-panel.component.spec.ts index 3318aa9..ced10d9 100644 --- a/src/app/students/recommendation-panel/recommendation-panel.component.spec.ts +++ b/src/app/students/recommendation-panel/recommendation-panel.component.spec.ts @@ -1,9 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule } from '@angular/forms'; -import { RecommendationService } from '../shared/recommendation.service' +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; +import { RouterTestingModule } from '@angular/router/testing'; + +import { StudentsService } from '../../services/students.service' import { RecommendationPanelComponent } from './recommendation-panel.component'; -import { HttpModule } from '@angular/http'; -import { RouterTestingModule } from '@angular/router/testing'; describe('RecommendationComponent', () => { let component: RecommendationPanelComponent; @@ -16,7 +17,7 @@ describe('RecommendationComponent', () => { HttpModule, RouterTestingModule ], - providers: [ RecommendationService ], + providers: [ StudentsService ], declarations: [ RecommendationPanelComponent ] }) .compileComponents(); diff --git a/src/app/students/recommendation-panel/recommendation-panel.component.ts b/src/app/students/recommendation-panel/recommendation-panel.component.ts index c72b3f8..5bb674c 100644 --- a/src/app/students/recommendation-panel/recommendation-panel.component.ts +++ b/src/app/students/recommendation-panel/recommendation-panel.component.ts @@ -4,7 +4,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import * as jsPDF from 'jspdf'; import { RecommendationData } from "../../shared/models"; -import { RecommendationService } from '../shared/recommendation.service'; +import { StudentsService } from '../../services/students.service'; @Component({ selector: 'app-recommendation-panel', @@ -13,12 +13,12 @@ import { RecommendationService } from '../shared/recommendation.service'; }) export class RecommendationPanelComponent implements OnInit { - @ViewChild( 'content' ) content: ElementRef; + @ViewChild('content') content: ElementRef; recommendation: RecommendationData = new RecommendationData(); idAux: number; constructor( - private recommendationService: RecommendationService, + private recommendationService: StudentsService, private router: Router, private route: ActivatedRoute ) { } diff --git a/src/app/students/referral-form/referral-form.component.spec.ts b/src/app/students/referral-form/referral-form.component.spec.ts index c87c3da..821f5c7 100644 --- a/src/app/students/referral-form/referral-form.component.spec.ts +++ b/src/app/students/referral-form/referral-form.component.spec.ts @@ -1,9 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule } from '@angular/forms'; -import { ReferralFormComponent } from './referral-form.component'; -import { ReferralService } from '../shared/referral.service'; -import { HttpModule } from '@angular/http'; -import { RouterTestingModule } from '@angular/router/testing'; +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; +import { RouterTestingModule } from '@angular/router/testing'; + +import { ReferralFormComponent } from './referral-form.component'; +import { StudentsService } from '../../services/students.service'; describe('ReferralFormComponent', () => { let component: ReferralFormComponent; @@ -17,7 +18,7 @@ describe('ReferralFormComponent', () => { RouterTestingModule ], declarations: [ ReferralFormComponent ], - providers: [ ReferralService ] + providers: [ StudentsService ] }) .compileComponents(); })); diff --git a/src/app/students/referral-form/referral-form.component.ts b/src/app/students/referral-form/referral-form.component.ts index 461f690..c2452fa 100644 --- a/src/app/students/referral-form/referral-form.component.ts +++ b/src/app/students/referral-form/referral-form.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { Referral } from "../../shared/models"; -import { ReferralService } from '../shared/referral.service'; +import { StudentsService } from '../../services/students.service'; @Component({ selector: 'app-referral-form', @@ -16,7 +16,7 @@ export class ReferralFormComponent implements OnInit { idC: number; constructor( - private referralService: ReferralService, + private StudentsService: StudentsService, private router: Router, private route: ActivatedRoute ) { } @@ -38,9 +38,9 @@ export class ReferralFormComponent implements OnInit { var result; this.referral.student_id = this.idC if (this.referral.id){ - result = this.referralService.updateReferral(this.referral); + result = this.StudentsService.updateReferral(this.referral); } else { - result = this.referralService.addReferral(this.referral); + result = this.StudentsService.addReferral(this.referral); } result.subscribe(data => this.router.navigate(['/referrals'])); diff --git a/src/app/students/referral-panel/referral-panel.component.spec.ts b/src/app/students/referral-panel/referral-panel.component.spec.ts index 2353055..cc5e914 100644 --- a/src/app/students/referral-panel/referral-panel.component.spec.ts +++ b/src/app/students/referral-panel/referral-panel.component.spec.ts @@ -1,9 +1,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ReferralService } from '../shared/referral.service'; -import { HttpModule } from '@angular/http'; -import { RouterTestingModule } from '@angular/router/testing'; +import { HttpModule } from '@angular/http'; +import { RouterTestingModule } from '@angular/router/testing'; +import { FormsModule } from '@angular/forms'; + +import { StudentsService } from '../../services/students.service'; + import { ReferralPanelComponent } from './referral-panel.component'; -import { FormsModule } from '@angular/forms'; + import * as jsPDF from 'jspdf'; describe('ReferralPanelComponent', () => { @@ -18,7 +21,7 @@ describe('ReferralPanelComponent', () => { RouterTestingModule ], declarations: [ ReferralPanelComponent ], - providers: [ ReferralService ] + providers: [ StudentsService ] }) .compileComponents(); })); diff --git a/src/app/students/referral-panel/referral-panel.component.ts b/src/app/students/referral-panel/referral-panel.component.ts index 004d7dd..b908476 100644 --- a/src/app/students/referral-panel/referral-panel.component.ts +++ b/src/app/students/referral-panel/referral-panel.component.ts @@ -4,7 +4,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import * as jsPDF from 'jspdf'; import { Referral } from "../../shared/models"; -import { ReferralService } from '../shared/referral.service'; +import { StudentsService } from '../../services/students.service'; @Component({ selector: 'app-referral-panel', @@ -19,7 +19,7 @@ export class ReferralPanelComponent implements OnInit { referral: Referral = new Referral(); constructor( - private referralService: ReferralService, + private studentsService: StudentsService, private router: Router, private route: ActivatedRoute ) { } @@ -31,7 +31,7 @@ export class ReferralPanelComponent implements OnInit { if (!id) return; - this.referralService.getReferral(id) + this.studentsService.getReferral(id) .subscribe( referral => this.referral = referral, response => {}); @@ -40,13 +40,13 @@ export class ReferralPanelComponent implements OnInit { deleteReferral(referral) { if (confirm("Você tem certeza que quer deletar o encaminhamento " + referral.id + "?")) { - this.referralService.deleteReferral(referral.id).subscribe(null); + this.studentsService.deleteReferral(referral.id).subscribe(null); } } updateReferral(referral){ var result; - result = this.referralService.updateReferral(this.referral); + result = this.studentsService.updateReferral(this.referral); result.subscribe(data => this.router.navigate(['/referrals'])); } diff --git a/src/app/students/referral/referral.component.spec.ts b/src/app/students/referral/referral.component.spec.ts index d16a5ee..0535702 100644 --- a/src/app/students/referral/referral.component.spec.ts +++ b/src/app/students/referral/referral.component.spec.ts @@ -1,9 +1,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpModule } from '@angular/http'; -import { StudentsService } from '../../services/students.service'; import { RouterTestingModule } from '@angular/router/testing'; import { FormsModule } from '@angular/forms'; -import { ReferralService } from '../shared/referral.service'; + +import { StudentsService } from '../../services/students.service'; import { ReferralComponent } from './referral.component'; @@ -19,7 +19,7 @@ describe('ReferralComponent', () => { RouterTestingModule ], declarations: [ ReferralComponent ], - providers: [ReferralService] + providers: [StudentsService] }) .compileComponents(); })); diff --git a/src/app/students/referral/referral.component.ts b/src/app/students/referral/referral.component.ts index b2eb198..636747f 100644 --- a/src/app/students/referral/referral.component.ts +++ b/src/app/students/referral/referral.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { Referral } from "../../shared/models"; -import { ReferralService } from '../shared/referral.service'; +import { StudentsService } from '../../services/students.service'; @Component({ selector: 'app-referral', @@ -13,7 +13,7 @@ export class ReferralComponent implements OnInit { private referrals: Referral[] = []; constructor( - private referralService: ReferralService, + private referralService: StudentsService, private router: Router, private route: ActivatedRoute ) { } diff --git a/src/app/students/shared/recommendation.service.ts b/src/app/students/shared/recommendation.service.ts deleted file mode 100644 index 84c1e75..0000000 --- a/src/app/students/shared/recommendation.service.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; - -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Rx'; - -@Injectable() -export class RecommendationService{ - - private url: string = "http://localhost:3000/recommendations"; - - constructor(private http: Http) {} - - getRecommendation(id){ - return this.http.get(this.url + '/' + id) - .map(res => res.json()); - } - - updateRecommendation(recommendation){ - return this.http.put(this.url + '/' + recommendation.id, {'recommendation': recommendation}) - .map(res => res.json()); - } - - createRecommendation(recommendation){ - return this.http.post(this.url, {recommendation}) - .map(res => res.json()); - } - -} diff --git a/src/app/students/shared/referral.service.ts b/src/app/students/shared/referral.service.ts deleted file mode 100644 index a961cda..0000000 --- a/src/app/students/shared/referral.service.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; - -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Rx'; - -@Injectable() -export class ReferralService{ - - private url: string = "http://localhost:3000/referrals"; - - constructor(private http: Http) {} - - - getReferrals(){ - return this.http.get(this.url) - .map(res => res.json()); - } - - getReferral(id){ - return this.http.get(this.url + '/' + id) - .map(res => res.json()); - } - - addReferral(referral){ - return this.http.post(this.url, {'referral': referral}) - .map(res => res.json()); - } - - updateReferral(referral){ - return this.http.put(this.url + '/' + referral.id, {'referral': referral}) - .map(res => res.json()); - } - - deleteReferral(id){ - return this.http.delete(this.url + '/' + id) - .map(res => res.json()); - } - -} From 68109e0197dd7c4027b93e1ec0ee2cb8facf4fb2 Mon Sep 17 00:00:00 2001 From: WillAllmeida Date: Wed, 13 Jun 2018 10:45:02 -0300 Subject: [PATCH 05/39] Changing Student Service tests Co-authored-by: IgorVeludo --- src/app/services/students.service.spec.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 186c818..d004150 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -1,19 +1,27 @@ import { TestBed, inject } from '@angular/core/testing'; -import { HttpModule } from '@angular/http'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { StudentsService } from './students.service'; import { RouterTestingModule } from '@angular/router/testing'; +import { HttpModule } from '@angular/http'; describe('StudentsService', () => { + let service: StudentsService; + let httpMock: HttpTestingController; + beforeEach(() => { TestBed.configureTestingModule({ - imports: [ HttpModule, - RouterTestingModule + imports: [ HttpClientTestingModule, + HttpModule ], providers: [StudentsService] }); + + service = TestBed.get(StudentsService); + httpMock = TestBed.get(HttpTestingController); + }); + + it('should have a service instance', () => { + expect(service).toBeDefined(); }); - it('should be created', inject([StudentsService], (service: StudentsService) => { - expect(service).toBeTruthy(); - })); }); From 7b91f14baaaf06c39780a92ea8dea16ee627fab5 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 12:42:12 -0300 Subject: [PATCH 06/39] Testing getStudent method Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index d004150..e18fd85 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -24,4 +24,11 @@ describe('StudentsService', () => { expect(service).toBeDefined(); }); + it('getUser should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.getStudent(userID); + expect(promise).toBeDefined(); + })); + }); From 2df7cb7d08170dce49f340d57e10c028e6f52b4f Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 13:18:48 -0300 Subject: [PATCH 07/39] Testing addStudent method Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index e18fd85..0c7387a 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -3,6 +3,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { StudentsService } from './students.service'; import { RouterTestingModule } from '@angular/router/testing'; import { HttpModule } from '@angular/http'; +import { Student } from '../shared/models' describe('StudentsService', () => { let service: StudentsService; @@ -31,4 +32,25 @@ describe('StudentsService', () => { expect(promise).toBeDefined(); })); + it('addStudent should return a promise', inject([StudentsService], (service: StudentsService) => { + const user: Student = { + id: 445, + name: 'adalberto', + birth_date: '12-12-1929', + age: 18, + year: 9, + student_class: 'a', + shift: 'matutino', + nationality: 'brasileiro', + father_name: 'jair', + mother_name: 'edineia', + responsible: 'responsavel', + address: 'riacho fundo', + parent_telephone: 444122323, + + }; + const promise = service.addStudent(user); + expect(promise).toBeDefined(); + })); + }); From 1d1446502a47252963f7d6f42843b919d9984911 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 13:36:17 -0300 Subject: [PATCH 08/39] Increase test getReport getDailyLog methods Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 0c7387a..5373703 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -25,13 +25,27 @@ describe('StudentsService', () => { expect(service).toBeDefined(); }); - it('getUser should return a promise', inject([StudentsService], (service: StudentsService) => { + it('getStudent should return a promise', inject([StudentsService], (service: StudentsService) => { const userID = 1; const promise = service.getStudent(userID); expect(promise).toBeDefined(); })); + it('getDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.getDailyLog(userID); + expect(promise).toBeDefined(); + })); + + it('getReport should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.getReport(userID); + expect(promise).toBeDefined(); + })); + it('addStudent should return a promise', inject([StudentsService], (service: StudentsService) => { const user: Student = { id: 445, From 298763c244f16b736c88d359f9844c7f638b41b9 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 13:48:39 -0300 Subject: [PATCH 09/39] Increase tests of deleteReport, deleteStudent and deleteDailyLog methods Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 5373703..5e2aa01 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -46,6 +46,27 @@ describe('StudentsService', () => { expect(promise).toBeDefined(); })); + it('deleteReport should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.deleteReport(userID); + expect(promise).toBeDefined(); + })); + + it('deleteStudent should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.deleteStudent(userID); + expect(promise).toBeDefined(); + })); + + it('deleteDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { + const userID = 1; + + const promise = service.deleteDailyLog(userID); + expect(promise).toBeDefined(); + })); + it('addStudent should return a promise', inject([StudentsService], (service: StudentsService) => { const user: Student = { id: 445, From c865030976e6144e3b74e84eaa3a4c933b0d6a04 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 14:07:09 -0300 Subject: [PATCH 10/39] Increase addDailyLog and addReport methods Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 62 +++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 5e2aa01..dba3d69 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -3,7 +3,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { StudentsService } from './students.service'; import { RouterTestingModule } from '@angular/router/testing'; import { HttpModule } from '@angular/http'; -import { Student } from '../shared/models' +import { Student, DailyLog, Report } from '../shared/models' describe('StudentsService', () => { let service: StudentsService; @@ -68,7 +68,7 @@ describe('StudentsService', () => { })); it('addStudent should return a promise', inject([StudentsService], (service: StudentsService) => { - const user: Student = { + const data: Student = { id: 445, name: 'adalberto', birth_date: '12-12-1929', @@ -84,7 +84,63 @@ describe('StudentsService', () => { parent_telephone: 444122323, }; - const promise = service.addStudent(user); + const promise = service.addStudent(data); + expect(promise).toBeDefined(); + })); + + it('addDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { + const data: DailyLog = { + id: 9, + date: '12-8-1998', + activity: 'natacao', + note: 'dificuldade no nado borboleta', + student_id: 9, + + }; + const promise = service.addDailyLog(data); + expect(promise).toBeDefined(); + })); + + it('addReport should return a promise', inject([StudentsService], (service: StudentsService) => { + const data: Report = { + id: 9, + init_date: '12-8-1998', + end_date: '12-8-1999', + school_phone: '999999999', + member_name: '88888888', + school_name: 'escola do riacho', + reason: '', + general_information: '', + synthesis: '', + conclusion: '', + family_orientation: '', + school_orientation: '', + pedagogue_name: '', + pedagogue_function: '', + pedagogue_registry: '', + psycholog_name: '', + psycholog_function: '', + psycholog_registry: '', + reason_adequation: true, + reason_emotional: true, + reason_performance: true, + reason_behavior: true, + reason_language: true, + level_school: true, + level_family: true, + level_student: true, + envolved_school: '', + envolved_family: '', + envolved_student: '', + realized_actions: '', + possibly_saa: true, + possibly_eeaa: true, + possibly_resources: true, + possibly_adequation: true, + student_id: 9, + + }; + const promise = service.addReport(data); expect(promise).toBeDefined(); })); From 2f49f8378e95f520d453a8ce9dc3e30e4880214e Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 14:20:50 -0300 Subject: [PATCH 11/39] Increase updates methods Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 77 +++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index dba3d69..703f777 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -144,4 +144,81 @@ describe('StudentsService', () => { expect(promise).toBeDefined(); })); + it('updateStudent should return a promise', inject([StudentsService], (service: StudentsService) => { + const data: Student = { + id: 445, + name: 'adalberto', + birth_date: '12-12-1929', + age: 18, + year: 9, + student_class: 'a', + shift: 'matutino', + nationality: 'brasileiro', + father_name: 'jair', + mother_name: 'edineia', + responsible: 'responsavel', + address: 'riacho fundo', + parent_telephone: 444122323, + + }; + const promise = service.updateStudent(data); + expect(promise).toBeDefined(); + })); + + it('updateReport should return a promise', inject([StudentsService], (service: StudentsService) => { + const data: Report = { + id: 9, + init_date: '12-8-1998', + end_date: '12-8-1999', + school_phone: '999999999', + member_name: '88888888', + school_name: 'escola do riacho', + reason: '', + general_information: '', + synthesis: '', + conclusion: '', + family_orientation: '', + school_orientation: '', + pedagogue_name: '', + pedagogue_function: '', + pedagogue_registry: '', + psycholog_name: '', + psycholog_function: '', + psycholog_registry: '', + reason_adequation: true, + reason_emotional: true, + reason_performance: true, + reason_behavior: true, + reason_language: true, + level_school: true, + level_family: true, + level_student: true, + envolved_school: '', + envolved_family: '', + envolved_student: '', + realized_actions: '', + possibly_saa: true, + possibly_eeaa: true, + possibly_resources: true, + possibly_adequation: true, + student_id: 9, + + }; + const promise = service.updateReport(data); + expect(promise).toBeDefined(); + })); + + it('updateDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { + const data: DailyLog = { + id: 9, + date: '12-8-1998', + activity: 'natacao', + note: 'dificuldade no nado borboleta', + student_id: 9, + + }; + const promise = service.updateDailyLog(data); + expect(promise).toBeDefined(); + })); + }); From e5d613bf432ef0f5f7ff5b82da21e778473c9a20 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 14:46:31 -0300 Subject: [PATCH 12/39] Increase .map() test Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 117 +++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 703f777..d8fe0e9 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -2,19 +2,22 @@ import { TestBed, inject } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { StudentsService } from './students.service'; import { RouterTestingModule } from '@angular/router/testing'; -import { HttpModule } from '@angular/http'; +import { HttpModule, XHRBackend, Response, ResponseOptions } from '@angular/http'; import { Student, DailyLog, Report } from '../shared/models' +import {MockBackend, MockConnection} from '@angular/http/testing'; describe('StudentsService', () => { let service: StudentsService; let httpMock: HttpTestingController; + let backend: MockBackend; + let studentService: StudentsService; beforeEach(() => { TestBed.configureTestingModule({ imports: [ HttpClientTestingModule, HttpModule ], - providers: [StudentsService] + providers: [StudentsService, { provide: XHRBackend, useClass: MockBackend }] }); service = TestBed.get(StudentsService); @@ -221,4 +224,114 @@ describe('StudentsService', () => { expect(promise).toBeDefined(); })); + it('should get students data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 445, + name: 'adalberto', + birth_date: '12-12-1929', + age: 18, + year: 9, + student_class: 'a', + shift: 'matutino', + nationality: 'brasileiro', + father_name: 'jair', + mother_name: 'edineia', + responsible: 'responsavel', + address: 'riacho fundo', + parent_telephone: 444122323 }, + { id: 1, name: 'Video 1' }, + + ] + } + + // When the request subscribes for results on a connection, return a fake response + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.getStudents().subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should get daily logs data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 9, + date: '12-8-1998', + activity: 'natacao', + note: 'dificuldade no nado borboleta', + student_id: 9 }, + { id: 1, name: 'Video 1' }, + + ] + } + + // When the request subscribes for results on a connection, return a fake response + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.getDailyLogs().subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should get reports data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 9, + init_date: '12-8-1998', + end_date: '12-8-1999', + school_phone: '999999999', + member_name: '88888888', + school_name: 'escola do riacho', + reason: '', + general_information: '', + synthesis: '', + conclusion: '', + family_orientation: '', + school_orientation: '', + pedagogue_name: '', + pedagogue_function: '', + pedagogue_registry: '', + psycholog_name: '', + psycholog_function: '', + psycholog_registry: '', + reason_adequation: true, + reason_emotional: true, + reason_performance: true, + reason_behavior: true, + reason_language: true, + level_school: true, + level_family: true, + level_student: true, + envolved_school: '', + envolved_family: '', + envolved_student: '', + realized_actions: '', + possibly_saa: true, + possibly_eeaa: true, + possibly_resources: true, + possibly_adequation: true, + student_id: 9 }, + { id: 1, name: 'Video 1' }, + + ] + } + + // When the request subscribes for results on a connection, return a fake response + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.getReports().subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + }); From 418dc28360bcb4c074aabfde6935265554a3853e Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Wed, 13 Jun 2018 15:07:59 -0300 Subject: [PATCH 13/39] Fixing add test methods Co-authored-by: WillAllmeida --- src/app/services/students.service.spec.ts | 110 +++++++++++++--------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index d8fe0e9..92fd72e 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -91,60 +91,76 @@ describe('StudentsService', () => { expect(promise).toBeDefined(); })); - it('addDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: DailyLog = { + it('should add daily log data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ id: 9, date: '12-8-1998', activity: 'natacao', note: 'dificuldade no nado borboleta', - student_id: 9, - - }; - const promise = service.addDailyLog(data); - expect(promise).toBeDefined(); + student_id: 9 } + ] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.addDailyLog(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); - it('addReport should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: Report = { - id: 9, - init_date: '12-8-1998', - end_date: '12-8-1999', - school_phone: '999999999', - member_name: '88888888', - school_name: 'escola do riacho', - reason: '', - general_information: '', - synthesis: '', - conclusion: '', - family_orientation: '', - school_orientation: '', - pedagogue_name: '', - pedagogue_function: '', - pedagogue_registry: '', - psycholog_name: '', - psycholog_function: '', - psycholog_registry: '', - reason_adequation: true, - reason_emotional: true, - reason_performance: true, - reason_behavior: true, - reason_language: true, - level_school: true, - level_family: true, - level_student: true, - envolved_school: '', - envolved_family: '', - envolved_student: '', - realized_actions: '', - possibly_saa: true, - possibly_eeaa: true, - possibly_resources: true, - possibly_adequation: true, - student_id: 9, + it('should add report data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 9, + init_date: '12-8-1998', + end_date: '12-8-1999', + school_phone: '999999999', + member_name: '88888888', + school_name: 'escola do riacho', + reason: '', + general_information: '', + synthesis: '', + conclusion: '', + family_orientation: '', + school_orientation: '', + pedagogue_name: '', + pedagogue_function: '', + pedagogue_registry: '', + psycholog_name: '', + psycholog_function: '', + psycholog_registry: '', + reason_adequation: true, + reason_emotional: true, + reason_performance: true, + reason_behavior: true, + reason_language: true, + level_school: true, + level_family: true, + level_student: true, + envolved_school: '', + envolved_family: '', + envolved_student: '', + realized_actions: '', + possibly_saa: true, + possibly_eeaa: true, + possibly_resources: true, + possibly_adequation: true, + student_id: 9 } + ] + } - }; - const promise = service.addReport(data); - expect(promise).toBeDefined(); + // When the request subscribes for results on a connection, return a fake response + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.addReport(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); it('updateStudent should return a promise', inject([StudentsService], (service: StudentsService) => { From 3951687ad6cd73450dc6d69afeef4593f90ef000 Mon Sep 17 00:00:00 2001 From: byronkamal Date: Wed, 13 Jun 2018 16:43:55 -0300 Subject: [PATCH 14/39] Adjusting Recommendation Panel Design --- .../recommendation-panel.component.html | 2 + .../student-panel/student-panel.component.css | 3 -- .../student-panel.component.html | 44 +++---------------- 3 files changed, 8 insertions(+), 41 deletions(-) diff --git a/src/app/students/recommendation-panel/recommendation-panel.component.html b/src/app/students/recommendation-panel/recommendation-panel.component.html index f13dfc5..48149f1 100644 --- a/src/app/students/recommendation-panel/recommendation-panel.component.html +++ b/src/app/students/recommendation-panel/recommendation-panel.component.html @@ -8,6 +8,8 @@

Painel de Recomendação

+
Nova Recomendação
+
Painel do Estudante
- - - - - - - - - - - - - - - - - - - -
-
-
+ From e1ed1bd40290ab6754f08e7e7a79b70ec79daf95 Mon Sep 17 00:00:00 2001 From: byronkamal Date: Wed, 13 Jun 2018 21:53:14 -0300 Subject: [PATCH 15/39] Adding admin page in routes Co-authored-by: gitgabiru --- src/app/app.module.ts | 4 +++- src/app/app.routes.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4759afd..76b534e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -34,6 +34,7 @@ import { ReferralPanelComponent } from './students/referral-panel/refe import { DailyLogPanelComponent } from './students/daily-log-panel/daily-log-panel.component'; import { RecommendationPanelComponent } from './students/recommendation-panel/recommendation-panel.component'; import { RecommendationService } from './students/shared/recommendation.service'; +import { AdminPageComponent } from './profile/admin-page/admin-page.component'; @NgModule({ declarations: [ @@ -55,7 +56,8 @@ import { RecommendationService } from './students/shared/recommendati ReferralFormComponent, ReferralPanelComponent, DailyLogPanelComponent, - RecommendationPanelComponent + RecommendationPanelComponent, + AdminPageComponent ], imports: [ HttpModule, diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 8b02410..26436ad 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -17,6 +17,7 @@ import { ReferralFormComponent } from './students/referral-form/referral- import { ReferralPanelComponent } from './students/referral-panel/referral-panel.component'; import { DailyLogPanelComponent } from './students/daily-log-panel/daily-log-panel.component'; import { RecommendationPanelComponent } from './students/recommendation-panel/recommendation-panel.component'; +import { AdminPageComponent } from './profile/admin-page/admin-page.component'; const APP_ROUTES: Routes = [ { path: '' , redirectTo: 'students' , pathMatch: 'full' }, @@ -35,7 +36,8 @@ const APP_ROUTES: Routes = [ { path: 'referral/:id' , component: ReferralFormComponent, canActivate: [AuthGuard] }, { path: 'referralpanel/:id' , component: ReferralPanelComponent, canActivate: [AuthGuard] }, { path: 'dailylogpanel/:id' , component: DailyLogPanelComponent, canActivate: [AuthGuard] }, - { path: 'recommendation/:id', component: RecommendationPanelComponent, canActivate: [AuthGuard] } + { path: 'recommendation/:id', component: RecommendationPanelComponent, canActivate: [AuthGuard] }, + { path: 'admin' , component: AdminPageComponent, canActivate: [AuthGuard] } ]; export const routes: ModuleWithProviders = RouterModule.forRoot(APP_ROUTES); From f565ce48f07b9bf013867a9332d3fbfc016802c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Arag=C3=A3o?= Date: Wed, 13 Jun 2018 23:52:17 -0300 Subject: [PATCH 16/39] Refactoring StudentForm --- .../student-form/student-form.component.html | 165 +++++++++--------- .../student-form.component.spec.ts | 3 + .../student-form/student-form.component.ts | 56 +++++- src/styles.css | 8 + 4 files changed, 145 insertions(+), 87 deletions(-) diff --git a/src/app/students/student-form/student-form.component.html b/src/app/students/student-form/student-form.component.html index 859b7a0..da02a8e 100644 --- a/src/app/students/student-form/student-form.component.html +++ b/src/app/students/student-form/student-form.component.html @@ -1,87 +1,90 @@ -
- -
+
+
+
+
Adicionar Aluno
+
+
+
-
-
-
-
Adicionar Aluno
+
+
+
+
Dados do Aluno
+
+
+ + + Nome é necessário! +
+
+ + + Data de nascimento é necessária +
+
+ + + Idade é necessária!
-
- -
-
- -
- - - Nome é necessário! -
-
- - - Data de nascimento é necessária -
-
- - - Idade é necessária! -
-
- - - Ano do estudante é necessário! -
-
- - - Turma do estudante é necessária! -
-
- - - Turno do estudante é necessário! -
-
- - - Naturalidade é necessária! -
-
- - - Nome do pai do estudante é necessário! -
-
- - - Nome é necessário! -
-
- - - Nome é necessário! -
-
- - - Telefone do responsável é necessário! -
-
- - - Endereço do estudante é necessário! -
- -
- - -
- - +
+
+ + Classe do estudante é necessária! +
+
+ + Turno do estudante é necessário! +
+
+ + + Naturalidade é necessária! +
+
+
+
+ + + Nome do pai do estudante é necessário! +
+
+ + + Nome é necessário! +
+
+
Dados do Responsável
+
+
+ + + Nome é necessário! +
+
+ + + Telefone do responsável é necessário! +
+
+
+
+ + + Endereço do estudante é necessário! +
- -
+
+ + +
+
diff --git a/src/app/students/student-form/student-form.component.spec.ts b/src/app/students/student-form/student-form.component.spec.ts index c33867c..b16a1b7 100644 --- a/src/app/students/student-form/student-form.component.spec.ts +++ b/src/app/students/student-form/student-form.component.spec.ts @@ -3,6 +3,8 @@ import { RouterTestingModule } from '@angular/router/testing'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; +import { MaterializeModule } from 'angular2-materialize'; + import { StudentFormComponent } from './student-form.component'; import { StudentsService } from '../../services/students.service'; @@ -15,6 +17,7 @@ describe('StudentFormComponent', () => { imports: [ FormsModule, HttpModule, + MaterializeModule, RouterTestingModule ], declarations: [ StudentFormComponent ], diff --git a/src/app/students/student-form/student-form.component.ts b/src/app/students/student-form/student-form.component.ts index fa4b367..8d52309 100644 --- a/src/app/students/student-form/student-form.component.ts +++ b/src/app/students/student-form/student-form.component.ts @@ -1,7 +1,9 @@ import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { Student } from "../../shared/models"; +import { MaterializeDirective } from 'angular2-materialize'; + +import { Student } from '../../shared/models'; import { StudentsService } from '../../services/students.service'; @Component({ @@ -14,6 +16,9 @@ export class StudentFormComponent implements OnInit { name: string; student: Student = new Student(); + classes = []; + selectedClass: number; + constructor( private studentService: StudentsService, @@ -27,17 +32,56 @@ export class StudentFormComponent implements OnInit { this.name = id ? 'Editar Estudante' : 'Criar Estudante'; - if (!id) - return; + if(!id) + return; this.studentService.getStudent(id) - .subscribe( - student => this.student = student, - response => {}); + .subscribe( + student => this.student = student, + response => {} + ); }); + + this.initClasses(); + } + + initClasses(){ + this.classes = [ + {value:1, name:"1º A"}, + {value:2, name:"1º B"}, + {value:3, name:"2º A"}, + {value:4, name:"2º B"} + ] + } + + selectClass(value: any){ + + switch(value) { + case '1': + this.student.year = 1; + this.student.student_class = 'A'; + break; + case '2': + this.student.year = 1; + this.student.student_class = 'B'; + break; + case '3': + this.student.year = 2; + this.student.student_class = 'A'; + break; + case '4': + this.student.year = 2; + this.student.student_class = 'B'; + break; + default: + console.log("Invalid choice"); + break; + } } save() { + this.selectClass(this.selectedClass); + var result; if (this.student.id){ diff --git a/src/styles.css b/src/styles.css index 5e96a76..5214e1a 100644 --- a/src/styles.css +++ b/src/styles.css @@ -41,6 +41,14 @@ main.main-full { overflow: hidden; } +.card .card-content { + padding: 10px 20px !important; +} + +.card .card-action { + padding: 8px 24px !important; +} + /* Container */ @media only screen and (min-width: 601px) { .container { From b316952076ceefaef8d506e5ac3d28771cf0b3a9 Mon Sep 17 00:00:00 2001 From: byronkamal Date: Thu, 14 Jun 2018 01:23:25 -0300 Subject: [PATCH 17/39] Loading information from team members to the admin panel Co-authored-by: gitgabiru --- .../admin-page/admin-page.component.html | 11 +++++++--- .../admin-page/admin-page.component.ts | 21 ++++++++++++++++++- src/app/services/auth.service.ts | 8 ++++++- src/app/shared/teamMember.ts | 5 +++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/app/shared/teamMember.ts diff --git a/src/app/profile/admin-page/admin-page.component.html b/src/app/profile/admin-page/admin-page.component.html index 68f8411..00c390a 100644 --- a/src/app/profile/admin-page/admin-page.component.html +++ b/src/app/profile/admin-page/admin-page.component.html @@ -1,3 +1,8 @@ -

- admin-page works! -

+
+ + {{ teamMember.name }} + {{ teamMember.email }} + + + +
diff --git a/src/app/profile/admin-page/admin-page.component.ts b/src/app/profile/admin-page/admin-page.component.ts index 109ad13..21b0694 100644 --- a/src/app/profile/admin-page/admin-page.component.ts +++ b/src/app/profile/admin-page/admin-page.component.ts @@ -1,5 +1,10 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from "@angular/router"; +import { Angular2TokenService } from "angular2-token"; + +import { AuthService } from "../../services/auth.service"; +import { TeamMember } from "../../shared/teamMember"; @Component({ selector: 'app-admin-page', templateUrl: './admin-page.component.html', @@ -7,9 +12,23 @@ import { Component, OnInit } from '@angular/core'; }) export class AdminPageComponent implements OnInit { - constructor() { } +private teamMember: TeamMember[] = []; + constructor( + public authTokenService: Angular2TokenService, + public authService: AuthService, + private router: Router + ) { } ngOnInit() { + this.authService.getTeamMembers() + .subscribe( + data => this.teamMember = data, + response => {} + ); + } + +getTeamMembers() { + return this.teamMember; } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index b001ee0..b9cdf67 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -14,8 +14,9 @@ import { Angular2TokenService, SignInData, RegisterData, UpdatePasswordData} fro export class AuthService { private url: string = "http://localhost:3000/auth"; + private url2: string = "http://localhost:3000/team_members"; - constructor(public _tokenService: Angular2TokenService) {} + constructor(public _tokenService: Angular2TokenService,private http: Http) {} public signIn(signInData: SignInData): Observable{ return this._tokenService.signIn(signInData) @@ -55,6 +56,11 @@ export class AuthService { return this._tokenService.deleteAccount(); } + getTeamMembers(){ + return this.http.get(this.url2) + .map(res => res.json()); + } + private handleErrors(error: Response){ console.log("SALVANDO O ERRO NUM ARQUIVO DE LOG - DETALHES DO ERRO => ", error); return Observable.throw(error); diff --git a/src/app/shared/teamMember.ts b/src/app/shared/teamMember.ts new file mode 100644 index 0000000..495b6c6 --- /dev/null +++ b/src/app/shared/teamMember.ts @@ -0,0 +1,5 @@ +export class TeamMember { + id: number; + name: string; + email: string; +} From d8d48043a0afc9652a979114fc7850933b63be63 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Thu, 14 Jun 2018 16:16:25 -0300 Subject: [PATCH 18/39] Creating recommendation.service.spec and creating getRecommendation test Co-authored-by: jpmota2208 Co-authored-by: WillAllmeida --- .../shared/recommendation.service.spec.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/app/students/shared/recommendation.service.spec.ts diff --git a/src/app/students/shared/recommendation.service.spec.ts b/src/app/students/shared/recommendation.service.spec.ts new file mode 100644 index 0000000..0c8c69f --- /dev/null +++ b/src/app/students/shared/recommendation.service.spec.ts @@ -0,0 +1,37 @@ +import { TestBed, inject } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpModule, XHRBackend, Response, ResponseOptions } from '@angular/http'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { RecommendationService } from './recommendation.service' + +describe('RecommendationService', () => { + let service: RecommendationService; + let httpMock: HttpTestingController; + let backend: MockBackend; + let recommendationService: RecommendationService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ HttpClientTestingModule, + HttpModule + ], + providers: [RecommendationService, { provide: XHRBackend, useClass: MockBackend }] + }); + + service = TestBed.get(RecommendationService); + httpMock = TestBed.get(HttpTestingController); + }); + + it('should have a service instance', () => { + expect(service).toBeDefined(); + }); + + it('getRecommendation should return a promise', inject([RecommendationService], (service: RecommendationService) => { + const userID = 1; + + const promise = service.getRecommendation(userID); + expect(promise).toBeDefined(); + })); + +}); From a6955d84c83539488f85dea3069094a091e2db35 Mon Sep 17 00:00:00 2001 From: William Almeida Date: Thu, 14 Jun 2018 16:26:09 -0300 Subject: [PATCH 19/39] Fixing students service tests Co-authored-by: IgorVeludo Co-authored-by: jpmota2208 --- src/app/services/students.service.spec.ts | 312 +++++++++++++++------- 1 file changed, 222 insertions(+), 90 deletions(-) diff --git a/src/app/services/students.service.spec.ts b/src/app/services/students.service.spec.ts index 92fd72e..c49dac4 100644 --- a/src/app/services/students.service.spec.ts +++ b/src/app/services/students.service.spec.ts @@ -28,90 +28,57 @@ describe('StudentsService', () => { expect(service).toBeDefined(); }); - it('getStudent should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.getStudent(userID); - expect(promise).toBeDefined(); - })); - - it('getDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.getDailyLog(userID); - expect(promise).toBeDefined(); - })); - - it('getReport should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.getReport(userID); - expect(promise).toBeDefined(); - })); - - it('deleteReport should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.deleteReport(userID); - expect(promise).toBeDefined(); - })); - - it('deleteStudent should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.deleteStudent(userID); - expect(promise).toBeDefined(); - })); - - it('deleteDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { - const userID = 1; - - const promise = service.deleteDailyLog(userID); - expect(promise).toBeDefined(); - })); - - it('addStudent should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: Student = { - id: 445, - name: 'adalberto', - birth_date: '12-12-1929', - age: 18, - year: 9, - student_class: 'a', - shift: 'matutino', - nationality: 'brasileiro', - father_name: 'jair', - mother_name: 'edineia', - responsible: 'responsavel', - address: 'riacho fundo', - parent_telephone: 444122323, + it('should get student data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 1, + name: 'adalberto', + birth_date: '12-12-1929', + age: 18, + year: 9, + student_class: 'a', + shift: 'matutino', + nationality: 'brasileiro', + father_name: 'jair', + mother_name: 'edineia', + responsible: 'responsavel', + address: 'riacho fundo', + parent_telephone: 444122323 } + ] + } - }; - const promise = service.addStudent(data); - expect(promise).toBeDefined(); + // When the request subscribes for results on a connection, return a fake response + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.getStudent(1).subscribe((res) => { + expect(res).toBeDefined(); + }); })); - it('should add daily log data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + it('should get daily log data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { const mockResponse = { - data: [{ - id: 9, - date: '12-8-1998', - activity: 'natacao', - note: 'dificuldade no nado borboleta', - student_id: 9 } - ] + data: [ + { id: 9, + date: '12-8-1998', + activity: 'natacao', + note: 'dificuldade no nado borboleta', + student_id: 9 } + ] } backend.connections.subscribe(connection => { connection.mockRespond(new Response( new ResponseOptions({ body: JSON.stringify(mockResponse) }))); }); - studentDataService.addDailyLog(mockResponse.data).subscribe((res) => { + studentDataService.getDailyLog(9).subscribe((res) => { expect(res).toBeDefined(); }); })); - it('should add report data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + it('should get report data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { const mockResponse = { data: [ { id: 9, @@ -151,20 +118,67 @@ describe('StudentsService', () => { student_id: 9 } ] } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.getReport(9).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); - // When the request subscribes for results on a connection, return a fake response + it('should delete Report 1 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 1 } + ] + } backend.connections.subscribe(connection => { connection.mockRespond(new Response( new ResponseOptions({ body: JSON.stringify(mockResponse) }))); }); - studentDataService.addReport(mockResponse.data).subscribe((res) => { + studentDataService.deleteReport(mockResponse.data).subscribe((res) => { expect(res).toBeDefined(); }); })); - it('updateStudent should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: Student = { + it('should delete Student 1 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 1 } + ] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.deleteStudent(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should delete DailyLog 1 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [ + { id: 1 } + ] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.deleteDailyLog(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('addStudent should return a promise', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ id: 445, name: 'adalberto', birth_date: '12-12-1929', @@ -177,15 +191,42 @@ describe('StudentsService', () => { mother_name: 'edineia', responsible: 'responsavel', address: 'riacho fundo', - parent_telephone: 444122323, + parent_telephone: 444122323 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.addStudent(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); - }; - const promise = service.updateStudent(data); - expect(promise).toBeDefined(); + it('addDailyLog should return a promise', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + date: '12-8-1998', + activity: 'natacao', + note: 'dificuldade no nado borboleta', + student_id: 9 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.addDailyLog(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); - it('updateReport should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: Report = { + it('addReport should return a promise', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ id: 9, init_date: '12-8-1998', end_date: '12-8-1999', @@ -221,23 +262,114 @@ describe('StudentsService', () => { possibly_resources: true, possibly_adequation: true, student_id: 9, + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.addReport(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); - }; - const promise = service.updateReport(data); - expect(promise).toBeDefined(); + it('should update student 445 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ + id: 445, + name: 'adalberto', + birth_date: '12-12-1929', + age: 18, + year: 9, + student_class: 'a', + shift: 'matutino', + nationality: 'brasileiro', + father_name: 'jair', + mother_name: 'edineia', + responsible: 'responsavel', + address: 'riacho fundo', + parent_telephone: 444122323 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.updateStudent(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); - it('updateDailyLog should return a promise', inject([StudentsService], (service: StudentsService) => { - const data: DailyLog = { + it('should update report 9 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + init_date: '12-8-1998', + end_date: '12-8-1999', + school_phone: '999999999', + member_name: '88888888', + school_name: 'escola do riacho', + reason: '', + general_information: '', + synthesis: '', + conclusion: '', + family_orientation: '', + school_orientation: '', + pedagogue_name: '', + pedagogue_function: '', + pedagogue_registry: '', + psycholog_name: '', + psycholog_function: '', + psycholog_registry: '', + reason_adequation: true, + reason_emotional: true, + reason_performance: true, + reason_behavior: true, + reason_language: true, + level_school: true, + level_family: true, + level_student: true, + envolved_school: '', + envolved_family: '', + envolved_student: '', + realized_actions: '', + possibly_saa: true, + possibly_eeaa: true, + possibly_resources: true, + possibly_adequation: true, + student_id: 9, + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.updateReport(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should update daily log 9 data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { + const mockResponse = { + data: [{ id: 9, date: '12-8-1998', activity: 'natacao', note: 'dificuldade no nado borboleta', - student_id: 9, - - }; - const promise = service.updateDailyLog(data); - expect(promise).toBeDefined(); + student_id: 9 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + studentDataService.updateDailyLog(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); it('should get students data', inject([StudentsService, XHRBackend], (studentDataService, backend) => { From 63a708d3cf10617e5da63462a2f326c4ffd55af3 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Thu, 14 Jun 2018 17:10:17 -0300 Subject: [PATCH 20/39] Creating createRecommendation and updateRecommendation test Co-authored-by: jpmota2208 Co-authored-by: WillAllmeida --- .../shared/recommendation.service.spec.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/app/students/shared/recommendation.service.spec.ts b/src/app/students/shared/recommendation.service.spec.ts index 0c8c69f..1fe6b40 100644 --- a/src/app/students/shared/recommendation.service.spec.ts +++ b/src/app/students/shared/recommendation.service.spec.ts @@ -4,6 +4,7 @@ import { RouterTestingModule } from '@angular/rout import { HttpModule, XHRBackend, Response, ResponseOptions } from '@angular/http'; import { MockBackend, MockConnection } from '@angular/http/testing'; import { RecommendationService } from './recommendation.service' +import { RecommendationData } from './recommendationData' describe('RecommendationService', () => { let service: RecommendationService; @@ -34,4 +35,44 @@ describe('RecommendationService', () => { expect(promise).toBeDefined(); })); + it('should update recommendation data', inject([RecommendationService, XHRBackend], (recommendationDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + title: '', + body: '', + student: 'Joao', + student_id: '' + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + recommendationDataService.updateRecommendation(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should create recommendation data', inject([RecommendationService, XHRBackend], (recommendationDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + title: '', + body: '', + student: 'Joao', + student_id: '' + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + recommendationDataService.createRecommendation(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + }); From 1ffc908420ba535e527e793c91948c25ba4ba81b Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Thu, 14 Jun 2018 17:19:09 -0300 Subject: [PATCH 21/39] Fixing getRecommendation test Co-authored-by: jpmota2208 Co-authored-by: WillAllmeida --- .../shared/recommendation.service.spec.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/students/shared/recommendation.service.spec.ts b/src/app/students/shared/recommendation.service.spec.ts index 1fe6b40..d91e9be 100644 --- a/src/app/students/shared/recommendation.service.spec.ts +++ b/src/app/students/shared/recommendation.service.spec.ts @@ -28,11 +28,20 @@ describe('RecommendationService', () => { expect(service).toBeDefined(); }); - it('getRecommendation should return a promise', inject([RecommendationService], (service: RecommendationService) => { - const userID = 1; - - const promise = service.getRecommendation(userID); - expect(promise).toBeDefined(); + it('should update recommendation data', inject([RecommendationService, XHRBackend], (recommendationDataService, backend) => { + const mockResponse = { + data: [{ + id: 9 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + recommendationDataService.getRecommendation(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); })); it('should update recommendation data', inject([RecommendationService, XHRBackend], (recommendationDataService, backend) => { From afbebe2223549073d91c6321884d523a76bc9554 Mon Sep 17 00:00:00 2001 From: IgorVeludo Date: Thu, 14 Jun 2018 18:10:52 -0300 Subject: [PATCH 22/39] Creating referral service.spec and testing the methods Co-authored-by: jpmota2208 Co-authored-by: WillAllmeida --- .../students/shared/referral.service.spec.ts | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/app/students/shared/referral.service.spec.ts diff --git a/src/app/students/shared/referral.service.spec.ts b/src/app/students/shared/referral.service.spec.ts new file mode 100644 index 0000000..a88a3eb --- /dev/null +++ b/src/app/students/shared/referral.service.spec.ts @@ -0,0 +1,103 @@ +import { TestBed, inject } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpModule, XHRBackend, Response, ResponseOptions } from '@angular/http'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { ReferralService } from './referral.service' +import { Referral } from './referral' + +describe('ReferralnService', () => { + let service: ReferralService; + let httpMock: HttpTestingController; + let backend: MockBackend; + let referralService: ReferralService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ HttpClientTestingModule, + HttpModule + ], + providers: [ReferralService, { provide: XHRBackend, useClass: MockBackend }] + }); + + service = TestBed.get(ReferralService); + httpMock = TestBed.get(HttpTestingController); + }); + + it('should have a service instance', () => { + expect(service).toBeDefined(); + }); + + it('should get referral id', inject([ReferralService, XHRBackend], (referralDataService, backend) => { + const mockResponse = { + data: [{ + id: 9 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + referralDataService.getReferral(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should add referral', inject([ReferralService, XHRBackend], (referralDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + title: '', + body: '', + student: 'Joao', + student_id: '' + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + referralDataService.addReferral(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should update referral', inject([ReferralService, XHRBackend], (referralDataService, backend) => { + const mockResponse = { + data: [{ + id: 9, + title: '', + body: '', + student: 'Joao', + student_id: '' + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + referralDataService.updateReferral(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + + it('should delete referral', inject([ReferralService, XHRBackend], (referralDataService, backend) => { + const mockResponse = { + data: [{ + id: 9 + }] + } + backend.connections.subscribe(connection => { + connection.mockRespond(new Response( new ResponseOptions({ + body: JSON.stringify(mockResponse) + }))); + }); + referralDataService.deleteReferral(mockResponse.data).subscribe((res) => { + expect(res).toBeDefined(); + }); + })); + +}); From f86412d55ead878ed1535365cdaf59928c0e6684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Arag=C3=A3o?= Date: Thu, 14 Jun 2018 23:57:44 -0300 Subject: [PATCH 23/39] Adding images to assets folder --- src/app/app.component.html | 3 +- src/app/login/login.component.css | 51 +---------------------- src/app/login/login.component.html | 2 +- src/app/login/login.component.spec.ts | 10 ++--- src/app/login/login.component.ts | 16 +++---- src/app/sidenav/sidenav.component.ts | 16 +++---- src/assets/images/inclucare-icontext.png | Bin 0 -> 4848 bytes src/assets/images/login-background.png | Bin 0 -> 731742 bytes 8 files changed, 24 insertions(+), 74 deletions(-) create mode 100644 src/assets/images/inclucare-icontext.png create mode 100644 src/assets/images/login-background.png diff --git a/src/app/app.component.html b/src/app/app.component.html index 9abb9c7..6424773 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -7,5 +7,4 @@ -
-
+
diff --git a/src/app/login/login.component.css b/src/app/login/login.component.css index 9bfd0a6..d938328 100644 --- a/src/app/login/login.component.css +++ b/src/app/login/login.component.css @@ -1,52 +1,3 @@ -.outer { - display: table; - position: absolute; - height: 100%; - width: 100%; - left: 0px; -} - -.middle { - background-image: url("https://www.secureaplus.com/wp-content/uploads/2016/04/SecureAPlus-For-Education-Background.png"); - /*background: linear-gradient(#0099BB, #006699);*/ - display: table-cell; - vertical-align: middle; -} - -.inner { - position: relative; - min-height: 338px; - width: calc(100% - 40px); - min-width: 320px; - max-width: 440px; - margin-left: auto; - margin-right: auto; - margin-bottom: 28px; - padding: 28px; - -} - -.logo { - max-width: 256px; - height: 24px; -} - -.text-title { - color: #404040; - font-size: 1.6rem; - font-weight: 500; - margin-top: 20px; - margin-bottom: 12px; -} - -.top-margin { - margin-top: 40px; -} - -img { - vertical-align: middle; -} - .login-outer { display: table; position: absolute; @@ -56,7 +7,7 @@ img { } .login-middle { - background-image: url("https://www.secureaplus.com/wp-content/uploads/2016/04/SecureAPlus-For-Education-Background.png"); + background-image: url('../../assets/images/login-background.png'); display: table-cell; vertical-align: middle; } diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index f621b13..3ccd71f 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,7 +1,7 @@