Commit f20f6d75 by Nabil Sadki

Mérites

parent 7ddd4ffc
......@@ -668,6 +668,14 @@
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/camera": {
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@ionic-native/camera/-/camera-5.13.0.tgz",
"integrity": "sha512-YlAyeOkrgpMerKsDaycqut/69iTSYZPMGoCpRNWweGmKbRdx3mOkibiAWIVxo7tRDp8elGmLLujrUmz4AhS7FA==",
"requires": {
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/core": {
"version": "5.8.0",
"resolved": "https://registry.npmjs.org/@ionic-native/core/-/core-5.8.0.tgz",
......@@ -684,6 +692,22 @@
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/file": {
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@ionic-native/file/-/file-5.13.0.tgz",
"integrity": "sha512-88fbrqLzZ9wJ0S9ybdtT0kQbv60cMT/5LbkevIBY5ST9Qbv/G7MoysvlJSvSXxf2bVPBsXqXD4W8y3VCZAJW5A==",
"requires": {
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/file-path": {
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@ionic-native/file-path/-/file-path-5.13.0.tgz",
"integrity": "sha512-oXuwYfmkITOYxl6ocQrscUnGu71jlUgTnQIgHfkIFw9IItWVbhvm3B4TeXbFY7go3GWr41XKdpvfrGEWZn10Wg==",
"requires": {
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/google-plus": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@ionic-native/google-plus/-/google-plus-5.0.0.tgz",
......@@ -700,6 +724,14 @@
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/ionic-webview": {
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@ionic-native/ionic-webview/-/ionic-webview-5.13.0.tgz",
"integrity": "sha512-hQ1cErAZP9p82OeAN7cnusu0NlqBYgMb9cVm1NHRx7MiXersjkPTX/l5e0qa1ozSbfZhglAYyF3H7QixfxNSKw==",
"requires": {
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/local-notifications": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/@ionic-native/local-notifications/-/local-notifications-5.11.0.tgz",
......@@ -2827,6 +2859,11 @@
"resolved": "https://registry.npmjs.org/cordova-plugin-badge/-/cordova-plugin-badge-0.8.8.tgz",
"integrity": "sha512-RhIBtd5xhD/iLnxjt35jvOae28oNW/wtMZBOmQR3Rf0y4wirvA1bpAZEhBoFqL+rZGhsd6ddOdQXdex1T0DRyQ=="
},
"cordova-plugin-camera": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-4.1.0.tgz",
"integrity": "sha512-fCLhWjWYn49q3X5xaypAPgTz6MAWSKFFQvD2Gpi5SuVlrRPRphtX2jIqR2zCBuDTBR082QVnlc+yUDXt65Mjgw=="
},
"cordova-plugin-device": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.2.tgz",
......@@ -2838,6 +2875,11 @@
"resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.1.tgz",
"integrity": "sha1-SWBrjBWlaI1HKPkuSnMloGHeB/U="
},
"cordova-plugin-filepath": {
"version": "1.5.6",
"resolved": "https://registry.npmjs.org/cordova-plugin-filepath/-/cordova-plugin-filepath-1.5.6.tgz",
"integrity": "sha512-YvrnXfoq4hzruVXnKo2qAiWlJ6xqo9RWLycEOI13WAIb69pzVvvFHXLREv7otSXkTn2tugpHQWcopxnPPOvFtA=="
},
"cordova-plugin-googleplus": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-googleplus/-/cordova-plugin-googleplus-8.0.0.tgz",
......
......@@ -23,10 +23,14 @@
"@ionic-native/app-version": "^5.11.0",
"@ionic-native/background-geolocation": "^5.8.0",
"@ionic-native/background-mode": "^5.11.0",
"@ionic-native/camera": "^5.13.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/diagnostic": "^5.8.0",
"@ionic-native/file": "^5.13.0",
"@ionic-native/file-path": "^5.13.0",
"@ionic-native/google-plus": "^5.0.0",
"@ionic-native/http": "^5.8.0",
"@ionic-native/ionic-webview": "^5.13.0",
"@ionic-native/local-notifications": "^5.11.0",
"@ionic-native/location-accuracy": "^5.8.0",
"@ionic-native/splash-screen": "^5.0.0",
......@@ -39,7 +43,9 @@
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-background-mode": "git+https://github.com/sercatven/cordova-plugin-background-mode.git",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-filepath": "^1.5.6",
"cordova-plugin-googleplus": "^8.0.0",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-play-games-services": "^1.1.2",
......@@ -134,7 +140,11 @@
"cordova-plugin-file": {},
"cordova-plugin-googleplus": {
"PLAY_SERVICES_VERSION": "11.8.0"
}
},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-filepath": {}
},
"platforms": [
"android"
......
......@@ -19,6 +19,10 @@ import { BackgroundMode } from '@ionic-native/background-mode/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { Camera } from '@ionic-native/Camera/ngx';
import { File } from '@ionic-native/File/ngx';
import { WebView } from '@ionic-native/ionic-webview/ngx';
import { FilePath } from '@ionic-native/file-path/ngx';
@NgModule({
declarations: [AppComponent],
......@@ -44,7 +48,11 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
BackgroundMode,
BackgroundGeolocation,
AppVersion,
GooglePlus
GooglePlus,
Camera,
File,
WebView,
FilePath
],
bootstrap: [AppComponent]
})
......
......@@ -44,4 +44,8 @@ div.start {
ion-spinner {
transform: scale(3);
}
}
ion-alert{
--width: 90vw !important;
--max-width: 90vw !important;
}
\ No newline at end of file
......@@ -26,6 +26,14 @@ const routes: Routes = [
loadChildren: '../partenaires/partenaires.module#PartenairesPageModule'
},
{
path: 'mes-merites',
loadChildren: '../mes-merites/mes-merites.module#MesMeritesPageModule'
},
{
path: 'reclamer-merites',
loadChildren: '../reclamer-merites/reclamer-merites.module#ReclamerMeritesPageModule'
},
{
path: 'params',
loadChildren: '../params/params.module#ParamsPageModule'
},
......
......@@ -19,6 +19,11 @@ export class MenuPage implements OnInit {
icon: 'contacts'
},
{
title: 'Mes mérites',
url: '/app/mes-merites',
icon: 'ribbon'
},
{
title: 'Paramètres',
url: '/app/params',
icon: 'settings'
......
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 { MesMeritesPage } from './mes-merites.page';
const routes: Routes = [
{
path: '',
component: MesMeritesPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [MesMeritesPage]
})
export class MesMeritesPageModule {}
<ion-header>
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-menu-button>
</ion-menu-button>
</ion-buttons>
<ion-title>Mes mérites</ion-title>
<ion-chip slot="end">
<ion-icon name="ribbon" color="secondary"></ion-icon>
<ion-label color="light">10 542</ion-label>
</ion-chip>
</ion-toolbar>
</ion-header>
<ion-content padding>
<div [ngSwitch]="viewList">
<ion-grid no-padding>
<ion-row>
<ion-col size="8">
<ion-button expand="block" color="success" routerLink="/app/reclamer-merites" routerDirection="forward"
routerLinkActive="active">
<ion-icon name="ribbon"></ion-icon>
Réclamer des mérites
</ion-button>
</ion-col>
<ion-col>
<ion-button expand="block" color="dark" routerLink="/app/reclamer-merites" routerDirection="forward"
routerLinkActive="active">
<ion-icon name="medal"></ion-icon>
Gains
</ion-button>
</ion-col>
</ion-row>
</ion-grid>
<ion-segment (ionChange)="segmentChanged($event)" padding-vertical scrollable>
<ion-segment-button value="approbation" checked>
<ion-label>En approbation</ion-label>
</ion-segment-button>
<ion-segment-button value="traitees">
<ion-label>Demandes traitées</ion-label>
</ion-segment-button>
<ion-segment-button value="gains">
<ion-label>Gains reçus</ion-label>
</ion-segment-button>
</ion-segment>
<ion-list *ngSwitchCase="'approbation'">
<ion-item *ngFor="let img of [1,2,3,4,5,6,7,8,9]">
<ion-icon name="timer" slot="start"></ion-icon>
<ion-label>
<h2>Connexion</h2>
<p>Se connecter à l'application la première fois</p>
<p>
<ion-icon name="calendar"></ion-icon> Demandé le : 0{{ img }}/09/2019
</p>
<p>
<ion-badge color="warning">
<ion-icon name="ribbon"></ion-icon>
100
</ion-badge>
</p>
</ion-label>
</ion-item>
</ion-list>
<ion-list *ngSwitchCase="'traitees'">
<ion-item>
<ion-badge color="warning" slot="start">
<ion-icon name="ribbon"></ion-icon>
200
</ion-badge>
<ion-label>
<h2>Connexion</h2>
<p>Se connecter à l'application la première fois</p>
<p>
<ion-icon name="calendar"></ion-icon> Terminé le : 04/09/2019
</p>
<p>
<ion-badge color="success" slot="start">
Approuvée
</ion-badge>
</p>
</ion-label>
</ion-item>
<ion-item *ngFor="let img of [1,2,3,4,5,6,7,8,9]">
<ion-badge color="warning" slot="start">
<ion-icon name="ribbon"></ion-icon>
500
</ion-badge>
<ion-label>
<h2>Parrainage</h2>
<p>Parrainer 10 ami(e)s</p>
<p>
<ion-icon name="calendar"></ion-icon> Terminé le : 0{{ img }}/09/2019
</p>
<p>
<ion-badge color="danger" slot="start">
Refusée
</ion-badge>
</p>
</ion-label>
</ion-item>
</ion-list>
</div>
</ion-content>
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MesMeritesPage } from './mes-merites.page';
describe('MesMeritesPage', () => {
let component: MesMeritesPage;
let fixture: ComponentFixture<MesMeritesPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MesMeritesPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MesMeritesPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-mes-merites',
templateUrl: './mes-merites.page.html',
styleUrls: ['./mes-merites.page.scss'],
})
export class MesMeritesPage implements OnInit {
viewList = 'approbation';
constructor() { }
ngOnInit() {
}
segmentChanged(event) {
this.viewList = event.detail.value;
}
}
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 { ReclamerMeritesPage } from './reclamer-merites.page';
const routes: Routes = [
{
path: '',
component: ReclamerMeritesPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [ReclamerMeritesPage]
})
export class ReclamerMeritesPageModule {}
<ion-header>
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-back-button defaultHref="/app/mes-merites" text="Retour"></ion-back-button>
</ion-buttons>
<ion-title>
Réclamer des mérites
</ion-title>
<ion-buttons slot="end">
<ion-button color="success" fill="solid" size="small">Valider</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-item lines="none" margin-top>
<ion-text class="ion-text-justify">
<small>
Pour récupérer les points de mérites <ion-icon name="ribbon" color="secondary"></ion-icon>, il suffit de
sélectionner l'offre, et présenter une preuve d'achat (ticket de caisse ou autre). Une fois votre demande est
approuvée, les mérites associés à l'offre seront rajoutés immédiatement à votre solde.<br>
On vous rappelle que les mérites vous permettent de gagner des lots si vous êtes un(e) membre fidèle!
</small>
</ion-text>
</ion-item>
<ion-card>
<ion-list>
<ion-list-header color="tertiary">Sélectionnez l'offre concernée</ion-list-header>
<ion-item>
<ion-label>Partenaire</ion-label>
<ion-select placeholder="Sélectionner">
<ion-select-option value="f">The green place</ion-select-option>
<ion-select-option value="m">Hollywood café restaurant</ion-select-option>
</ion-select>
</ion-item>
<ion-item lines="none">
<ion-label>Offre</ion-label>
<ion-select placeholder="Sélectionner">
<ion-select-option value="f">50% sur le second petit-déjeuner</ion-select-option>
<ion-select-option value="m">10% sur le petit-déjeuner</ion-select-option>
</ion-select>
</ion-item>
</ion-list>
</ion-card>
<ion-card>
<ion-list>
<ion-list-header color="tertiary">Preuve(s) d'achat</ion-list-header>
<ion-item *ngFor="let img of images; index as pos" text-wrap>
<ion-thumbnail slot="start">
<ion-img [src]="img.path"></ion-img>
</ion-thumbnail>
<ion-label>
{{ img.name }}
</ion-label>
<ion-button slot="end" fill="clear" (click)="deleteImage(img, pos)">
<ion-icon slot="icon-only" name="trash"></ion-icon>
</ion-button>
</ion-item>
<ion-text class="ion-padding-horizontal">
<small>La preuve d'achat doit avoir la date d'achat affichée en claire.</small>
</ion-text>
<ion-item no-padding>
<ion-button fill="solid" expand="full" color="success" (click)="selectImage()" class="ion-margin-horizontal">
<ion-icon slot="start" name="camera"></ion-icon>
Preuves d'achat (ticket de caisse, bons, ...)
</ion-button>
</ion-item>
<ion-item lines="none">
<ion-label position="floating">Commentaires</ion-label>
<ion-textarea rows="5" placeholder="Plus d'indications sur l'achat si besoin..."></ion-textarea>
</ion-item>
</ion-list>
</ion-card>
</ion-content>
\ No newline at end of file
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReclamerMeritesPage } from './reclamer-merites.page';
describe('ReclamerMeritesPage', () => {
let component: ReclamerMeritesPage;
let fixture: ComponentFixture<ReclamerMeritesPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReclamerMeritesPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ReclamerMeritesPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { Camera, CameraOptions, PictureSourceType } from '@ionic-native/Camera/ngx';
import { ActionSheetController, ToastController, Platform, LoadingController } from '@ionic/angular';
import { File, FileEntry } from '@ionic-native/File/ngx';
import { HttpClient } from '@angular/common/http';
import { WebView } from '@ionic-native/ionic-webview/ngx';
import { Storage } from '@ionic/storage';
import { FilePath } from '@ionic-native/file-path/ngx';
import { finalize } from 'rxjs/operators';
const STORAGE_KEY = 'my_images';
@Component({
selector: 'app-reclamer-merites',
templateUrl: './reclamer-merites.page.html',
styleUrls: ['./reclamer-merites.page.scss'],
})
export class ReclamerMeritesPage implements OnInit {
images = [];
constructor(
private camera: Camera,
private file: File,
private http: HttpClient,
private webview: WebView,
private actionSheetController: ActionSheetController,
private toastController: ToastController,
private storage: Storage,
private plt: Platform,
// private loadingController: LoadingController,
private ref: ChangeDetectorRef,
private filePath: FilePath) { }
ngOnInit() {
this.plt.ready().then(() => {
this.loadStoredImages();
});
}
loadStoredImages() {
this.storage.get(STORAGE_KEY).then(images => {
if (images) {
let arr = JSON.parse(images);
this.images = [];
for (let img of arr) {
let filePath = this.file.dataDirectory + img;
let resPath = this.pathForImage(filePath);
this.images.push({ name: img, path: resPath, filePath: filePath });
}
}
});
}
pathForImage(img) {
if (img === null) {
return '';
} else {
let converted = this.webview.convertFileSrc(img);
return converted;
}
}
async presentToast(text) {
const toast = await this.toastController.create({
message: text,
position: 'bottom',
duration: 3000
});
toast.present();
}
async selectImage() {
const actionSheet = await this.actionSheetController.create({
header: "Select Image source",
buttons: [{
text: 'Load from Library',
handler: () => {
this.takePicture(this.camera.PictureSourceType.PHOTOLIBRARY);
}
},
{
text: 'Use Camera',
handler: () => {
this.takePicture(this.camera.PictureSourceType.CAMERA);
}
},
{
text: 'Cancel',
role: 'cancel'
}
]
});
await actionSheet.present();
}
takePicture(sourceType: PictureSourceType) {
var options: CameraOptions = {
quality: 100,
sourceType: sourceType,
saveToPhotoAlbum: false,
correctOrientation: true
};
this.camera.getPicture(options).then(imagePath => {
if (this.plt.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY) {
this.filePath.resolveNativePath(imagePath)
.then(filePath => {
let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('?'));
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
});
} else {
var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
}
});
}
createFileName() {
var d = new Date(),
n = d.getTime(),
newFileName = n + ".jpg";
return newFileName;
}
copyFileToLocalDir(namePath, currentName, newFileName) {
this.file.copyFile(namePath, currentName, this.file.dataDirectory, newFileName).then(success => {
this.updateStoredImages(newFileName);
}, error => {
this.presentToast('Error while storing file.');
});
}
updateStoredImages(name) {
this.storage.get(STORAGE_KEY).then(images => {
let arr = JSON.parse(images);
if (!arr) {
let newImages = [name];
this.storage.set(STORAGE_KEY, JSON.stringify(newImages));
} else {
arr.push(name);
this.storage.set(STORAGE_KEY, JSON.stringify(arr));
}
let filePath = this.file.dataDirectory + name;
let resPath = this.pathForImage(filePath);
let newEntry = {
name: name,
path: resPath,
filePath: filePath
};
this.images = [newEntry, ...this.images];
this.ref.detectChanges(); // trigger change detection cycle
});
}
deleteImage(imgEntry, position) {
this.images.splice(position, 1);
this.storage.get(STORAGE_KEY).then(images => {
let arr = JSON.parse(images);
let filtered = arr.filter(name => name != imgEntry.name);
this.storage.set(STORAGE_KEY, JSON.stringify(filtered));
var correctPath = imgEntry.filePath.substr(0, imgEntry.filePath.lastIndexOf('/') + 1);
this.file.removeFile(correctPath, imgEntry.name).then(res => {
this.presentToast('File removed.');
});
});
}
startUpload(imgEntry) {
this.file.resolveLocalFilesystemUrl(imgEntry.filePath)
.then(entry => {
(entry as FileEntry).file(file => this.readFile(file));
})
.catch(err => {
this.presentToast('Error while reading file.');
});
}
readFile(file: any) {
const reader = new FileReader();
reader.onloadend = () => {
const formData = new FormData();
const imgBlob = new Blob([reader.result], {
type: file.type
});
formData.append('file', imgBlob, file.name);
this.uploadImageData(formData);
};
reader.readAsArrayBuffer(file);
}
async uploadImageData(formData: FormData) {
// const loading = await this.loadingController.create({
// content: 'Uploading image...',
// });
// await loading.present();
this.http.post("http://localhost:8888/upload.php", formData)
.pipe(
finalize(() => {
// loading.dismiss();
})
)
.subscribe(res => {
if (res['success']) {
this.presentToast('File upload complete.');
} else {
this.presentToast('File upload failed.');
}
});
}
}
......@@ -7,94 +7,94 @@ 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 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; });
// console.log(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);
}
}
......@@ -144,6 +144,14 @@
--ion-color-purple-shade: #b17bc8;
--ion-color-purple-tint: #ce98e6;
/** Orange **/
--ion-color-orange: #FFA500;
--ion-color-orange-rgb: 255,165,0;
--ion-color-orange-contrast: #000000;
--ion-color-orange-contrast-rgb: 0,0,0;
--ion-color-orange-shade: #e09100;
--ion-color-orange-tint: #ffae1a;
--ion-font-family: "Open Sans";
}
......@@ -200,3 +208,12 @@
--ion-color-shade: var(--ion-color-purple-shade);
--ion-color-tint: var(--ion-color-purple-tint);
}
.ion-color-orange {
--ion-color-base: var(--ion-color-orange);
--ion-color-base-rgb: var(--ion-color-orange-rgb);
--ion-color-contrast: var(--ion-color-orange-contrast);
--ion-color-contrast-rgb: var(--ion-color-orange-contrast-rgb);
--ion-color-shade: var(--ion-color-orange-shade);
--ion-color-tint: var(--ion-color-orange-tint);
}
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