-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPDATE: Creation the main functionnalities
* Creating Card & CardList component * Auth page * Nearby shops page * Favorite shops page
- Loading branch information
Showing
24 changed files
with
367 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
<p> | ||
card-list works! | ||
</p> | ||
<div class="card-deck"> | ||
<app-card *ngFor="let shop of data" [shop]="shop" (liked)="updateShops($event)" [is_favorite]="is_favorite"></app-card> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-xs-12 col-12"> | ||
<pagination [totalItems]="shops.total" [(ngModel)]="shops.current_page" [maxSize]="5" [boundaryLinks]="true" [itemsPerPage]="12" (pageChanged)="pageChanged($event)"></pagination> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import {Component, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core'; | ||
import {ShopsService} from '../../services/shops.service'; | ||
import {ToastrService} from 'ngx-toastr'; | ||
|
||
@Component({ | ||
selector: 'app-card-list', | ||
templateUrl: './card-list.component.html', | ||
styleUrls: ['./card-list.component.css'] | ||
}) | ||
export class CardListComponent implements OnInit { | ||
export class CardListComponent implements OnInit, OnChanges { | ||
|
||
constructor() { } | ||
@Input() shops: any; | ||
@Input() is_favorite: boolean; | ||
@Output() paginate = new EventEmitter<number>(); | ||
data: object[]; | ||
|
||
constructor(public shopsService: ShopsService, | ||
public toastr: ToastrService) { | ||
this.data = []; | ||
this.is_favorite = false; | ||
} | ||
|
||
ngOnInit() { | ||
this.data = this.shops.data; | ||
} | ||
|
||
ngOnChanges() { | ||
this.data = this.shops.data; | ||
} | ||
|
||
/** | ||
* Function to be used in trackBy for ngForOf | ||
* @param index | ||
* @param shop | ||
*/ | ||
trackShop(index: number, shop: any) { | ||
return shop ? shop.id : undefined; | ||
} | ||
|
||
/** | ||
* Paginate to the page | ||
* @param event | ||
*/ | ||
pageChanged(event: any): void { | ||
this.paginate.emit(event.page); | ||
} | ||
|
||
/** | ||
* Update list of Shops after liking or disliking a shop ;-) | ||
* @param update | ||
*/ | ||
updateShops(update) { | ||
if (update) { | ||
this.pageChanged(this.shops.current_page); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
<p> | ||
card works! | ||
</p> | ||
<div class="card" style="width: 18rem;"> | ||
<img class="card-img-top" src="{{ shop.picture }}" alt="Card image cap"> | ||
<div class="card-body"> | ||
<h5 class="card-title">{{ shop.name }}</h5> | ||
<p class="card-text"><span class="">Email: {{ shop.email }}</span> <span class="">City: {{ shop.city }}</span></p> | ||
</div> | ||
<div class="card-body"> | ||
<button (click)="like(shop.id)" *ngIf="!is_favorite" class="card-link" ngClass="btn btn-success"><i class="fa fa-thumbs-up"></i> Like</button> | ||
<button (click)="delete(shop.id)" *ngIf="is_favorite" class="card-link" ngClass="btn btn-warning"><i class="fa fa-times"></i> Delete</button> | ||
<button class="card-link" *ngIf="!is_favorite" (click)="dislike(shop.id)" class="btn btn-danger pull-right"><i class="fa fa-thumbs-down"></i> Dislike</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 32 additions & 3 deletions
35
src/app/modules/auth/components/login/login.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
<p> | ||
login works! | ||
</p> | ||
<div class=""> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-6 offset-md-3"> | ||
<img src="assets/images/hidden-founders.png" alt="Hidden Founders logo"> | ||
<form name="form" (ngSubmit)="f.form.valid && onSubmit()" #f="ngForm" novalidate> | ||
<div class="form-group"> | ||
<label for="email">Email</label> | ||
<input type="text" class="form-control" name="email" [(ngModel)]="model.email" | ||
#email="ngModel" [ngClass]="{ 'is-invalid': f.submitted && email.invalid }" required email /> | ||
<div *ngIf="f.submitted && email.invalid" class="invalid-feedback"> | ||
<div *ngIf="email.errors.required">Email is required</div> | ||
<div *ngIf="email.errors.email">Email must be a valid email address</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password">Password</label> | ||
<input type="password" class="form-control" name="password" [(ngModel)]="model.password" | ||
#password="ngModel" [ngClass]="{ 'is-invalid': f.submitted && password.invalid }" required minlength="6" /> | ||
<div *ngIf="f.submitted && password.invalid" class="invalid-feedback"> | ||
<div *ngIf="password.errors.required">Password is required</div> | ||
<div *ngIf="password.errors.minlength">Password must be at least 6 characters</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<button class="btn btn-primary">Register</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.