Skip to content

Commit

Permalink
Merge pull request #5 from graphefruit/integerFix
Browse files Browse the repository at this point in the history
Integer Fix + Last coffee default
  • Loading branch information
graphefruit authored Jun 21, 2018
2 parents 0ad75bf + 7cb03f9 commit 8599336
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 116 deletions.
2 changes: 1 addition & 1 deletion src/app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="navigation-menu">
<ion-list class="no-label-margin">
<button ion-item (click)="openPage($event,pages.home)" [class.active]="pages.home.active">
Expand Down
9 changes: 7 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**Core**/
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule} from '@angular/core';
import {ErrorHandler, NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
/**Ionic**/
import {IonicApp, IonicErrorHandler, IonicModule} from 'ionic-angular';
import {IonicStorageModule} from '@ionic/storage';
Expand Down Expand Up @@ -51,6 +51,9 @@ import {UIStatistic} from '../services/uiStatistic';
import {FormatDatePipe} from '../pipes/formatDate';
import {KeysPipe} from '../pipes/keys';
import {ToDecimalPipe} from '../pipes/toDecimal';

/**Directive**/
import {PreventCharacterDirective} from '../directive/preventCharacters'
/**Components**/
import {TimerComponent} from '../components/timer/timer';

Expand All @@ -68,6 +71,7 @@ import {TimerComponent} from '../components/timer/timer';
FormatDatePipe,
KeysPipe,
ToDecimalPipe,
PreventCharacterDirective,
BrewsPage,
BrewsAddModal, TimerComponent, BrewsEditModal,BrewsPhotoView,BrewsDetailsModal,BrewsPopover,
AboutPage, ContactPage, LicencesPage
Expand Down Expand Up @@ -113,7 +117,8 @@ import {TimerComponent} from '../components/timer/timer';
UIImage,
UIBeanStorage, AppMinimize, {provide: ErrorHandler, useClass: IonicErrorHandler},
MediaCapture, ImagePicker,AndroidPermissions, UIBrewStorage,UIStatistic
]
],exports:[PreventCharacterDirective],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule {
}
8 changes: 8 additions & 0 deletions src/classes/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {ISettings} from "../../interfaces/settings/iSettings";
import {Config} from "../objectConfig/objectConfig";
/**Enums**/
import {BREW_VIEW_ENUM} from '../../enums/settings/brewView';

import {DefaultLastCoffeeParameters} from "./settingsDefaultLastCoffeeParameter";
export class Settings implements ISettings {
public brew_view: BREW_VIEW_ENUM;
public brew_time: boolean;
Expand All @@ -20,6 +22,8 @@ export class Settings implements ISettings {
public coffee_concentration: boolean;
public coffee_first_drip_time: boolean;
public coffee_blooming_time: boolean;
public set_last_coffee_brew:boolean;
public default_last_coffee_parameters:DefaultLastCoffeeParameters;
public config: Config;


Expand All @@ -43,7 +47,11 @@ export class Settings implements ISettings {
this.note = true;
this.attachments = true;
this.rating = true;
this.set_last_coffee_brew = false;
this.config = new Config();

this.default_last_coffee_parameters = new DefaultLastCoffeeParameters();

}


Expand Down
36 changes: 36 additions & 0 deletions src/classes/settings/settingsDefaultLastCoffeeParameter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**Interfacdes**/

import {IDefaultLastCoffeeParameters} from "../../interfaces/settings/iDefaultLastCoffeeParameters";

export class DefaultLastCoffeeParameters implements IDefaultLastCoffeeParameters {
public brew_time: boolean;
public grind_size: boolean;
public grind_weight: boolean;
public method_of_preparation: boolean;
public brew_quantity: boolean;
public bean_type: boolean;
public brew_temperature:boolean;
public note: boolean;
public coffee_type:boolean;
public coffee_concentration:boolean;
public coffee_first_drip_time:boolean;
public coffee_blooming_time:boolean;
public rating:boolean;

constructor() {
this.bean_type = true;
this.brew_time = true;
this.grind_size = true;
this.grind_weight = true;
this.method_of_preparation = true;
this.brew_quantity = true;
this.bean_type = true;
this.brew_temperature = true;
this.note = false;
this.coffee_type = true;
this.coffee_concentration = true;
this.coffee_first_drip_time = true;
this.coffee_blooming_time = true;
this.rating = false;
}
}
2 changes: 1 addition & 1 deletion src/components/timer/timer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-item class="no-bottom-border item">
<ion-label stacked>Zeit</ion-label>
<ion-input type="number" [(ngModel)]="timer.seconds"></ion-input>
<ion-input [prevent-characters] type="number" [(ngModel)]="timer.seconds"></ion-input>
<button ion-button icon-left clear color="danger" small (click)="initTimer()" item-right
*ngIf="!timer.runTimer && (timer.hasStarted || timer.hasFinished) || timer.hasFinished">
<ion-icon name="refresh"></ion-icon>
Expand Down
6 changes: 6 additions & 0 deletions src/components/timer/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class TimerComponent {
return this.timer.hasFinished;
}

public setTime(seconds:number){
this.timer.seconds = seconds;

this.timer.displayTime = this.getSecondsAsDigitalClock(this.timer.seconds);
}

initTimer() {
if(!this.timeInSeconds) { this.timeInSeconds = 0; }

Expand Down
62 changes: 62 additions & 0 deletions src/directive/preventCharacters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**Core**/
import {Directive} from '@angular/core';
import {NgModel} from '@angular/forms';

@Directive({
selector: '[ngModel][prevent-characters]',
providers: [NgModel],
host: {
'(keydown)': 'onKeyDown($event)',
"(ionBlur)": 'blur()'
}
})
export class PreventCharacterDirective {


//@Output() ngModelChange:EventEmitter<any> = new EventEmitter();

constructor(private model: NgModel) {

}


onKeyDown($event) {
let pressedKeyCode: number = $event.keyCode;

if ($event.shiftKey == false && $event.ctrlKey == false && (pressedKeyCode >= 48 && pressedKeyCode <= 57) || (pressedKeyCode >= 96 && pressedKeyCode <= 105)) {
// 0-9 only
//Its okay
}
else if (pressedKeyCode == 8) {
//Delete backspace ok
}
else if (pressedKeyCode == 190 || pressedKeyCode == 188) {
//Comma, Point support
}
else {
//Everything else we block
$event.preventDefault();
$event.stopPropagation();
}

}

blur(){

let val: any = this.model.control.value;
val = val + "";
console.log(val);
if (val == "") {
val = "0";
}
if (val.indexOf(',')) {
val = val.replace(/,/g, '.');
}

//Emit worked aswell but I don't know what its doing in depth
//this.ngModelChange.emit(parseFloat(val));

this.model.control.setValue(parseFloat(val));

}
}
21 changes: 21 additions & 0 deletions src/interfaces/settings/iDefaultLastCoffeeParameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**Interfaces**/


export interface IDefaultLastCoffeeParameters {
//Properties
brew_time: boolean,
grind_size: boolean,
grind_weight: boolean,
method_of_preparation: boolean,
brew_quantity: boolean,
bean_type: boolean,
brew_temperature:boolean,
note: boolean,
coffee_type:boolean,
coffee_concentration:boolean,
coffee_first_drip_time:boolean,
coffee_blooming_time:boolean,
rating:boolean;
}


4 changes: 4 additions & 0 deletions src/interfaces/settings/iSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {IConfig} from '../objectConfig/iObjectConfig';
/**Enums**/
import {BREW_VIEW_ENUM} from '../../enums/settings/brewView';
import {IDefaultLastCoffeeParameters} from "./iDefaultLastCoffeeParameters";

export interface ISettings {
//Properties
Expand All @@ -18,9 +19,12 @@ export interface ISettings {
coffee_concentration:boolean,
coffee_first_drip_time:boolean,
coffee_blooming_time:boolean,
set_last_coffee_brew:boolean,
attachments:boolean;
rating:boolean;

default_last_coffee_parameters:IDefaultLastCoffeeParameters;

config:IConfig;
}

Expand Down
9 changes: 4 additions & 5 deletions src/pages/beans/add/beans-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@
<ion-content>
<form #addBeanForm="ngForm" novalidate>
<ion-item>
<ion-label fixed >Name*</ion-label>
<ion-label floating >Name*</ion-label>
<ion-input [(ngModel)]="data.name" name="name" type="text" #name="ngModel" spellcheck="false"
autocapitalize="off" required>
</ion-input>
</ion-item>
<ion-item>

<ion-label>Röstgrad*</ion-label>
<ion-label floating>Röstgrad*</ion-label>
<ion-select [(ngModel)]="data.roast" name="roast" #roast="ngModel">
<ion-option *ngFor="let key of roastsEnum | keys" value="{{key}}">{{roastsEnum[key]}}</ion-option>

</ion-select>
</ion-item>

<ion-item>
<ion-label fixed >Röstdatum*</ion-label>
<ion-label floating>Röstdatum*</ion-label>
<ion-datetime min="2000-01-01" max="2999-12-31" displayFormat="DD.MM.YYYY" [(ngModel)]="data.roastingDate" name="roastingDate"
#roastingDate="ngModel"></ion-datetime>
</ion-item>
<ion-item>
<ion-label fixed>Notizen</ion-label>
<ion-label floating>Notizen</ion-label>
<ion-textarea autocomplete="true" spellcheck="true" autocorrect="true" name="note" #note="ngModel" rows="5" [(ngModel)]="data.note"></ion-textarea>
</ion-item>
<button ion-item (click)="addImage()">
Expand Down
8 changes: 4 additions & 4 deletions src/pages/beans/edit/beans-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
<ion-content>
<form #editBeanForm="ngForm" novalidate>
<ion-item>
<ion-label fixed>Name*</ion-label>
<ion-label floating>Name*</ion-label>
<ion-input [(ngModel)]="data.name" name="name" type="text" #name="ngModel" spellcheck="false"
autocapitalize="off" required>
</ion-input>
</ion-item>
<ion-item>
<ion-label>Röstgrad*</ion-label>
<ion-label floating>Röstgrad*</ion-label>
<ion-select [(ngModel)]="data.roast" name="roast" #roast="ngModel">
<ion-option *ngFor="let key of roastsEnum | keys" value="{{key}}">{{roastsEnum[key]}}</ion-option>

</ion-select>
</ion-item>
<ion-item>
<ion-label fixed>Röstdatum*</ion-label>
<ion-label floating>Röstdatum*</ion-label>
<ion-datetime min="2000-01-01" max="2999-12-31" displayFormat="DD.MM.YYYY" [(ngModel)]="data.roastingDate"
name="roastingDate"
#roastingDate="ngModel"></ion-datetime>
</ion-item>
<ion-item>
<ion-label fixed>Notizen</ion-label>
<ion-label floating>Notizen</ion-label>
<ion-textarea autocomplete="true" spellcheck="true" autocorrect="true" name="note" #note="ngModel" rows="5"
[(ngModel)]="data.note"></ion-textarea>
</ion-item>
Expand Down
14 changes: 5 additions & 9 deletions src/pages/brews/add/brews-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
</ion-item>
<ion-item *ngIf="settings.grind_weight === true">
<ion-label floating>Gewicht</ion-label>
<ion-input type="number" [ngModel]="data.grind_weight"
(ngModelChange)="data.grind_weight = uiHelper.convertToNumber($event)" step="0.1" pattern="[0-9,.]*" step="any"></ion-input>
<ion-input [prevent-characters] [(ngModel)]="data.grind_weight" type="text" ></ion-input>
</ion-item>
<ion-item *ngIf="settings.brew_temperature === true">
<ion-label floating>Temperatur</ion-label>
<ion-input type="number" [ngModel]="data.brew_temperature" (ngModelChange)="data.brew_temperature = uiHelper.convertToNumber($event)" step="0.1" pattern="[0-9,.]*" step="any"></ion-input>
<ion-input [prevent-characters] [(ngModel)]="data.brew_temperature" type="text"></ion-input>
</ion-item>
<ion-item *ngIf="settings.method_of_preparation === true">
<ion-label floating>Zubereitungsmethode</ion-label>
Expand All @@ -42,26 +41,23 @@
<timer #timer timeInSeconds="0" *ngIf="settings.brew_time === true"></timer>
<ion-item *ngIf="settings.coffee_blooming_time === true">
<ion-label stacked>Blooming-Zeit / Preinfusion</ion-label>
<ion-input type="number" [ngModel]="data.coffee_blooming_time"
(ngModelChange)="data.coffee_blooming_time = uiHelper.convertToNumber($event)"></ion-input>
<ion-input [prevent-characters] [(ngModel)]="data.coffee_blooming_time" type="text" ></ion-input>
<button ion-button icon-left clear small color="primary" (click)="setCoffeeBloomingTime()" item-right>
<ion-icon name="time"></ion-icon>
Zeit!
</button>
</ion-item>
<ion-item *ngIf="settings.coffee_first_drip_time === true">
<ion-label stacked>Erster Kaffeetropfen</ion-label>
<ion-input type="number" [ngModel]="data.coffee_first_drip_time"
(ngModelChange)="data.coffee_first_drip_time = uiHelper.convertToNumber($event)"></ion-input>
<ion-input [prevent-characters] [(ngModel)]="data.coffee_first_drip_time" type="text"></ion-input>
<button ion-button icon-left clear small color="primary" (click)="setCoffeeDripTime()" item-right>
<ion-icon name="time"></ion-icon>
Zeit!
</button>
</ion-item>
<ion-item *ngIf="settings.brew_quantity === true">
<ion-label floating>Bezugsmenge</ion-label>
<ion-input type="number" [ngModel]="data.brew_quantity"
(ngModelChange)="data.brew_quantity = uiHelper.convertToNumber($event)" step="0.1" pattern="[0-9,.]*" step="any"></ion-input>
<ion-input [prevent-characters] [(ngModel)]="data.brew_quantity" type="text"></ion-input>
</ion-item>
<ion-item *ngIf="settings.coffee_type=== true">
<ion-label floating>Kaffeetyp</ion-label>
Expand Down
Loading

0 comments on commit 8599336

Please sign in to comment.