Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/main/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ShipQtComponent } from './ship-qt/ship-qt.component';
import { RctQtComponent } from './rct-qt/rct-qt.component';
import { EditComponent } from './edit/edit.component';
import { AboutComponent } from './about/about.component';
import { HttpClientModule } from "@angular/common/http";

@NgModule({
declarations: [
Expand All @@ -46,7 +47,8 @@ import { AboutComponent } from './about/about.component';
imports: [
BrowserModule,
AppRoutingModule,
FormsModule
FormsModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
2 changes: 1 addition & 1 deletion frontend/main/src/app/body/body.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@ <h3 class="dropdown-item-title">
</div>
<div style="padding-left: 20px;">
<div class="small">Logged in as:</div>
<span>{{name}}<br><a routerLink="" (click)="sair()" class="small" style="color: red;">Sair</a>&nbsp;&nbsp;&nbsp;&nbsp;<a routerLink="edit" class="small">Edit</a> </span>
<span>{{loginService.user}}<br><a routerLink="" (click)="sair()" class="small" style="color: red;">Sair</a>&nbsp;&nbsp;&nbsp;&nbsp;<a routerLink="edit" class="small">Edit</a> </span>
</div>
</aside>
7 changes: 3 additions & 4 deletions frontend/main/src/app/body/body.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { LoginComponent } from '../login/login.component';
import { LoginserviceService } from '../loginservice.service';

@Component({
Expand All @@ -8,16 +9,14 @@ import { LoginserviceService } from '../loginservice.service';
})
export class BodyComponent implements OnInit {

name:string = "Admin"

constructor(private login:LoginserviceService) { }
constructor(public loginService:LoginserviceService) { }

ngOnInit(): void {
}

sair(){

this.login.succeed = false;
this.loginService.succeed = false;

}

Expand Down
2 changes: 2 additions & 0 deletions frontend/main/src/app/login/login.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<input type="text" [(ngModel)]="user" placeholder="User"><br>
<input type="text" [(ngModel)]="password" placeholder="Password"><br>
<button class="btn btn-outline-primary" (click)="submit()">Entrar!</button>
19 changes: 16 additions & 3 deletions frontend/main/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { catchError, of } from 'rxjs';
import { LoginserviceService } from '../loginservice.service';

@Component({
Expand All @@ -9,15 +10,27 @@ import { LoginserviceService } from '../loginservice.service';
})
export class LoginComponent implements OnInit {

constructor(private router:Router, private login:LoginserviceService) { }
user!:string
password!:string

constructor(private router:Router, private loginService:LoginserviceService) { }

ngOnInit(): void {
this.login.succeed = false
this.loginService.succeed = false
}

submit():void{
this.login.succeed = true
this.loginService.succeed = true
this.router.navigateByUrl('home');
this.loginService.logging(this.user, this.password)
.pipe(
catchError((error)=>{
return of(['Deu erro parcero é isso', 'tu não vai encontrar detalhe aqui','pode sair já...', error, 'só pq sou teu amigo vou deixar esse error ai'])
})
)
.subscribe((response)=>{
console.log('Running...', response);
});
}

}
10 changes: 9 additions & 1 deletion frontend/main/src/app/loginservice.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
Expand All @@ -7,9 +8,16 @@ import { Observable } from 'rxjs';
})
export class LoginserviceService implements CanActivate {

user!:string
TMSLoginAPI:string = "https://imagina-uma-api-bem-daora-aqui.com"
succeed!:boolean

constructor(private router:Router) {}
constructor(private router:Router, private http:HttpClient) {}

logging(user:string, password:string){
this.user = user
return this.http.get<any>(this.TMSLoginAPI+user+password)
}

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {

Expand Down