diff --git a/package.json b/package.json
index a0da017..082d5e4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "WorkTime",
- "version": "0.3.0",
+ "version": "0.3.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
diff --git a/src/app/analysis/analysis.page.html b/src/app/analysis/analysis.page.html
index f8fa282..560e6cf 100644
--- a/src/app/analysis/analysis.page.html
+++ b/src/app/analysis/analysis.page.html
@@ -19,7 +19,7 @@
-
+
diff --git a/src/app/analysis/analysis.page.ts b/src/app/analysis/analysis.page.ts
index b864f38..c83506f 100644
--- a/src/app/analysis/analysis.page.ts
+++ b/src/app/analysis/analysis.page.ts
@@ -24,6 +24,7 @@ import {briefcase, card, pizza} from "ionicons/icons";
import {NgIf} from "@angular/common";
import {SettingsService} from "../../services/settings.service";
import {Settings} from "../../models/settings";
+import {AppComponent} from "../app.component";
@Component({
selector: 'app-tab2',
@@ -54,6 +55,12 @@ export class AnalysisPage {
}
ionViewDidEnter() {
+ this.currentDate = AppComponent.currentDate;
+ this.updateCurrentData();
+ }
+
+ public updateCurrentDate() {
+ AppComponent.currentDate = this.currentDate;
this.updateCurrentData();
}
@@ -65,26 +72,50 @@ export class AnalysisPage {
this.driveTime = 0;
this.combinedWorkTime = 0;
- if (this.timeData.length < 2) {
+ if (this.timeData.length == 0) {
this.showEmptyChart();
return;
}
- for (let i = 1; i < this.timeData.length; i++) {
- const start = this.timeData[i - 1];
- const end = this.timeData[i];
- const diff = this.time.calculateTimespanInMinutes(start, end);
+ if (this.timeData.length >= 1 && this.time.isToday(this.currentDate)) {
+ const lastEntry = this.timeData[this.timeData.length - 1];
+ const diff = this.time.calculateTimespanInMinutes(lastEntry, {
+ type: undefined,
+ registeredAt: new Date(Date.now())
+ });
- if (start.type == 'start-drive' && end.type == 'end-drive') {
- this.driveTime += diff;
- }
- else if (start.type === 'login') {
+ if (lastEntry.type == "login") {
this.workTime += diff;
}
- else {
- this.pauseTime += diff;
+ else if (lastEntry.type == "start-drive") {
+ this.driveTime += diff;
+ }
+
+ if (lastEntry.registeredAt.getHours() < this.settings.dontTrackPauseAfter) {
+ if (lastEntry.type == "logout" || lastEntry.type == "end-drive") {
+ this.pauseTime += diff;
+ }
}
}
+
+ if (this.timeData.length > 2) {
+ for (let i = 1; i < this.timeData.length; i++) {
+ const start = this.timeData[i - 1];
+ const end = this.timeData[i];
+ const diff = this.time.calculateTimespanInMinutes(start, end);
+
+ if (start.type == 'start-drive' && end.type == 'end-drive') {
+ this.driveTime += diff;
+ }
+ else if (start.type === 'login') {
+ this.workTime += diff;
+ }
+ else {
+ this.pauseTime += diff;
+ }
+ }
+ }
+
this.combinedWorkTime = this.workTime + this.driveTime;
if (this.combinedWorkTime < 360) {
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index c5ba44f..9091b3a 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -8,5 +8,6 @@ import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
imports: [IonApp, IonRouterOutlet],
})
export class AppComponent {
+ public static currentDate: any;
constructor() {}
}
diff --git a/src/app/settings/settings.page.html b/src/app/settings/settings.page.html
index af7d0e2..1f94e67 100644
--- a/src/app/settings/settings.page.html
+++ b/src/app/settings/settings.page.html
@@ -45,6 +45,11 @@
Minuten
+
+ Nicht tracken nach
+
+ Uhr
+
Überstunden
diff --git a/src/app/settings/settings.page.scss b/src/app/settings/settings.page.scss
index 60a165a..845ec3f 100644
--- a/src/app/settings/settings.page.scss
+++ b/src/app/settings/settings.page.scss
@@ -6,3 +6,7 @@ ion-item-divider {
ion-item {
--border-style: none;
}
+
+ion-label {
+ min-width: 60px;
+}
diff --git a/src/app/settings/settings.page.ts b/src/app/settings/settings.page.ts
index b53bbe4..167fdb9 100644
--- a/src/app/settings/settings.page.ts
+++ b/src/app/settings/settings.page.ts
@@ -43,6 +43,7 @@ export class SettingsPage {
this.input.pauseAfter9 ??= this.settings.pauseAfter9;
this.input.maxOverTime ??= this.settings.maxOverTime;
this.input.desiredOverTime ??= this.settings.desiredOverTime;
+ this.input.dontTrackPauseAfter ??= this.settings.dontTrackPauseAfter;
this.settingsProvider.saveSettings(this.input);
diff --git a/src/app/time/time.page.html b/src/app/time/time.page.html
index b2d0bab..7e994c4 100644
--- a/src/app/time/time.page.html
+++ b/src/app/time/time.page.html
@@ -19,7 +19,7 @@
-
+
diff --git a/src/app/time/time.page.ts b/src/app/time/time.page.ts
index 2efdff1..b83cdb2 100644
--- a/src/app/time/time.page.ts
+++ b/src/app/time/time.page.ts
@@ -15,6 +15,7 @@ import {addIcons} from "ionicons";
import {add} from "ionicons/icons";
import {FormsModule} from "@angular/forms";
import {TimeService} from "../../services/time.service";
+import {AppComponent} from "../app.component";
@Component({
selector: 'app-tab1',
@@ -45,6 +46,14 @@ export class TimePage {
addIcons({add});
}
+ ionViewDidEnter() {
+ this.currentDate = AppComponent.currentDate;
+ }
+
+ public updateCurrentDate() {
+ AppComponent.currentDate = this.currentDate;
+ }
+
public getEntriesOfToday(): TimeEntry[] {
const today = new Date(this.currentDate || Date.now()).toLocaleDateString();
this.today = this.data.filter(entry => entry.registeredAt.toLocaleDateString() === today);
@@ -186,7 +195,7 @@ export class TimePage {
}
public isToday(): boolean {
- return new Date(this.currentDate || Date.now()).toLocaleDateString() === new Date(Date.now()).toLocaleDateString();
+ return this.timeService.isToday(this.currentDate);
}
protected readonly open = open;
diff --git a/src/models/settings.ts b/src/models/settings.ts
index 40e727a..e443bc4 100644
--- a/src/models/settings.ts
+++ b/src/models/settings.ts
@@ -4,6 +4,7 @@
defaultPauseTime?: number;
pauseAfter6?: number;
pauseAfter9?: number;
+ dontTrackPauseAfter?: number;
maxOverTime?: number;
desiredOverTime?: number;
}
diff --git a/src/services/settings.service.ts b/src/services/settings.service.ts
index 944f21e..7aa4bff 100644
--- a/src/services/settings.service.ts
+++ b/src/services/settings.service.ts
@@ -27,6 +27,7 @@ export class SettingsService {
defaultPauseTime: 0,
pauseAfter6: 30,
pauseAfter9: 45,
+ dontTrackPauseAfter: 14,
maxOverTime: 60,
desiredOverTime: 30
};
diff --git a/src/services/time.service.ts b/src/services/time.service.ts
index 5b24684..a631c57 100644
--- a/src/services/time.service.ts
+++ b/src/services/time.service.ts
@@ -43,4 +43,8 @@ export class TimeService {
public saveEntries(entries: TimeEntry[]): void {
localStorage.setItem("time-data", JSON.stringify(entries));
}
+
+ public isToday(currentDate: any): boolean {
+ return new Date(currentDate || Date.now()).toLocaleDateString() === new Date(Date.now()).toLocaleDateString();
+ }
}