Skip to content

Commit

Permalink
Merge pull request #51 from fga-gpp-mds/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
byronkamal authored Jun 26, 2018
2 parents bf7d94f + c39ed64 commit 859d75b
Show file tree
Hide file tree
Showing 80 changed files with 642 additions and 405 deletions.
51 changes: 29 additions & 22 deletions src/app/app.routes.ts → src/app/app-router.module.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NgModule } from "@angular/core";
import { RouterModule } from "@angular/router";

import { AuthGuard } from "./guards/auth.guard";
import { LoginGuard } from "./guards/login.guard";
import { LoginComponent } from "./login/login.component";
import { ProfileComponent } from "./profile/profile.component";
import { StudentsComponent } from './students/students.component';
import { StudentFormComponent } from './students/student-form/student-form.component';
import { StudentPanelComponent } from './students/student-panel/student-panel.component';
import { DailyLogComponent } from './students/daily-log/daily-log.component';
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 { 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 { LoginComponent } from "./login/login.component";
import { ProfileComponent } from "./profile/profile.component";
import { AdminPageComponent } from './profile/admin-page/admin-page.component';
import { StudentsComponent } from './students/students.component';
import { StudentFormComponent } from './students/student-form/student-form.component';
import { StudentPanelComponent } from './students/student-panel/student-panel.component';
import { DailyLogComponent } from './students/daily-log/daily-log.component';
import { DailyLogFormComponent } from './students/daily-log-form/daily-log-form.component';
import { DailyLogPanelComponent } from './students/daily-log-panel/daily-log-panel.component';
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 { ReportComponent } from './students/report/report.component';
import { ReportFormComponent } from './students/report-form/report-form.component';
import { RecommendationPanelComponent } from './students/recommendation-panel/recommendation-panel.component';
import { AdminPageComponent } from './profile/admin-page/admin-page.component';
import { TutorialComponent } from './tutorial/tutorial.component';

const APP_ROUTES: Routes = [
import { AuthGuard } from "./shared/guards/auth.guard";
import { LoginGuard } from "./shared/guards/login.guard";

const ROUTES = RouterModule.forRoot([
{ path: '' , redirectTo: 'students' , pathMatch: 'full' },
{ path: 'login' , component: LoginComponent , canActivate: [LoginGuard]},
{ path: 'profile' , component: ProfileComponent , canActivate: [AuthGuard] },
{ path: 'admin' , component: AdminPageComponent , canActivate: [AuthGuard] },
{ path: 'students' , component: StudentsComponent , pathMatch: 'full' , canActivate: [AuthGuard] },
{ path: 'students/new' , component: StudentFormComponent , canActivate: [AuthGuard] },
{ path: 'studentpanel/:id' , component: StudentPanelComponent , canActivate: [AuthGuard] },
Expand All @@ -35,7 +38,11 @@ const APP_ROUTES: Routes = [
{ path: 'report/:id' , component: ReportFormComponent , canActivate: [AuthGuard] },
{ path: 'reports' , component: ReportComponent , canActivate: [AuthGuard] },
{ path: 'recommendation/:id', component: RecommendationPanelComponent, canActivate: [AuthGuard] },
{ path: 'admin' , component: AdminPageComponent, canActivate: [AuthGuard] }
];
{ path: 'tutorial' , component: TutorialComponent, canActivate: [AuthGuard] }
])

export const routes: ModuleWithProviders = RouterModule.forRoot(APP_ROUTES);
@NgModule({
imports: [ROUTES],
exports: [RouterModule]
})
export class AppRouterModule {}
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header *ngIf="authService.userSignedIn()">
<header>
<app-navbar></app-navbar>
<app-sidenav></app-sidenav>
</header>
Expand Down
6 changes: 3 additions & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { MaterializeModule } from 'angular2-materialize';
import { Angular2TokenService } from 'angular2-token';

import { AppComponent } from './app.component';
import { NavbarComponent } from './navbar/navbar.component';
import { SidenavComponent } from './sidenav/sidenav.component';
import { NavbarComponent } from './header/navbar/navbar.component';
import { SidenavComponent } from './header/sidenav/sidenav.component';
import { RegisterFormComponent } from './register/register-form/register-form.component';
import { AuthService } from './services/auth.service';
import { AuthService } from './shared/services/auth.service';

describe('AppComponent', () => {
let tokenMock = jasmine.createSpyObj('tokenMock', ['init', 'validateToken', 'subscribe']);
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component } from '@angular/core';
import { Angular2TokenService } from 'angular2-token';

import { environment } from '../environments/environment';
import { AuthService } from './services/auth.service';
import { AuthService } from './shared/services/auth.service';

@Component({
selector: 'app-root',
Expand Down
27 changes: 15 additions & 12 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import { HttpModule } from '@angular/http';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { MaterializeModule } from 'angular2-materialize';
import { MaterializeModule } from 'angular2-materialize';
import { Angular2TokenService } from 'angular2-token';
import { OrderModule } from 'ngx-order-pipe';

import { AppComponent } from './app.component';
import { routes } from './app.routes';
import { AuthGuard } from "./guards/auth.guard";
import { LoginGuard } from "./guards/login.guard";
import { AuthService } from "./services/auth.service";
import { AppRouterModule } from "./app-router.module";
import { AuthGuard } from "./shared/guards/auth.guard";
import { LoginGuard } from "./shared/guards/login.guard";
import { AuthService } from "./shared/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 './shared/services/students.service';
import { StudentsComponent } from './students/students.component';
import { StudentFormComponent } from './students/student-form/student-form.component';
import { FilterPipe } from './shared/filter.pipe';
import { SidenavComponent } from './sidenav/sidenav.component';
import { NavbarComponent } from './navbar/navbar.component';
import { FilterPipe } from './shared/pipes/filter.pipe';
import { SidenavComponent } from './header/sidenav/sidenav.component';
import { NavbarComponent } from './header/navbar/navbar.component';
import { StudentPanelComponent } from './students/student-panel/student-panel.component';
import { DailyLogComponent } from './students/daily-log/daily-log.component';
import { DailyLogFormComponent } from './students/daily-log-form/daily-log-form.component';
Expand All @@ -32,6 +32,8 @@ 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 { AdminPageComponent } from './profile/admin-page/admin-page.component';
import { TutorialComponent } from './tutorial/tutorial.component';
import { TutorialLoginComponent } from "./tutorial/tutorial-login/tutorial-login.component";

@NgModule({
declarations: [
Expand All @@ -54,8 +56,9 @@ import { AdminPageComponent } from './profile/admin-page/admin-pag
ReferralPanelComponent,
DailyLogPanelComponent,
RecommendationPanelComponent,
AdminPageComponent

AdminPageComponent,
TutorialComponent,
TutorialLoginComponent
],
imports: [
HttpModule,
Expand All @@ -64,7 +67,7 @@ import { AdminPageComponent } from './profile/admin-page/admin-pag
OrderModule,
ReactiveFormsModule,
MaterializeModule,
routes
AppRouterModule
],
providers: [
LoginGuard,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="navbar-fixed">
<div *ngIf="authService.userSignedIn()" class="navbar-fixed">
<nav>
<a [routerLink]="['']" class="brand-logo">IncluCare</a>
<ul class="right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { MaterializeModule } from 'angular2-materialize';
import { Angular2TokenService } from 'angular2-token';

import { NavbarComponent } from './navbar.component';
import { RegisterFormComponent } from '../register/register-form/register-form.component';
import { RegisterFormComponent } from '../../register/register-form/register-form.component';

import { AuthService } from '../services/auth.service';
import { AuthService } from '../../shared/services/auth.service';

describe('NavbarComponent', () => {
let tokenMock = jasmine.createSpyObj('tokenMock', ['validateToken', 'subscribe']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Router } from "@angular/router";
import { MaterializeDirective } from "angular2-materialize";
import { Angular2TokenService } from "angular2-token";

import { AuthService } from "../services/auth.service";
import { RegisterFormComponent } from "../register/register-form/register-form.component";
import { AuthService } from "../../shared/services/auth.service";
import { RegisterFormComponent } from "../../register/register-form/register-form.component";

@Component({
selector: 'app-navbar',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ul id="slide-out" class="side-nav fixed">
<ul *ngIf="authService.userSignedIn()" id="slide-out" class="side-nav fixed">
<li class="li-hover mt-6">
<p class="ultra-small margin more-text">Alunos</p>
</li>
<li class="no-padding">
<ul class="collapsible collapsible-accordion">
<ul class="collapsible collapsible-accordion" materialize="collapsible">
<li class="bold">
<a class="collapsible-header waves-effect waves-cyan">
<i class="material-icons">class</i>
Expand Down Expand Up @@ -37,7 +37,7 @@
<li class="bold">
<a class="collapsible-header waves-effect waves-cyan">
<i class="material-icons">account_circle</i>
<span class="nav-text" *ngIf='authTokenService.currentUserData'>{{authTokenService.currentUserData.name}}</span>
<span class="nav-text" *ngIf='authService.currentUserData()'>{{authService.currentUserData().name}}</span>
</a>
<div class="collapsible-body">
<ul>
Expand All @@ -47,7 +47,7 @@
<span>Visitar Perfil</span>
</a>
</li>
<li *ngIf="authTokenService.currentUserData.admin == true ">
<li *ngIf="authService.userIsAdmin()">
<a href="javascript:void(0);" (click)="presentAuthDialog()">
<i class="material-icons">person_add</i>
<span>Cadastrar Novo Membro</span>
Expand All @@ -58,6 +58,24 @@
</li>
</ul>
</li>
<li class="no-padding">
<ul class="collapsible collapsible-accordion">
<li class="bold">
<a class="collapsible-header waves-effect waves-cyan">
<span class="nav-text" *ngIf='authTokenService.currentUserData'>Novo no sistema?</span>
</a>
<div class="collapsible-body">
<ul>
<li>
<a [routerLink]="['/tutorial']">
<span>Visitar Tutorial</span>
</a>
</li>
</ul>
</div>
</li>
</ul>
</li>
</ul>

<app-register-form #registerForm ></app-register-form>
<app-register-form #registerForm></app-register-form>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { MaterializeModule } from 'angular2-materialize';
import { Angular2TokenService } from 'angular2-token';

import { SidenavComponent } from './sidenav.component';
import { RegisterFormComponent } from '../register/register-form/register-form.component';
import { RegisterFormComponent } from '../../register/register-form/register-form.component';

import { AuthService } from '../services/auth.service';
import { AuthService } from '../../shared/services/auth.service';

describe('SidenavComponent', () => {
let tokenMock = jasmine.createSpyObj('tokenMock', ['validateToken', 'subscribe']);
Expand Down
29 changes: 29 additions & 0 deletions src/app/header/sidenav/sidenav.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from "@angular/router";

import { MaterializeDirective } from "angular2-materialize";

import { TeamMember } from "../../shared/models/team-member.model";
import { AuthService } from "../../shared/services/auth.service";
import { RegisterFormComponent } from "../../register/register-form/register-form.component";

@Component({
selector: 'app-sidenav',
templateUrl: './sidenav.component.html',
styleUrls: ['./sidenav.component.css']
})
export class SidenavComponent implements OnInit {
@ViewChild('registerForm') registerForm: RegisterFormComponent;

constructor(
public authService: AuthService,
private router: Router
) {}

ngOnInit() {}

presentAuthDialog(){
this.registerForm.openDialog();
}

}
7 changes: 7 additions & 0 deletions src/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ <h5 class="login-title">Entrar</h5>
</form>
</div>
</div>
<div class="fixed-action-btn">
<a href="javascript:void(0);" (click)="openTutorial()" class="btn-floating cyan">
<i class="material-icons">help_outline</i>
</a>
</div>
</div>

<app-tutorial-login #tutorialLogin ></app-tutorial-login>
10 changes: 8 additions & 2 deletions src/app/login/login.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { HttpModule } from '@angular/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';

import { MaterializeModule } from 'angular2-materialize';
import { Angular2TokenService } from 'angular2-token';

import { AuthService } from "../services/auth.service";
import { AuthService } from "../shared/services/auth.service";
import { LoginComponent } from './login.component';
import { TutorialLoginComponent } from '../tutorial/tutorial-login/tutorial-login.component';

describe('LoginComponent', () => {
let component: LoginComponent;
Expand All @@ -17,10 +19,14 @@ describe('LoginComponent', () => {
tokenMock.validateToken.and.returnValue(tokenMock);

TestBed.configureTestingModule({
declarations: [ LoginComponent ],
declarations: [
LoginComponent,
TutorialLoginComponent
],
imports: [
HttpModule,
FormsModule,
MaterializeModule,
ReactiveFormsModule,
RouterTestingModule
],
Expand Down
19 changes: 13 additions & 6 deletions src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from "@angular/router";
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";

import { MaterializeAction } from "angular2-materialize";
import { RegisterData } from "angular2-token";

import { AuthService } from "../services/auth.service";
import { AuthService } from "../shared/services/auth.service";
import { FormUtils } from "../shared/form.utils";
import { TutorialLoginComponent } from "../tutorial/tutorial-login/tutorial-login.component";

@Component({
selector: 'app-login',
Expand All @@ -18,16 +19,14 @@ export class LoginComponent implements OnInit {
formUtils: FormUtils;
public submitted: boolean;
public formErrors: Array<string>;
@ViewChild('tutorialLogin') tutorialLogin: TutorialLoginComponent;

constructor(
private router: Router,
private formBuilder: FormBuilder,
private authService: AuthService
private authService: AuthService,
) {
this.setupForm();
this.formUtils = new FormUtils(this.form);
this.submitted = false;
this.formErrors = null;
}

ngOnInit() {}
Expand All @@ -48,10 +47,18 @@ export class LoginComponent implements OnInit {
);
}

openTutorial(){
this.tutorialLogin.openDialog();
}

private setupForm(){
this.form = this.formBuilder.group({
email: [null, [Validators.required, Validators.email]],
password: [null, [Validators.required, Validators.minLength(8)]]
});

this.formUtils = new FormUtils(this.form);
this.submitted = false;
this.formErrors = null;
}
}
4 changes: 2 additions & 2 deletions src/app/profile/admin-page/admin-page.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div *ngIf="authTokenService.currentUserData">
<div *ngIf="authTokenService.currentUserData.nickname == 'admin'; else elseBlock ">
<div *ngIf="authService.currentUserData()">
<div *ngIf="authService.currentUserData().nickname == 'admin'; else elseBlock ">
<h3>Painel de Membros</h3>
<table class="striped">
<thead>
Expand Down
Loading

0 comments on commit 859d75b

Please sign in to comment.