Browse Source

create user

Rachelle 6 years ago
parent
commit
997b1dc1b9

+ 0
- 3
MyPassionProject/src/main/java/com/example/demo/Repository/GameRepo.java View File

5
 import org.springframework.data.jpa.repository.Query;
5
 import org.springframework.data.jpa.repository.Query;
6
 import org.springframework.data.repository.query.Param;
6
 import org.springframework.data.repository.query.Param;
7
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
7
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
8
-import org.springframework.http.ResponseEntity;
9
-
10
 import java.util.Collection;
8
 import java.util.Collection;
11
-import java.util.Set;
12
 
9
 
13
 @RepositoryRestResource
10
 @RepositoryRestResource
14
 public interface GameRepo extends JpaRepository<Game,Long> {
11
 public interface GameRepo extends JpaRepository<Game,Long> {

+ 2
- 0
MyPassionProjectClient/src/app/app.module.ts View File

7
 import { MyApp } from './app.component';
7
 import { MyApp } from './app.component';
8
 import {MenuPageModule} from "../pages/menu/menu.module";
8
 import {MenuPageModule} from "../pages/menu/menu.module";
9
 import { HttpClientModule } from '../../node_modules/@angular/common/http';
9
 import { HttpClientModule } from '../../node_modules/@angular/common/http';
10
+import { UsersService } from '../providers/users-service';
10
 
11
 
11
 
12
 
12
 @NgModule({
13
 @NgModule({
26
   providers: [
27
   providers: [
27
     StatusBar,
28
     StatusBar,
28
     SplashScreen,
29
     SplashScreen,
30
+    UsersService,
29
     {provide: ErrorHandler, useClass: IonicErrorHandler}
31
     {provide: ErrorHandler, useClass: IonicErrorHandler}
30
   ]
32
   ]
31
 })
33
 })

+ 3
- 3
MyPassionProjectClient/src/pages/signup/signup.html View File

8
 
8
 
9
 
9
 
10
 <ion-content>
10
 <ion-content>
11
-  <form (submit)="doSignup()">
11
+  <form (submit)="createAccount()">
12
     <ion-list>
12
     <ion-list>
13
 
13
 
14
       <ion-item>
14
       <ion-item>
15
         <ion-label floating>Profilename</ion-label>
15
         <ion-label floating>Profilename</ion-label>
16
-        <ion-input type="text" [(ngModel)]="account.profilename" name="profilename"></ion-input>
16
+        <ion-input type="text" [(ngModel)]="account.profileName" name="profilename"></ion-input>
17
       </ion-item>
17
       </ion-item>
18
 
18
 
19
       <ion-item>
19
       <ion-item>
20
         <!--<ion-label fixed>{{ 'USERNAME' | translate }}</ion-label>-->
20
         <!--<ion-label fixed>{{ 'USERNAME' | translate }}</ion-label>-->
21
         <ion-label floating>Username</ion-label>
21
         <ion-label floating>Username</ion-label>
22
-        <ion-input type="text" [(ngModel)]="account.username" name="username"></ion-input>
22
+        <ion-input type="text" [(ngModel)]="account.userName" name="username"></ion-input>
23
       </ion-item>
23
       </ion-item>
24
 
24
 
25
       <ion-item>
25
       <ion-item>

+ 9
- 6
MyPassionProjectClient/src/pages/signup/signup.ts View File

1
 import { Component } from '@angular/core';
1
 import { Component } from '@angular/core';
2
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
2
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
3
 import {MenuPage} from "../menu/menu";
3
 import {MenuPage} from "../menu/menu";
4
+import { UsersService } from '../../providers/users-service';
4
 
5
 
5
 /**
6
 /**
6
  * Generated class for the SignupPage page.
7
  * Generated class for the SignupPage page.
15
   templateUrl: 'signup.html',
16
   templateUrl: 'signup.html',
16
 })
17
 })
17
 export class SignupPage {
18
 export class SignupPage {
18
-  account: { profilename: string, username: string, password: string } = {
19
-    profilename:'',
20
-    username:'',
19
+  account = {
20
+    profileName:'',
21
+    userName:'',
21
     password:''
22
     password:''
22
   };
23
   };
23
 
24
 
24
-  constructor(public navCtrl: NavController, public navParams: NavParams) {
25
+  constructor(public navCtrl: NavController, public navParams: NavParams, private usersService: UsersService) {
25
   }
26
   }
26
 
27
 
27
-  doSignup() {
28
-    this.navCtrl.setRoot(MenuPage);
28
+  createAccount() {
29
+    this.usersService.addUser(this.account).subscribe(response  => {
30
+      this.navCtrl.setRoot(MenuPage);
31
+    })
29
   }
32
   }
30
 
33
 
31
 }
34
 }

+ 5
- 0
MyPassionProjectClient/src/providers/users-service.ts View File

13
   getUserById() {
13
   getUserById() {
14
       return this.http.get(this.USERS_API+"/1")
14
       return this.http.get(this.USERS_API+"/1")
15
   }
15
   }
16
+
17
+  addUser(account): Observable<any>{
18
+    console.log(account);
19
+    return this.http.post(this.USERS_API,account);
20
+  }
16
 }
21
 }