diff --git a/src/app/app.component.html b/src/app/app.component.html index 9541dd6..962f22b 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cc64064..3395cff 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -2,6 +2,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io'; +import { HttpModule } from '@angular/http'; import { AppComponent } from './app.component'; import { DocumentListComponent } from './components/document-list/document-list.component'; @@ -39,6 +40,7 @@ const config: SocketIoConfig = { url: 'http://localhost:4444', options: {} }; ], imports: [ BrowserModule, + HttpModule, FormsModule, SocketIoModule.forRoot(config) ], diff --git a/src/app/components/register/register.component.html b/src/app/components/register/register.component.html index dd0a12d..bbc037d 100644 --- a/src/app/components/register/register.component.html +++ b/src/app/components/register/register.component.html @@ -2,22 +2,22 @@ - + - + - + - +
username:

email:

password:

repeat password:

- +
You are already part of greenvironment? - login - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts index 8d69477..1b60d8d 100644 --- a/src/app/components/register/register.component.ts +++ b/src/app/components/register/register.component.ts @@ -6,29 +6,29 @@ import {Registration} from '../../models/registration'; selector: 'registration', templateUrl: './register.component.html', styleUrls: ['./register.component.sass'] -})/* +}) export class RegisterComponent implements OnInit { - registration: Registration + registration: Registration - constructor(private registerService: RegisterService) {} + constructor(private registerService: RegisterService) { + this.registration = {username: null, passwordHash: null, email: null}; + } + + onClickSubmit(pUsername: string, pEmail: string, pPasswordHash: string,pPasswordHashRepeat: string ) { + console.log('username: ' + pUsername); + console.log('email: ' + pEmail); - onClickSubmit(pUsername: string, pEmail: string, pPasswordHash: string) { + if(pPasswordHash == pPasswordHashRepeat){ + console.log('password same'); this.registration.username = pUsername this.registration.email = pEmail this.registration.passwordHash = pPasswordHash this.registerService.register(this.registration) + } else{console.log('password NOT same'); } } ngOnInit() {} } -*/ -export class RegisterComponent implements OnInit { - - constructor() { } - ngOnInit() { - } - -} diff --git a/src/app/services/register/register.service.ts b/src/app/services/register/register.service.ts index 8862c91..a750046 100644 --- a/src/app/services/register/register.service.ts +++ b/src/app/services/register/register.service.ts @@ -11,20 +11,24 @@ export class RegisterService { public register(registration: Registration) { - let url = './graphql' + //let url = './graphql' + let url = 'https://greenvironment.net/graphql' let headers = new Headers(); headers.set('Content-Type', 'application/json'); - return this.http.post(url, headers, this.buildJson(registration)); + return this.http.post(url, this.buildJson(registration)).subscribe(response => console.log(response.text())); } - public buildJson(registration: Registration): String { - const body = 'mutation {' - + 'register(username: ' + registration.username + ', email: ' + registration.email - + 'passwordHash: ' + registration.passwordHash + ') {' - 'id} }' - return body + public buildJson(registration: Registration): any { + const body = {query: `mutation($username: String, $email: String, $pwHash: String) { + register(username: $username, email: $email, passwordHash: $pwHash) {id} + }`, variables: { + email: registration.email, + pwHash: registration.passwordHash, + username: registration.username, + }}; + return body; } }