Kaynağa Gözat

changed navigation to myGames

Rachelle 6 yıl önce
ebeveyn
işleme
832e7c2166

+ 130
- 857
.idea/workspace.xml
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 0
- 44
MyPassionProjectClient/src/pages/games/games.html Dosyayı Görüntüle

@@ -1,44 +0,0 @@
1
-<ion-header>
2
-  <ion-navbar>
3
-    <ion-buttons start>
4
-      <button ion-button menuToggle>
5
-        <ion-icon name="menu"></ion-icon>
6
-      </button>
7
-    </ion-buttons>
8
-    <ion-title>Games</ion-title>
9
-  </ion-navbar>
10
-</ion-header>
11
-
12
-
13
-<ion-content padding>
14
-
15
-  <ion-searchbar [(ngModel)]="searchTerm" (ionInput)="getItems($event)" placeholder="Search Games"></ion-searchbar>
16
-  <ion-list>
17
-    <ion-item-sliding *ngFor="let game of filteredGames">
18
-      <ion-item>
19
-      <ion-thumbnail item-start>
20
-        <img src={{game.thumbnail}}>
21
-      </ion-thumbnail>
22
-      <h2>{{game.name}}</h2>
23
-      <p>{{game.mechanics}}</p>
24
-      <button ion-button clear item-end>View</button>
25
-        </ion-item>
26
-
27
-
28
-      <ion-item-options side="left">
29
-        <button ion-button color="primary" (click)="doAddToOwnedAndPlayedList()">
30
-          <ion-icon name="add"></ion-icon> Owned and Played
31
-        </button>
32
-      </ion-item-options>
33
-
34
-      <ion-item-options side="right">
35
-      <button ion-button color="primary" (click)="doAddToOwnedList()">
36
-      <ion-icon name="add"></ion-icon> Owned
37
-      </button>
38
-        <button ion-button color="secondary" (click)="doAddToPlayedList()">
39
-          <ion-icon name="add"></ion-icon> Played
40
-        </button>
41
-      </ion-item-options>
42
-    </ion-item-sliding>
43
-  </ion-list>
44
-</ion-content>

+ 0
- 17
MyPassionProjectClient/src/pages/games/games.module.ts Dosyayı Görüntüle

@@ -1,17 +0,0 @@
1
-import { NgModule } from '@angular/core';
2
-import { IonicPageModule } from 'ionic-angular';
3
-import { GamesPage } from './games';
4
-import { GamesService } from '../../providers/games-service';
5
-
6
-@NgModule({
7
-  declarations: [
8
-    GamesPage,
9
-  ],
10
-  imports: [
11
-    IonicPageModule.forChild(GamesPage),
12
-  ],
13
-  providers: [
14
-    GamesService
15
-  ],
16
-})
17
-export class GamesPageModule {}

+ 0
- 3
MyPassionProjectClient/src/pages/games/games.scss Dosyayı Görüntüle

@@ -1,3 +0,0 @@
1
-page-games {
2
-
3
-}

+ 1
- 5
MyPassionProjectClient/src/pages/menu/menu.ts Dosyayı Görüntüle

@@ -1,4 +1,4 @@
1
-import {GamesPage} from "../games/games";
1
+import {MyGamesPage} from "../my-games/my-games";
2 2
 import {FriendsPage} from "../friends/friends";
3 3
 import {SummaryPage} from "../summary/summary";
4 4
 import { TabsPage } from './../tabs/tabs';
@@ -29,7 +29,6 @@ export class MenuPage {
29 29
 
30 30
   pages: PageInterface[] = [
31 31
     { title: 'MyPage', pageName: 'TabsPage', tabComponent: 'SummaryPage', index: 0, icon: 'home' },
32
-    { title: 'MyGames', pageName: 'TabsPage', tabComponent: 'GamesPage', index: 1, icon: 'search' },
33 32
     { title: 'Game Search', pageName: 'TabsPage', tabComponent: 'GameSearchPage', index: 2, icon: 'search' },
34 33
     { title: 'Friends', pageName: 'TabsPage', tabComponent: 'FriendsPage', index: 3, icon: 'contacts' },
35 34
     { title: 'Settings', pageName: 'SettingsPage', icon: 'build' },
@@ -53,9 +52,6 @@ export class MenuPage {
53 52
     } else {
54 53
       // Tabs are not active, so reset the root page
55 54
       // In this case: moving to or from SpecialPage
56
-      console.log(params);
57
-      console.log("param2");
58
-      console.log(this.usersService.user);
59 55
       this.nav.setRoot(page.pageName, params);
60 56
     }
61 57
   }

+ 45
- 0
MyPassionProjectClient/src/pages/my-games/my-games.html Dosyayı Görüntüle

@@ -0,0 +1,45 @@
1
+<ion-header>
2
+    <ion-navbar>
3
+      <ion-buttons start>
4
+        <button ion-button menuToggle>
5
+          <ion-icon name="menu"></ion-icon>
6
+        </button>
7
+      </ion-buttons>
8
+      <ion-title>Games</ion-title>
9
+    </ion-navbar>
10
+  </ion-header>
11
+  
12
+  
13
+  <ion-content padding>
14
+  
15
+    <ion-searchbar [(ngModel)]="searchTerm" (ionInput)="getItems($event)" placeholder="Search Games"></ion-searchbar> 
16
+    <ion-list>
17
+      <ion-item-sliding *ngFor="let game of filteredGames">
18
+        <ion-item>
19
+        <ion-thumbnail item-start>
20
+          <img src={{game.thumbnail}}>
21
+        </ion-thumbnail>
22
+        <h2>{{game.name}}</h2>
23
+        <p>{{game.mechanics}}</p>
24
+        <button ion-button clear item-end>View</button>
25
+          </ion-item>
26
+  
27
+  
28
+        <ion-item-options side="left">
29
+          <button ion-button color="primary" (click)="doAddToOwnedAndPlayedList()">
30
+            <ion-icon name="add"></ion-icon> Owned and Played
31
+          </button>
32
+        </ion-item-options>
33
+  
34
+        <ion-item-options side="right">
35
+        <button ion-button color="primary" (click)="doAddToOwnedList()">
36
+        <ion-icon name="add"></ion-icon> Owned
37
+        </button>
38
+          <button ion-button color="secondary" (click)="doAddToPlayedList()">
39
+            <ion-icon name="add"></ion-icon> Played
40
+          </button>
41
+        </ion-item-options>
42
+      </ion-item-sliding>
43
+    </ion-list>
44
+  </ion-content>
45
+  

+ 19
- 0
MyPassionProjectClient/src/pages/my-games/my-games.module.ts Dosyayı Görüntüle

@@ -0,0 +1,19 @@
1
+import { NgModule } from '@angular/core';
2
+import { IonicPageModule } from 'ionic-angular';
3
+import { MyGamesPage } from './my-games';
4
+import { GamesService } from '../../providers/games-service';
5
+import { UsersService } from '../../providers/users-service';
6
+
7
+@NgModule({
8
+  declarations: [
9
+    MyGamesPage,
10
+  ],
11
+  imports: [
12
+    IonicPageModule.forChild(MyGamesPage),
13
+  ],
14
+  providers: [
15
+    GamesService,
16
+    UsersService,
17
+  ],
18
+})
19
+export class MyGamesPageModule {}

+ 3
- 0
MyPassionProjectClient/src/pages/my-games/my-games.scss Dosyayı Görüntüle

@@ -0,0 +1,3 @@
1
+page-my-games {
2
+
3
+}

MyPassionProjectClient/src/pages/games/games.ts → MyPassionProjectClient/src/pages/my-games/my-games.ts Dosyayı Görüntüle

@@ -1,26 +1,28 @@
1 1
 import { Component } from '@angular/core';
2 2
 import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
3
-import { GamesService } from '../../providers/games-service';
4 3
 import { UsersService } from '../../providers/users-service';
5 4
  
6 5
 @IonicPage()
7 6
 @Component({
8
-  selector: 'page-games',
9
-  templateUrl: 'games.html',
7
+  selector: 'page-my-games',
8
+  templateUrl: 'my-games.html',
10 9
 })
11
-export class GamesPage {
10
+export class MyGamesPage {
12 11
     games: any;
13 12
     filteredGames: any;
13
+    userId: any;
14 14
 
15
-  constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public gamesService: GamesService) {
16
-    this.gamesService.getUsersGames().subscribe(games=>{
17
-      this.filteredGames = games;
18
-      this.games = games;
19
-    })
20
-    ;
15
+  constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public usersService: UsersService) {
16
+    console.log(navParams.get('id'));
17
+    this.userId = navParams.get('id');
21 18
   }
22 19
   
23 20
     ionViewDidLoad() {
21
+      this.usersService.getUsersGames(this.userId).subscribe(games=>{
22
+        this.filteredGames = games;
23
+        this.games = games;
24
+      })
25
+      ;
24 26
     }
25 27
 
26 28
     getItems(ev: any) {
@@ -47,6 +49,5 @@ export class GamesPage {
47 49
       position: 'bottom'
48 50
     });
49 51
     toast.present();
50
-
51 52
   }
52 53
 }

+ 1
- 5
MyPassionProjectClient/src/pages/summary/summary.html Dosyayı Görüntüle

@@ -26,15 +26,11 @@
26 26
             {{user.summary}}
27 27
           </p>
28 28
     
29
-          <!-- <button ion-item (click)="get()">
30
-            GetUserName
31
-          </button> -->
32
-    
33 29
         </ion-card-content>
34 30
     
35 31
       </ion-card>
36 32
     
37
-      <ion-card>
33
+      <ion-card (click)=viewGames()>
38 34
     
39 35
         <ion-card-header>
40 36
           <strong>My Games</strong>

+ 5
- 0
MyPassionProjectClient/src/pages/summary/summary.ts Dosyayı Görüntüle

@@ -18,5 +18,10 @@ export class SummaryPage {
18 18
     console.log(this.usersService.user);
19 19
   }
20 20
 
21
+  viewGames(){ 
22
+    let params = {id: this.user.id};
23
+    this.navCtrl.push('MyGamesPage',params);
24
+  }
25
+
21 26
 }
22 27
  

+ 0
- 1
MyPassionProjectClient/src/pages/tabs/tabs.html Dosyayı Görüntüle

@@ -1,7 +1,6 @@
1 1
 <ion-tabs>
2 2
     
3 3
     <ion-tab [root]="summaryRoot" tabTitle="MyPage" tabIcon="home"></ion-tab>
4
-    <ion-tab [root]="gamesRoot" tabTitle="MyGames" tabIcon="search"></ion-tab>
5 4
     <ion-tab [root]="gameSearchRoot" tabTitle="Game Search" tabIcon="search"></ion-tab>
6 5
     <ion-tab [root]="friendsRoot" tabTitle="Friends" tabIcon="contacts"></ion-tab>
7 6
 </ion-tabs>

+ 1
- 2
MyPassionProjectClient/src/pages/tabs/tabs.ts Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 import { Component } from '@angular/core';
2
-import {IonicPage, NavController, NavParams} from 'ionic-angular';
2
+import {IonicPage, NavParams} from 'ionic-angular';
3 3
 
4 4
 @IonicPage()
5 5
 @Component({
@@ -9,7 +9,6 @@ import {IonicPage, NavController, NavParams} from 'ionic-angular';
9 9
 export class TabsPage {
10 10
   summaryRoot: any = 'SummaryPage';
11 11
   friendsRoot: any = 'FriendsPage';
12
-  gamesRoot: any = 'GamesPage';
13 12
   gameSearchRoot: any = 'GameSearchPage';
14 13
   myIndex: number;
15 14
 

+ 1
- 4
MyPassionProjectClient/src/providers/games-service.ts Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 import {Injectable} from "@angular/core";
2 2
 import {HttpClient} from "@angular/common/http";
3 3
 import {Observable} from "rxjs/Observable";
4
+import { UsersService } from "./users-service";
4 5
 
5 6
 @Injectable()
6 7
 export class GamesService{
@@ -28,8 +29,4 @@ export class GamesService{
28 29
     return this.gameId = game.id;
29 30
   }
30 31
 
31
-  getUsersGames(){
32
-    return this.http.get(this.GAMES_API+"/library/"+this.gameId);
33
-  }
34
-
35 32
 }

+ 6
- 0
MyPassionProjectClient/src/providers/users-service.ts Dosyayı Görüntüle

@@ -20,6 +20,7 @@ export class User {
20 20
 export class UsersService{
21 21
   public API = "https://tabletoptracker.herokuapp.com";
22 22
   public USERS_API = this.API + "/users";
23
+  public GAMES_API = this.API + "/games";
23 24
   public user: User;
24 25
   public userId: any;
25 26
 
@@ -34,6 +35,7 @@ export class UsersService{
34 35
   setUser(account){
35 36
     this.userId = account.id;
36 37
     this.user = account;
38
+    console.log(this.userId);
37 39
   }
38 40
 
39 41
   getUser() {
@@ -57,4 +59,8 @@ export class UsersService{
57 59
     console.log(this.USERS_API + "/" + this.userId + "/library");
58 60
     return this.http.put(this.USERS_API + "/" + this.userId + "/library", gameId);
59 61
   }
62
+
63
+  getUsersGames(userId){
64
+    return this.http.get(this.GAMES_API+"/library/"+userId);
65
+  }
60 66
 }