From 17eaa8208bc52b239ad2199921c0a53d76567aba Mon Sep 17 00:00:00 2001 From: Graphefruit Date: Tue, 16 Jan 2018 11:09:44 +0100 Subject: [PATCH] Finalizing export --- config.xml | 3 ++- package-lock.json | 12 +++++++++- package.json | 9 +++++--- src/app/app.component.ts | 1 + src/app/app.module.ts | 2 ++ src/pages/beans/beans.ts | 22 +++++++++++++++--- src/pages/brews/brews.ts | 27 +++++++++++++--------- src/pages/preparations/preparations.ts | 32 +++++++++++++++++++------- src/services/uiHelper.ts | 3 ++- 9 files changed, 83 insertions(+), 28 deletions(-) diff --git a/config.xml b/config.xml index 51bc41ea5..877ba8fbc 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + Beanconqueror Lars Saalbach @@ -93,4 +93,5 @@ + diff --git a/package-lock.json b/package-lock.json index 89ffb567f..b4c5d0891 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "beanconqueror", - "version": "0.0.6", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -114,6 +114,11 @@ "resolved": "https://registry.npmjs.org/@ionic-native/app-minimize/-/app-minimize-4.3.1.tgz", "integrity": "sha512-MDwPdNyN94EZ4VUwSiSTZKbPF4a673OS5q4QFK0ykmLNQfzVLfqvOfGPPnVGhRtT+fx0uyhd1ZpkgTR6w7MPUw==" }, + "@ionic-native/app-version": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@ionic-native/app-version/-/app-version-4.5.2.tgz", + "integrity": "sha512-XLZXN1QpFyoklM0OC9J9EfPj5NSXlndaHFF+sqBPzz6J09W2VPmtLwPD43hO70O47y53/uwNiTkIkKVu3FuPdw==" + }, "@ionic-native/core": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@ionic-native/core/-/core-4.3.0.tgz", @@ -1188,6 +1193,11 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-android-permissions/-/cordova-plugin-android-permissions-1.0.0.tgz", "integrity": "sha1-nnwRa+Zo6336QUkbE9jUfalUgUk=" }, + "cordova-plugin-app-version": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/cordova-plugin-app-version/-/cordova-plugin-app-version-0.1.9.tgz", + "integrity": "sha1-nbBgeGMzenEEiTAuX1CpBPFEm9s=" + }, "cordova-plugin-appminimize": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cordova-plugin-appminimize/-/cordova-plugin-appminimize-1.0.0.tgz", diff --git a/package.json b/package.json index 45c67c26f..713e73a3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "beanconqueror", - "version": "1.0.0", + "version": "1.0.1", "author": "Lars Saalbach, Richard Polzin", "homepage": "https://github.com/graphefruit/beanconqueror", "private": true, @@ -26,6 +26,7 @@ "@angular/platform-browser-dynamic": "5.0.0", "@ionic-native/android-permissions": "^4.4.2", "@ionic-native/app-minimize": "^4.3.1", + "@ionic-native/app-version": "^4.5.2", "@ionic-native/core": "4.3.0", "@ionic-native/image-picker": "^4.4.2", "@ionic-native/media-capture": "^4.3.1", @@ -36,6 +37,7 @@ "cordova-android": "^6.2.3", "cordova-plugin-allow-backup": "0.0.2", "cordova-plugin-android-permissions": "^1.0.0", + "cordova-plugin-app-version": "^0.1.9", "cordova-plugin-appminimize": "^1.0.0", "cordova-plugin-compat": "^1.0.0", "cordova-plugin-device": "^1.1.4", @@ -77,10 +79,11 @@ "com.synconset.imagepicker": { "PHOTO_LIBRARY_USAGE_DESCRIPTION": "Bitte um Freigabe" }, - "cordova-plugin-android-permissions": {} + "cordova-plugin-android-permissions": {}, + "cordova-plugin-app-version": {} }, "platforms": [ "android" ] } -} \ No newline at end of file +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9a3c124f3..f9a993c9e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -2,6 +2,7 @@ import {Component, ViewChild} from '@angular/core'; /**Ionic**/ import {Nav, Platform, IonicApp, MenuController} from 'ionic-angular'; +import { AppVersion } from '@ionic-native/app-version'; /**Ionic native**/ import {StatusBar} from '@ionic-native/status-bar'; import {SplashScreen} from '@ionic-native/splash-screen'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 03ba03fb1..2bdbb9436 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,6 +12,7 @@ import {AppMinimize} from '@ionic-native/app-minimize'; import {MediaCapture} from '@ionic-native/media-capture'; import {ImagePicker} from '@ionic-native/image-picker'; import { AndroidPermissions } from '@ionic-native/android-permissions'; +import { AppVersion } from '@ionic-native/app-version'; /**Pages**/ import {MyApp} from './app.component'; import {HomePage} from '../pages/home/home'; @@ -99,6 +100,7 @@ import {TimerComponent} from '../components/timer/timer'; ], providers: [ StatusBar, + AppVersion, SplashScreen, UIStorage, UISettingsStorage, diff --git a/src/pages/beans/beans.ts b/src/pages/beans/beans.ts index 1ea001def..901ef7452 100644 --- a/src/pages/beans/beans.ts +++ b/src/pages/beans/beans.ts @@ -4,6 +4,7 @@ import {Component, ChangeDetectorRef} from '@angular/core'; import {ModalController} from 'ionic-angular'; /**Services**/ import {UIBeanStorage} from '../../services/uiBeanStorage'; +import {UIBrewStorage} from '../../services/uiBrewStorage'; import {UIAlert} from '../../services/uiAlert'; /**Modals**/ import {BeansAddModal} from '../beans/add/beans-add'; @@ -14,6 +15,7 @@ import {IBean} from '../../interfaces/bean/iBean'; * Classes */ import {Bean} from '../../classes/bean/bean'; +import {Brew} from '../../classes/brew/brew'; @Component({ templateUrl: 'beans.html', selector: 'beans-list', @@ -22,7 +24,7 @@ export class BeansPage { beans: Array = null; - constructor(public modalCtrl: ModalController, private changeDetectorRef: ChangeDetectorRef, private uiBeanStorage: UIBeanStorage, private uiAlert: UIAlert) { + constructor(public modalCtrl: ModalController, private changeDetectorRef: ChangeDetectorRef, private uiBeanStorage: UIBeanStorage, private uiAlert: UIAlert, private uiBrewStorage:UIBrewStorage) { } @@ -56,9 +58,10 @@ export class BeansPage { } public deleteBean(_bean: IBean) { - this.uiAlert.showConfirm("Bohne löschen?", "Sicher?").then(() => { + this.uiAlert.showConfirm("Bohne löschen? Alle zugehörigen Brühungen werden mit entfernt.", "Sicher?").then(() => { //Yes - this.__deleteBean(_bean) + this.__deleteBean(_bean); + }, () => { //No @@ -67,6 +70,19 @@ export class BeansPage { } private __deleteBean(_bean: IBean) { + let brews:Array = this.uiBrewStorage.getAllEntries(); + + let deletingBrewIndex:Array = []; + for (let i=0;i { + var processRow = (row) => { var finalVal = ''; for (var j = 0; j < row.length; j++) { var innerValue = row[j] === null ? '' : row[j].toString(); if (row[j] instanceof Date) { innerValue = row[j].toLocaleString(); } - ; + var result = innerValue.replace(/"/g, '""'); if (result.search(/("|,|\n)/g) >= 0) result = '"' + result + '"'; if (j > 0) - finalVal += ';'; + finalVal += ','; finalVal += result; } return finalVal + '\n'; @@ -128,11 +128,16 @@ export class BrewsPage { csvFile += processRow(rows[i]); } - me.uiHelper.exportCSV(filename, csvFile).then(() => { - alert('Datei wurde erfolgreich heruntergeladen'); + this.uiHelper.exportCSV(filename, csvFile).then((_downloadedFileName) => { + let alert = this.alertCtrl.create({ + title: 'Heruntergeladen!', + subTitle: `CSV-Datei '${_downloadedFileName}' wurde erfolgreich in den Download-Ordner heruntergeladen!`, + buttons: ['OK'] + }); + alert.present(); }); - } + }; let entries: Array> = []; @@ -153,7 +158,7 @@ export class BrewsPage { {"VALUE": brew.coffee_concentration, "LABEL": "Kaffee-Konzentration"}, {"VALUE": brew.coffee_first_drip_time, "LABEL": "Erster Kaffeetropfen"}, {"VALUE": brew.coffee_blooming_time, "LABEL": "Blooming-Zeit / Preinfusion"}, - {"VALUE":brew.getCalculatedBeanAge(),"LABEL":"Bohnenalter"}, + {"VALUE": brew.getCalculatedBeanAge(), "LABEL": "Bohnenalter"}, ]; entries.push(entry); } diff --git a/src/pages/preparations/preparations.ts b/src/pages/preparations/preparations.ts index e8d9956e1..1af12cef4 100644 --- a/src/pages/preparations/preparations.ts +++ b/src/pages/preparations/preparations.ts @@ -4,22 +4,25 @@ import {Component, ChangeDetectorRef} from '@angular/core'; import {ModalController} from 'ionic-angular'; /**Services**/ import {UIPreparationStorage} from '../../services/uiPreparationStorage'; +import {UIBrewStorage} from '../../services/uiBrewStorage'; import {UIAlert} from '../../services/uiAlert'; /**Modals**/ import {PreparationsAddModal} from '../preparations/add/preparations-add'; import {PreparationsEditModal} from '../preparations/edit/preparations-edit'; -/**Interfaces**/ -import {IPreparation} from '../../interfaces/preparation/iPreparation'; - +/** + * Classes + */ +import {Brew} from '../../classes/brew/brew'; +import {Preparation} from '../../classes/preparation/preparation'; @Component({ templateUrl: 'preparations.html' }) export class PreparationsPage { - preparations: Array = []; + preparations: Array = []; - constructor(public modalCtrl: ModalController, private changeDetectorRef: ChangeDetectorRef, private uiPreparationStorage:UIPreparationStorage, private uiAlert:UIAlert) { + constructor(public modalCtrl: ModalController, private changeDetectorRef: ChangeDetectorRef, private uiPreparationStorage:UIPreparationStorage, private uiAlert:UIAlert, private uiBrewStorage:UIBrewStorage) { } @@ -52,8 +55,8 @@ export class PreparationsPage { } - public deletePreparation(_preparation: IPreparation) { - this.uiAlert.showConfirm("Zubereitungsmethode löschen?", "Sicher?").then(() => { + public deletePreparation(_preparation: Preparation) { + this.uiAlert.showConfirm("Zubereitungsmethode löschen? Alle zugehörigen Brühungen werden mit entfernt.", "Sicher?").then(() => { //Yes this.__deletePreparation(_preparation) }, @@ -63,7 +66,20 @@ export class PreparationsPage { } - private __deletePreparation(_preparation: IPreparation) { + private __deletePreparation(_preparation: Preparation) { + let brews:Array = this.uiBrewStorage.getAllEntries(); + let deletingBrewIndex:Array = []; + for (let i=0;i