Skip to content

Commit

Permalink
Merge branch 'feature/one_spout_espresso' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
graphefruit committed Jan 16, 2025
2 parents 9ca5eef + 5ce759a commit 53bab4e
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/app/beans/bean-sort/bean-sort.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<ion-icon name="beanconqueror-filter-aa" slot="start"></ion-icon>
<ion-label>{{"BEAN_SORT_WEIGHT" | translate}}</ion-label>
</ion-item>
<ion-item (click)="setSortAfter(beanSortAfterEnum.WEIGHT_REMAINING)" [class.active]="isSortActive(beanSortAfterEnum.WEIGHT_REMAINING)" class="ion-margin-top" lines="none" tappable>
<ion-icon name="beanconqueror-filter-aa" slot="start"></ion-icon>
<ion-label>{{"BEAN_SORT_WEIGHT_REMAINING" | translate}}</ion-label>
</ion-item>
<ion-item (click)="setSortAfter(beanSortAfterEnum.AROMATICS)" [class.active]="isSortActive(beanSortAfterEnum.AROMATICS)" class="ion-margin-top" lines="none" tappable>
<ion-icon name="beanconqueror-filter-aa" slot="start"></ion-icon>
<ion-label>{{"BEAN_SORT_AROMATICS" | translate}}</ion-label>
Expand Down
10 changes: 10 additions & 0 deletions src/app/settings/settings.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,16 @@ <h2>{{"SMART_SCALE_FIRST_DRIP_THRESHOLD" | translate}}</h2>
</ion-range>
</ion-item>

<ion-item [lines]="'full'">
<ion-checkbox label-placement='start' (ngModelChange)="saveSettings();"
[(ngModel)]="settings.bluetooth_scale_espresso_just_one_cup">
<div class='ion-label' style="white-space: normal;">
<h2>{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}}</h2>
<p>{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_DESCRIPTION" | translate}}</p>
</div>
</ion-checkbox>
</ion-item>

<ion-item lines="none">
<ion-label>
<h2>{{"SMART_SCALE_COMMAND_DELAY" | translate}}</h2>
Expand Down
5 changes: 4 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1470,5 +1470,8 @@
"EXPORT_CAUTION_IOS": "iOS: If you want to set up a new phone, the best and easiest way is using the iCloud Backup",
"PAGE_SETTINGS_LANGUAGE_NORWEGIAN": "Norwegian",
"VISUALIZER_SHOT_IMPORT_FAILED": "Visualizer shot import failed",
"PAGE_SETTINGS_LANGUAGE_PORTUGUESE": "Portuguese"
"PAGE_SETTINGS_LANGUAGE_PORTUGUESE": "Portuguese",
"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE": "Weight doubling - 1 of 2 cups on scale",
"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_DESCRIPTION": "If just one cups fits on your scale, you can enable this setting. This makes it possible that you can choose in the brew, to activate a checkbox, when you have two cups, but just one is on the scale. The weight will get when the settings is activated doubled, to behave like there would be two cups on the scale.",
"BEAN_SORT_WEIGHT_REMAINING": "Remaining weight"
}
10 changes: 6 additions & 4 deletions src/classes/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class Settings implements ISettings {
public bluetooth_scale_listening_threshold_active: boolean;
public bluetooth_scale_ignore_weight_button_active: boolean;
public bluetooth_scale_first_drip_threshold: number;
public bluetooth_scale_espresso_just_one_cup: boolean;

public maximize_hide_value_cards_on_maximize_screen: boolean;

Expand Down Expand Up @@ -512,6 +513,7 @@ export class Settings implements ISettings {
this.bluetooth_scale_listening_threshold_active = false;
this.bluetooth_scale_ignore_weight_button_active = false;
this.bluetooth_scale_first_drip_threshold = 0.1;
this.bluetooth_scale_espresso_just_one_cup = false;

this.maximize_hide_value_cards_on_maximize_screen = false;

Expand Down Expand Up @@ -577,25 +579,25 @@ export class Settings implements ISettings {
this.default_last_coffee_parameters = new DefaultBrewParameter();
Object.assign(
this.default_last_coffee_parameters,
settingsObj.default_last_coffee_parameters
settingsObj.default_last_coffee_parameters,
);

this.repeat_coffee_parameters = new RepeatBrewParameter();
Object.assign(
this.repeat_coffee_parameters,
settingsObj.repeat_coffee_parameters
settingsObj.repeat_coffee_parameters,
);

this.bean_manage_parameters = new BeanManageParameter();
Object.assign(
this.bean_manage_parameters,
settingsObj.bean_manage_parameters
settingsObj.bean_manage_parameters,
);

this.bean_visible_list_view_parameters = new BeanListViewParameter();
Object.assign(
this.bean_visible_list_view_parameters,
settingsObj.bean_visible_list_view_parameters
settingsObj.bean_visible_list_view_parameters,
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
@let shallProfileHidden = shallFlowProfileBeHidden();

@if(settings.bluetooth_scale_espresso_just_one_cup === true && brewComponent.choosenPreparation.style_type === PREPARATION_STYLE_TYPE.ESPRESSO)
{
<ion-grid class="ion-padding-horizontal ion-margin-bottom ion-no-padding brew-information-panel">
<ion-row>
<ion-col size="12">
<ion-checkbox label-placement='end'
[(ngModel)]="espressoJustOneCup">
<div class='ion-label' style="white-space: normal;">
<h2>{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}}</h2>
</div>
</ion-checkbox>
</ion-col>
</ion-row>
</ion-grid>
}
<ion-item [hidden]="shallProfileHidden" [style.order]="(settings | brewFieldOrderPipe: [settings.brew_order.while.brew_time,
brewComponent.choosenPreparation.brew_order.while.brew_time,
brewComponent.choosenPreparation.use_custom_parameters])" class="ion-padding-bottom-half" lines="none">
Expand Down Expand Up @@ -26,6 +42,11 @@
</ion-item>
<ion-item [hidden]="shallProfileHidden" *ngIf='isDetail ===false' lines="none">
<ion-grid class="ion-text-center ion-no-padding brew-information-panel">
<ion-row *ngIf="settings.bluetooth_scale_espresso_just_one_cup === true && brewComponent.choosenPreparation.style_type === PREPARATION_STYLE_TYPE.ESPRESSO">
<ion-col size="12">

</ion-col>
</ion-row>
<ion-row style="padding-bottom:5px;">
<ion-col *ngIf='(uiSmartScaleConnected || ( uiPreparationDeviceConnected && uiPreparationDeviceType === PREPARATION_DEVICE_TYPE_ENUM.METICULOUS))' size="{{graphIconColSize}}"
style="padding-right:5px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export class BrewBrewingGraphComponent implements OnInit {

public graphIconColSize: number = 2;

public espressoJustOneCup: boolean = false;

constructor(
private readonly platform: Platform,
private readonly bleManager: CoffeeBluetoothDevicesService,
Expand Down Expand Up @@ -2215,6 +2217,7 @@ export class BrewBrewingGraphComponent implements OnInit {
this.deattachToFlowChange();

let didWeReceiveAnyFlow: boolean = false;

this.scaleFlowChangeSubscription = scale.flowChange.subscribe((_val) => {
this.setActualSmartInformation();
didWeReceiveAnyFlow = true;
Expand Down Expand Up @@ -2741,7 +2744,19 @@ export class BrewBrewingGraphComponent implements OnInit {
}
}

let oneEspressoCup: boolean = false;
if (
this.espressoJustOneCup === true &&
this.data.getPreparation().style_type ===
PREPARATION_STYLE_TYPE.ESPRESSO
) {
oneEspressoCup = true;
}

this.scaleFlowSubscription = scale.flowChange.subscribe((_valChange) => {
if (oneEspressoCup === true) {
_valChange.actual = _valChange.actual * 2;
}
let _val;
if (this.ignoreScaleWeight === false) {
_val = this.mutateWeightAndSeeAnomalys(
Expand Down
1 change: 1 addition & 0 deletions src/enums/beans/beanSortAfter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export enum BEAN_SORT_AFTER {
INFORMATION_REGION = 'SORT_INFORMATION_REGION',
INFORMATION_VARIETY = 'SORT_INFORMATION_VARIETY',
INFORMATION_PROCESSING = 'SORT_INFORMATION_PROCESSING',
WEIGHT_REMAINING = 'WEIGHT_REMAINING',
}
1 change: 1 addition & 0 deletions src/interfaces/settings/iSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export interface ISettings {
bluetooth_scale_listening_threshold_active: boolean;
bluetooth_scale_ignore_weight_button_active: boolean;
bluetooth_scale_first_drip_threshold: number;
bluetooth_scale_espresso_just_one_cup: boolean;

maximize_hide_value_cards_on_maximize_screen: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import { BeanSortComponent } from '../../app/beans/bean-sort/bean-sort.component
import { BeanFilterComponent } from '../../app/beans/bean-filter/bean-filter.component';
import { ModalController } from '@ionic/angular';
import { UIHelper } from '../uiHelper';
import { Brew } from '../../classes/brew/brew';
import { UIBeanHelper } from '../uiBeanHelper';

@Injectable({
providedIn: 'root',
})
export class BeanSortFilterHelperService {
constructor(
private readonly modalCtrl: ModalController,
private readonly uiHelper: UIHelper
private readonly uiHelper: UIHelper,
private readonly uiBeanHelper: UIBeanHelper,
) {}

public async showSort(_sort: IBeanPageSort) {
Expand Down Expand Up @@ -68,11 +71,11 @@ export class BeanSortFilterHelperService {
_beans: Array<Bean>,
_searchText: string,
_sort: IBeanPageSort,
_filter: IBeanPageFilter
_filter: IBeanPageFilter,
) {
let filterBeans: Array<Bean> = this.manageFilterBeans(
_type,
this.uiHelper.cloneData(_beans)
this.uiHelper.cloneData(_beans),
);

filterBeans = this.manageFavourites(_filter, filterBeans);
Expand Down Expand Up @@ -100,13 +103,13 @@ export class BeanSortFilterHelperService {
private manageFilterBeans(_type: string, beansCopy: Bean[]): Bean[] {
if (_type === 'open') {
return beansCopy.filter(
(bean) => !bean.finished && bean.isFrozen() === false
(bean) => !bean.finished && bean.isFrozen() === false,
);
} else if (_type === 'archive') {
return beansCopy.filter((bean) => bean.finished);
} else if (_type === 'frozen') {
return beansCopy.filter(
(bean) => !bean.finished && bean.isFrozen() === true
(bean) => !bean.finished && bean.isFrozen() === true,
);
}
}
Expand Down Expand Up @@ -237,6 +240,21 @@ export class BeanSortFilterHelperService {
return 0;
});
break;
case BEAN_SORT_AFTER.WEIGHT_REMAINING:
filterBeans = filterBeans.sort((a, b) => {
const remainingWeightA =
a?.weight - this.getUsedWeightCount(a.config.uuid);
const remainingWeightB =
b?.weight - this.getUsedWeightCount(b.config.uuid);
if (remainingWeightA < remainingWeightB) {
return -1;
}
if (remainingWeightA > remainingWeightB) {
return 1;
}
return 0;
});
break;
case BEAN_SORT_AFTER.AROMATICS:
filterBeans = filterBeans.sort((a, b) => {
const nameA = a.aromatics.toUpperCase();
Expand Down Expand Up @@ -325,6 +343,20 @@ export class BeanSortFilterHelperService {
return filterBeans;
}

public getUsedWeightCount(_uuid: string): number {
let usedWeightCount: number = 0;
const relatedBrews: Array<Brew> =
this.uiBeanHelper.getAllBrewsForThisBean(_uuid);
for (const brew of relatedBrews) {
if (brew.bean_weight_in > 0) {
usedWeightCount += brew.bean_weight_in;
} else {
usedWeightCount += brew.grind_weight;
}
}
return usedWeightCount;
}

private manageRoastingDateEnd(filter: IBeanPageFilter, filterBeans: Bean[]) {
if (filter.roastingDateEnd) {
const roastingDateEnd = moment(filter.roastingDateEnd)
Expand All @@ -344,7 +376,7 @@ export class BeanSortFilterHelperService {

private manageRoastingDateStart(
filter: IBeanPageFilter,
filterBeans: Bean[]
filterBeans: Bean[],
): Bean[] {
if (filter.roastingDateStart) {
const roastingStart = moment(filter.roastingDateStart)
Expand All @@ -365,31 +397,31 @@ export class BeanSortFilterHelperService {
private manageRoaster(filter: IBeanPageFilter, filterBeans: Bean[]) {
if (filter.bean_roaster) {
filterBeans = filterBeans.filter(
(e: Bean) => filter.bean_roaster.includes(e.roaster) === true
(e: Bean) => filter.bean_roaster.includes(e.roaster) === true,
);
}
return filterBeans;
}

private manageRoastRange(
filterBeans: Bean[],
filter: IBeanPageFilter
filter: IBeanPageFilter,
): Bean[] {
return filterBeans.filter(
(e: Bean) =>
e.roast_range >= filter.roast_range.lower &&
e.roast_range <= filter.roast_range.upper
e.roast_range <= filter.roast_range.upper,
);
}

private manageRoastingType(
filter: IBeanPageFilter,
filterBeans: Bean[]
filterBeans: Bean[],
): Bean[] {
if (filter.bean_roasting_type.length > 0) {
return filterBeans.filter(
(e: Bean) =>
filter.bean_roasting_type.includes(e.bean_roasting_type) === true
filter.bean_roasting_type.includes(e.bean_roasting_type) === true,
);
}
return filterBeans;
Expand All @@ -398,13 +430,13 @@ export class BeanSortFilterHelperService {
private manageRating(filterBeans: Bean[], filter: IBeanPageFilter): Bean[] {
return filterBeans.filter(
(e: Bean) =>
e.rating >= filter.rating.lower && e.rating <= filter.rating.upper
e.rating >= filter.rating.lower && e.rating <= filter.rating.upper,
);
}

private manageFavourites(
filter: IBeanPageFilter,
filterBeans: Bean[]
filterBeans: Bean[],
): Bean[] {
if (filter.favourite) {
return filterBeans.filter((e) => e.favourite === true);
Expand Down

0 comments on commit 53bab4e

Please sign in to comment.