Commit 8a6d2099 by Nabil Sadki

Filtres offres

parent 89236633
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber;
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber;
public appVersionCode;
public appPackageName;
public appAppName;
constructor(
private appVersion: AppVersion
) {
console.log(
this.appVersion.getAppName(),
this.appVersion.getPackageName(),
this.appVersion.getVersionCode(),
this.appVersion.getVersionNumber()
);
}
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber;
public appVersionCode;
public appPackageName;
public appAppName;
constructor(
private appVersion: AppVersion
) {
this.appVersion.getAppName().then((appName) => {
console.log(appName);
});
this.appVersion.getPackageName().then((packageName) => {
console.log(packageName);
});
this.appVersion.getVersionCode().then((versionCode) => {
console.log(versionCode);
});
this.appVersion.getVersionNumber().then((versionNumber) => {
console.log(versionNumber);
});
}
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber;
public appVersionCode;
public appPackageName;
public appAppName;
constructor(
private platform: Platform,
private appVersion: AppVersion
) {
this.platform.ready().then(() => {
this.appVersion.getAppName().then((appName) => {
this.appAppName = appName;
});
this.appVersion.getPackageName().then((packageName) => {
this.appPackageName = packageName;
});
this.appVersion.getVersionCode().then((versionCode) => {
this.appVersionCode = versionCode;
});
this.appVersion.getVersionNumber().then((versionNumber) => {
this.appVersionNumber = versionNumber;
});
});
}
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber = '1';
public appVersionCode = '1';
public appPackageName = 'com.allo_testeurs.app';
public appAppName = 'Allo Testeurs';
constructor(
private platform: Platform,
private appVersion: AppVersion
) {
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
this.appVersion.getAppName().then((appName) => {
this.appAppName = appName;
});
this.appVersion.getPackageName().then((packageName) => {
this.appPackageName = packageName;
});
this.appVersion.getVersionCode().then((versionCode) => {
this.appVersionCode = versionCode;
});
this.appVersion.getVersionNumber().then((versionNumber) => {
this.appVersionNumber = versionNumber;
});
}
});
}
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber = '1';
public appVersionCode: any = '1';
public appPackageName = 'com.allo_testeurs.app';
public appAppName = 'Allo Testeurs';
constructor(
private platform: Platform,
private appVersion: AppVersion
) {
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
this.appVersion.getAppName().then((appName) => {
this.appAppName = appName;
});
this.appVersion.getPackageName().then((packageName) => {
this.appPackageName = packageName;
});
this.appVersion.getVersionCode().then((versionCode) => {
this.appVersionCode = versionCode;
});
this.appVersion.getVersionNumber().then((versionNumber) => {
this.appVersionNumber = versionNumber;
});
}
});
}
ngOnInit() {
}
}
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { AppVersion } from '@ionic-native/app-version/ngx';
@Component({
selector: 'app-a-propos',
templateUrl: './a-propos.page.html',
styleUrls: ['./a-propos.page.scss'],
})
export class AProposPage implements OnInit {
public appVersionNumber: any = '1';
public appVersionCode: any = '1';
public appPackageName: any = 'com.allo_testeurs.app';
public appAppName: any = 'Allo Testeurs';
constructor(
private platform: Platform,
private appVersion: AppVersion
) {
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
this.appVersion.getAppName().then((appName) => {
this.appAppName = appName;
});
this.appVersion.getPackageName().then((packageName) => {
this.appPackageName = packageName;
});
this.appVersion.getVersionCode().then((versionCode) => {
this.appVersionCode = versionCode;
});
this.appVersion.getVersionNumber().then((versionNumber) => {
this.appVersionNumber = versionNumber;
});
}
});
}
ngOnInit() {
}
}
......@@ -105,5 +105,8 @@
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<plugin name="cordova-plugin-google-analytics" spec="^1.8.6">
<variable name="GMS_VERSION" value="16.0.3" />
</plugin>
<engine name="android" spec="^8.1.0" />
</widget>
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -29,7 +29,6 @@
"@ionic-native/diagnostic": "^5.8.0",
"@ionic-native/file": "^5.14.0",
"@ionic-native/file-path": "^5.14.0",
"@ionic-native/google-analytics": "^5.15.0",
"@ionic-native/google-plus": "^5.0.0",
"@ionic-native/http": "^5.8.0",
"@ionic-native/ionic-webview": "^5.14.0",
......@@ -73,12 +72,19 @@
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic-native/google-analytics": "^5.15.0",
"@ionic/angular-toolkit": "~1.5.1",
"@ionic/lab": "2.0.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.0.0",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^4.0.0",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-whitelist": "1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
......@@ -89,13 +95,7 @@
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6",
"cordova-plugin-whitelist": "1.3.3",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-ionic-webview": "^4.0.0",
"cordova-plugin-ionic-keyboard": "^2.0.5"
"typescript": "~3.1.6"
},
"browser": {
"crypto": false,
......@@ -123,10 +123,13 @@
"cordova-plugin-file": {},
"cordova-plugin-googleplus": {
"PLAY_SERVICES_VERSION": "11.8.0"
},
"cordova-plugin-google-analytics": {
"GMS_VERSION": "16.0.3"
}
},
"platforms": [
"android"
]
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import { AppVersion } from '@ionic-native/app-version/ngx';
import { TripService } from './services/trip-service';
import { AuthService } from './services/auth.service';
// import { LocationService } from './services/location-service';
import * as Config from './constants';
@Component({
selector: 'app-root',
......@@ -43,12 +44,19 @@ export class AppComponent {
this.splashScreen.hide();
// Start GA tracking
this.ga.startTrackerWithId('UA-129706772-2')
console.log('GA', this.ga);
this.ga.startTrackerWithId(Config.GA_TRACKID)
.then(() => {
this.appVersion.getVersionNumber().then((versionNumber) => {
this.ga.setAppVersion(versionNumber);
});
}).catch(e => alert('Error starting GoogleAnalytics == ' + e));
console.log('tracker started');
this.appVersion.getVersionNumber().then((versionNumber) => {
this.ga.setAppVersion(versionNumber);
});
})
.catch(e => {
console.log('Error starting GoogleAnalytics == ' + e);
});
// Set params
this.setDefaultParams();
......
export const WORDPRESS_URL = 'http://www.allo-testeurs.com/';
export const WORDPRESS_REST_API_URL = WORDPRESS_URL + 'wp-json/wp/v2/';
export const GA_TRACKID = 'UA-129706772-2';
......@@ -10,15 +10,17 @@
<ion-list>
<ion-item>
<ion-label>Catégories</ion-label>
<ion-select class="wide-select" value="all" okText="Valider" cancelText="Annuler" (ionChange)="_TRIP.filterList($event.detail.value)">
<ion-select [(ngModel)]="_TRIP.filters.cat" class="wide-select" value="all" okText="Valider" cancelText="Annuler"
(ionChange)="_TRIP.filterOffers()">
<ion-select-option value="all">Toutes</ion-select-option>
<ion-select-option *ngFor="let cat of _TRIP.cats" value="{{cat.id}}">{{cat.label}}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Partenaires</ion-label>
<ion-select class="wide-select" value="all" okText="Valider" cancelText="Annuler" (ionChange)="_TRIP.filterByBrandId($event.detail.value)">
<ion-select-option value="all">Tous</ion-select-option>
<ion-select [(ngModel)]="_TRIP.filters.brand" class="wide-select" value="all" okText="Valider"
cancelText="Annuler" (ionChange)="_TRIP.filterOffers()">
<ion-select-option value="all">Tous</ion-select-option>
<ion-select-option *ngFor="let brand of _TRIP.brands" value="{{brand.id}}">{{brand.label}}</ion-select-option>
</ion-select>
</ion-item>
......@@ -31,7 +33,7 @@
</ion-row>
<ion-row>
<ion-col no-padding>
<ion-segment mode="ios" margin-bottom>
<ion-segment [(ngModel)]="_TRIP.filters.type" (ionChange)="_TRIP.filterOffers()" mode="ios" margin-bottom>
<ion-segment-button mode="ios" value="all">
<ion-label>Tout</ion-label>
</ion-segment-button>
......@@ -50,6 +52,7 @@
</ion-content>
<ion-footer>
<ion-toolbar>
<ion-button slot="end" color="dark" size="small" (click)="_TRIP.resetData(); modalController.dismiss();">Réinitialiser</ion-button>
<ion-button slot="end" color="dark" size="small" (click)="_TRIP.resetData(); modalController.dismiss();">
Réinitialiser</ion-button>
</ion-toolbar>
</ion-footer>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
@Component({
selector: 'app-a-propos',
......@@ -16,7 +17,8 @@ export class AProposPage implements OnInit {
constructor(
private platform: Platform,
private appVersion: AppVersion
private appVersion: AppVersion,
private ga: GoogleAnalytics
) {
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
......@@ -37,6 +39,7 @@ export class AProposPage implements OnInit {
}
ngOnInit() {
this.ga.trackView('Page : A propos');
}
}
......@@ -4,6 +4,7 @@ import { ModalController } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AlloService } from '../../../services/allo-service';
import { AuthService } from '../../../services/auth.service';
import { LoginHelpPage } from '../../../modals/login-help/login-help.page';
......@@ -37,11 +38,13 @@ export class LoginPage implements OnInit {
public router: Router,
public modalController: ModalController,
private googlePlus: GooglePlus,
private ga: GoogleAnalytics,
public _ALLO: AlloService,
public _AUTH: AuthService
) { }
ngOnInit() {
this.ga.trackView('Page : Login');
this._AUTH.getAuthState().subscribe(state => {
if (state) {
let name = this._AUTH.infoNicename === 'anonymous' ? 'Anonyme' : this._AUTH.infoFullname;
......@@ -65,6 +68,7 @@ export class LoginPage implements OnInit {
}
doAnonymousLogIn() {
this.ga.trackEvent('Login', 'Tapped button', 'Anonymous login');
this._AUTH.isAnonymous = true;
const wpUser = {
token: null,
......@@ -85,10 +89,12 @@ export class LoginPage implements OnInit {
}
onSubmit(values) {
this.ga.trackEvent('Login', 'Tapped button', 'Try normal login');
this._ALLO.presentLoading();
this._AUTH.doLogin(values)
.then(
res => {
this.ga.trackEvent('Login', 'Result', 'Successfull connection');
this._ALLO.dismissLoading();
this._AUTH.isAnonymous = false;
this.storage.get('APP_PARAMS').then(appParams => {
......@@ -100,6 +106,7 @@ export class LoginPage implements OnInit {
});
},
err => {
this.ga.trackEvent('Login', 'Result', 'Connection error : ' + err);
this._ALLO.dismissLoading();
// swal('Connexion', 'Email ou Mot de passe incorrects. Veuillez réessayer.', 'error');
// this._ALLO.presentAlert('Connexion', 'Email ou Mot de passe incorrects.<br>Veuillez réessayer.');
......
import { Component, OnInit } from '@angular/core';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
@Component({
selector: 'app-contact',
......@@ -7,9 +8,13 @@ import { Component, OnInit } from '@angular/core';
})
export class ContactPage implements OnInit {
constructor() { }
constructor(
private ga: GoogleAnalytics
) {
}
ngOnInit() {
this.ga.trackView('Page : Contact');
}
}
......@@ -43,6 +43,7 @@ export class MainsliderPage implements OnInit {
}
ngOnInit() {
this.ga.trackView('Page : Présentation');
this.mainSlider.getActiveIndex().then(index => {
this.mainSlider.slideTo(0);
});
......@@ -50,7 +51,7 @@ export class MainsliderPage implements OnInit {
skipPresentation($event) {
if (this.platform.is('cordova')) {
this.ga.trackEvent('Presentation', 'Tapped button', 'Skip presentation');
this.ga.trackEvent('Présentation', 'Tapped button', 'Skip presentation');
}
this.mainSlider.getActiveIndex().then(index => {
this.hideSlider = true;
......@@ -65,23 +66,23 @@ export class MainsliderPage implements OnInit {
this._PERM.checkGps();
this._LOCATE.initLocator();
}
this._STOR.get('APP_PARAMS').then(appParams => {
this.storage.get('APP_PARAMS').then(appParams => {
appParams.PARAM_mainslider = true;
appParams.PARAM_geolocate = true;
this._STOR.set('APP_PARAMS', appParams);
this.goToDashboard();
this.storage.set('APP_PARAMS', appParams);
this.goToDashboard();
});
}
getDashboard() {
this._STOR.set('PARAM_geolocate', false);
this.storage.set('PARAM_geolocate', false);
this.goToDashboard();
}
goToDashboard() {
this._STOR.get('APP_PARAMS').then(appParams => {
this.storage.get('APP_PARAMS').then(appParams => {
appParams.PARAM_mainslider = true;
this._STOR.set('APP_PARAMS', appParams);
this.storage.set('APP_PARAMS', appParams);
});
this.router.navigate(['app/dashboard']);
}
......
......@@ -8,7 +8,26 @@
<!-- <ion-icon name="menu" size="large" color="light"></ion-icon> -->
</ion-menu-button>
</ion-buttons>
<!-- <ion-grid no-padding>
<ion-row>
<ion-col no-padding>
<ion-icon name="ribbon" color="secondary"></ion-icon>
<ion-label color="light">10 542</ion-label>
</ion-col>
</ion-row>
<ion-row>
<ion-col no-padding>
<ion-icon name="ribbon" color="secondary"></ion-icon>
<ion-label color="light">10 542</ion-label>
</ion-col>
</ion-row>
</ion-grid> -->
<ion-chip slot="end">
<ion-icon name="trending-up" color="blue"></ion-icon>
<ion-label color="dark" class="ion-padding-end">10 542</ion-label>
<ion-icon name="ribbon" color="secondary"></ion-icon>
<ion-label color="dark">10 542</ion-label>
</ion-chip>
<!-- <ion-buttons slot="end">
<ion-button (click)="showHideMoreFilters()">
<ion-icon name="options"></ion-icon>
......
......@@ -2,6 +2,9 @@ ion-header {
ion-card {
margin-top: 4px;
}
ion-chip {
--background: #fff !important;
}
}
.dashboard {
ion-card {
......
......@@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { ToastController, IonInfiniteScroll, ModalController } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AlloService } from '../../../services/allo-service';
import { AuthService } from '../../../services/auth.service';
import { TripService } from '../../../services/trip-service';
......@@ -21,12 +22,15 @@ export class OffresCartePage implements OnInit {
public _ALLO: AlloService,
public _AUTH: AuthService,
public _TRIP: TripService,
private ga: GoogleAnalytics,
public modalController: ModalController,
public toastCtrl: ToastController,
private router: Router,
private storage: Storage) { }
ngOnInit() { }
ngOnInit() {
this.ga.trackView('Page : Offres Carte Testeur');
}
loadData(event) {
setTimeout(() => {
......@@ -78,6 +82,8 @@ export class OffresCartePage implements OnInit {
// view trip detail
viewDetail(id) {
const offer = this._TRIP.getItemById('products', id);
this.ga.trackEvent('Offres CT', 'Tapped button', 'Voir l\'offre : [' + id + '] ' + offer.name);
this.router.navigateByUrl('/app/details-offre/' + id);
}
......
import { Component, OnInit, ViewChild } from '@angular/core';
import { ToastController, IonInfiniteScroll } from '@ionic/angular';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AlloService } from '../../../services/allo-service';
import { AuthService } from '../../../services/auth.service';
import { TripService } from '../../../services/trip-service';
......@@ -19,9 +20,11 @@ export class OffresTlmPage implements OnInit {
public _TRIP: TripService,
public toastCtrl: ToastController,
private router: Router,
private ga: GoogleAnalytics,
private storage: Storage) { }
ngOnInit() {
this.ga.trackView('Page : Offres Carte Testeur');
}
setImgVisible(trip) {
......@@ -33,7 +36,7 @@ export class OffresTlmPage implements OnInit {
offer = result;
});
}
viewDetail(id) {
this.router.navigateByUrl('/app/details-offre/' + id);
}
......
......@@ -5,6 +5,7 @@ import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http
import { HTTP } from '@ionic-native/http/ngx';
import { Router } from '@angular/router';
import { BehaviorSubject } from 'rxjs';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AlloService } from './allo-service';
......@@ -30,6 +31,7 @@ export class AuthService {
private http: HttpClient,
private httpAdv: HTTP,
private router: Router,
private ga: GoogleAnalytics,
private _ALLO: AlloService
) {
this.platform.ready().then(() => {
......@@ -85,6 +87,7 @@ export class AuthService {
}
logOut() {
this.ga.trackEvent('Logout', 'Tapped button', 'Logout');
this.authState.next(false);
return this.storage.remove('wpUser');
}
......
......@@ -4,6 +4,7 @@ import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AlloService } from './allo-service';
@Injectable({ providedIn: 'root' })
......@@ -16,6 +17,7 @@ export class TripService {
public brands: Array<any> = [];
public cats: Array<any> = [];
public request: any;
public filters = {};
constructor(
private platform: Platform,
......@@ -23,6 +25,7 @@ export class TripService {
private httpAdv: HTTP,
private storage: Storage,
private router: Router,
private ga: GoogleAnalytics,
private _ALLO: AlloService
) {
this.fetchData();
......@@ -120,9 +123,46 @@ export class TripService {
this.products.splice(this.products.indexOf(item), 1);
}
filterList(categoryId) {
console.log(this.products);
filterOffers() {
let offers = this.products;
console.log(this.filters, offers);
// tslint:disable-next-line: forin
for (let key in this.filters) {
let value = this.filters[key];
offers = offers.filter(item => {
let return_value = false;
if (value === 'all') {
return_value = true;
} else if (key === 'cat') {
return_value = item.categories_ids.includes(parseInt(value));
} else if (key === 'brand') {
return_value = item.brand_id === value;
} else if (key === 'type') {
switch (value) {
case 'offres':
return_value = item.price_adult === '';
break;
case 'reductions':
return_value = item.price_adult !== '';
break;
default:
return_value = true;
break;
}
}
return return_value;
});
}
this.filtredProducts = offers;
this.offersCardList = this.filtredProducts.slice(0, 2);
}
filterList(categoryId) {
const category = this.getItemById('cats', categoryId);
this.ga.trackEvent('Filtres', 'Tapped button', 'Catégorie : [' + categoryId + '] ' + category.label);
this.filtredProducts = this.filterByCategoryId(categoryId);
this.offersCardList = this.filtredProducts.slice(0, 2);
this.offersCardListPointer = 1;
......@@ -136,7 +176,7 @@ export class TripService {
filterByBrandId(brandId) {
console.log(brandId);
this.filtredProducts = this.filtredProducts.filter(item => {
return item.brand_id === brandId || brandId === 'all';
});
......@@ -149,6 +189,7 @@ export class TripService {
}
wishList(offer, action) {
this.ga.trackEvent('Wishlist', action, 'Offre : [' + offer.id + '] ' + offer.name);
return new Promise<any>((resolve, reject) => {
this.storage.get('WISHLIST').then(
wishList => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment