Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
allo-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
allo-app
Commits
93fdbc94
Commit
93fdbc94
authored
Sep 01, 2019
by
Nabil Sadki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Categories tags
parent
e561b39e
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
523 additions
and
226 deletions
+523
-226
dashboard.module.ts
src/app/pages/dashboard/dashboard.module.ts
+27
-3
dashboard.page.html
src/app/pages/dashboard/dashboard.page.html
+15
-62
dashboard.page.scss
src/app/pages/dashboard/dashboard.page.scss
+2
-36
dashboard.page.ts
src/app/pages/dashboard/dashboard.page.ts
+1
-45
offres-carte.module.ts
src/app/pages/offres-carte/offres-carte.module.ts
+27
-0
offres-carte.page.html
src/app/pages/offres-carte/offres-carte.page.html
+73
-0
offres-carte.page.scss
src/app/pages/offres-carte/offres-carte.page.scss
+117
-0
offres-carte.page.spec.ts
src/app/pages/offres-carte/offres-carte.page.spec.ts
+27
-0
offres-carte.page.ts
src/app/pages/offres-carte/offres-carte.page.ts
+58
-0
offres-tlm.module.ts
src/app/pages/offres-tlm/offres-tlm.module.ts
+26
-0
offres-tlm.page.html
src/app/pages/offres-tlm/offres-tlm.page.html
+9
-0
offres-tlm.page.scss
src/app/pages/offres-tlm/offres-tlm.page.scss
+0
-0
offres-tlm.page.spec.ts
src/app/pages/offres-tlm/offres-tlm.page.spec.ts
+27
-0
offres-tlm.page.ts
src/app/pages/offres-tlm/offres-tlm.page.ts
+15
-0
pipes.module.ts
src/app/pipes/pipes.module.ts
+12
-0
trip-service.ts
src/app/services/trip-service.ts
+87
-80
No files found.
src/app/pages/dashboard/dashboard.module.ts
View file @
93fdbc94
...
...
@@ -4,14 +4,38 @@ import { FormsModule } from '@angular/forms';
import
{
Routes
,
RouterModule
}
from
'@angular/router'
;
import
{
IonicModule
}
from
'@ionic/angular'
;
import
{
SearchPipe
}
from
'../../pipes/search/search.pipe'
;
import
{
DashboardPage
}
from
'./dashboard.page'
;
const
routes
:
Routes
=
[
{
path
:
''
,
component
:
DashboardPage
component
:
DashboardPage
,
children
:
[
{
path
:
'offres-carte'
,
children
:
[
{
path
:
''
,
loadChildren
:
'../offres-carte/offres-carte.module#OffresCartePageModule'
}
]
},
{
path
:
'offres-tlm'
,
children
:
[
{
path
:
''
,
loadChildren
:
'../offres-tlm/offres-tlm.module#OffresTlmPageModule'
}
]
},
{
path
:
''
,
redirectTo
:
'/app/dashboard/offres-carte'
,
pathMatch
:
'full'
}
]
}
];
...
...
@@ -22,6 +46,6 @@ const routes: Routes = [
IonicModule
,
RouterModule
.
forChild
(
routes
)
],
declarations
:
[
DashboardPage
,
SearchPipe
]
declarations
:
[
DashboardPage
]
})
export
class
DashboardPageModule
{}
src/app/pages/dashboard/dashboard.page.html
View file @
93fdbc94
...
...
@@ -8,20 +8,7 @@
<!-- <ion-icon name="menu" size="large" color="light"></ion-icon> -->
</ion-menu-button>
</ion-buttons>
<ion-card
class=
"top-card"
no-margin
>
<ion-card-content
no-padding
>
<ion-item
lines=
"none"
>
<ion-label
class=
"text-1x bold text-primary"
>
Catégories
</ion-label>
<ion-select
cancelText=
"Fermer"
class=
"text-primary"
[(
ngModel
)]="
terms
"
(
ionChange
)="
onContextChange
($
event
.
id
)"
>
<ion-select-option
value=
"all"
>
- Tout -
</ion-select-option>
<ion-select-option
*
ngFor=
"let category of _TRIP.cats"
[
value
]="
category
.
id
"
>
{{ category.label }}
</ion-select-option>
</ion-select>
</ion-item>
</ion-card-content>
</ion-card>
<ion-buttons
slot=
"end"
>
<!-- <ion-button (click)="showHideMoreFilters()"> -->
<ion-button>
...
...
@@ -71,53 +58,18 @@
</ion-grid>
</ion-header>
<ion-content
padding
class=
"dashboard"
>
<ion-refresher
(
ionRefresh
)="
doRefresh
($
event
)"
>
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<!--list of trips-->
<ion-card
*
ngFor=
"let trip of _TRIP.products | search : terms"
(
click
)="
viewDetail
(
trip
.
id
)"
tappable
no-margin
margin-bottom
>
<div
class=
"img-spinner-wrap ion-text-center"
>
<ion-spinner
name=
"dots"
*
ngIf=
"trip.hidden"
></ion-spinner>
</div>
<ion-img
[
src
]="
trip
.
thumb
"
[
class
.
no-visibility
]="
trip
.
hidden
"
(
ionImgDidLoad
)="
setImgVisible
(
trip
)"
></ion-img>
<ion-card-header>
<ion-card-subtitle
color=
"primary"
>
<ion-icon
name=
"pin"
></ion-icon>
<ion-label>
{{ trip.location }}
</ion-label>
<ion-badge
fill=
"outline"
*
ngIf=
"trip.price_adult"
color=
"warning"
>
-{{ ((trip.price_adult_before - trip.price_adult) * 100) / trip.price_adult_before | number:'1.0-0' }}%
</ion-badge>
</ion-card-subtitle>
<ion-card-title>
{{ trip.name | slice:0:100 }}
</ion-card-title>
</ion-card-header>
<!-- <ion-item>
<ion-icon name="pin" slot="start"></ion-icon>
<ion-label>{{ trip.location }}</ion-label>
<ion-button fill="outline" slot="end">View</ion-button>
</ion-item> -->
<ion-card-content
no-padding
padding-horizontal
padding-bottom
>
{{ trip.description | slice:0:130 }}...
</ion-card-content>
<ion-item
*
ngIf=
"trip.price_adult"
color=
"primary"
lines=
"none"
>
<ion-icon
name=
"cash"
slot=
"start"
></ion-icon>
<ion-button
slot=
"end"
class=
"before"
>
<ion-text
color=
"light"
>
({{ trip.price_adult_before }} Dh)
</ion-text>
</ion-button>
<ion-button
slot=
"end"
color=
"light"
>
<ion-text
color=
"primary"
>
{{ trip.price_adult }} Dh
</ion-text>
</ion-button>
</ion-item>
</ion-card>
<ion-content>
<ion-tabs>
<ion-tab-bar
slot=
"bottom"
>
<ion-tab-button
tab=
"offres-carte"
>
<ion-icon
name=
"card"
></ion-icon>
<ion-label>
Offres Carte Testeur
</ion-label>
</ion-tab-button>
<ion-tab-button
tab=
"offres-tlm"
>
<ion-icon
name=
"people"
></ion-icon>
<ion-label>
Pour tout le monde
</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-content>
\ No newline at end of file
src/app/pages/dashboard/dashboard.page.scss
View file @
93fdbc94
...
...
@@ -2,39 +2,4 @@ ion-header {
ion-card
{
margin-top
:
4px
;
}
}
.dashboard
{
ion-card
{
ion-badge
{
float
:
right
;
margin-top
:
-36px
;
width
:
18vw
;
height
:
8vw
;
font-size
:
large
;
}
ion-img
{
min-height
:
10rem
;
background
:
var
(
--
ion-color-tertiary
,
#989aa2
);
}
ion-item
{
ion-button
{
font-size
:
large
;
height
:
10vw
;
}
ion-button
.before
{
text-decoration
:
line-through
;
font-size
:
initial
;
height
:
auto
;
}
}
}
}
.no-visibility
{
visibility
:
hidden
;
}
.img-spinner-wrap
{
position
:
absolute
;
width
:
100%
;
min-height
:
10rem
;
padding-top
:
4
.5rem
;
}
}
\ No newline at end of file
src/app/pages/dashboard/dashboard.page.ts
View file @
93fdbc94
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
NavController
,
ToastController
}
from
"@ionic/angular"
;
import
{
AlloService
}
from
'../../services/allo-service'
;
import
{
TripService
}
from
'../../services/trip-service'
;
import
{
HTTP
}
from
'@ionic-native/http/ngx'
;
import
{
HttpClient
,
HttpHeaders
,
HttpErrorResponse
}
from
'@angular/common/http'
;
import
{
Storage
}
from
'@ionic/storage'
;
import
{
Router
}
from
'@angular/router'
;
@
Component
({
selector
:
'app-dashboard'
,
...
...
@@ -16,18 +10,11 @@ import { Router } from '@angular/router';
export
class
DashboardPage
implements
OnInit
{
// list of products
public
products
:
any
;
public
toast
:
any
;
public
terms
:
any
;
public
show_more_filters
=
false
;
constructor
(
public
nav
:
NavController
,
public
_ALLO
:
AlloService
,
public
_TRIP
:
TripService
,
public
http
:
HttpClient
,
public
toastCtrl
:
ToastController
,
private
router
:
Router
,
private
storage
:
Storage
public
_TRIP
:
TripService
)
{
}
...
...
@@ -36,10 +23,6 @@ export class DashboardPage implements OnInit {
// this._ALLO.presentLoading();
}
setImgVisible
(
trip
)
{
trip
.
hidden
=
false
;
}
showHideMoreFilters
()
{
if
(
this
.
show_more_filters
===
false
)
{
this
.
show_more_filters
=
true
;
...
...
@@ -47,31 +30,4 @@ export class DashboardPage implements OnInit {
this
.
show_more_filters
=
false
;
}
}
async
presentToast
()
{
const
toast
=
await
this
.
toastCtrl
.
create
({
message
:
'Liste mise à jour'
,
showCloseButton
:
true
,
position
:
'bottom'
,
closeButtonText
:
'OK'
,
duration
:
2000
});
toast
.
present
();
}
async
doRefresh
(
refresher
)
{
try
{
this
.
toast
.
dismiss
();
}
catch
(
e
)
{
}
console
.
log
(
'refreshing'
);
this
.
_TRIP
.
fetchData
(
true
);
refresher
.
target
.
complete
();
this
.
presentToast
();
}
// view trip detail
viewDetail
(
id
)
{
this
.
router
.
navigateByUrl
(
'/app/details-offre/'
+
id
);
}
}
src/app/pages/offres-carte/offres-carte.module.ts
0 → 100644
View file @
93fdbc94
import
{
NgModule
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
Routes
,
RouterModule
}
from
'@angular/router'
;
import
{
IonicModule
}
from
'@ionic/angular'
;
import
{
SearchPipe
}
from
'../../pipes/search/search.pipe'
;
import
{
OffresCartePage
}
from
'./offres-carte.page'
;
const
routes
:
Routes
=
[
{
path
:
''
,
component
:
OffresCartePage
}
];
@
NgModule
({
imports
:
[
CommonModule
,
FormsModule
,
IonicModule
,
RouterModule
.
forChild
(
routes
)
],
declarations
:
[
OffresCartePage
,
SearchPipe
]
})
export
class
OffresCartePageModule
{}
src/app/pages/offres-carte/offres-carte.page.html
0 → 100644
View file @
93fdbc94
<ion-list-header>
Catégories :
</ion-list-header>
<div
class=
"app"
>
<ul
class=
"hs"
>
<li
*
ngFor=
"let category of _TRIP.cats"
class=
"item"
>
<ion-chip
(
click
)="
_TRIP
.
filterList
(
category
.
id
)"
>
<ion-label>
{{ category.label }}
</ion-label>
</ion-chip>
</li>
</ul>
</div>
<ion-content
padding-horizontal
padding-bottom
class=
"dashboard"
>
<ion-refresher
(
ionRefresh
)="
doRefresh
($
event
)"
>
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<!-- <ion-card class="top-card" no-margin>
<ion-card-content no-padding>
<ion-item lines="none">
<ion-label class="text-1x bold text-primary">Catégories</ion-label>
<ion-select cancelText="Fermer" class="text-primary" [(ngModel)]="terms" (ionChange)="onContextChange($event.id)">
<ion-select-option value="all">- Tout -</ion-select-option>
<ion-select-option *ngFor="let category of _TRIP.cats" [value]="category.id">
{{ category.label }}
</ion-select-option>
</ion-select>
</ion-item>
</ion-card-content>
</ion-card> -->
<!--list of trips-->
<ion-card
*
ngFor=
"let trip of _TRIP.filtredProducts"
(
click
)="
viewDetail
(
trip
.
id
)"
tappable
no-margin
margin-bottom
>
<div
class=
"img-spinner-wrap ion-text-center"
>
<ion-spinner
name=
"dots"
*
ngIf=
"trip.hidden"
></ion-spinner>
</div>
<ion-img
[
src
]="
trip
.
thumb
"
[
class
.
no-visibility
]="
trip
.
hidden
"
(
ionImgDidLoad
)="
setImgVisible
(
trip
)"
></ion-img>
<ion-card-header>
<ion-card-subtitle
color=
"primary"
>
<ion-icon
name=
"pin"
></ion-icon>
<ion-label>
{{ trip.location }}
</ion-label>
<ion-badge
fill=
"outline"
*
ngIf=
"trip.price_adult"
color=
"warning"
>
-{{ ((trip.price_adult_before - trip.price_adult) * 100) / trip.price_adult_before | number:'1.0-0' }}%
</ion-badge>
</ion-card-subtitle>
<ion-card-title>
{{ trip.name | slice:0:100 }}
</ion-card-title>
</ion-card-header>
<!-- <ion-item>
<ion-icon name="pin" slot="start"></ion-icon>
<ion-label>{{ trip.location }}</ion-label>
<ion-button fill="outline" slot="end">View</ion-button>
</ion-item> -->
<ion-card-content
no-padding
padding-horizontal
padding-bottom
>
{{ trip.description | slice:0:130 }}...
</ion-card-content>
<ion-item
*
ngIf=
"trip.price_adult"
color=
"primary"
lines=
"none"
>
<ion-icon
name=
"cash"
slot=
"start"
></ion-icon>
<ion-button
slot=
"end"
class=
"before"
>
<ion-text
color=
"light"
>
({{ trip.price_adult_before }} Dh)
</ion-text>
</ion-button>
<ion-button
slot=
"end"
color=
"light"
>
<ion-text
color=
"primary"
>
{{ trip.price_adult }} Dh
</ion-text>
</ion-button>
</ion-item>
</ion-card>
</ion-content>
\ No newline at end of file
src/app/pages/offres-carte/offres-carte.page.scss
0 → 100644
View file @
93fdbc94
.dashboard
{
ion-card
{
ion-badge
{
float
:
right
;
margin-top
:
-36px
;
width
:
18vw
;
height
:
8vw
;
font-size
:
large
;
}
ion-img
{
min-height
:
10rem
;
background
:
var
(
--
ion-color-tertiary
,
#989aa2
);
}
ion-item
{
ion-button
{
font-size
:
large
;
height
:
10vw
;
}
ion-button
.before
{
text-decoration
:
line-through
;
font-size
:
initial
;
height
:
auto
;
}
}
}
}
.no-visibility
{
visibility
:
hidden
;
}
.img-spinner-wrap
{
position
:
absolute
;
width
:
100%
;
min-height
:
10rem
;
padding-top
:
4
.5rem
;
}
div
[
scrollx
=
true
],
div
[
scrolly
=
true
]
{
position
:
relative
;
overflow
:
hidden
;
::-webkit-scrollbar
{
display
:
none
;
}
}
div
[
scrollx
=
true
]
{
overflow-x
:
auto
;
}
div
[
scrolly
=
true
]
{
overflow-y
:
auto
;
}
.app
{
padding
:
0
;
display
:
grid
;
grid-gap
:
20px
0
;
// grid-template-columns: 20px 1fr 20px;
align-content
:
start
;
}
.app
>
*
{
grid-column
:
2
/
-2
;
}
.app
>
.full
{
grid-column
:
1
/
-1
;
}
.hs
{
display
:
grid
;
// grid-gap: calc(20px / 2);
grid-template-columns
:
repeat
(
9999999
,
auto
);
// grid-template-rows: minmax(150px, 1fr);
overflow-x
:
scroll
;
scroll-snap-type
:
x
proximity
;
// padding-bottom: calc(.75 * 20px);
// margin-bottom: calc(-.25 * 20px);
}
/* Demo styles */
ion-content
{
display
:
grid
;
place-items
:
center
;
// background: #456173;
}
ul
{
list-style
:
none
;
padding
:
0
;
}
h1
,
h2
,
h3
{
margin
:
0
;
}
.app
{
// background: #DBD0BC;
overflow-y
:
scroll
;
}
.hs
>
li
,
.item
{
scroll-snap-align
:
center
;
// padding: calc(20px / 2 * 1.5);
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
background
:
#fff
;
border-radius
:
8px
;
}
\ No newline at end of file
src/app/pages/offres-carte/offres-carte.page.spec.ts
0 → 100644
View file @
93fdbc94
import
{
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
OffresCartePage
}
from
'./offres-carte.page'
;
describe
(
'OffresCartePage'
,
()
=>
{
let
component
:
OffresCartePage
;
let
fixture
:
ComponentFixture
<
OffresCartePage
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
OffresCartePage
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
OffresCartePage
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/pages/offres-carte/offres-carte.page.ts
0 → 100644
View file @
93fdbc94
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
ToastController
}
from
'@ionic/angular'
;
import
{
AlloService
}
from
'../../services/allo-service'
;
import
{
TripService
}
from
'../../services/trip-service'
;
import
{
Storage
}
from
'@ionic/storage'
;
import
{
Router
}
from
'@angular/router'
;
@
Component
({
selector
:
'app-offres-carte'
,
templateUrl
:
'./offres-carte.page.html'
,
styleUrls
:
[
'./offres-carte.page.scss'
],
})
export
class
OffresCartePage
implements
OnInit
{
public
toast
:
any
;
constructor
(
public
_ALLO
:
AlloService
,
public
_TRIP
:
TripService
,
public
toastCtrl
:
ToastController
,
private
router
:
Router
,
private
storage
:
Storage
)
{
}
ngOnInit
()
{
}
setImgVisible
(
trip
)
{
trip
.
hidden
=
false
;
}
async
presentToast
()
{
const
toast
=
await
this
.
toastCtrl
.
create
({
message
:
'Liste mise à jour'
,
showCloseButton
:
true
,
position
:
'bottom'
,
closeButtonText
:
'OK'
,
duration
:
2000
});
toast
.
present
();
}
async
doRefresh
(
refresher
)
{
try
{
this
.
toast
.
dismiss
();
}
catch
(
e
)
{
}
console
.
log
(
'refreshing'
);
this
.
_TRIP
.
fetchData
(
true
);
refresher
.
target
.
complete
();
this
.
presentToast
();
}
// view trip detail
viewDetail
(
id
)
{
this
.
router
.
navigateByUrl
(
'/app/details-offre/'
+
id
);
}
}
src/app/pages/offres-tlm/offres-tlm.module.ts
0 → 100644
View file @
93fdbc94
import
{
NgModule
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
Routes
,
RouterModule
}
from
'@angular/router'
;
import
{
IonicModule
}
from
'@ionic/angular'
;
import
{
OffresTlmPage
}
from
'./offres-tlm.page'
;
const
routes
:
Routes
=
[
{
path
:
''
,
component
:
OffresTlmPage
}
];
@
NgModule
({
imports
:
[
CommonModule
,
FormsModule
,
IonicModule
,
RouterModule
.
forChild
(
routes
)
],
declarations
:
[
OffresTlmPage
]
})
export
class
OffresTlmPageModule
{}
src/app/pages/offres-tlm/offres-tlm.page.html
0 → 100644
View file @
93fdbc94
<ion-header>
<ion-toolbar>
<ion-title>
offres-tlm
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
</ion-content>
src/app/pages/offres-tlm/offres-tlm.page.scss
0 → 100644
View file @
93fdbc94
src/app/pages/offres-tlm/offres-tlm.page.spec.ts
0 → 100644
View file @
93fdbc94
import
{
CUSTOM_ELEMENTS_SCHEMA
}
from
'@angular/core'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
OffresTlmPage
}
from
'./offres-tlm.page'
;
describe
(
'OffresTlmPage'
,
()
=>
{
let
component
:
OffresTlmPage
;
let
fixture
:
ComponentFixture
<
OffresTlmPage
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
OffresTlmPage
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
],
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
OffresTlmPage
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/pages/offres-tlm/offres-tlm.page.ts
0 → 100644
View file @
93fdbc94
import
{
Component
,
OnInit
}
from
'@angular/core'
;
@
Component
({
selector
:
'app-offres-tlm'
,
templateUrl
:
'./offres-tlm.page.html'
,
styleUrls
:
[
'./offres-tlm.page.scss'
],
})
export
class
OffresTlmPage
implements
OnInit
{
constructor
()
{
}
ngOnInit
()
{
}
}
src/app/pipes/pipes.module.ts
0 → 100644
View file @
93fdbc94
import
{
NgModule
}
from
'@angular/core'
;
import
{
SearchPipe
}
from
'./search/search.pipe'
;
@
NgModule
({
declarations
:
[
SearchPipe
],
imports
:
[],
exports
:
[
SearchPipe
]
})
export
class
PipesModule
{}
src/app/services/trip-service.ts
View file @
93fdbc94
...
...
@@ -7,94 +7,101 @@ import { AlloService } from './allo-service';
@
Injectable
({
providedIn
:
'root'
})
export
class
TripService
{
public
products
:
Array
<
any
>
=
[];
public
brands
:
Array
<
any
>
=
[];
public
cats
:
Array
<
any
>
=
[];
public
request
:
any
;
public
products
:
Array
<
any
>
=
[];
public
filtredProducts
:
Array
<
any
>
=
[];
public
brands
:
Array
<
any
>
=
[];
public
cats
:
Array
<
any
>
=
[];
public
request
:
any
;
constructor
(
private
platform
:
Platform
,
private
http
:
HttpClient
,
private
httpAdv
:
HTTP
,
private
storage
:
Storage
,
private
_ALLO
:
AlloService
)
{
this
.
fetchData
();
}
constructor
(
private
platform
:
Platform
,
private
http
:
HttpClient
,
private
httpAdv
:
HTTP
,
private
storage
:
Storage
,
private
_ALLO
:
AlloService
)
{
this
.
fetchData
();
}
fetchData
(
force
?:
boolean
)
{
this
.
storage
.
get
(
'REST_services'
).
then
((
REST_services
)
=>
{
if
(
REST_services
&&
!
force
)
{
this
.
setData
(
REST_services
);
}
else
if
(
this
.
platform
.
is
(
'cordova'
))
{
this
.
httpAdv
.
get
(
'https://www.allo-testeurs.com/services.json?'
+
Math
.
random
(),
{},
{})
.
then
((
response
)
=>
{
const
json
=
JSON
.
parse
(
response
.
data
);
this
.
storage
.
set
(
'REST_services'
,
json
);
this
.
setData
(
json
);
});
}
else
{
this
.
http
.
get
(
'https://www.allo-testeurs.com/services.json?'
+
Math
.
random
())
.
subscribe
((
data
)
=>
{
this
.
storage
.
set
(
'REST_services'
,
data
);
this
.
setData
(
data
);
});
}
});
}
fetchData
(
force
?:
boolean
)
{
this
.
storage
.
get
(
'REST_services'
).
then
((
REST_services
)
=>
{
if
(
REST_services
&&
!
force
)
{
this
.
setData
(
REST_services
);
}
else
if
(
this
.
platform
.
is
(
'cordova'
))
{
this
.
httpAdv
.
get
(
'https://www.allo-testeurs.com/services.json?'
+
Math
.
random
(),
{},
{})
.
then
((
response
)
=>
{
const
json
=
JSON
.
parse
(
response
.
data
);
this
.
storage
.
set
(
'REST_services'
,
json
);
this
.
setData
(
json
);
});
}
else
{
this
.
http
.
get
(
'https://www.allo-testeurs.com/services.json?'
+
Math
.
random
())
.
subscribe
((
data
)
=>
{
this
.
storage
.
set
(
'REST_services'
,
data
);
this
.
setData
(
data
);
});
}
});
}
setData
(
data
)
{
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'products'
))
{
var
products
=
this
.
_ALLO
.
jsonToArray
(
data
.
products
);
setData
(
data
)
{
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'products'
))
{
var
products
=
this
.
_ALLO
.
jsonToArray
(
data
.
products
);
this
.
products
=
this
.
_ALLO
.
shuffleArray
(
products
);
this
.
products
.
forEach
((
element
)
=>
{
element
.
hidden
=
true
;
});
// console.log(this.products)
;
}
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'cats'
))
{
var
cats
=
this
.
_ALLO
.
jsonToArray
(
data
.
cats
);
this
.
products
=
this
.
_ALLO
.
shuffleArray
(
products
);
this
.
products
.
forEach
((
element
)
=>
{
element
.
hidden
=
true
;
});
this
.
filtredProducts
=
this
.
products
;
}
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'cats'
))
{
var
cats
=
this
.
_ALLO
.
jsonToArray
(
data
.
cats
);
this
.
cats
=
this
.
_ALLO
.
shuffleArray
(
cats
);
}
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'brands'
))
{
var
brands
=
this
.
_ALLO
.
jsonToArray
(
data
.
brands
);
this
.
cats
=
this
.
_ALLO
.
shuffleArray
(
cats
);
}
if
(
null
!==
data
&&
'object'
===
typeof
data
&&
data
.
hasOwnProperty
(
'brands'
))
{
var
brands
=
this
.
_ALLO
.
jsonToArray
(
data
.
brands
);
this
.
brands
=
brands
;
}
}
this
.
brands
=
brands
;
}
}
getRequest
()
{
if
(
this
.
platform
.
is
(
'cordova'
))
{
return
this
.
httpAdv
.
get
(
'http://www.allo-testeurs.com/services.json?'
+
Math
.
random
(),
{},
{});
}
else
{
return
this
.
http
.
get
(
'http://www.allo-testeurs.com/services.json?'
+
Math
.
random
());
}
}
getRequest
()
{
if
(
this
.
platform
.
is
(
'cordova'
))
{
return
this
.
httpAdv
.
get
(
'http://www.allo-testeurs.com/services.json?'
+
Math
.
random
(),
{},
{});
}
else
{
return
this
.
http
.
get
(
'http://www.allo-testeurs.com/services.json?'
+
Math
.
random
());
}
}
getItem
(
id
)
{
for
(
var
i
=
0
;
i
<
this
.
products
.
length
;
i
++
)
{
// console.log(this.products[i].id);
// console.log(id);
if
(
this
.
products
[
i
].
id
===
parseInt
(
id
))
{
return
this
.
products
[
i
];
}
}
return
null
;
}
getItem
(
id
)
{
for
(
var
i
=
0
;
i
<
this
.
products
.
length
;
i
++
)
{
// console.log(this.products[i].id);
// console.log(id);
if
(
this
.
products
[
i
].
id
===
parseInt
(
id
))
{
return
this
.
products
[
i
];
}
}
return
null
;
}
getItemById
(
element
,
id
)
{
let
elm
=
'this.'
+
element
;
let
runnable
:
any
=
eval
(
elm
);
for
(
var
i
=
0
;
i
<
runnable
.
length
;
i
++
)
{
if
(
parseInt
(
runnable
[
i
].
id
)
===
id
)
{
return
runnable
[
i
];
}
}
return
null
;
}
getItemById
(
element
,
id
)
{
let
elm
=
'this.'
+
element
;
let
runnable
:
any
=
eval
(
elm
);
for
(
var
i
=
0
;
i
<
runnable
.
length
;
i
++
)
{
if
(
parseInt
(
runnable
[
i
].
id
)
===
id
)
{
return
runnable
[
i
];
}
}
return
null
;
}
remove
(
item
)
{
this
.
products
.
splice
(
this
.
products
.
indexOf
(
item
),
1
);
}
remove
(
item
)
{
this
.
products
.
splice
(
this
.
products
.
indexOf
(
item
),
1
);
}
filterList
(
categoryId
)
{
this
.
filtredProducts
=
this
.
products
.
filter
(
item
=>
{
return
item
.
categories_ids
.
includes
(
categoryId
);
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment