From 970e018ec2893de98a9bd5537b72b783418f0059 Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Wed, 26 Feb 2025 19:44:29 +0100 Subject: [PATCH] Added moba feature --- .gitlab-ci.yml | 17 ++++++++++++++++- src/app/analysis/analysis.page.ts | 3 ++- src/app/time/time.page.html | 10 ++++++++-- src/app/time/time.page.ts | 26 +++++++++++++++----------- src/models/timeEntry.ts | 1 + 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3f8851..c4c0c62 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: - install - lint - build + - publish install: stage: install @@ -36,7 +37,8 @@ build: - npm run build artifacts: paths: - - $CI_PROJECT_DIR/dist + - $CI_PROJECT_DIR/www + expire_in: 10 minutes cache: key: files: @@ -44,3 +46,16 @@ build: paths: - node_modules policy: pull + +publish: + stage: publish + script: + - export VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//') + - docker login -u leon.hoppe -p ${CI_REGISTRY_PASSWORD} registry.leon-hoppe.de + - docker build -t registry.leon-hoppe.de/leon.hoppe/worktime:$VERSION -t registry.leon-hoppe.de/leon.hoppe/worktime:latest . + - docker push registry.leon-hoppe.de/leon.hoppe/worktime:$VERSION + - docker push registry.leon-hoppe.de/leon.hoppe/worktime:latest + only: + - tags + dependencies: + - build diff --git a/src/app/analysis/analysis.page.ts b/src/app/analysis/analysis.page.ts index 1cf762d..732f525 100644 --- a/src/app/analysis/analysis.page.ts +++ b/src/app/analysis/analysis.page.ts @@ -76,7 +76,8 @@ export class AnalysisPage { const lastEntry = this.timeData[this.timeData.length - 1]; const diff = this.time.calculateTimespanInMinutes(lastEntry, { type: undefined, - registeredAt: new Date(Date.now()) + registeredAt: new Date(Date.now()), + isMoba: false }); if (lastEntry.type == "login") { diff --git a/src/app/time/time.page.html b/src/app/time/time.page.html index 1dd2c9c..7fadfe8 100644 --- a/src/app/time/time.page.html +++ b/src/app/time/time.page.html @@ -27,6 +27,7 @@
+ {{getTypeText(entry.type)}} {{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}} @@ -37,7 +38,10 @@
- {{translateCurrentAction()}} + + + {{translateCurrentAction()}} + @@ -50,7 +54,6 @@ Abbrechen - Welcome Speichern @@ -75,6 +78,9 @@ Dienstreise beenden + + Mobieles Arbeiten + diff --git a/src/app/time/time.page.ts b/src/app/time/time.page.ts index fa72811..b8edd3c 100644 --- a/src/app/time/time.page.ts +++ b/src/app/time/time.page.ts @@ -5,23 +5,21 @@ import { IonTitle, IonContent, IonButton, - IonList, IonItem, IonLabel, IonIcon, IonModal, IonButtons, - IonInput, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption, - AlertController + AlertController, ViewDidEnter, IonCheckbox } from '@ionic/angular/standalone'; import {TimeEntry, TimeType} from "../../models/timeEntry"; import {NgClass, NgForOf, NgIf} from "@angular/common"; import {addIcons} from "ionicons"; -import {add, trash} from "ionicons/icons"; +import {add, home, trash} from "ionicons/icons"; import {FormsModule} from "@angular/forms"; import {TimeService} from "../../services/time.service"; import {AppComponent} from "../app.component"; @@ -31,9 +29,9 @@ import {AppComponent} from "../app.component"; templateUrl: 'time.page.html', styleUrls: ['time.page.scss'], standalone: true, - imports: [IonHeader, IonToolbar, IonTitle, IonContent, NgForOf, IonButton, IonList, IonItem, IonLabel, NgIf, NgClass, IonIcon, IonModal, IonButtons, IonInput, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption, FormsModule], + imports: [IonHeader, IonToolbar, IonTitle, IonContent, NgForOf, IonButton, IonItem, IonLabel, NgIf, NgClass, IonIcon, IonModal, IonButtons, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption, FormsModule, IonCheckbox], }) -export class TimePage { +export class TimePage implements ViewDidEnter { public data: TimeEntry[] = []; public today: TimeEntry[] = []; public shouldAnimate: boolean[] = []; @@ -42,6 +40,8 @@ export class TimePage { public modalDate: any; public currentDate: any; + public modalMoba: boolean; + public currentlyMoba: boolean; constructor(private timeService: TimeService, private alerts: AlertController) { this.data = timeService.loadEntries(); @@ -52,7 +52,7 @@ export class TimePage { this.updateCurrentAction(); - addIcons({add, trash}); + addIcons({add, trash, home}); } ionViewDidEnter() { @@ -115,7 +115,8 @@ export class TimePage { this.data.push({ registeredAt: new Date(Date.now()), - type: this.currentAction + type: this.currentAction, + isMoba: this.currentlyMoba }); this.data.sort((a: TimeEntry, b: TimeEntry) => { return a.registeredAt.getTime() - b.registeredAt.getTime(); @@ -156,9 +157,9 @@ export class TimePage { if (this.data.length == 0) { this.currentAction = 'login'; }else { - const lastAction = this.data[this.data.length - 1].type; + const lastEntry = this.data[this.data.length - 1] - switch (lastAction) { + switch (lastEntry.type) { case "start-drive": this.currentAction = 'end-drive'; break; @@ -176,6 +177,8 @@ export class TimePage { this.currentAction = 'login'; break; } + + this.currentlyMoba = lastEntry.isMoba && lastEntry.type == "login"; } } @@ -215,7 +218,8 @@ export class TimePage { this.data.push({ registeredAt: date, - type: action || this.currentAction + type: action || this.currentAction, + isMoba: this.modalMoba }); this.data.sort((a: TimeEntry, b: TimeEntry) => { return a.registeredAt.getTime() - b.registeredAt.getTime(); diff --git a/src/models/timeEntry.ts b/src/models/timeEntry.ts index 5287cf4..5a19670 100644 --- a/src/models/timeEntry.ts +++ b/src/models/timeEntry.ts @@ -1,6 +1,7 @@ export interface TimeEntry { registeredAt: Date; type: TimeType; + isMoba: boolean; } export type TimeType = 'login' | 'logout' | 'start-drive' | 'end-drive';