diff --git a/web-angular/src/app/services/resource.service.ts b/web-angular/src/app/services/resource.service.ts index a93080c..2c2a623 100644 --- a/web-angular/src/app/services/resource.service.ts +++ b/web-angular/src/app/services/resource.service.ts @@ -446,6 +446,10 @@ export class ResourceService { + 'Adressleiste Deines Browsers kopiert hast, stell sicher, dass der Link vollständig ist.', 'activate_error_expiredlink': 'Der Aktivierungslink ist nicht mehr gültig. Entweder wurder er schon benutzt oder er ist abgelaufen.', // TODO: Time Sheet labels DE + 'time_shet_update_btn_tooltip': 'Aktualisieren', + 'time_shet_export_btn_tooltip': 'Exportieren', + 'time_shet_export_as_csv_label': 'als CSV', + 'time_shet_export_as_json_label': 'als JSON', 'time_sheet_title': 'Stundenzettel', 'time_sheet_table_date': 'Datum', 'time_sheet_table_from': 'von', @@ -454,17 +458,26 @@ export class ResourceService { 'time_sheet_table_place': 'Arbeitsplatz', 'time_sheet_table_device': 'Gerät', 'time_sheet_config_label': 'Konfiguration', - 'time_sheet_toggle_default_label': 'Standard', - 'time_sheet_toggle_acc_label': 'Akk.', + 'time_sheet_toggle_default_label': 'Arbeit', + 'time_sheet_toggle_default_tooltip': 'Gedeckelte & zusammengefasste Arbeitszeit je Tag.', + 'time_sheet_toggle_acc_label': 'Normal', + 'time_sheet_toggle_acc_tooltip': 'Ungedeckelte & zusammengefasste Zeiteinträge je Tag.', 'time_sheet_toggle_by_days_label': 'Nach Tagen', + 'time_sheet_toggle_by_days_tooltip': 'Alle Zeiteinträge je Tag.', 'time_sheet_toggle_raw_label': 'Rohdaten', + 'time_sheet_toggle_raw_tooltip': 'Rohdaten', 'time_sheet_select_device_label': 'Gerät', + 'time_sheet_select_device_tooltip': 'Filtert die Zeiteinträge auf das ausgewählte Gerät.', 'time_sheet_no_device_selected': 'Keins', 'time_sheet_break_time_label': 'Pausendauer', + 'time_sheet_break_time_tooltip': 'Gibt an, ab welcher Dauer die Abwesenheit vom Arbeitsplatz als Pausendauer ' + + 'zu werten ist und somit nicht zum Zeiteintrag hinzugerechnet wird.', + 'time_sheet_break_time_minutes': 'Minuten', 'time_sheet_no_break_time_selected': 'Keine', 'time_sheet_time_period_label': 'Zeitraum', + 'time_sheet_time_period_tooltip': 'Markiert den Zeitraum für die auszuwertendend Daten.', 'time_sheet_workplace_button': 'Arbeitsplatz auswählen', - 'time_sheet_workplace_clear_list': 'List leeren', + 'time_sheet_workplace_clear_list': 'Liste leeren', // layouts 'drawer_navigation': 'Navigation', 'drawer_settings': 'Einstellungen', @@ -908,6 +921,10 @@ export class ResourceService { + 'make sure to copy it completely.', 'activate_error_expiredlink': 'The activation link is no longer valid. Did you already use it?', // TODO: Time Sheet labels EN + 'time_shet_update_btn_tooltip': 'Update', + 'time_shet_export_btn_tooltip': 'Export', + 'time_shet_export_as_csv_label': 'as CSV', + 'time_shet_export_as_json_label': 'as JSON', 'time_sheet_title': 'Time Sheet', 'time_sheet_table_date': 'Date', 'time_sheet_table_from': 'from', @@ -916,15 +933,24 @@ export class ResourceService { 'time_sheet_table_place': 'Workplace', 'time_sheet_table_device': 'Device', 'time_sheet_config_label': 'Configuration', - 'time_sheet_toggle_default_label': 'Default', - 'time_sheet_toggle_acc_label': 'Acc.', + 'time_sheet_toggle_default_label': 'Work', + 'time_sheet_toggle_default_tooltip': 'Capped & accumulated working time per day.', + 'time_sheet_toggle_acc_label': 'Normal', + 'time_sheet_toggle_acc_tooltip': 'Uncapped & accumulated time entries per day.', 'time_sheet_toggle_by_days_label': 'By Days', + 'time_sheet_toggle_by_days_tooltip': 'All time entries per day.', 'time_sheet_toggle_raw_label': 'Raw', + 'time_sheet_toggle_raw_tooltip': 'Raw data.', 'time_sheet_select_device_label': 'Device', + 'time_sheet_select_device_tooltip': 'Filters the time entries to the selected device.', 'time_sheet_no_device_selected': 'None', 'time_sheet_break_time_label': 'Break Time', + 'time_sheet_break_time_tooltip': 'Specifies the duration from which the absence from the work ' + + 'place is to be valuated as a break duration and is therefore not added to the time entry.', + 'time_sheet_break_time_minutes': 'Minutes', 'time_sheet_no_break_time_selected': 'None', 'time_sheet_time_period_label': 'Time Period', + 'time_sheet_time_period_tooltip': 'Marks the period for the data to be evaluated.', 'time_sheet_workplace_button': 'Select Workplace', 'time_sheet_workplace_clear_list': 'Clear List', // layouts diff --git a/web-angular/src/app/services/time-sheet.service.ts b/web-angular/src/app/services/time-sheet.service.ts index 5cb66f8..8ca8bfb 100644 --- a/web-angular/src/app/services/time-sheet.service.ts +++ b/web-angular/src/app/services/time-sheet.service.ts @@ -32,8 +32,7 @@ export enum Grouping { export enum ExportType { CSV = '.csv', - JSON = '.json', - XML = '.xml' + JSON = '.json' } type DateRange = { range?: SatDatepickerRangeValue, begin?: number, end?: number }; @@ -45,7 +44,6 @@ const LINE_SEPARATOR = '\r\n'; providedIn: 'root' }) export class TimeSheetService extends MatTableDataSource { -// export class TimeSheetService { private static readonly BATCH_SIZE = 500; @@ -69,7 +67,6 @@ export class TimeSheetService extends MatTableDataSource { * for a known bug in angular, where mat-selection is fireing * a "selectionChange" event twice when the selected value is null. */ private _grouped: Grouping = Grouping.DEFAULT; - private _prevGrouped: Grouping = Grouping.DEFAULT; private _device: Device = null; private _prevDevice: Device = null; private _breakTime: number = null; @@ -77,9 +74,6 @@ export class TimeSheetService extends MatTableDataSource { private _dateRange: DateRange = {}; private _workPlaces: Place[] = []; - /* Final data which is shown to the user. */ - // timeSheet: TimeSheetData[] = []; - /** Creates an empty page. */ private static emptyPage() { return { elements: [], offset: 0, total: -1, size: 0 }; @@ -112,9 +106,8 @@ export class TimeSheetService extends MatTableDataSource { set grouped(grouped: Grouping) { if (grouped != null) { if (this._grouped !== grouped) { - if (this._grouped === Grouping.DEFAULT && this._breakTime) + if ((this._grouped === Grouping.DEFAULT || this.grouped === Grouping.BY_DAY_ACC) && this._breakTime) this._breakTime = null; - this._prevGrouped = this._grouped; this._grouped = grouped; this.updateTimeSheet(); } @@ -399,51 +392,36 @@ export class TimeSheetService extends MatTableDataSource { if (ts.deviceId) devices.add(ts.deviceId); }); - let accWorkingHours: Time; - if (Grouping.DEFAULT && this.breakTime !== null) { - const btThreshold = this.breakTime * 60_000; - accWorkingHours = tsList - .reduce( - (prev: { sheet?: TimeSheetData, skip: boolean, acc: Time }, curr: TimeSheetData) => { - // FIXME: The accumulation with the break time included is not working properly. - if (!prev.skip) { - if (prev) { - const breakDiff = curr.beginDate.getTime() - prev.sheet.endDate.getTime(); - if (breakDiff <= btThreshold) { - const time = this.getWorkingTime(prev.sheet.beginDate.getTime(), curr.endDate.getTime()); - prev.acc.hours += time.hours; - prev.acc.minutes += time.minutes; - prev.skip = true; - } else { - prev.acc.hours += curr.workingTime.hours; - prev.acc.minutes += curr.workingTime.minutes; - } - } - } else { - prev.skip = false; - } - // console.log('prev', prev); - // console.log('curr', curr); - prev.sheet = curr; - return prev; - }, - { sheet: null, skip: false, acc: { hours: 0, minutes: 0 }} - ).acc; - } else { - accWorkingHours = tsList - .map((ts: TimeSheetData) => ts.workingTime) - .reduce((prev, curr) => { - prev.hours += curr.hours; - prev.minutes += curr.minutes; - return prev; - }, - { hours: 0, minutes: 0 } - ); - } + const btThreshold = (this.breakTime) ? this.breakTime * 60_000 : 0; + let accWorkingHours = tsList.reduce( + (prev: { sheet?: TimeSheetData, skip: boolean, acc: Time }, curr: TimeSheetData) => { + if (prev.sheet && btThreshold > 0) { + const breakDiff = curr.beginDate.getTime() - prev.sheet.endDate.getTime(); + if (breakDiff <= btThreshold) { + const time = this.getWorkingTime( + prev.sheet.endDate.getTime(), + curr.beginDate.getTime() + ); + prev.acc.hours += time.hours; + prev.acc.minutes += time.minutes; + } + } + prev.acc.hours += curr.workingTime.hours; + prev.acc.minutes += curr.workingTime.minutes; + prev.sheet = curr; + return prev; + }, + { sheet: null, skip: false, acc: { hours: 0, minutes: 0 }} + ).acc; accWorkingHours.hours += Math.floor(accWorkingHours.minutes / 60); accWorkingHours.minutes = accWorkingHours.minutes % 60; - if (this.grouped == Grouping.DEFAULT && accWorkingHours.hours > 10) - accWorkingHours = { hours: 10, minutes: 0 }; + if (this.grouped === Grouping.DEFAULT){ + if (accWorkingHours.hours >= 10) + accWorkingHours = { hours: 10, minutes: 0 }; + else { + // TODO: Aufrunden von angebrochenen viertel Stunden. + } + } timeSheet.push({ overlappingDays: false, @@ -521,9 +499,6 @@ export class TimeSheetService extends MatTableDataSource { case 'json': exportStr = this.createJSON(); break; - case 'xml': - exportStr = this.createXML(); - break; } if (!exportStr) return false; @@ -587,8 +562,4 @@ export class TimeSheetService extends MatTableDataSource { }, []) ); } - - private createXML(): string | null { - throw new Error('Not implemented yet'); - } } diff --git a/web-angular/src/app/views/time-sheet.component.html b/web-angular/src/app/views/time-sheet.component.html index b8a5491..497c918 100644 --- a/web-angular/src/app/views/time-sheet.component.html +++ b/web-angular/src/app/views/time-sheet.component.html @@ -1,380 +1,170 @@ - -
- - -
- access_time_icon - {{ res.strings('time_sheet_title') }} -
+ +
+ + -
- -
- - - - - - - - - - -
- - - - - - - - -

{{ res.strings('time_sheet_config_label') }}

-
- - - {{ res.strings('time_sheet_toggle_default_label') }} - {{ res.strings('time_sheet_toggle_acc_label') }} - {{ res.strings('time_sheet_toggle_by_days_label') }} - - - -
- - - - {{ res.strings('time_sheet_select_device_label') }} - - {{ res.strings('time_sheet_no_device_selected') }} - - - {{ device.model }} - - - - - - - - {{ res.strings('time_sheet_break_time_label') }} - - {{ res.strings('time_sheet_no_break_time_selected') }} - - {{ opt }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Address - {{ getWorkplaceName(workPlace) }} - Delete - delete_icon -
- - - - + + + +
+
+ + +
+
+ +

{{ res.strings('time_sheet_config_label') }}

+ + + + {{ res.strings('time_sheet_toggle_default_label') }} + + {{ res.strings('time_sheet_toggle_acc_label') }} + + {{ res.strings('time_sheet_toggle_by_days_label') }} + + + + + {{ res.strings('time_sheet_select_device_label') }} + + {{ res.strings('time_sheet_no_device_selected') }} + + + {{ device.model }} + + + + + + {{ res.strings('time_sheet_break_time_label') }} + + {{ res.strings('time_sheet_no_break_time_selected') }} + + {{ opt + ' ' + res.strings('time_sheet_break_time_minutes') }} + + + + + + + + +
+ + + + + + + + +
+ + {{ getWorkplaceName(workPlace) }} +
+ + + + +
+
+
+ + + + + + + + + + + + - - - - - - - - - -

{{ res.strings('time_sheet_config_label') }}

-
- - - {{ res.strings('time_sheet_toggle_default_label') }} - {{ res.strings('time_sheet_toggle_acc_label') }} - - - - - {{ res.strings('time_sheet_select_device_label') }} - - {{ res.strings('time_sheet_no_device_selected') }} - - - {{ device.model }} - - - - - - - - {{ res.strings('time_sheet_break_time_label') }} - - {{ res.strings('time_sheet_no_break_time_selected') }} - - {{ opt }} - - - - - - - - - - - -
-
-
- - - - - - - - -
{{ res.strings('time_sheet_table_date') }}{{ getDate(data) }}
- - - - - - - - - - -
- {{ getWorkplaceName(workPlace) }} - - delete_icon -
- - - - - - -
-
- + + {{ res.strings('time_sheet_table_from') }} + + {{ data.beginDate | date:'H:mm' }} + + - - - - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - - -
{{ res.strings('time_sheet_table_to') }} + {{ data.endDate | date:'H:mm' }} + {{ res.strings('time_sheet_table_date') }}{{ getDate(data) }}{{ res.strings('time_sheet_table_working_time') }}{{ getWorkingTime(data.workingTime) }}{{ res.strings('time_sheet_table_from') }} - {{ data.beginDate | date:'H:mm' }} - {{ res.strings('time_sheet_table_place') }}{{ getWorkplaceString(data) }}{{ res.strings('time_sheet_table_to') }} - {{ data.endDate | date:'H:mm' }} - {{ res.strings('time_sheet_table_device') }}{{ getDeviceNameString(data) }}{{ res.strings('time_sheet_table_working_time') }}{{ getWorkingTime(data.workingTime) }}{{ res.strings('time_sheet_table_place') }}{{ getWorkplaceString(data) }}{{ res.strings('time_sheet_table_device') }}{{ getDeviceNameString(data) }}
- -
-
- - + + + + + +
+
\ No newline at end of file diff --git a/web-angular/src/app/views/time-sheet.component.ts b/web-angular/src/app/views/time-sheet.component.ts index 0f68ee1..1eede67 100644 --- a/web-angular/src/app/views/time-sheet.component.ts +++ b/web-angular/src/app/views/time-sheet.component.ts @@ -18,31 +18,37 @@ import { Device, Place } from '../../api/models'; selector: 'app-time-sheet', templateUrl: './time-sheet.component.html', styles: [ - 'table { width: 100%; }', - 'mat-sidenav { width: 350px }', - 'mat-button-toggle { font-size: 14px; }', - `.main-content { - margin: 4px; - padding-right: 16px; - padding-left: 16px; - padding-bottom: 8px; - padding-top: 8px; - }` + `.flex-center { display: flex; flex: 1 1 auto; justify-content: center; }`, + `.divider { margin: 16px; }`, + `.timesheet-container { + display: flex; + flex-flow: row-reverse wrap; + justify-content: center; + align-items: flex-start; + }`, + `.timesheet-config { width: 350px; max-width: 350px; }`, + `.config-col { display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; }`, + `.config-col .config-item { margin-left: 32px; margin-right: 32px; }`, + '.config-col .toggle-btn { font-size: 14px; margin: 20px 0px }', + `.main-content { flex: 1 1 auto; margin: 4px; padding: 8px 16px; }`, + `.main-content .main-table { width: 100%; }`, + `.main-content .mat-column-date { width: 16% !important; }`, + `.main-content .mat-column-to-time, .mat-column-from-time { width: 7% !important; }`, + `.main-content .mat-column-time { width: 10% !important; }`, + `.main-content .mat-column-device { width: 20% !important; }`, + `.main-content .mat-column-place { width: 40% !important; }` ], }) export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { - private static readonly SIDENAV_BREAKPOINT = 960; - readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150]; + private static readonly LAYOUT_BREAKPOINT = 960; + readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150, 180]; @ViewChild(MatSidenav, { static: true }) sidenav: MatSidenav; - @ViewChild('workPlacesTable', { read: CdkTable, static: false }) workPlacesTable: CdkTable; @ViewChild(MatSort, { static: true }) sort: MatSort; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; compact = false; - isSidenavOpened = true; - // TODO: Implement TableHandler Logic. static readonly normalDisplayCol = ['date', 'from-time', 'to-time', 'time', 'device', 'place']; static readonly compactDisplayCol = ['date', 'time']; displayedColumns = TimeSheetComponent.normalDisplayCol; @@ -52,8 +58,6 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { timeSheetDataSource: MatTableDataSource; private subscriptions: Subscription; - // TODO: Implement PaginationHandler Logic. - private pageHandler: PaginationHandler>; constructor( public res: ResourceService, @@ -65,16 +69,10 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { ngOnInit(): void { this.workPlaces = this.timeSheetService.workPlaces; this.timeSheetDataSource = this.timeSheetService; + this.updateDisplayedColumns(window.innerWidth); - this.updateSidenav(window.innerWidth); - this.isSidenavOpened = this.sidenav.opened; - - this.subscriptions = this.sidenav.openedChange - .subscribe((state: boolean) => this.isSidenavOpened = state); - this.subscriptions.add( - this.deviceService.connect(null) - .subscribe((devices: Device[]) => this.devices = devices) - ); + this.subscriptions = this.deviceService.connect(null) + .subscribe((devices: Device[]) => this.devices = devices); this.deviceService.reload(); } @@ -91,17 +89,17 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { @HostListener('window:resize', ['$event']) onResize(event: Event): void { - this.updateSidenav((event.target as Window).innerWidth); + this.updateDisplayedColumns((event.target as Window).innerWidth); } updateTimeSheetTable(): void { - // if (!this.timeSheetService.fetching$.getValue()) - // this.timeSheetService.fetchData(); - console.log(this.sort); + if (!this.timeSheetService.fetching$.getValue()) + this.timeSheetService.fetchData(); } exportTimeSheet(type: string): void { if (!this.timeSheetService.exportTimeSheet(type)) { + // TODO: Implement Dialog console.log('Did not export!'); } } @@ -149,7 +147,6 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { deleteWorkPlaceEntry(workPlace: Place): void { this.workPlaces = this.workPlaces.filter(place => workPlace !== place); this.timeSheetService.workPlaces = this.workPlaces; - this.workPlacesTable.renderRows(); } clearWorkPlaceList(): void { @@ -161,24 +158,14 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit { return this.timeSheetService.getDate(data); } - private updateSidenav(width: number): void { - if (width < TimeSheetComponent.SIDENAV_BREAKPOINT && !this.compact) { - this.sidenav.close(); + private updateDisplayedColumns(width: number): void { + if (width < TimeSheetComponent.LAYOUT_BREAKPOINT && !this.compact) { this.compact = true; - this.isSidenavOpened = false; this.displayedColumns = TimeSheetComponent.compactDisplayCol; this.timeSheetService.grouped = Grouping.BY_DAY_ACC; - } else if (width >= TimeSheetComponent.SIDENAV_BREAKPOINT && this.compact) { + } else if (width >= TimeSheetComponent.LAYOUT_BREAKPOINT && this.compact) { this.compact = false; - this.sidenav.open(); - this.isSidenavOpened = true; this.displayedColumns = TimeSheetComponent.normalDisplayCol; } - if (this.sidenav.opened !== this.isSidenavOpened) { - if (this.isSidenavOpened) - this.sidenav.open(); - else - this.sidenav.close(); - } } }