Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial generator service
  • Loading branch information
rrc12004 committed Mar 4, 2019
1 parent 76487d0 commit a2af557
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/app/authentication/authentication.component.html
Expand Up @@ -2,23 +2,20 @@
<div class="row">
<div class="col-md-6 mx-auto mt-4">
<h4 class="text-center mb-3">Log In</h4>
<form id="loginForm">
<form>

<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input #email_input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"
placeholder="Enter email">
</div>

<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input #password_input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>

<!-- <a routerLink="/generator-search"><button type="submit" class="btn btn-primary">Submit</button></a> -->
<a href="#" class="btn btn-primary" (click)="logOn()">Submit</a>
<a routerLink="/generator-search"><button type="submit" class="btn btn-primary">Submit</button></a>
</form>
<p id='peep'></p>
<p>
<br>
The Kinsley Group is a leading energy solutions supplier with a 50 plus year legacy of sales, rental and
Expand All @@ -28,4 +25,4 @@
</p>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/app/authentication/authentication.component.ts
Expand Up @@ -35,9 +35,9 @@ export class AuthenticationComponent implements OnInit {
const message = data['message'];
if (message === 'Authorized') {
// Authorized
// console.log(token);
localStorage.setItem('auth_token', token);
this.router.navigateByUrl('/generator-search');
// console.log(token);
}
});
} catch (err) {
Expand Down
12 changes: 12 additions & 0 deletions src/app/services/generator.service.spec.ts
@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { GeneratorService } from './generator.service';

describe('GeneratorService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: GeneratorService = TestBed.get(GeneratorService);
expect(service).toBeTruthy();
});
});
18 changes: 18 additions & 0 deletions src/app/services/generator.service.ts
@@ -0,0 +1,18 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
providedIn: 'root'
})
export class GeneratorService {

constructor(private http: HttpClient) { }

getUser(token) {
return this.http.get('http://sd5-backend.engr.uconn.edu/user/generators', {
headers: {
Authorization: 'Bearer ' + token
}
});
}
}
2 changes: 1 addition & 1 deletion src/app/services/login.service.ts
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/catch';
Expand Down

0 comments on commit a2af557

Please sign in to comment.