Skip to content

Commit

Permalink
GENERAL: do some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ouladck committed Sep 19, 2018
1 parent 98f6d40 commit bc90d4a
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 38 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# NearbyShopsFront

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.1.2.
This is a coding challenge for Hidden founders.

This is just the Front-Service using Angula 6.1.2.
You can find the Back-Service [Here](https://github.com/karim88/nearby-shops-back-service).

# Installation

* First you need Angula CLI: `npm i @angular/cil -g`
* Clone the project `git clone [email protected]:karim88/nearby-shops-front-service.git`
* Navigate to the project folder `cd nearby-shops-front-service`
* Install dependencies `npm i`
* Now you are Ready To Go you can run `ng serve --aot` for developement or `ng seve --prod` for production.

```
Note: don't forget to change the environement files.
```

## Development server

Expand Down
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Routes, RouterModule } from '@angular/router';
import { AuthComponent } from './components/layouts/auth/auth.component';
import { AppComponent } from './components/layouts/app/app.component';
import { PublicGuard, ProtectedGuard } from 'ngx-auth';
import {LogoutComponent} from './modules/auth/components/logout/logout.component';
import { LogoutComponent } from './modules/auth/components/logout/logout.component';

const routes: Routes = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BrowserModule } from '@angular/platform-browser';
import {CUSTOM_ELEMENTS_SCHEMA, NgModule, NO_ERRORS_SCHEMA} from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand Down
8 changes: 6 additions & 2 deletions src/app/components/card-list/card-list.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.card-columns {
padding-top: 85px;
.pagination-row {
margin-top: 30px;
}

.pagination-component {
display: flex;
}
12 changes: 8 additions & 4 deletions src/app/components/card-list/card-list.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<div class="card-columns">
<app-card *ngFor="let shop of data" [shop]="shop" (liked)="updateShops($event)" [is_favorite]="is_favorite"></app-card>
<div class="row">
<div class="col-md-4" *ngFor="let shop of data">
<app-card [shop]="shop" (liked)="updateShops($event)" [is_favorite]="is_favorite"></app-card>
</div>
</div>

<div class="row">
<div class="row pagination-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>
<pagination class="mx-auto pagination-component" [totalItems]="shops.total" [(ngModel)]="shops.current_page"
[maxSize]="5" [boundaryLinks]="true" [itemsPerPage]="12"
(pageChanged)="pageChanged($event)"></pagination>
</div>
</div>

2 changes: 1 addition & 1 deletion src/app/components/card-list/card-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';


@Component({
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/card/card.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {ShopsService} from '../../services/shops.service';
import {ToastrService} from 'ngx-toastr';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ShopsService } from '../../services/shops.service';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-card',
Expand All @@ -13,7 +13,7 @@ export class CardComponent implements OnInit {
@Input() is_favorite: boolean;
@Output() liked = new EventEmitter<boolean>();
constructor(public shopsService: ShopsService,
public toastr: ToastrService) {
public toastr: ToastrService) {
}

ngOnInit() {
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/layouts/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
selector: 'app-app',
Expand All @@ -19,7 +19,7 @@ export class AppComponent implements OnInit {
/**
* Change route url to be for active class
*/
changeRoute () {
changeRoute() {
this.current_url = this.router.url;
}

Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/auth/components/register/register.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import {AuthenticationService} from '../../../../services/authentication.service';
import {ToastrService} from 'ngx-toastr';
import {Router} from '@angular/router';
import { AuthenticationService } from '../../../../services/authentication.service';
import { ToastrService } from 'ngx-toastr';
import { Router } from '@angular/router';

@Component({
selector: 'app-register',
Expand All @@ -14,8 +14,8 @@ export class RegisterComponent implements OnInit {


constructor(public auth: AuthenticationService,
public toastr: ToastrService,
public router: Router) { }
public toastr: ToastrService,
public router: Router) { }

ngOnInit() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container {
margin-top: 85px;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<div class="container" *ngIf="data">
<div class="container" *ngIf="data && data.data.length > 0">
<app-card-list [shops]="data" (paginate)="paginated($event)" [is_favorite]="true"></app-card-list>
</div>

<div class="container" *ngIf="!data || data.data.length === 0">
<div class="alert alert-warning" role="alert">
You did not like any shop, why?<br>
do some likes and come back ;-)
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import {ShopsService} from '../../../../services/shops.service';
import {ToastrService} from 'ngx-toastr';
import { ShopsService } from '../../../../services/shops.service';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-favorites',
Expand All @@ -11,7 +11,7 @@ export class FavoritesComponent implements OnInit {

data: any;
constructor(public shopsService: ShopsService,
public toastr: ToastrService) {
public toastr: ToastrService) {
}

ngOnInit() {
Expand Down
3 changes: 3 additions & 0 deletions src/app/modules/shops/components/nearby/nearby.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container {
margin-top: 85px;
}
7 changes: 7 additions & 0 deletions src/app/modules/shops/components/nearby/nearby.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<div class="container" *ngIf="data">
<app-card-list [shops]="data" (paginate)="paginated($event)" [is_favorite]="false"></app-card-list>
</div>

<div class="container" *ngIf="!data || data.data.length === 0">
<div class="alert alert-warning" role="alert">
Something bad occured while fetching data<br>
Please allow localisation of you position to get the list of shops ;-(
</div>
</div>
8 changes: 4 additions & 4 deletions src/app/modules/shops/components/nearby/nearby.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {ShopsService} from '../../../../services/shops.service';
import {ToastrService} from 'ngx-toastr';
import { Component, OnInit } from '@angular/core';
import { ShopsService } from '../../../../services/shops.service';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-nearby',
Expand All @@ -11,7 +11,7 @@ export class NearbyComponent implements OnInit {

data: any;
constructor(public shopsService: ShopsService,
public toastr: ToastrService) {
public toastr: ToastrService) {
}

ngOnInit() {
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/shops/shops.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ShopsRoutingModule } from './shops-routing.module';
import { FavoritesComponent } from './components/favorites/favorites.component';
import { NearbyComponent } from './components/nearby/nearby.component';
import {CardListComponent} from '../../components/card-list/card-list.component';
import {CardComponent} from '../../components/card/card.component';
import {PaginationModule} from 'ngx-bootstrap/pagination';
import {FormsModule} from '@angular/forms';
import { CardListComponent } from '../../components/card-list/card-list.component';
import { CardComponent } from '../../components/card/card.component';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import { FormsModule } from '@angular/forms';

@NgModule({
imports: [
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/shops.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {environment} from '../../environments/environment';
import {Observable} from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../../environments/environment';
import { Observable } from 'rxjs';

@Injectable({
providedIn: 'root'
Expand Down

0 comments on commit bc90d4a

Please sign in to comment.