Browse Source

added checkbox

Kr Younger 6 years ago
parent
commit
6c70fd2c5e

+ 992
- 992
ionic-beer/package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 1
ionic-beer/package.json View File

55
       "android"
55
       "android"
56
     ]
56
     ]
57
   }
57
   }
58
-}
58
+}

BIN
ionic-beer/src/assets/imgs/BardBeer.png View File


BIN
ionic-beer/src/assets/imgs/WilderBeer.png View File


+ 1
- 0
ionic-beer/src/pages/about/about.html View File

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

+ 6
- 1
ionic-beer/src/pages/beer/beer.html View File

1
 <ion-header>
1
 <ion-header>
2
   <ion-navbar>
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
     <ion-buttons end>
9
     <ion-buttons end>
5
       <button ion-button icon-only (click)="openModal()" color="primary">
10
       <button ion-button icon-only (click)="openModal()" color="primary">
6
         <ion-icon name="add-circle"></ion-icon>
11
         <ion-icon name="add-circle"></ion-icon>

+ 6
- 3
ionic-beer/src/pages/beer/beer.ts View File

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

+ 1
- 1
ionic-beer/src/pages/contact/contact.html View File

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

+ 5
- 5
ionic-beer/src/pages/home/home.html View File

5
 </ion-header>
5
 </ion-header>
6
 
6
 
7
 <ion-content padding>
7
 <ion-content padding>
8
-  <h2>Welcome to Ionic!</h2>
8
+  <h2>Welcome to Kristofer's Beers!</h2>
9
   <p>
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
   </p>
11
   </p>
12
+  <h3><strong>“I would give all my fame for a pot of ale and safety”</strong></h3>
13
   <p>
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
   </p>
15
   </p>
16
+  <p><img src="assets/imgs/BardBeer.png"></p>
17
 </ion-content>
17
 </ion-content>

+ 2
- 2
ionic-beer/src/pages/tabs/tabs.ts View File

11
 export class TabsPage {
11
 export class TabsPage {
12
   tab1Root = HomePage;
12
   tab1Root = HomePage;
13
   tab2Root = BeerPage;
13
   tab2Root = BeerPage;
14
-  tab3Root = AboutPage;
15
-  tab4Root = ContactPage;
14
+  tab3Root = ContactPage;
15
+  tab4Root = AboutPage;
16
 
16
 
17
   constructor() {
17
   constructor() {
18
 
18
 

+ 14
- 2
ionic-beer/src/providers/beer-service.ts View File

4
 
4
 
5
 @Injectable()
5
 @Injectable()
6
 export class BeerService {
6
 export class BeerService {
7
-  public API = 'http://192.168.1.48:8080';
7
+  public API = 'http://localhost:8080';
8
   public BEER_API = this.API + '/beers';
8
   public BEER_API = this.API + '/beers';
9
-
9
+  public good: boolean;
10
   constructor(public http: HttpClient) {
10
   constructor(public http: HttpClient) {
11
+    this.good = false;
11
   }
12
   }
12
 
13
 
13
   getGoodBeers(): Observable<any> {
14
   getGoodBeers(): Observable<any> {
14
     return this.http.get(this.API + '/good-beers');
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
   get(id: string) {
29
   get(id: string) {
18
     return this.http.get(this.BEER_API + '/' + id);
30
     return this.http.get(this.BEER_API + '/' + id);
19
   }
31
   }

+ 2
- 2
server/src/main/java/com/example/demo/beer/BeerCommandLineRunner.java View File

17
     @Override
17
     @Override
18
     public void run(String... strings) throws Exception {
18
     public void run(String... strings) throws Exception {
19
         // Top beers from https://www.beeradvocate.com/lists/top/
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
                 repository.save(new Beer(name))
22
                 repository.save(new Beer(name))
23
         );
23
         );
24
         repository.findAll().forEach(System.out::println);
24
         repository.findAll().forEach(System.out::println);

+ 8
- 0
server/src/main/java/com/example/demo/beer/BeerController.java View File

29
                 !beer.getName().equals("Coors Light") &&
29
                 !beer.getName().equals("Coors Light") &&
30
                 !beer.getName().equals("PBR");
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
 }