Kaynağa Gözat

added checkbox

Kr Younger 6 yıl önce
ebeveyn
işleme
6c70fd2c5e

+ 992
- 992
ionic-beer/package-lock.json
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 1
- 1
ionic-beer/package.json Dosyayı Görüntüle

@@ -55,4 +55,4 @@
55 55
       "android"
56 56
     ]
57 57
   }
58
-}
58
+}

BIN
ionic-beer/src/assets/imgs/BardBeer.png Dosyayı Görüntüle


BIN
ionic-beer/src/assets/imgs/WilderBeer.png Dosyayı Görüntüle


+ 1
- 0
ionic-beer/src/pages/about/about.html Dosyayı Görüntüle

@@ -7,5 +7,6 @@
7 7
 </ion-header>
8 8
 
9 9
 <ion-content padding>
10
+  <p><img src="assets/imgs/WilderBeer.png"></p>
10 11
 
11 12
 </ion-content>

+ 6
- 1
ionic-beer/src/pages/beer/beer.html Dosyayı Görüntüle

@@ -1,6 +1,11 @@
1 1
 <ion-header>
2 2
   <ion-navbar>
3
-    <ion-title>Good Beers</ion-title>
3
+    <ion-title>Kristofer's Nasty Beers</ion-title>
4
+    <ion-item>
5
+      <ion-label>Show Good Beers</ion-label>
6
+    <ion-checkbox [(ngModel)]="goodbeers" (click)="changeList()"></ion-checkbox>
7
+    </ion-item>
8
+
4 9
     <ion-buttons end>
5 10
       <button ion-button icon-only (click)="openModal()" color="primary">
6 11
         <ion-icon name="add-circle"></ion-icon>

+ 6
- 3
ionic-beer/src/pages/beer/beer.ts Dosyayı Görüntüle

@@ -11,14 +11,14 @@ import { BeerModalPage } from './beer-modal';
11 11
 })
12 12
 export class BeerPage {
13 13
   private beers: Array<any>;
14
-
14
+  public goodbeers: boolean;
15 15
   constructor(public navCtrl: NavController, public navParams: NavParams,
16 16
               public beerService: BeerService, public giphyService: GiphyService,
17 17
               public modalCtrl: ModalController, public toastCtrl: ToastController) {
18 18
   }
19 19
 
20 20
   ionViewDidLoad() {
21
-    this.beerService.getGoodBeers().subscribe(beers => {
21
+    this.beerService.getBeers().subscribe(beers => {
22 22
       this.beers = beers;
23 23
       for (const beer of this.beers) {
24 24
         this.giphyService.get(beer.name).subscribe(url => {
@@ -27,7 +27,10 @@ export class BeerPage {
27 27
       }
28 28
     })
29 29
   }
30
-
30
+  changeList(event) {
31
+    this.beerService.good = this.goodbeers.valueOf();
32
+    this.ionViewDidLoad();
33
+  }
31 34
   openModal(beerId) {
32 35
     let modal = this.modalCtrl.create(BeerModalPage, beerId);
33 36
     modal.present();

+ 1
- 1
ionic-beer/src/pages/contact/contact.html Dosyayı Görüntüle

@@ -11,7 +11,7 @@
11 11
     <ion-list-header>Follow us on Twitter</ion-list-header>
12 12
     <ion-item>
13 13
       <ion-icon name="ionic" item-start></ion-icon>
14
-      @ionicframework
14
+      Don't call me, I'll call you! 
15 15
     </ion-item>
16 16
   </ion-list>
17 17
 </ion-content>

+ 5
- 5
ionic-beer/src/pages/home/home.html Dosyayı Görüntüle

@@ -5,13 +5,13 @@
5 5
 </ion-header>
6 6
 
7 7
 <ion-content padding>
8
-  <h2>Welcome to Ionic!</h2>
8
+  <h2>Welcome to Kristofer's Beers!</h2>
9 9
   <p>
10
-    This starter project comes with simple tabs-based layout for apps
11
-    that are going to primarily use a Tabbed UI.
10
+    Tabs, Beers, and nothing else.
12 11
   </p>
12
+  <h3><strong>“I would give all my fame for a pot of ale and safety”</strong></h3>
13 13
   <p>
14
-    Take a look at the <code>src/pages/</code> directory to add or change tabs,
15
-    update any existing page or create new pages.
14
+<em>Henry V: Act 3, Scene 2.</em>
16 15
   </p>
16
+  <p><img src="assets/imgs/BardBeer.png"></p>
17 17
 </ion-content>

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

@@ -11,8 +11,8 @@ import { BeerPage } from '../beer/beer';
11 11
 export class TabsPage {
12 12
   tab1Root = HomePage;
13 13
   tab2Root = BeerPage;
14
-  tab3Root = AboutPage;
15
-  tab4Root = ContactPage;
14
+  tab3Root = ContactPage;
15
+  tab4Root = AboutPage;
16 16
 
17 17
   constructor() {
18 18
 

+ 14
- 2
ionic-beer/src/providers/beer-service.ts Dosyayı Görüntüle

@@ -4,16 +4,28 @@ import { HttpClient } from '@angular/common/http';
4 4
 
5 5
 @Injectable()
6 6
 export class BeerService {
7
-  public API = 'http://192.168.1.48:8080';
7
+  public API = 'http://localhost:8080';
8 8
   public BEER_API = this.API + '/beers';
9
-
9
+  public good: boolean;
10 10
   constructor(public http: HttpClient) {
11
+    this.good = false;
11 12
   }
12 13
 
13 14
   getGoodBeers(): Observable<any> {
14 15
     return this.http.get(this.API + '/good-beers');
15 16
   }
16 17
 
18
+  getAllBeers(): Observable<any> {
19
+    return this.http.get(this.API + '/all-beers');
20
+  }
21
+
22
+  getBeers(): Observable<any> {
23
+    if (this.good) {
24
+      return this.http.get(this.API + '/good-beers');
25
+    }
26
+    return this.http.get(this.API + '/all-beers');
27
+  }
28
+
17 29
   get(id: string) {
18 30
     return this.http.get(this.BEER_API + '/' + id);
19 31
   }

+ 2
- 2
server/src/main/java/com/example/demo/beer/BeerCommandLineRunner.java Dosyayı Görüntüle

@@ -17,8 +17,8 @@ public class BeerCommandLineRunner implements CommandLineRunner {
17 17
     @Override
18 18
     public void run(String... strings) throws Exception {
19 19
         // Top beers from https://www.beeradvocate.com/lists/top/
20
-        Stream.of("Kentucky Brunch Brand Stout", "Good Morning", "Very Hazy", "King Julius",
21
-                "Budweiser", "Coors Light", "PBR").forEach(name ->
20
+        Stream.of("Kentucky Quail Egg Stout", "Good Morning, Breakfast Weiss", "Very Hazy", "King Henry's Favorite Fried Chicken Porter",
21
+                "Budweiser", "Coors Light", "PBR", "Goat Spit Ale", "Diabetic Pony", "Funky T-shirt").forEach(name ->
22 22
                 repository.save(new Beer(name))
23 23
         );
24 24
         repository.findAll().forEach(System.out::println);

+ 8
- 0
server/src/main/java/com/example/demo/beer/BeerController.java Dosyayı Görüntüle

@@ -29,4 +29,12 @@ public class BeerController {
29 29
                 !beer.getName().equals("Coors Light") &&
30 30
                 !beer.getName().equals("PBR");
31 31
     }
32
+    @GetMapping("/all-beers")
33
+    @CrossOrigin(origins = {"http://localhost:8100","http://localhost:8080"})
34
+    public Collection<Beer> allBeers() {
35
+
36
+        return repository.findAll().stream()
37
+                .collect(Collectors.toList());
38
+    }
39
+
32 40
 }