Commit 871ebe8c by Nabil Sadki

Optimise params && anonymous mode

parent ab4d459e
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="11000" id="com.allotesteurs.app" version="1.1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <widget android-versionCode="11000" id="com.allotesteurs.app" version="1.1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Allo Testeurs</name> <name>Allo Testeurs</name>
<description>Découvrir les bon plans à Kénitra et ailleurs!</description> <description>Découvrir les bon plans à Kénitra et ailleurs!</description>
<author email="contact@allo-testeurs.com" href="https://www.allo-testeurs.com">Allo Testeurs Agency</author> <author email="contact@allo-testeurs.com" href="https://www.allo-testeurs.com">Allo Testeurs Agency</author>
<content src="index.html" /> <content src="index.html" />
<access origin="*" /> <access origin="*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<allow-navigation href="*" />
<allow-intent href="http://*/*" /> <allow-intent href="http://*/*" />
<allow-intent href="https://*/*" /> <allow-intent href="https://*/*" />
<allow-navigation href="http://*/*" /> <allow-navigation href="http://*/*" />
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"dependencies": { "dependencies": {
"@angular/common": "^7.2.2", "@angular/common": "^7.2.2",
"@angular/core": "^7.2.2", "@angular/core": "^7.2.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "^7.2.2", "@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2", "@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2", "@angular/platform-browser": "^7.2.2",
...@@ -47,11 +48,13 @@ ...@@ -47,11 +48,13 @@
"cordova-sqlite-storage": "^3.2.0", "cordova-sqlite-storage": "^3.2.0",
"cordova.plugins.diagnostic": "^5.0.0", "cordova.plugins.diagnostic": "^5.0.0",
"core-js": "^2.5.4", "core-js": "^2.5.4",
"firebase": "^6.6.1",
"ionic-image-loader": "^6.3.3", "ionic-image-loader": "^6.3.3",
"leaflet": "^1.5.1", "leaflet": "^1.5.1",
"leaflet.markercluster": "^1.4.1", "leaflet.markercluster": "^1.4.1",
"path": "^0.12.7", "path": "^0.12.7",
"rxjs": "~6.5.1", "rxjs": "~6.5.1",
"sweetalert": "^2.1.2",
"tslib": "^1.9.0", "tslib": "^1.9.0",
"zone.js": "~0.8.29" "zone.js": "~0.8.29"
}, },
......
...@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; ...@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [ const routes: Routes = [
{ path: '', redirectTo: 'start', pathMatch: 'full' }, { path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'start', loadChildren: './pages/start/start.module#StartPageModule' }, { path: 'start', loadChildren: './pages/start/start.module#StartPageModule' },
{ path: 'login', loadChildren: './pages/compte/login/login.module#LoginPageModule' }, { path: 'login', loadChildren: './pages/compte/login/login.module#LoginPageModule' },
{ path: 'mainslider', loadChildren: './pages/mainslider/mainslider.module#MainsliderPageModule' }, { path: 'mainslider', loadChildren: './pages/mainslider/mainslider.module#MainsliderPageModule' },
......
...@@ -46,7 +46,8 @@ export class AppComponent { ...@@ -46,7 +46,8 @@ export class AppComponent {
this._STOR.get('wpUser').then((wpUser) => { this._STOR.get('wpUser').then((wpUser) => {
if (wpUser) { if (wpUser) {
this._AUTH.validateAuthToken(wpUser.token); this.router.navigateByUrl('/app/dashboard', { replaceUrl: true });
// this._AUTH.validateAuthToken(wpUser.token);
} else { } else {
this.router.navigateByUrl('/login', { replaceUrl: true }); this.router.navigateByUrl('/login', { replaceUrl: true });
} }
...@@ -69,34 +70,16 @@ export class AppComponent { ...@@ -69,34 +70,16 @@ export class AppComponent {
} }
setDefaultParams() { setDefaultParams() {
this._STOR.get('PARAM_geolocate').then((val) => { this._STOR.get('APP_PARAMS').then((val) => {
if (val === null) { if (val === null) {
this._STOR.set('PARAM_geolocate', true); this._STOR.set('APP_PARAMS', {
} PARAM_geolocate: true,
}); PARAM_geoarea: 1000,
this._STOR.get('PARAM_geoarea').then((val) => { PARAM_notiftime: 2880,
if (val === null) { PARAM_trackdelay: 60000,
this._STOR.set('PARAM_geoarea', 1000); PARAM_notifnbr: 'all',
} NOTIF_shownpartners: [],
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notiftime', 2880);
}
}); });
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val === null) {
this._STOR.set('PARAM_trackdelay', 60000);
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notifnbr', 'all');
}
});
this._STOR.get('NOTIF_shownpartners').then((val) => {
if (val === null) {
this._STOR.set('NOTIF_shownpartners', []);
} }
}); });
} }
......
...@@ -19,6 +19,13 @@ import { BackgroundMode } from '@ionic-native/background-mode/ngx'; ...@@ -19,6 +19,13 @@ import { BackgroundMode } from '@ionic-native/background-mode/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AppVersion } from '@ionic-native/app-version/ngx'; import { AppVersion } from '@ionic-native/app-version/ngx';
import { GooglePlus } from '@ionic-native/google-plus/ngx'; import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { environment } from 'src/environments/environment';
import { AuthService } from './services/auth.service';
import { AngularFireAuthModule } from '@angular/fire/auth';
// import * as firebase from 'firebase';
// firebase.initializeApp(environment.firebase);
@NgModule({ @NgModule({
declarations: [AppComponent], declarations: [AppComponent],
...@@ -31,7 +38,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx'; ...@@ -31,7 +38,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
name: '__allo_testeurs_app', name: '__allo_testeurs_app',
driverOrder: ['websql', 'sqlite', 'indexeddb'] driverOrder: ['websql', 'sqlite', 'indexeddb']
}), }),
HttpClientModule HttpClientModule,
AngularFireAuthModule
], ],
providers: [ providers: [
StatusBar, StatusBar,
...@@ -44,7 +52,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx'; ...@@ -44,7 +52,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
BackgroundMode, BackgroundMode,
BackgroundGeolocation, BackgroundGeolocation,
AppVersion, AppVersion,
GooglePlus GooglePlus,
AuthService
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
......
...@@ -59,18 +59,26 @@ ...@@ -59,18 +59,26 @@
</div> </div>
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
<a href="javascript:;"> <!-- <a href="javascript:;">
<ion-text color="light"> <ion-text color="light">
Mot de passe oublié? Mot de passe oublié?
</ion-text> </ion-text>
</a> </a> -->
<ion-item-divider color="primary"> </ion-item-divider> <ion-item-divider color="primary"> </ion-item-divider>
<ion-button color="dark" expand="block" type="submit" [disabled]="validationsForm.invalid" no-margin>Connexion</ion-button> <ion-button color="dark" expand="block" type="submit" [disabled]="validationsForm.invalid" no-margin>
<ion-icon name="log-in"></ion-icon>
Connexion
</ion-button>
</form> </form>
<ion-item-divider color="primary" lines="none"> </ion-item-divider> <ion-item-divider color="primary" lines="none"> </ion-item-divider>
<ion-item-divider color="primary" justify-content-center> <!-- <ion-item-divider color="primary" justify-content-center>
Se connecter avec Facebook ou Google Se connecter avec Facebook ou Google
</ion-item-divider> </ion-item-divider> -->
<ion-button color="light" expand="block" class="btn-g" (click)="doAnonymousLogIn()" no-margin>
<ion-icon name="walk"></ion-icon>
Connexion anonyme
</ion-button>
<ion-grid> <ion-grid>
<ion-row> <ion-row>
<!-- <ion-col> <!-- <ion-col>
...@@ -79,9 +87,9 @@ ...@@ -79,9 +87,9 @@
</ion-button> </ion-button>
</ion-col> --> </ion-col> -->
<ion-col> <ion-col>
<ion-button color="light" expand="block" class="btn-g" (click)="doGoogleLogin()" no-margin> <!-- <ion-button color="light" expand="block" class="btn-g" (click)="doGoogleLogin()" no-margin>
<ion-icon name="logo-google"></ion-icon> <ion-icon name="logo-google"></ion-icon>
</ion-button> </ion-button> -->
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
......
...@@ -5,6 +5,7 @@ import { AuthService } from '../../../services/auth.service'; ...@@ -5,6 +5,7 @@ import { AuthService } from '../../../services/auth.service';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { GooglePlus } from '@ionic-native/google-plus/ngx'; import { GooglePlus } from '@ionic-native/google-plus/ngx';
// import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
...@@ -47,9 +48,44 @@ export class LoginPage implements OnInit { ...@@ -47,9 +48,44 @@ export class LoginPage implements OnInit {
}); });
} }
doAnonymousLogIn() {
this.storage.set('wpUser', {
token: null,
user_nicename: 'anonymous',
user_display_name: 'Mode anonyme',
user_email: 'nomail',
});
this.router.navigateByUrl('/mainslider', { replaceUrl: true });
}
onSubmit(values) { onSubmit(values) {
console.log(values); this._ALLO.presentLoading();
this._AUTH.doLogin(values.email, values.password); this._AUTH.doLogin(values)
.then(
res => {
this._ALLO.dismissLoading();
console.log('User exist', res);
this.router.navigateByUrl('/mainslider', { replaceUrl: true });
},
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.');
this._ALLO.presentToast('', 'Email ou Mot de passe incorrects.<br>Veuillez réessayer.', 'top');
console.log('Auth error', err);
});
// this._ALLO.presentLoading();
// this._AUTH.firebaseRegister(values)
// .then(res => {
// this._ALLO.dismissLoading();
// console.log('User exist', res);
// // this.errorMessage = "";
// // this.navCtrl.navigateForward('/dashboard');
// }, err => {
// this._ALLO.dismissLoading();
// // this.errorMessage = err.message;
// console.log('Auth error', err);
// });
} }
async doGoogleLogin() { async doGoogleLogin() {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</ion-col> </ion-col>
<ion-col size="8"> <ion-col size="8">
<ion-text> <ion-text>
<h4>Nabil Sadki</h4> <h4>{{ _AUTH.infoFullname }}</h4>
</ion-text> </ion-text>
<ion-chip color="light" outline="true"> <ion-chip color="light" outline="true">
<ion-icon name="star"></ion-icon> <ion-icon name="star"></ion-icon>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</ion-menu-toggle> </ion-menu-toggle>
</ion-col> </ion-col>
<ion-col no-padding class="column"> <ion-col no-padding class="column">
<ion-button size="small" color="dark" href="/login"> <ion-button size="small" color="dark" (click)="logout()">
<ion-icon name="log-out"></ion-icon> <ion-icon name="log-out"></ion-icon>
Déconnexion Déconnexion
</ion-button> </ion-button>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth.service';
@Component({ @Component({
selector: 'app-menu', selector: 'app-menu',
...@@ -40,7 +42,15 @@ export class MenuPage implements OnInit { ...@@ -40,7 +42,15 @@ export class MenuPage implements OnInit {
} }
]; ];
constructor() { } constructor(
public router: Router,
public _AUTH: AuthService
) { }
logout() {
this._AUTH.logOut();
this.router.navigateByUrl('/login', { replaceUrl: true });
}
ngOnInit() { ngOnInit() {
// this._ALLO.presentLoading(); // this._ALLO.presentLoading();
......
...@@ -31,7 +31,7 @@ export class OffresCartePage implements OnInit { ...@@ -31,7 +31,7 @@ export class OffresCartePage implements OnInit {
if (loadedData) { if (loadedData) {
this._TRIP.offersCardListPointer = this._TRIP.offersCardListPointer + 1; this._TRIP.offersCardListPointer = this._TRIP.offersCardListPointer + 1;
this._TRIP.offersCardList = this._TRIP.offersCardList.concat(loadedData); this._TRIP.offersCardList = this._TRIP.offersCardList.concat(loadedData);
console.log(loadedData, this._TRIP.offersCardList, this._TRIP.offersCardListPointer); // console.log(loadedData, this._TRIP.offersCardList, this._TRIP.offersCardListPointer);
event.target.complete(); event.target.complete();
} else { } else {
event.target.disabled = true; event.target.disabled = true;
......
<ion-content> <ion-content padding>
<ion-list-header>Meilleures deals</ion-list-header> <ion-card color="light" margin-bottom>
<ion-text class="ion-text-center">
<img class="soon" src="../../../../assets/img/soon.png">
</ion-text>
</ion-card>
<ion-text class="ion-text-justify">
<p>
Que vous soyez détenteur(se) ou non de la Carte Testeur, cette section est ouverte à tout le monde, et permettra
dans un future proche de bénéficier des offres de nos partenaires.
</p>
<p>
Les plus fidéles seront <strong color="primary">trop bien</strong> récompensés!!
</p>
<p>
Restez à l'écoute!
</p>
</ion-text>
<!-- <ion-list-header>Meilleures deals</ion-list-header>
<div class="app"> <div class="app">
<ul class="hs"> <ul class="hs">
<li class="item">test</li> <li class="item">test</li>
...@@ -14,5 +31,5 @@ ...@@ -14,5 +31,5 @@
<ion-item> <ion-item>
Offre Offre
</ion-item> </ion-item>
</ion-list> </ion-list> -->
</ion-content> </ion-content>
\ No newline at end of file
...@@ -57,3 +57,9 @@ ul { ...@@ -57,3 +57,9 @@ ul {
background: #fff; background: #fff;
border-radius: 8px; border-radius: 8px;
} }
img.soon {
height: 30vh !important;
width: auto !important;
margin: 0 auto;
}
\ No newline at end of file
...@@ -13,64 +13,40 @@ ...@@ -13,64 +13,40 @@
<form class="list-form"> <form class="list-form">
<!-- <ion-item> <!-- <ion-item>
<ion-label color="dark" class="text-1x">Cacher l'écran d'accueil</ion-label> <ion-label color="dark" class="text-1x">Cacher l'écran d'accueil</ion-label>
<ion-toggle checked color="primary" [(ngModel)]="prm_mainslider" [ngModelOptions]="{standalone: true}" <ion-toggle checked color="primary" [(ngModel)]="prmMainslider" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('mainslider')"></ion-toggle> (ionChange)="setParam('mainslider')"></ion-toggle>
</ion-item> --> </ion-item> -->
<ion-item> <ion-item>
<ion-label color="dark" class="text-1x">Géo-notifications</ion-label> <ion-label color="dark" class="text-1x">Géo-notifications</ion-label>
<ion-toggle checked color="primary" [(ngModel)]="prm_geolocate" [ngModelOptions]="{standalone: true}" <ion-toggle color="primary" [(ngModel)]="prmGeolocate" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('geolocate')"></ion-toggle> (ionChange)="setParam('geolocate')"></ion-toggle>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label color="dark" class="text-1x">Rayon de détection</ion-label> <ion-label color="dark" class="text-1x">Rayon de détection</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_geoarea" [ngModelOptions]="{standalone: true}" <ion-select class="text-primary" [(ngModel)]="prmGeoarea" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('geoarea')"> (ionChange)="setParam('geoarea')">
<ion-select-option value="400">400m</ion-select-option> <ion-select-option *ngFor="let gOpt of geoAreaOptions | keyvalue" [value]="gOpt.key">{{ gOpt.value }}</ion-select-option>
<ion-select-option value="800">800m</ion-select-option>
<ion-select-option value="1200">1,2Km</ion-select-option>
<ion-select-option value="1600">1,6Km</ion-select-option>
<ion-select-option value="2000">2Km</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label color="dark" class="text-1x">Raffraichir la position GPS chaque</ion-label> <ion-label color="dark" class="text-1x">Raffraichir la position GPS chaque</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_trackdelay" [ngModelOptions]="{standalone: true}" <ion-select class="text-primary" [(ngModel)]="prmTrackdelay" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('trackdelay')"> (ionChange)="setParam('trackdelay')">
<ion-select-option value="60000">minute</ion-select-option> <ion-select-option *ngFor="let tdOpt of trackDelayOptions | keyvalue" [value]="tdOpt.key">{{ tdOpt.value }}</ion-select-option>
<ion-select-option value="120000">2 minutes</ion-select-option>
<ion-select-option value="180000">3 minutes</ion-select-option>
<ion-select-option value="240000">4 minutes</ion-select-option>
<ion-select-option value="300000">5 minutes</ion-select-option>
<ion-select-option value="360000">6 minutes</ion-select-option>
<ion-select-option value="420000">7 minutes</ion-select-option>
<ion-select-option value="480000">8 minutes</ion-select-option>
<ion-select-option value="540000">9 minutes</ion-select-option>
<ion-select-option value="600000">10 minutes</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label color="dark" class="text-1x">Réaffichage des notifications</ion-label> <ion-label color="dark" class="text-1x">Réaffichage des notifications</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_notiftime" [ngModelOptions]="{standalone: true}" <ion-select class="text-primary" [(ngModel)]="prmNotiftime" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('notiftime')"> (ionChange)="setParam('notiftime')">
<ion-select-option value="5">5 min</ion-select-option> <ion-select-option *ngFor="let ntOpt of notifTimeOptions | keyvalue" [value]="ntOpt.key">{{ ntOpt.value }}</ion-select-option>
<ion-select-option value="15">15 min</ion-select-option>
<ion-select-option value="30">30 min</ion-select-option>
<ion-select-option value="45">45 min</ion-select-option>
<ion-select-option value="60">1 h</ion-select-option>
<ion-select-option value="120">2 h</ion-select-option>
<ion-select-option value="480">4 h</ion-select-option>
<ion-select-option value="960">8 h</ion-select-option>
<ion-select-option value="2880">1 j</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-label color="dark" class="text-1x">Notifications par rafraîchissement</ion-label> <ion-label color="dark" class="text-1x">Notifications par rafraîchissement</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_notifnbr" [ngModelOptions]="{standalone: true}" <ion-select class="text-primary" [(ngModel)]="prmNotifnbr" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('notifnbr')"> (ionChange)="setParam('notifnbr')">
<ion-select-option value="2">Pas plus de 2 à la fois</ion-select-option> <ion-select-option *ngFor="let nnOpt of notifNbrOptions | keyvalue" [value]="nnOpt.key">{{ nnOpt.value }}</ion-select-option>
<ion-select-option value="4">Pas plus de 4 à la fois</ion-select-option>
<ion-select-option value="6">Pas plus de 6 à la fois</ion-select-option>
<ion-select-option value="all">Afficher toutes les notifications</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
</form> </form>
......
...@@ -11,12 +11,49 @@ import { AlloService } from '../../services/allo-service'; ...@@ -11,12 +11,49 @@ import { AlloService } from '../../services/allo-service';
}) })
export class ParamsPage implements OnInit { export class ParamsPage implements OnInit {
public prm_mainslider = true; public prmMainslider = true;
public prm_geolocate = false; public prmGeolocate = false;
public prm_geoarea: any = 400; public prmGeoarea: any = 400;
public prm_notiftime = 15; public prmNotiftime = 15;
public prm_trackdelay = 60000; public prmTrackdelay = 60000;
public prm_notifnbr: any = 'all'; public prmNotifnbr: any = 'all';
public geoAreaOptions = {
400: '400m',
800: '800m',
1200: '1,2Km',
1600: '1,6m',
2000: '2Km',
};
public trackDelayOptions = {
60000: '1 minute',
120000: '2 minutes',
180000: '3 minutes',
240000: '4 minutes',
300000: '5 minutes',
360000: '6 minutes',
420000: '7 minutes',
480000: '8 minutes',
540000: '9 minutes',
600000: '10 minutes',
};
public notifTimeOptions = {
5: '5 minutes',
15: '15 minutes',
30: '30 minutes',
45: '45 minutes',
60: '1 heure',
120: '2 heure',
480: '4 heure',
960: '8 heure',
2880: '1 jour',
};
public notifNbrOptions = {
2: 'Pas plus de 2 à la fois',
4: 'Pas plus de 4 à la fois',
6: 'Pas plus de 6 à la fois',
all: 'Afficher toutes les notifications',
};
constructor( constructor(
private _STOR: Storage, private _STOR: Storage,
...@@ -24,46 +61,27 @@ export class ParamsPage implements OnInit { ...@@ -24,46 +61,27 @@ export class ParamsPage implements OnInit {
private _LOCAT: LocationService, private _LOCAT: LocationService,
private _ALLO: AlloService private _ALLO: AlloService
) { ) {
this._STOR.get('PARAM_mainslider').then((val) => { this._STOR.get('APP_PARAMS').then((appParams) => {
if (val !== null) { if (appParams !== null) {
this.prm_mainslider = val; this.prmGeolocate = appParams.PARAM_geolocate;
} this.prmGeoarea = appParams.PARAM_geoarea;
}); this.prmNotiftime = appParams.PARAM_notiftime;
this._STOR.get('PARAM_geolocate').then((val) => { this.prmTrackdelay = appParams.PARAM_trackdelay;
if (val !== null) { this.prmNotifnbr = appParams.PARAM_notifnbr;
this.prm_geolocate = val;
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
if (val !== null) {
this.prm_geoarea = val;
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val !== null) {
this.prm_notiftime = val;
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val !== null) {
this.prm_trackdelay = val;
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val !== null) {
this.prm_notifnbr = val;
} }
}); });
} }
setParam(name) { setParam(name) {
this._STOR.get('APP_PARAMS').then((appParams) => {
if (appParams !== null) {
switch (name) { switch (name) {
case 'mainslider': // case 'mainslider':
this._ALLO.setParam('mainslider', this.prm_mainslider); // this._ALLO.setParam('mainslider', this.prm_mainslider);
break; // break;
case 'geolocate': case 'geolocate':
this._ALLO.setParam('geolocate', this.prm_geolocate); appParams.PARAM_geolocate = this.prmGeolocate;
if (this.prm_geolocate) { if (this.prmGeolocate) {
this._PERM.checkGps(); this._PERM.checkGps();
this._LOCAT.initLocator(); this._LOCAT.initLocator();
} else { } else {
...@@ -71,19 +89,22 @@ export class ParamsPage implements OnInit { ...@@ -71,19 +89,22 @@ export class ParamsPage implements OnInit {
} }
break; break;
case 'geoarea': case 'geoarea':
this._ALLO.setParam('geoarea', +this.prm_geoarea); appParams.PARAM_geoarea = +this.prmGeoarea;
break; break;
case 'notiftime': case 'notiftime':
this._ALLO.setParam('notiftime', +this.prm_notiftime); appParams.PARAM_notiftime = +this.prmNotiftime;
break; break;
case 'notifnbr': case 'notifnbr':
this._ALLO.setParam('notifnbr', +this.prm_notifnbr); appParams.PARAM_notifnbr = +this.prmNotifnbr;
break; break;
case 'trackdelay': case 'trackdelay':
this._ALLO.setParam('trackdelay', +this.prm_trackdelay); appParams.PARAM_trackdelay = +this.prmTrackdelay;
this._LOCAT.restartTracking(); this._LOCAT.restartTracking();
break; break;
} }
this._STOR.set('APP_PARAMS', appParams);
}
});
} }
ngOnInit() { ngOnInit() {
......
import { LoadingController, AlertController } from "@ionic/angular"; import { LoadingController, AlertController, ToastController } from '@ionic/angular';
import { Injectable } from "@angular/core"; import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
...@@ -12,44 +12,25 @@ export class AlloService { ...@@ -12,44 +12,25 @@ export class AlloService {
public prmNotiftime = 15; public prmNotiftime = 15;
public prmTrackdelay = 60000; public prmTrackdelay = 60000;
public prmNotifnbr: any = 'all'; public prmNotifnbr: any = 'all';
public loading;
constructor( constructor(
private alertCtrl: AlertController, private alertCtrl: AlertController,
private loadingCtrl: LoadingController, private loadingCtrl: LoadingController,
private toastCtrl: ToastController,
private _STOR: Storage private _STOR: Storage
) { ) {
this.setDefaultParams(); this.setDefaultParams();
} }
setDefaultParams() { setDefaultParams() {
this._STOR.get('PARAM_mainslider').then((val) => { this._STOR.get('APP_PARAMS').then((appParams) => {
if (val !== null) { if (appParams !== null) {
this.prmMainslider = val; this.prmGeolocate = appParams.PARAM_geolocate;
} this.prmGeoarea = appParams.PARAM_geoarea;
}); this.prmNotiftime = appParams.PARAM_notiftime;
this._STOR.get('PARAM_geolocate').then((val) => { this.prmTrackdelay = appParams.PARAM_trackdelay;
if (val !== null) { this.prmNotifnbr = appParams.PARAM_notifnbr;
this.prmGeolocate = val;
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
if (val !== null) {
this.prmGeoarea = val;
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val !== null) {
this.prmNotiftime = val;
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val !== null) {
this.prmTrackdelay = val;
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val !== null) {
this.prmNotifnbr = val;
} }
}); });
} }
...@@ -111,19 +92,38 @@ export class AlloService { ...@@ -111,19 +92,38 @@ export class AlloService {
async presentLoading() { async presentLoading() {
this.showPage = false; this.showPage = false;
const loading = await this.loadingCtrl.create({ this.loading = await this.loadingCtrl.create({
// spinner: null, // spinner: null,
duration: 0, duration: 0,
message: 'Chargement...', message: 'Chargement...',
translucent: true, translucent: true,
cssClass: 'custom-class custom-loading' cssClass: 'custom-class custom-loading'
}); });
return await loading.present().then(() => { return await this.loading.present().then(() => {
this.showPage = true; this.showPage = true;
}); });
} }
dismissLoading() { dismissLoading() {
this.loadingCtrl.dismiss(); this.loading.dismiss();
}
async presentToast(header, message, position) {
const toast = await this.toastCtrl.create({
message: message,
duration: 3000,
header: header,
position: position,
buttons: [
{
text: 'OK',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
toast.present();
} }
} }
...@@ -7,6 +7,8 @@ import { Router } from '@angular/router'; ...@@ -7,6 +7,8 @@ import { Router } from '@angular/router';
import { AlloService } from './allo-service'; import { AlloService } from './allo-service';
// import * as firebase from 'firebase/app';
// import 'firebase/auth';
import * as Config from '../constants'; import * as Config from '../constants';
@Injectable({ @Injectable({
...@@ -14,6 +16,10 @@ import * as Config from '../constants'; ...@@ -14,6 +16,10 @@ import * as Config from '../constants';
}) })
export class AuthService { export class AuthService {
public infoNicename;
public infoFullname;
public infoEmail;
constructor( constructor(
private platform: Platform, private platform: Platform,
public storage: Storage, public storage: Storage,
...@@ -21,37 +27,58 @@ export class AuthService { ...@@ -21,37 +27,58 @@ export class AuthService {
private httpAdv: HTTP, private httpAdv: HTTP,
private router: Router, private router: Router,
private _ALLO: AlloService private _ALLO: AlloService
) { } ) {
this.storage.get('wpUser').then(wpUser => {
if (wpUser) {
this.infoNicename = wpUser.user_nicename;
this.infoFullname = wpUser.user_display_name;
this.infoEmail = wpUser.user_email;
}
});
}
// Wordpress
getUser() { getUser() {
return this.storage.get('wpUser'); return this.storage.get('wpUser');
} }
setUser(user) { setUser(user) {
this.infoNicename = user.user_nicename;
this.infoFullname = user.user_display_name;
this.infoEmail = user.user_email;
return this.storage.set('wpUser', user); return this.storage.set('wpUser', user);
} }
logOut() { logOut() {
return this.storage.clear(); return this.storage.remove('wpUser');
} }
doLogin(username, password) { doLogin(values) {
this._ALLO.presentLoading();
let authData = { let authData = {
username: username, username: values.email,
password: password password: values.password
}; };
return new Promise<any>((resolve, reject) => {
if (this.platform.is('cordova')) { if (this.platform.is('cordova')) {
return this.httpAdv.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData, {}).then(result => { this.httpAdv.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData, {}).then(
this.setUser(result); res => {
this._ALLO.dismissLoading(); this.setUser(res);
}); resolve(res);
},
err => reject(err)
);
} else { } else {
return this.http.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData).subscribe(result => { this.http.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData).subscribe(
this.setUser(result); res => {
this._ALLO.dismissLoading(); this.setUser(res);
}); resolve(res);
},
err => reject(err)
);
} }
});
} }
doRegister(user_data, token) { doRegister(user_data, token) {
...@@ -99,4 +126,41 @@ export class AuthService { ...@@ -99,4 +126,41 @@ export class AuthService {
this.router.navigateByUrl('/mainslider', { replaceUrl: true }); this.router.navigateByUrl('/mainslider', { replaceUrl: true });
} }
} }
// Firebase
firebaseRegister(value) {
return new Promise<any>((resolve, reject) => {
firebase.auth().createUserWithEmailAndPassword(value.email, value.password)
.then(
res => resolve(res),
err => reject(err));
})
}
firebaseLogin(value) {
return new Promise<any>((resolve, reject) => {
firebase.auth().signInWithEmailAndPassword(value.email, value.password)
.then(
res => resolve(res),
err => reject(err));
});
}
firebaseLogout() {
return new Promise((resolve, reject) => {
if (firebase.auth().currentUser) {
firebase.auth().signOut()
.then(() => {
console.log("LOG Out");
resolve();
}).catch((error) => {
reject();
});
}
})
}
firebaseUserDetails() {
return firebase.auth().currentUser;
}
} }
export const environment = { export const environment = {
production: true production: true,
firebase: {
apiKey: 'AIzaSyDCp8ZFLfMtRtCIuFCYbmmcBU5jcu64MIg',
authDomain: 'allo-testeurs-1546348822085.firebaseapp.com',
databaseURL: 'https://allo-testeurs-1546348822085.firebaseio.com',
projectId: 'allo-testeurs-1546348822085',
storageBucket: '',
messagingSenderId: '536597038498',
appId: '1:536597038498:web:7896f1f4b2960e72479efb'
}
}; };
...@@ -3,7 +3,16 @@ ...@@ -3,7 +3,16 @@
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment = { export const environment = {
production: false production: false,
firebase: {
apiKey: 'AIzaSyDCp8ZFLfMtRtCIuFCYbmmcBU5jcu64MIg',
authDomain: 'allo-testeurs-1546348822085.firebaseapp.com',
databaseURL: 'https://allo-testeurs-1546348822085.firebaseio.com',
projectId: 'allo-testeurs-1546348822085',
storageBucket: '',
messagingSenderId: '536597038498',
appId: '1:536597038498:web:7896f1f4b2960e72479efb'
}
}; };
/* /*
......
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