Author SHA1 Message Date
Adriano Markovic f5691ef3a3 [66] #REFACTOR 'layout: user'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
LocationBasedServices/maptology/master This commit looks good
{Added css flex classes.}
2020-03-18 13:04:09 +01:00
Adriano Markovic 8e3dc80fb8 [66] #REFACTOR 'layout: tables'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Revised layouts and solved linter issues with time-sheet.service.ts.}
2020-02-26 16:24:27 +01:00
Adriano Markovic 20108b282d [66] #REFACTOR 'layout: user'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Layout revised.}
2020-02-26 13:24:50 +01:00
Adriano Markovic aac6c5f5f3 [66] #REFACTOR 'layout: export'
{Revised the layout of the exort component.}
2020-02-26 12:05:52 +01:00
Adriano Markovic 3b644cece3 [66] #REFACTOR 'Layout: tables'
{Table view layout revised.}
2020-02-26 11:36:05 +01:00
Adriano Markovic 6b5f01a573 [66] #REFACTOR 'layout: privileges'
{Layout revised. Added content-layout.}
2020-02-26 11:13:07 +01:00
Adriano Markovic 98212476f4 Removed old templates. 2020-02-26 10:36:08 +01:00
Adriano Markovic eac84438f1 [66] #REFACTOR 'Component Renamed' 2020-02-26 10:34:01 +01:00
Adriano Markovic dfacfd4ff4 [66] #REFACTOR 'layout: notices'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Revised layout.}
2020-02-25 21:06:56 +01:00
Adriano Markovic 301578f241 [66] #REFACTOR 'layout: timesheet'
{Revised layout.}
2020-02-25 21:05:59 +01:00
Adriano Markovic 41dc0030c3 [misc] #REFACTOR 'layout: drawer'
{Moved the timesheet nav button up.}
2020-02-25 21:04:46 +01:00
Adriano Markovic 73ea8185a4 [66] #IMPLEMENT 'layout: header'
{Implemented the layout header layout and revised the basic layout.}
2020-02-25 21:03:52 +01:00
Adriano Markovic ff89c9a7cc [66] #REFACTOR 'component:time-sheet'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Layout revised.}
2020-02-19 22:08:28 +01:00
Adriano Markovic 7451e492c6 [66] #IMPLEMENT 'component:basic-layout'
{Basic layout component added and global stylesheet revised. }
2020-02-19 22:07:04 +01:00
23 changed files with 796 additions and 529 deletions
+12 -8
View File
@@ -29,9 +29,9 @@ import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs'; import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip';
import { MatButtonToggleModule } from "@angular/material/button-toggle"; import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { CdkTableModule } from "@angular/cdk/table"; import { CdkTableModule } from '@angular/cdk/table';
import { SatDatepickerModule, SatNativeDateModule } from 'saturn-datepicker' import { SatDatepickerModule, SatNativeDateModule } from 'saturn-datepicker';
import { LocationStrategy, PathLocationStrategy, registerLocaleData, DatePipe } from '@angular/common'; import { LocationStrategy, PathLocationStrategy, registerLocaleData, DatePipe } from '@angular/common';
import LocaleDE from '@angular/common/locales/de'; import LocaleDE from '@angular/common/locales/de';
@@ -44,6 +44,8 @@ import { AppComponent } from './app.component';
import { InsideComponent } from './layouts/inside.component'; import { InsideComponent } from './layouts/inside.component';
import { OutsideComponent } from './layouts/outside.component'; import { OutsideComponent } from './layouts/outside.component';
import { FooterComponent } from './layouts/footer.component'; import { FooterComponent } from './layouts/footer.component';
import { ContentLayoutComponent } from './layouts/content-layout.component';
import { ContentHeaderComponent } from './layouts/content-header.component';
import { ToolbarButtonComponent } from './widgets/toolbar-button.component'; import { ToolbarButtonComponent } from './widgets/toolbar-button.component';
import { LoginComponent } from './views/login.component'; import { LoginComponent } from './views/login.component';
@@ -108,7 +110,7 @@ import { DevicePositionService } from './services/device-position.service';
import { DevicePositionsComponent } from './views/device-positions.component'; import { DevicePositionsComponent } from './views/device-positions.component';
import { ChartComponent } from './widgets/chart.component'; import { ChartComponent } from './widgets/chart.component';
import { TimeSheetComponent } from './views/time-sheet.component'; import { TimeSheetComponent } from './views/time-sheet.component';
import { PlacesDialogComponent } from "./widgets/places-dialog.component"; import { PlacesDialogComponent } from './widgets/places-dialog.component';
/** /**
@@ -181,6 +183,8 @@ registerLocaleData(LocaleDE);
ChartComponent, ChartComponent,
TimeSheetComponent, TimeSheetComponent,
PlacesDialogComponent, PlacesDialogComponent,
ContentLayoutComponent,
ContentHeaderComponent,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@@ -240,10 +244,10 @@ registerLocaleData(LocaleDE);
ManageLogService, ManageUserService, ManageNoticeService ManageLogService, ManageUserService, ManageNoticeService
], ],
entryComponents: [ entryComponents: [
MessageDialogComponent, MessageDialogComponent,
ConfirmationDialogComponent, ConfirmationDialogComponent,
ShareDialogComponent, ShareDialogComponent,
NicknameDialogComponent, NicknameDialogComponent,
LogDialogComponent, LogDialogComponent,
PlacesDialogComponent, PlacesDialogComponent,
], ],
@@ -0,0 +1,4 @@
<mat-toolbar id="content-toolbar" [ngClass]="headerClass" [ngStyle]="headerStyle">
<ng-content select=".header-title"></ng-content>
<ng-content select=".header-actions"></ng-content>
</mat-toolbar>
@@ -0,0 +1,22 @@
import { Component, Input } from '@angular/core';
/**
* Simple content header component which is containing the name of the page on
* the left side and the action buttons on the right side.
*
* @author Adriano
*/
@Component({
selector: 'app-content-header',
templateUrl: './content-header.component.html'
})
export class ContentHeaderComponent {
/* Attributes which are forwarding the styles and classes
* to the mat-toolbar which where specified on the app-content-header.*/
@Input() headerStyle?: { [klass: string]: any; };
@Input() headerClass?: string | string[] | Set<string> | { [klass: string]: any; };
constructor() { }
}
@@ -0,0 +1,8 @@
<div class="outer-container" [ngClass]="layoutClass" [ngStyle]="layoutStyle">
<ng-content select="app-content-header"></ng-content>
<div #mainDiv class="inner-container">
<ng-content select="aside"></ng-content>
<ng-content select="main"></ng-content>
</div>
</div>
@@ -0,0 +1,32 @@
import { Component, AfterViewInit, ViewChild, ElementRef, Input } from '@angular/core';
/**
* Content layout component which displays an <app-header>
* on the top, a <main> on the left and an <aside> on the right side
* through angular projection.
* The <main> tag is mandatory and the other two can be omitted if necessary.
*
* @author Adriano
*/
@Component({
selector: 'app-content-layout',
templateUrl: './content-layout.component.html'
})
export class ContentLayoutComponent implements AfterViewInit {
/* Attributes which are forwarding the styles and classes
* to the div.outer-container which where specified on the app-content-layout.*/
@Input() layoutStyle?: { [klass: string]: any; };
@Input() layoutClass?: string | string[] | Set<string> | { [klass: string]: any; };
@ViewChild('mainDiv') mainDiv: ElementRef;
constructor() { }
ngAfterViewInit(): void {
const div: HTMLDivElement = this.mainDiv.nativeElement;
if (div.getElementsByTagName('main').length === 0) {
throw new Error('<main> tag not specified!');
}
}
}
@@ -8,6 +8,10 @@
<mat-icon class="icon-button">share</mat-icon> <mat-icon class="icon-button">share</mat-icon>
<span class="mat-button">{{ res.strings('privileges_title') }}</span> <span class="mat-button">{{ res.strings('privileges_title') }}</span>
</a> </a>
<a mat-list-item routerLink="/timesheet">
<mat-icon class="icon-button">access_time_icon</mat-icon>
<span class="mat-button">{{ res.strings('time_sheet_title') }}</span>
</a>
<a mat-list-item routerLink="/devices"> <a mat-list-item routerLink="/devices">
<mat-icon class="icon-button">devices</mat-icon> <mat-icon class="icon-button">devices</mat-icon>
<span class="mat-button">{{ res.strings('devices_title') }}</span> <span class="mat-button">{{ res.strings('devices_title') }}</span>
@@ -20,10 +24,6 @@
<mat-icon class="icon-button">cloud_download</mat-icon> <mat-icon class="icon-button">cloud_download</mat-icon>
<span class="mat-button">{{ res.strings('export_title') }}</span> <span class="mat-button">{{ res.strings('export_title') }}</span>
</a> </a>
<a mat-list-item routerLink="/timesheet">
<mat-icon class="icon-button">access_time_icon</mat-icon>
<span class="mat-button">{{ res.strings('time_sheet_title') }}</span>
</a>
<h3 mat-subheader>{{res.strings('drawer_settings')}}</h3> <h3 mat-subheader>{{res.strings('drawer_settings')}}</h3>
<a mat-list-item routerLink="/profile"> <a mat-list-item routerLink="/profile">
<mat-icon class="icon-button">perm_identity</mat-icon> <mat-icon class="icon-button">perm_identity</mat-icon>
@@ -473,7 +473,7 @@ export class ResourceService {
'time_sheet_select_device_tooltip': 'Filtert die Zeiteinträge auf das ausgewählte 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_no_device_selected': 'Keins',
'time_sheet_break_time_label': 'Pausendauer', 'time_sheet_break_time_label': 'Pausendauer',
'time_sheet_break_time_tooltip': 'Gibt an, ab welcher Dauer die Abwesenheit vom Arbeitsplatz als 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.', + 'zu werten ist und somit nicht zum Zeiteintrag hinzugerechnet wird.',
'time_sheet_break_time_minutes': 'Minuten', 'time_sheet_break_time_minutes': 'Minuten',
'time_sheet_no_break_time_selected': 'Keine', 'time_sheet_no_break_time_selected': 'Keine',
@@ -29,7 +29,7 @@ export interface TimeSheetData {
} }
/** /**
* Determines how the TimeSheetData * Determines how the TimeSheetData
* of the service is grouped. * of the service is grouped.
*/ */
export enum Grouping { export enum Grouping {
@@ -39,13 +39,17 @@ export enum Grouping {
RAW = 4 /* Raw data which was extracted from the call to the '/users/current/visits' api */ RAW = 4 /* Raw data which was extracted from the call to the '/users/current/visits' api */
} }
type DateRange = { range?: SatDatepickerRangeValue<Date>, begin?: number, end?: number }; interface DateRange {
range?: SatDatepickerRangeValue<Date>;
begin?: number;
end?: number;
}
const COLUMN_SEPARATOR = ';'; const COLUMN_SEPARATOR = ';';
const LINE_SEPARATOR = '\r\n'; const LINE_SEPARATOR = '\r\n';
/** /**
* A service which is fetching data from the '/users/current/visits' * A service which is fetching data from the '/users/current/visits'
* api and transforms it to TimeSheetData. * api and transforms it to TimeSheetData.
*/ */
@Injectable({ @Injectable({
@@ -57,19 +61,19 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
private static readonly DAY_IN_MILLI = 86_400_000; private static readonly DAY_IN_MILLI = 86_400_000;
/* Properties representing the current progress in /* Properties representing the current progress in
* fetching Visit data from the server. */ * fetching Visit data from the server. */
fetching$ = new BehaviorSubject<boolean>(false); fetching$ = new BehaviorSubject<boolean>(false);
error$ = new BehaviorSubject<boolean>(false); error$ = new BehaviorSubject<boolean>(false);
private _visitsAvailable: boolean = false; private _visitsAvailable = false;
private visitsPage: VisitPage = TimeSheetService.emptyPage(); private visitsPage: VisitPage = TimeSheetService.emptyPage();
private request = 0; private request = 0;
/* These Properties are used to filter the Visit data which then, /* These Properties are used to filter the Visit data which then,
* in turn can be composed to the final timeSheet data shown * in turn can be composed to the final timeSheet data shown
* to the user. * to the user.
* At least the dateRange & workPlaces have to contain * At least the dateRange & workPlaces have to contain
* valid values to start the composition process. * valid values to start the composition process.
* Remark: The prefixed _prev... values serve as a workaround * Remark: The prefixed _prev... values serve as a workaround
* for a known bug in angular, where mat-selection is fireing * for a known bug in angular, where mat-selection is fireing
@@ -81,14 +85,14 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
private _prevBreakTime: number = null; private _prevBreakTime: number = null;
private _dateRange: DateRange = {}; private _dateRange: DateRange = {};
private _workPlaces: Place[] = []; private _workPlaces: Place[] = [];
/** Creates an empty page. */ /** Creates an empty page. */
private static emptyPage() { private static emptyPage() {
return { elements: [], offset: 0, total: -1, size: 0 }; return { elements: [], offset: 0, total: -1, size: 0 };
} }
constructor( constructor(
private apiClientService: ApiClientService, private apiClientService: ApiClientService,
private userService: UserService private userService: UserService
) { ) {
super([]); super([]);
@@ -114,8 +118,10 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
set grouped(grouped: Grouping) { set grouped(grouped: Grouping) {
if (grouped != null) { if (grouped != null) {
if (this._grouped !== grouped) { if (this._grouped !== grouped) {
if ((this._grouped === Grouping.DEFAULT || this.grouped === Grouping.BY_DAY_ACC) && this._breakTime) if ((this._grouped === Grouping.DEFAULT || this.grouped === Grouping.BY_DAY_ACC)
&& this._breakTime) {
this._breakTime = null; this._breakTime = null;
}
this._grouped = grouped; this._grouped = grouped;
this.updateTimeSheet(); this.updateTimeSheet();
} }
@@ -129,8 +135,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
set device(device: Device | null) { set device(device: Device | null) {
this._prevDevice = this._device; this._prevDevice = this._device;
this._device = device; this._device = device;
if (this._prevDevice === null && device === null) if (this._prevDevice === null && device === null) { return; }
return;
this.updateTimeSheet(); this.updateTimeSheet();
} }
@@ -141,8 +146,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
set breakTime(breakTime: number | null) { set breakTime(breakTime: number | null) {
this._prevBreakTime = this._breakTime; this._prevBreakTime = this._breakTime;
this._breakTime = breakTime; this._breakTime = breakTime;
if (this._prevBreakTime === null && breakTime === null) if (this._prevBreakTime === null && breakTime === null) { return; }
return;
this.updateTimeSheet(); this.updateTimeSheet();
} }
@@ -154,7 +158,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
if (dateRange !== null) { if (dateRange !== null) {
const beginMillis = dateRange.begin.getTime(); const beginMillis = dateRange.begin.getTime();
const endMillis = new Date(dateRange.end.getTime() + TimeSheetService.DAY_IN_MILLI).getTime(); const endMillis = new Date(dateRange.end.getTime() + TimeSheetService.DAY_IN_MILLI).getTime();
this._dateRange = { this._dateRange = {
range: dateRange, range: dateRange,
begin: beginMillis, begin: beginMillis,
end: endMillis end: endMillis
@@ -174,7 +178,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
this.updateTimeSheet(); this.updateTimeSheet();
} }
setup(paginator?: MatPaginator, sort?: MatSort): void{ setup(paginator?: MatPaginator, sort?: MatSort): void {
this.paginator = paginator; this.paginator = paginator;
this.sort = sort; this.sort = sort;
this.fetchData(); this.fetchData();
@@ -188,7 +192,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
fetchData(): void { fetchData(): void {
if (this.fetching$.getValue()) return; if (this.fetching$.getValue()) { return; }
this.resetService(true); this.resetService(true);
this.fetchAllVisits(this.request); this.fetchAllVisits(this.request);
} }
@@ -263,8 +267,9 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
}); });
/* Filter for specified device. */ /* Filter for specified device. */
if (this.device != null) if (this.device != null) {
filteredVisits = filteredVisits.filter(visit => visit.device === this.device.id); filteredVisits = filteredVisits.filter(visit => visit.device === this.device.id);
}
/* Map filtered visits to TimeSheetData */ /* Map filtered visits to TimeSheetData */
if (filteredVisits.length > 0) { if (filteredVisits.length > 0) {
@@ -274,10 +279,9 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
timeSheet = this.accumulateV2TsByDay(filteredVisits); timeSheet = this.accumulateV2TsByDay(filteredVisits);
break; break;
case Grouping.BY_DAY: case Grouping.BY_DAY:
let tsMap = this.mapV2TsByDay(filteredVisits); const tsMap = this.mapV2TsByDay(filteredVisits);
tsMap.forEach((ts: TimeSheetData[]) => { tsMap.forEach((ts: TimeSheetData[]) => {
if (ts.length > 0) if (ts.length > 0) { timeSheet.push(...ts); }
timeSheet.push(...ts);
}); });
break; break;
case Grouping.RAW: case Grouping.RAW:
@@ -285,13 +289,13 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
break; break;
} }
} }
} }
this.data = timeSheet; this.data = timeSheet;
} }
/** /**
* Mapping the passed Visit objects to raw TimeSheetData objects. * Mapping the passed Visit objects to raw TimeSheetData objects.
* *
* @param visits Visits to map. * @param visits Visits to map.
* @return List of the corresponding TimeSheetData objects. * @return List of the corresponding TimeSheetData objects.
*/ */
@@ -319,7 +323,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
* timestamp: 1580425200000 * timestamp: 1580425200000
* GMT: Thursday, 30. January 2020 23:00:00 * GMT: Thursday, 30. January 2020 23:00:00
* Germany: Freitag, 31. Januar 2020 00:00:00 GMT+01:00 * Germany: Freitag, 31. Januar 2020 00:00:00 GMT+01:00
* *
* @param visits Visits to map. * @param visits Visits to map.
* @return Map of TimeSheetData objects grouped by days. * @return Map of TimeSheetData objects grouped by days.
*/ */
@@ -327,29 +331,29 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
const timeSheetMap = new Map<number, TimeSheetData[]>(); const timeSheetMap = new Map<number, TimeSheetData[]>();
const rawTimeSheet: TimeSheetData[] = this.mapVisitsToTimeSheet(visits); const rawTimeSheet: TimeSheetData[] = this.mapVisitsToTimeSheet(visits);
const putInMap = (map: Map<number, TimeSheetData[]>, key: number, value: TimeSheetData) => { const putInMap = (map: Map<number, TimeSheetData[]>, key: number, value: TimeSheetData) => {
if (map.has(key)) if (map.has(key)) {
map.get(key).push(value); map.get(key).push(value);
else } else {
map.set(key, [value]); map.set(key, [value]);
}
}; };
if (rawTimeSheet.length > 0) { if (rawTimeSheet.length > 0) {
return rawTimeSheet return rawTimeSheet
.reduce((prevMap: Map<number, TimeSheetData[]>, currTS: TimeSheetData) => { .reduce((prevMap: Map<number, TimeSheetData[]>, currTS: TimeSheetData) => {
let beginMidnight = this.getMidnightDate(currTS.beginDate.getTime()).getTime(); const beginMidnight = this.getMidnightDate(currTS.beginDate.getTime()).getTime();
let endMidnight = this.getMidnightDate(currTS.endDate.getTime()).getTime(); const endMidnight = this.getMidnightDate(currTS.endDate.getTime()).getTime();
if (beginMidnight === endMidnight) { if (beginMidnight === endMidnight) {
putInMap(prevMap, beginMidnight, currTS); putInMap(prevMap, beginMidnight, currTS);
} } else {
else {
/* If beginDate & endDate are overlapping two or more days then split /* If beginDate & endDate are overlapping two or more days then split
* object into multiple TimeSheetData objects till endDate is reached. */ * object into multiple TimeSheetData objects till endDate is reached. */
const DAY = TimeSheetService.DAY_IN_MILLI; const DAY = TimeSheetService.DAY_IN_MILLI;
for (let j = beginMidnight + DAY; j <= endMidnight; j += DAY) { for (let j = beginMidnight + DAY; j <= endMidnight; j += DAY) {
const begin = (j == beginMidnight + DAY) ? currTS.beginDate.getTime() : j - DAY; const begin = (j === beginMidnight + DAY) ? currTS.beginDate.getTime() : j - DAY;
const end = j; const end = j;
const newTS = { const newTimeSheet = {
overlappingDays: false, overlappingDays: false,
beginDate: new Date(begin), beginDate: new Date(begin),
endDate: new Date(end), endDate: new Date(end),
@@ -357,7 +361,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
placeId: currTS.placeId, placeId: currTS.placeId,
deviceId: currTS.deviceId deviceId: currTS.deviceId
}; };
putInMap(prevMap, end - DAY, newTS); putInMap(prevMap, end - DAY, newTimeSheet);
} }
const newTS = { const newTS = {
@@ -378,10 +382,10 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
/** /**
* Maps a list of Visits to a list of TimeSheetData which in turn * Maps a list of Visits to a list of TimeSheetData which in turn
* is containing only accumulated TimeSheetData object each * is containing only accumulated TimeSheetData object each
* representing a single day. * representing a single day.
* *
* @param visits Visits to map. * @param visits Visits to map.
* @param workingTimeAcc Function to accumulate the working time. * @param workingTimeAcc Function to accumulate the working time.
* @returns List of accumulated TimeSheetData. * @returns List of accumulated TimeSheetData.
@@ -400,8 +404,8 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
const places = new Set<number>(); const places = new Set<number>();
const devices = new Set<number>(); const devices = new Set<number>();
tsList.forEach((ts: TimeSheetData) => { tsList.forEach((ts: TimeSheetData) => {
if (ts.placeId) places.add(ts.placeId); if (ts.placeId) { places.add(ts.placeId); }
if (ts.deviceId) devices.add(ts.deviceId); if (ts.deviceId) { devices.add(ts.deviceId); }
}); });
const btThreshold = (this.breakTime) ? this.breakTime * 60_000 : 0; const btThreshold = (this.breakTime) ? this.breakTime * 60_000 : 0;
@@ -430,7 +434,6 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
{ sheet: null, acc: { hours: 0, minutes: 0 }, breakAcc: { hours: 0, minutes: 0} } { sheet: null, acc: { hours: 0, minutes: 0 }, breakAcc: { hours: 0, minutes: 0} }
); );
const accWorkingHours = this.processWorkingHours(timeAccumulation.acc, timeAccumulation.breakAcc); const accWorkingHours = this.processWorkingHours(timeAccumulation.acc, timeAccumulation.breakAcc);
timeSheet.push({ timeSheet.push({
overlappingDays: false, overlappingDays: false,
beginDate: new Date(erliestBegin), beginDate: new Date(erliestBegin),
@@ -441,14 +444,14 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
}); });
} }
}); });
return timeSheet; return timeSheet;
} }
/** /**
* Processes the work and break time. If Grouping is DEFAULT, the break time is evaluated * Processes the work and break time. If Grouping is DEFAULT, the break time is evaluated
* and has to fit the legal requirements of having at least a 30 or 45 minutes break when * and has to fit the legal requirements of having at least a 30 or 45 minutes break when
* working more than 6 or 9 hours respectively. * working more than 6 or 9 hours respectively.
* *
* @param working The time that is counting as work time. * @param working The time that is counting as work time.
* @param breaking The time between the single work time entries * @param breaking The time between the single work time entries
* which can be seen as break time. * which can be seen as break time.
@@ -459,25 +462,26 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
if (this.grouped === Grouping.DEFAULT) { if (this.grouped === Grouping.DEFAULT) {
let subtrahend = 0; let subtrahend = 0;
breaking = this.normalizeTime(breaking); breaking = this.normalizeTime(breaking);
if (working.hours >= 6 && breaking.hours === 0 && breaking.minutes < 30) if (working.hours >= 6 && breaking.hours === 0 && breaking.minutes < 30) {
subtrahend = 30 - breaking.minutes; subtrahend = 30 - breaking.minutes;
else if (working.hours >= 9 && breaking.hours === 0 && breaking.minutes < 45) } else if (working.hours >= 9 && breaking.hours === 0 && breaking.minutes < 45) {
subtrahend = 45 - breaking.minutes; subtrahend = 45 - breaking.minutes;
}
working.minutes -= subtrahend; working.minutes -= subtrahend;
if (working.minutes < 0) { if (working.minutes < 0) {
--working.hours; --working.hours;
working.minutes = 60 - working.minutes; working.minutes = 60 - working.minutes;
} }
/* Rounds up the minutes to a multiple of 15. */ /* Rounds up the minutes to a multiple of 15. */
if (working.minutes !== 0) if (working.minutes !== 0) {
working.minutes += Math.floor(15 - working.minutes % 15); working.minutes += Math.floor(15 - working.minutes % 15);
}
if (working.minutes === 60) { if (working.minutes === 60) {
++working.hours; ++working.hours;
working.minutes = 0; working.minutes = 0;
} }
if (working.hours >= 10) if (working.hours >= 10) { working = { hours: 10, minutes: 0 }; }
working = { hours: 10, minutes: 0 };
} }
return working; return working;
} }
@@ -489,14 +493,14 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
private getMidnightDate(tstp: number): Date { private getMidnightDate(tstp: number): Date {
let midnight = new Date(tstp); const midnight = new Date(tstp);
midnight.setHours(0, 0, 0, 0); midnight.setHours(0, 0, 0, 0);
return midnight; return midnight;
}; }
private getWorkingTime(beginMillis: number, endMillis: number): Time { private getWorkingTime(beginMillis: number, endMillis: number): Time {
const beginMinutes = Math.floor(beginMillis/1000/60); const beginMinutes = Math.floor(beginMillis / 1000 / 60);
const endMinutes = Math.floor(endMillis/1000/60); const endMinutes = Math.floor(endMillis / 1000 / 60);
const totalMinutes = endMinutes - beginMinutes; const totalMinutes = endMinutes - beginMinutes;
const totalHours = totalMinutes / 60; const totalHours = totalMinutes / 60;
@@ -511,18 +515,18 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
getWorkplaceName(place: Place): string { getWorkplaceName(place: Place): string {
return (place.nickname != null && place.nickname.length > 0)? place.nickname : place.address; return (place.nickname != null && place.nickname.length > 0) ? place.nickname : place.address;
} }
getWorkplaceString(data: TimeSheetData): string { getWorkplaceString(data: TimeSheetData): string {
let res = ''; let res = '';
if (data.placeId) { if (data.placeId) {
const place = this.workPlaces.find(place => place.id === data.placeId); const place = this.workPlaces.find(p => p.id === data.placeId);
res = this.getWorkplaceName(place); res = this.getWorkplaceName(place);
} else { } else {
data.placesSet.forEach(id => { data.placesSet.forEach(id => {
const place = this.workPlaces.find(place => place.id === id); const place = this.workPlaces.find(p => p.id === id);
res += this.getWorkplaceName(place) + ', ' res += this.getWorkplaceName(place) + ', ';
}); });
res = res.slice(0, res.length - 2); res = res.slice(0, res.length - 2);
} }
@@ -530,9 +534,9 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
getDate(data: TimeSheetData): string { getDate(data: TimeSheetData): string {
if (this.grouped == Grouping.RAW) { if (this.grouped === Grouping.RAW) {
let prefix = ''; let prefix = '';
let date = formatDate(data.endDate, 'dd.LL.yyyy', 'de'); const date = formatDate(data.endDate, 'dd.LL.yyyy', 'de');
if (data.overlappingDays) { if (data.overlappingDays) {
prefix = formatDate(data.beginDate, 'dd', 'de') + ' - '; prefix = formatDate(data.beginDate, 'dd', 'de') + ' - ';
} }
@@ -552,13 +556,13 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
exportStr = this.createJSON(); exportStr = this.createJSON();
break; break;
} }
if (!exportStr) return false; if (!exportStr) { return false; }
/* '\ufeff' -> UTF-8 Header Byte prepended. */ /* '\ufeff' -> UTF-8 Header Byte prepended. */
const blob = new Blob(['\ufeff', exportStr], { type: `text/${type};` }); const blob = new Blob(['\ufeff', exportStr], { type: `text/${type};` });
const login = this.userService.getLogin(); const login = this.userService.getLogin();
let name = 'timesheet-export'; let name = 'timesheet-export';
if (login != null) name += '-' + login; if (login != null) { name += '-' + login; }
name += '-' + Date.now(); name += '-' + Date.now();
this.saveAs(`${name}.${type}`, blob); this.saveAs(`${name}.${type}`, blob);
return true; return true;
@@ -580,8 +584,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
private createCSV(): string | null { private createCSV(): string | null {
if (this.data.length === 0) if (this.data.length === 0) { return null; }
return null;
let result = ''; let result = '';
result += 'DATE' + COLUMN_SEPARATOR; result += 'DATE' + COLUMN_SEPARATOR;
result += 'FROM' + COLUMN_SEPARATOR; result += 'FROM' + COLUMN_SEPARATOR;
@@ -609,7 +612,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
to: formatDate(td.endDate, 'H:mm', 'de'), to: formatDate(td.endDate, 'H:mm', 'de'),
workingTime: `${td.duration.hours} h ${td.duration.minutes} m`, workingTime: `${td.duration.hours} h ${td.duration.minutes} m`,
workplaces: this.getWorkplaceString(td) workplaces: this.getWorkplaceString(td)
} };
}) })
); );
} }
@@ -1,9 +1,12 @@
<div style="margin: 20px;"> <app-content-layout [layoutClass]="'table-page'">
<mat-toolbar> <app-content-header>
<mat-icon>devices</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('devices_title') }}</span> <mat-icon>devices</mat-icon>
</mat-toolbar> <span>{{ res.strings('devices_title') }}</span>
<div class="mat-elevation-z2"> </div>
</app-content-header>
<main class="mat-elevation-z2">
<ng-container *ngIf="loading.getValue()"> <ng-container *ngIf="loading.getValue()">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -65,6 +68,5 @@
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true"> <mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
</div> </main>
</app-content-layout>
</div>
+61 -63
View File
@@ -1,63 +1,61 @@
<ng-container> <app-content-layout>
<div style="flex: 1 1 100%;"> <app-content-header [headerClass]="'header-transparent'">
<mat-toolbar style="margin-top:20px;background:transparent"> <div class="header-title">
<mat-icon style="margin-left:20px;">cloud_download</mat-icon> <mat-icon>cloud_download</mat-icon>
<span style="margin-left: 10px">{{ res.strings('export_title') }}</span> <span>{{ res.strings('export_title') }}</span>
</mat-toolbar> </div>
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="450" class="grid-layout"> </app-content-header>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card"> <main class="flex-row-wrap justify-space-evenly">
<mat-card-title-group> <mat-card class="mat-typography user-card">
<mat-card-title>{{ res.strings('export_explain_title') }}</mat-card-title> <mat-card-title-group>
<mat-card-subtitle>{{ res.strings('export_explain_subtitle') }}</mat-card-subtitle> <mat-card-title>{{ res.strings('export_explain_title') }}</mat-card-title>
</mat-card-title-group> <mat-card-subtitle>{{ res.strings('export_explain_subtitle') }}</mat-card-subtitle>
<mat-card-content style="min-height:130px"> </mat-card-title-group>
<p class="mat-body">{{ res.strings('export_explain_content') }}</p> <mat-card-content>
<p class="mat-body">{{ res.strings('export_explain_process') }}</p> <p class="mat-body">{{ res.strings('export_explain_content') }}</p>
</mat-card-content> <p class="mat-body">{{ res.strings('export_explain_process') }}</p>
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center"> </mat-card-content>
<ng-container *ngIf="exportService.downloading | async; else exportButton"> <mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
<button mat-raised-button color="accent" (click)="exportService.stopDownload()"> <ng-container *ngIf="exportService.downloading | async; else exportButton">
<mat-icon class="icon-button">cancel</mat-icon> <button mat-raised-button color="accent" (click)="exportService.stopDownload()">
<span>{{ res.strings('button_cancel') }}</span> <mat-icon class="icon-button">cancel</mat-icon>
</button> <span>{{ res.strings('button_cancel') }}</span>
</ng-container> </button>
<ng-template #exportButton> </ng-container>
<button mat-raised-button color="primary" (click)="exportService.startDownload()"> <ng-template #exportButton>
<mat-icon class="icon-button">import_export</mat-icon> <button mat-raised-button color="primary" (click)="exportService.startDownload()">
<span>{{ res.strings('button_export') }}</span> <mat-icon class="icon-button">import_export</mat-icon>
</button> <span>{{ res.strings('button_export') }}</span>
</ng-template> </button>
</mat-card-actions> </ng-template>
</mat-card> </mat-card-actions>
</mat-grid-tile> </mat-card>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card"> <mat-card class="mat-typography user-card">
<mat-card-title-group> <mat-card-title-group>
<mat-card-title>{{ res.strings('export_download_title') }}</mat-card-title> <mat-card-title>{{ res.strings('export_download_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('export_download_subtitle') }}</mat-card-subtitle> <mat-card-subtitle>{{ res.strings('export_download_subtitle') }}</mat-card-subtitle>
</mat-card-title-group> </mat-card-title-group>
<mat-card-content> <mat-card-content>
<mat-list> <mat-list>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<mat-list-item> <mat-list-item>
<mat-label style="font-size:85%" matLine>{{ res.strings('export_devices') }}<div style="float: right;">{{ (exportService.devices | async)?.size }}</div></mat-label> <mat-label class="progress-label" matLine>{{ res.strings('export_devices') }}<div class="progress-float">{{ (exportService.devices | async)?.size }}</div></mat-label>
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.devices | async)" matLine></mat-progress-bar> <mat-progress-bar mode="determinate" [value]="progressValue(exportService.devices | async)" matLine></mat-progress-bar>
</mat-list-item> </mat-list-item>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<mat-list-item> <mat-list-item>
<mat-label style="font-size:85%" matLine>{{ res.strings('export_places') }}<div style="float: right;">{{ (exportService.places | async)?.size }}</div></mat-label> <mat-label class="progress-label" matLine>{{ res.strings('export_places') }}<div class="progress-float">{{ (exportService.places | async)?.size }}</div></mat-label>
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.places | async)" matLine></mat-progress-bar> <mat-progress-bar mode="determinate" [value]="progressValue(exportService.places | async)" matLine></mat-progress-bar>
</mat-list-item> </mat-list-item>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<mat-list-item> <mat-list-item>
<mat-label style="font-size:85%" matLine>{{ res.strings('export_visits') }}<div style="float: right;">{{ (exportService.visits | async)?.size }}</div></mat-label> <mat-label class="progress-label" matLine>{{ res.strings('export_visits') }}<div class="progress-float">{{ (exportService.visits | async)?.size }}</div></mat-label>
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.visits | async)" matLine></mat-progress-bar> <mat-progress-bar mode="determinate" [value]="progressValue(exportService.visits | async)" matLine></mat-progress-bar>
</mat-list-item> </mat-list-item>
</mat-list> </mat-list>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</mat-grid-tile> </main>
</mat-grid-list> </app-content-layout>
</div>
</ng-container>
@@ -12,7 +12,11 @@ import { Snackbars } from '../utils/snackbars';
@Component({ @Component({
selector: 'app-export', selector: 'app-export',
templateUrl: './export.component.html' templateUrl: './export.component.html',
styles: [
`.progress-label { font-size: 85% !important; }`,
`.progress-float { float: right; }`
]
}) })
export class ExportComponent implements OnInit, OnDestroy { export class ExportComponent implements OnInit, OnDestroy {
@@ -1,20 +1,32 @@
<mat-toolbar style="margin-top:20px;background:transparent"> <app-content-layout [layoutClass]="'table-page'">
<mat-icon style="margin-left:20px;">subject</mat-icon> <app-content-header>
<span style="margin-left: 10px">Logs</span> <div class="header-title">
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <mat-icon>subject</mat-icon>
<button mat-icon-button [matTooltip]="res.strings('manage_logs_connect_tooltip')" (click)="onConnect()" [disabled]="connected || (connecting | async)"> <span>Logs</span>
<mat-icon>play_circle_outline</mat-icon> </div>
<div class="header-actions">
<button mat-icon-button
[matTooltip]="res.strings('manage_logs_connect_tooltip')"
(click)="onConnect()"
[disabled]="connected || (connecting | async)">
<mat-icon>play_circle_outline</mat-icon>
</button> </button>
<button mat-icon-button [matTooltip]="res.strings('manage_logs_disconnect_tooltip')" (click)="onDisconnect()" [disabled]="!connected || (connecting | async)"> <button mat-icon-button
<mat-icon>pause_circle_outline</mat-icon> [matTooltip]="res.strings('manage_logs_disconnect_tooltip')"
(click)="onDisconnect()"
[disabled]="!connected || (connecting | async)">
<mat-icon>pause_circle_outline</mat-icon>
</button> </button>
<button mat-icon-button [matTooltip]="res.strings('manage_logs_clear_tooltip')" (click)="onClear()" [disabled]="(connecting | async)"> <button mat-icon-button
<mat-icon>not_interested</mat-icon> [matTooltip]="res.strings('manage_logs_clear_tooltip')"
(click)="onClear()"
[disabled]="(connecting | async)">
<mat-icon>not_interested</mat-icon>
</button> </button>
</div> </div>
</mat-toolbar> </app-content-header>
<div style="margin: 20px;">
<div class="mat-elevation-z2"> <main class="mat-elevation-z2">
<ng-container *ngIf="connecting | async"> <ng-container *ngIf="connecting | async">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -66,6 +78,5 @@
<mat-header-row *matHeaderRowDef="getColumns()"></mat-header-row> <mat-header-row *matHeaderRowDef="getColumns()"></mat-header-row>
<mat-row *matRowDef="let row; columns: getColumns();"></mat-row> <mat-row *matRowDef="let row; columns: getColumns();"></mat-row>
</mat-table> </mat-table>
</main>
</div> </app-content-layout>
</div>
@@ -1,15 +1,18 @@
<div style="margin: 20px;"> <app-content-layout [layoutClass]="'table-page'">
<mat-toolbar> <app-content-header>
<mat-icon>forum</mat-icon> <div class="header-title">
<span style="margin-left: 10px">Hinweise</span> <mat-icon>forum</mat-icon>
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <span>{{ res.strings('manage_notices_title') }}</span>
<app-language-select style="padding-top:5px;" [value]="language" (change)="language = $event"></app-language-select> </div>
<div class="header-actions flex-row-nowrap align-center">
<app-language-select [value]="language" (change)="language = $event"></app-language-select>
<button mat-icon-button matTooltip="Hinweis hinzufügen" routerLink="0" [disabled]="loading.getValue()"> <button mat-icon-button matTooltip="Hinweis hinzufügen" routerLink="0" [disabled]="loading.getValue()">
<mat-icon>add_circle_outline</mat-icon> <mat-icon>add_circle_outline</mat-icon>
</button> </button>
</div> </div>
</mat-toolbar> </app-content-header>
<div class="mat-elevation-z2">
<main class="mat-elevation-z2">
<ng-container *ngIf="loading.getValue()"> <ng-container *ngIf="loading.getValue()">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -90,6 +93,5 @@
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true"> <mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
</div> </main>
</app-content-layout>
</div>
@@ -1,29 +1,40 @@
<div style="margin: 20px;"> <app-content-layout [layoutClass]="'table-page'">
<mat-toolbar> <app-content-header>
<mat-icon>people</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('manage_users_title') }}</span> <mat-icon>people</mat-icon>
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <span>{{ res.strings('manage_users_title') }}</span>
<div style="padding-top:15px;"> </div>
<form #searchForm="ngForm" style="font-size: 12px"> <div class="header-actions flex-row-nowrap">
<mat-form-field style="max-width:120px"> <form #searchForm="ngForm" style="font-size: 12px">
<input matInput #termField="ngModel" maxlength="64" name="term" [placeholder]="res.strings('manage_users_term_placeholder')" [(ngModel)]="term" pattern="([A-Za-z]|[\u00C0-\u00FF]| ){0,64}" <mat-form-field style="max-width:120px">
[disabled]="loading.getValue()" (keyup.enter)="onSearch()"> <input matInput #termField="ngModel"
<mat-error *ngIf="termField.invalid"> maxlength="64" name="term"
<ng-container [ngSwitch]="encode(termField.errors)"> [placeholder]="res.strings('manage_users_term_placeholder')"
<ng-container *ngSwitchCase="FormErrorCode.REQUIRED">{{res.strings('manage_users_term_required')}}</ng-container> [(ngModel)]="term"
<ng-container *ngSwitchCase="FormErrorCode.PATTERN">{{res.strings('manage_users_term_pattern')}}</ng-container> pattern="([A-Za-z]|[\u00C0-\u00FF]| ){0,64}"
[disabled]="loading.getValue()" (keyup.enter)="onSearch()">
<mat-error *ngIf="termField.invalid">
<ng-container [ngSwitch]="encode(termField.errors)">
<ng-container *ngSwitchCase="FormErrorCode.REQUIRED">
{{res.strings('manage_users_term_required')}}
</ng-container> </ng-container>
</mat-error> <ng-container *ngSwitchCase="FormErrorCode.PATTERN">
</mat-form-field> {{res.strings('manage_users_term_pattern')}}
</form> </ng-container>
</div> </ng-container>
<button mat-icon-button [matTooltip]="res.strings('manage_users_search_tooltip')" (click)="onSearch()" [disabled]="loading.getValue()"> </mat-error>
</mat-form-field>
</form>
<button mat-icon-button
[matTooltip]="res.strings('manage_users_search_tooltip')"
(click)="onSearch()"
[disabled]="loading.getValue()">
<mat-icon>search</mat-icon> <mat-icon>search</mat-icon>
</button> </button>
</div> </div>
</app-content-header>
</mat-toolbar> <main class="mat-elevation-z2">
<div class="mat-elevation-z2">
<ng-container *ngIf="loading.getValue()"> <ng-container *ngIf="loading.getValue()">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -112,6 +123,5 @@
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true"> <mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
</div> </main>
</app-content-layout>
</div>
@@ -4,21 +4,24 @@
</div> </div>
</ng-container> </ng-container>
<ng-template #content> <ng-template #content>
<div style="flex: 1 1 100%;"> <app-content-layout>
<mat-toolbar style="margin-top:20px;background:transparent"> <app-content-header [headerClass]="'header-transparent'">
<mat-icon style="margin-left:20px">message</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('notices_title') }}</span> <mat-icon>message</mat-icon>
</mat-toolbar> <span>{{ res.strings('notices_title') }}</span>
<div> </div>
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="480" class="grid-layout"> </app-content-header>
<ng-container *ngFor="let n of page.getValue().elements">
<ng-container *ngIf="canShow(n, getLanguage())"> <main class="flex-row-wrap justify-space-evenly">
<mat-grid-tile colspan="1" rowspan="1"> <ng-container *ngFor="let n of page.getValue().elements">
<app-notice-card [language]="getLanguage()" [notice]="n" class="notice-card"></app-notice-card> <ng-container *ngIf="canShow(n, getLanguage())">
</mat-grid-tile> <app-notice-card
</ng-container> [language]="getLanguage()"
[notice]="n"
class="flex-notice-card">
</app-notice-card>
</ng-container> </ng-container>
</mat-grid-list> </ng-container>
</div> </main>
</div> </app-content-layout>
</ng-template> </ng-template>
+21 -16
View File
@@ -1,20 +1,26 @@
<div style="margin: 20px;"> <app-content-layout [layoutClass]="'table-page'">
<mat-toolbar> <app-content-header>
<mat-icon>pie_chart_outlined</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('places_title') }}</span> <mat-icon>pie_chart_outlined</mat-icon>
<div style="padding-top:20px;" flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <span>{{ res.strings('places_title') }}</span>
<form style="font-size: 12px;" fxLayoutAlign="center center" flexLayout="row"> </div>
<mat-form-field fxFlex="1 1 180px">
<mat-select [placeholder]="res.strings('places_order_placeholder')" [value]="order.getValue()" (selectionChange)="order.next($event.source.value)"> <div class="header-actions">
<mat-option *ngFor="let o of getOrders()" [value]="o"> <form style="font-size: 12px;">
<span>{{ getOrderName(o) }}</span> <mat-form-field>
</mat-option> <mat-select [placeholder]="res.strings('places_order_placeholder')"
[value]="order.getValue()"
(selectionChange)="order.next($event.source.value)">
<mat-option *ngFor="let o of getOrders()" [value]="o">
<span>{{ getOrderName(o) }}</span>
</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
</mat-toolbar> </app-content-header>
<div class="mat-elevation-z2">
<main class="mat-elevation-z2">
<ng-container *ngIf="loading.getValue() || deleting.getValue()"> <ng-container *ngIf="loading.getValue() || deleting.getValue()">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -72,6 +78,5 @@
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true"> <mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
</div> </main>
</app-content-layout>
</div>
@@ -1,15 +1,20 @@
<div style="margin: 20px;"> <app-content-layout [layoutClass]="'table-page'">
<mat-toolbar> <app-content-header>
<mat-icon>share</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('privileges_title') }}</span> <mat-icon>share</mat-icon>
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <span>{{ res.strings('privileges_title') }}</span>
<button mat-icon-button [matTooltip]="res.strings('privileges_add_tooltip')" (click)="onAdd()" [disabled]="loading.getValue() || deleting.getValue()"> </div>
<mat-icon>add_circle_outline</mat-icon> <div class="header-actions">
<button mat-icon-button
[matTooltip]="res.strings('privileges_add_tooltip')"
(click)="onAdd()"
[disabled]="loading.getValue() || deleting.getValue()">
<mat-icon>add_circle_outline</mat-icon>
</button> </button>
</div> </div>
</app-content-header>
</mat-toolbar> <main class="mat-elevation-z2">
<div class="mat-elevation-z2">
<ng-container *ngIf="loading.getValue() || deleting.getValue()"> <ng-container *ngIf="loading.getValue() || deleting.getValue()">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
</ng-container> </ng-container>
@@ -68,6 +73,5 @@
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true"> <mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
</mat-paginator> </mat-paginator>
</div> </main>
</app-content-layout>
</div>
@@ -1,15 +1,22 @@
<ng-container> <app-content-layout>
<mat-toolbar style="display: flex; background:transparent;"> <app-content-header [headerClass]="'header-transparent'">
<mat-icon style="margin-left: 5px;">access_time_icon</mat-icon> <div class="header-title">
<span style="margin-left: 10px">{{ res.strings('time_sheet_title') }}</span> <mat-icon>access_time_icon</mat-icon>
<span>{{ res.strings('time_sheet_title') }}</span>
</div>
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px"> <div class="header-actions">
<button mat-icon-button <button mat-icon-button
[matTooltip]="res.strings('time_sheet_update_btn_tooltip')" [matTooltip]="res.strings('time_sheet_update_btn_tooltip')"
(click)="updateTimeSheetTable()"> (click)="updateTimeSheetTable()">
<mat-icon style="font-size: 18px;">update_icon</mat-icon> <mat-icon>update_icon</mat-icon>
</button> </button>
<button mat-icon-button
[matMenuTriggerFor]="exportMenu"
[matTooltip]="res.strings('time_sheet_export_btn_tooltip')">
<mat-icon>import_export</mat-icon>
</button>
<mat-menu #exportMenu="matMenu" class="mat-elevation-z1"> <mat-menu #exportMenu="matMenu" class="mat-elevation-z1">
<ng-template matMenuContent> <ng-template matMenuContent>
<button mat-menu-item <button mat-menu-item
@@ -24,20 +31,16 @@
</button> </button>
</ng-template> </ng-template>
</mat-menu> </mat-menu>
<button mat-icon-button
[matMenuTriggerFor]="exportMenu"
[matTooltip]="res.strings('time_sheet_export_btn_tooltip')">
<mat-icon >import_export</mat-icon>
</button>
</div> </div>
</mat-toolbar> </app-content-header>
<!-- Configuration Side Panel --> <!-- Configuration Side Panel -->
<div class="timesheet-container"> <aside>
<div class="timesheet-config"> <mat-list>
<mat-list class="config-col"> <mat-list-item class="flex-vrt-center">
<h3 mat-subheader class="flex-center">{{ res.strings('time_sheet_config_label') }}</h3> <h3 mat-subheader>{{ res.strings('time_sheet_config_label') }}</h3>
<mat-list-item class="flex-center toggle-btn"> </mat-list-item>
<mat-list-item class="flex-vrt-center">
<mat-button-toggle-group <mat-button-toggle-group
[(value)]="timeSheetService.grouped" [(value)]="timeSheetService.grouped"
name="groupingChoice" name="groupingChoice"
@@ -52,114 +55,119 @@
{{ res.strings('time_sheet_toggle_raw_label') }}</mat-button-toggle> {{ res.strings('time_sheet_toggle_raw_label') }}</mat-button-toggle>
</mat-button-toggle-group> </mat-button-toggle-group>
</mat-list-item> </mat-list-item>
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_select_device_tooltip')"> <mat-list-item class="vrt-margin">
<mat-label>{{ res.strings('time_sheet_select_device_label') }}</mat-label> <mat-form-field class="hrz-margin" [matTooltip]="res.strings('time_sheet_select_device_tooltip')">
<mat-select <mat-label>{{ res.strings('time_sheet_select_device_label') }}</mat-label>
[(value)]="timeSheetService.device"> <mat-select
<mat-option [value]="null">{{ res.strings('time_sheet_no_device_selected') }}</mat-option> [(value)]="timeSheetService.device">
<ng-container *ngIf="devices"> <mat-option [value]="null">{{ res.strings('time_sheet_no_device_selected') }}</mat-option>
<mat-option *ngFor="let device of devices" [value]="device"> <ng-container *ngIf="devices">
{{ device.model }} <mat-option *ngFor="let device of devices" [value]="device">
</mat-option> {{ device.model }}
</ng-container> </mat-option>
</mat-select> </ng-container>
</mat-form-field> </mat-select>
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_break_time_tooltip')"> </mat-form-field>
<mat-label>{{ res.strings('time_sheet_break_time_label') }}</mat-label> </mat-list-item>
<mat-select <mat-list-item class="vrt-margin">
[(value)]="timeSheetService.breakTime" <mat-form-field class="hrz-margin" [matTooltip]="res.strings('time_sheet_break_time_tooltip')">
[disabled]="timeSheetService.grouped > 2"> <mat-label>{{ res.strings('time_sheet_break_time_label') }}</mat-label>
<mat-option [value]="null">{{ res.strings('time_sheet_no_break_time_selected') }}</mat-option> <mat-select
<mat-option *ngFor="let opt of breakTimeOptions" [value]="opt"> [(value)]="timeSheetService.breakTime"
{{ opt + ' ' + res.strings('time_sheet_break_time_minutes') }} [disabled]="timeSheetService.grouped > 2">
</mat-option> <mat-option [value]="null">{{ res.strings('time_sheet_no_break_time_selected') }}</mat-option>
</mat-select> <mat-option *ngFor="let opt of breakTimeOptions" [value]="opt">
</mat-form-field> {{ opt + ' ' + res.strings('time_sheet_break_time_minutes') }}
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_time_period_tooltip')"> </mat-option>
<input matInput </mat-select>
[placeholder]="res.strings('time_sheet_time_period_label')" </mat-form-field>
[satDatepicker]="picker" </mat-list-item>
[value]="timeSheetService.dateRange" <mat-list-item class="vrt-margin">
(dateChange)="timeSheetService.dateRange = $event.target.value"> <mat-form-field class="hrz-margin" [matTooltip]="res.strings('time_sheet_time_period_tooltip')">
<sat-datepicker #picker [rangeMode]="true" orderPeriodLabel="month"></sat-datepicker> <input matInput
<sat-datepicker-toggle matSuffix [for]="picker"></sat-datepicker-toggle> [placeholder]="res.strings('time_sheet_time_period_label')"
</mat-form-field> [satDatepicker]="picker"
</mat-list> [value]="timeSheetService.dateRange"
(dateChange)="timeSheetService.dateRange = $event.target.value">
<sat-datepicker #picker [rangeMode]="true" orderPeriodLabel="month"></sat-datepicker>
<sat-datepicker-toggle matSuffix [for]="picker"></sat-datepicker-toggle>
</mat-form-field>
</mat-list-item>
<mat-divider class="divider"></mat-divider> <mat-divider class="divider"></mat-divider>
<mat-list class="config-col"> <mat-list-item class="flex-vrt-center">
<button mat-subheader mat-button class="config-item" (click)="openWorkPlacesDialog()"> <button mat-subheader mat-button (click)="openWorkPlacesDialog()">
<mat-icon class="icon-button">list_icon</mat-icon> <mat-icon class="icon-button">list_icon</mat-icon>
<span>{{ res.strings('time_sheet_workplace_button') }}</span> <span>{{ res.strings('time_sheet_workplace_button') }}</span>
</button> </button>
</mat-list-item>
<ng-container *ngIf="workPlaces.length > 0"> <ng-container *ngIf="workPlaces.length > 0">
<mat-divider class="divider"></mat-divider> <mat-divider class="divider"></mat-divider>
<div class="config-item" *ngFor="let workPlace of workPlaces"> <mat-list-item class="hrz-margin" *ngFor="let workPlace of workPlaces">
<button mat-icon-button (click)="deleteWorkPlaceEntry(workPlace)"> <button mat-icon-button (click)="deleteWorkPlaceEntry(workPlace)">
<mat-icon class="icon-button">clear_icon</mat-icon> <mat-icon class="icon-button">clear_icon</mat-icon>
</button> </button>
<span fxLayoutAlign="center" fxFlex="1 1 auto">{{ getWorkplaceName(workPlace) }}</span> <span>{{ getWorkplaceName(workPlace) }}</span>
</div> </mat-list-item>
<mat-divider class="divider"></mat-divider> <mat-divider class="divider"></mat-divider>
<button mat-button style="margin-bottom: 10px;" (click)="clearWorkPlaceList()" color="primary"> <mat-list-item>
<mat-icon class="icon-button" style="margin-left: 12px">delete_icon</mat-icon> <button mat-button style="margin-bottom: 10px;" (click)="clearWorkPlaceList()" color="primary">
<span>{{ res.strings('time_sheet_workplace_clear_list') }}</span> <mat-icon class="icon-button" style="margin-left: 12px">delete_icon</mat-icon>
</button> <span>{{ res.strings('time_sheet_workplace_clear_list') }}</span>
</button>
</mat-list-item>
</ng-container> </ng-container>
</mat-list> </mat-list>
</div> </aside>
<!-- Table Content --> <!-- Table Content -->
<ng-container *ngIf="false"> <main class="mat-elevation-z2">
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar> <ng-container *ngIf="false">
</ng-container> <mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
<mat-card class="main-content mat-elevation-z2"> </ng-container>
<mat-card-content> <table mat-table #timeSheet class="main-table" [dataSource]="timeSheetDataSource">
<table mat-table #timeSheet class="main-table" [dataSource]="timeSheetDataSource">
<ng-container matColumnDef="date"> <ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_date') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_date') }}</th>
<td mat-cell *matCellDef="let data">{{ getDate(data) }}</td> <td mat-cell *matCellDef="let data">{{ getDate(data) }}</td>
</ng-container> </ng-container>
<ng-container matColumnDef="from-time"> <ng-container matColumnDef="from-time">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_from') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_from') }}</th>
<td mat-cell *matCellDef="let data"> <td mat-cell *matCellDef="let data">
{{ data.beginDate | date:'H:mm' }} {{ data.beginDate | date:'H:mm' }}
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="to-time"> <ng-container matColumnDef="to-time">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_to') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_to') }}</th>
<td mat-cell *matCellDef="let data"> <td mat-cell *matCellDef="let data">
{{ data.endDate | date:'H:mm' }} {{ data.endDate | date:'H:mm' }}
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="time"> <ng-container matColumnDef="time">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_working_time') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_working_time') }}</th>
<td mat-cell *matCellDef="let data">{{ getWorkingTime(data.duration) }}</td> <td mat-cell *matCellDef="let data">{{ getWorkingTime(data.duration) }}</td>
</ng-container> </ng-container>
<ng-container matColumnDef="place"> <ng-container matColumnDef="place">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_place') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_place') }}</th>
<td mat-cell *matCellDef="let data">{{ getWorkplaceString(data) }}</td> <td mat-cell *matCellDef="let data">{{ getWorkplaceString(data) }}</td>
</ng-container> </ng-container>
<ng-container matColumnDef="device"> <ng-container matColumnDef="device">
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_device') }}</th> <th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_device') }}</th>
<td mat-cell *matCellDef="let data">{{ getDeviceNameString(data) }}</td> <td mat-cell *matCellDef="let data">{{ getDeviceNameString(data) }}</td>
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="showTimeSheetRowInfo(row)"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="showTimeSheetRowInfo(row)"></tr>
</table> </table>
<mat-paginator #paginator [pageSizeOptions]="[10, 20, 50, 100]" showFirstLastButtons></mat-paginator> <mat-paginator #paginator [pageSizeOptions]="[10, 20, 50, 100]" showFirstLastButtons></mat-paginator>
</mat-card-content> </main>
</mat-card> </app-content-layout>
</div>
</ng-container>
@@ -1,70 +1,62 @@
import { Component, OnInit, HostListener, ViewChild, OnDestroy, AfterViewInit } from '@angular/core'; import { Component, OnInit, HostListener, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { Time, formatDate } from '@angular/common'; import { Time, formatDate } from '@angular/common';
import { MatPaginator } from "@angular/material/paginator"; import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from '@angular/material/table';
import { MatDialog } from "@angular/material/dialog"; import { MatDialog } from '@angular/material/dialog';
import { Subscription } from "rxjs"; import { Subscription } from 'rxjs';
import { ResourceService } from "../services/resource.service"; import { ResourceService } from '../services/resource.service';
import { DeviceService } from "../services/device.service"; import { DeviceService } from '../services/device.service';
import { TimeSheetService, TimeSheetData, Grouping } from '../services/time-sheet.service'; import { TimeSheetService, TimeSheetData, Grouping } from '../services/time-sheet.service';
import { PlacesDialogComponent } from "../widgets/places-dialog.component"; import { PlacesDialogComponent } from '../widgets/places-dialog.component';
import { Device, Place } from '../../api/models'; import { Device, Place } from '../../api/models';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
/** /**
* A view that offers the functionality to generate a timesheet by filtering on the * A view that offers the functionality to generate a timesheet by filtering on the
* time period and the places a device has been. * time period and the places a device has been.
* It offers three modes: * It offers three modes:
* 1. Default -> Shows the time entries per day processed in terms of legal working requirements. * 1. Default -> Shows the time entries per day processed in terms of legal working requirements.
* It also offers the functionality of defining a filter at which point the * It also offers the functionality of defining a filter at which point the
* absence from a defined "working place" should be booked as a break. * absence from a defined "working place" should be booked as a break.
* 2. Summed -> Shows the time entries per day without any processing at all. * 2. Summed -> Shows the time entries per day without any processing at all.
* 3. By Day -> Shows every single time entry. Due to that a single day can occure frequently. * 3. By Day -> Shows every single time entry. Due to that a single day can occure frequently.
*
* @author Adriano
*/ */
@Component({ @Component({
selector: 'app-time-sheet', selector: 'app-time-sheet',
templateUrl: './time-sheet.component.html', templateUrl: './time-sheet.component.html',
styles: [ styles: [
`.flex-center { display: flex; flex: 1 1 auto; justify-content: center; }`, `mat-list .hrz-margin { width: 100%; margin-left: 32px; margin-right: 32px; }`,
`.divider { margin: 16px; }`, `mat-list .vrt-margin { margin-top: 20px; margin-bottom: 20px; }`,
`.timesheet-container { `mat-list .divider { margin: 16px; }`,
display: flex; `.main-table { width: 100%; }`,
flex-flow: row-reverse wrap; `.main-table .mat-column-date { width: 16% !important; }`,
justify-content: center; `.main-table .mat-column-to-time, .mat-column-from-time { width: 7% !important; }`,
align-items: flex-start; `.main-table .mat-column-time { width: 10% !important; }`,
}`, `.main-table .mat-column-device { width: 20% !important; }`,
`.timesheet-config { width: 350px; max-width: 350px; }`, `.main-table .mat-column-place { width: 40% !important; }`
`.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 { export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
private static readonly LAYOUT_BREAKPOINT = 960; private static readonly LAYOUT_BREAKPOINT = 960;
readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150, 180];
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
compact = false;
static readonly normalDisplayCol = ['date', 'from-time', 'to-time', 'time', 'device', 'place']; static readonly normalDisplayCol = ['date', 'from-time', 'to-time', 'time', 'device', 'place'];
static readonly compactDisplayCol = ['date', 'time']; static readonly compactDisplayCol = ['date', 'time'];
readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150, 180];
@ViewChild(MatPaginator) paginator: MatPaginator;
compact = false;
displayedColumns = TimeSheetComponent.normalDisplayCol; displayedColumns = TimeSheetComponent.normalDisplayCol;
workPlaces: Place[]; workPlaces: Place[];
devices: Device[]; devices: Device[];
timeSheetDataSource: MatTableDataSource<TimeSheetData>; timeSheetDataSource: MatTableDataSource<TimeSheetData>;
private subscriptions: Subscription; private subscriptions: Subscription;
constructor( constructor(
@@ -84,7 +76,7 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
this.deviceService.reload(); this.deviceService.reload();
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.timeSheetService.setup(this.paginator); this.timeSheetService.setup(this.paginator);
} }
@@ -101,20 +93,22 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
} }
updateTimeSheetTable(): void { updateTimeSheetTable(): void {
if (!this.timeSheetService.fetching$.getValue()) if (!this.timeSheetService.fetching$.getValue()) {
this.timeSheetService.fetchData(); this.timeSheetService.fetchData();
}
} }
exportTimeSheet(type: string): void { exportTimeSheet(type: string): void {
if (!this.timeSheetService.exportTimeSheet(type)) if (!this.timeSheetService.exportTimeSheet(type)) {
this.openMessageDialog( this.openMessageDialog(
this.res.strings('time_sheet_export_error_msg_title'), this.res.strings('time_sheet_export_error_msg_title'),
this.res.strings('time_sheet_export_error_msg') this.res.strings('time_sheet_export_error_msg')
); );
}
} }
showTimeSheetRowInfo(data: TimeSheetData): void { showTimeSheetRowInfo(data: TimeSheetData): void {
if (!this.compact) return; if (!this.compact) { return; }
const res_values = [ const res_values = [
'time_sheet_table_date', 'time_sheet_table_from', 'time_sheet_table_to', 'time_sheet_table_date', 'time_sheet_table_from', 'time_sheet_table_to',
@@ -123,10 +117,10 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
const data_values = [ const data_values = [
`${this.getDate(data)}`, `${formatDate(data.beginDate, 'H:mm', 'de')}`, `${this.getDate(data)}`, `${formatDate(data.beginDate, 'H:mm', 'de')}`,
`${formatDate(data.endDate, 'H:mm', 'de')}`, `${this.getWorkingTime(data.duration)}`, `${formatDate(data.endDate, 'H:mm', 'de')}`, `${this.getWorkingTime(data.duration)}`,
`${this.getWorkplaceString(data)}`,`${this.getWorkplaceString(data)}` `${this.getWorkplaceString(data)}`, `${this.getWorkplaceString(data)}`
]; ];
let msg = ''; let msg = '';
res_values.forEach((val: string, idx: number, _) => msg += `${this.res.strings(val)}: ${data_values[idx]}; `) res_values.forEach((val: string, idx: number, _) => msg += `${this.res.strings(val)}: ${data_values[idx]}; `);
this.openMessageDialog(this.res.strings('time_sheet_table_row_dialog_title'), msg.slice(0, msg.length - 2)); this.openMessageDialog(this.res.strings('time_sheet_table_row_dialog_title'), msg.slice(0, msg.length - 2));
} }
@@ -150,12 +144,12 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
getDeviceNameString(data: TimeSheetData): string { getDeviceNameString(data: TimeSheetData): string {
let res = ''; let res = '';
if (data.deviceId) { if (data.deviceId) {
const device = this.devices.find(device => device.id === data.deviceId); const device = this.devices.find(d => d.id === data.deviceId);
res = device.model; res = device.model;
} else { } else {
data.devicesSet.forEach(id => { data.devicesSet.forEach(id => {
const device = this.devices.find(place => place.id === id); const device = this.devices.find(place => place.id === id);
res += device.model + '; ' res += device.model + '; ';
}); });
res = res.slice(0, res.length - 2); res = res.slice(0, res.length - 2);
} }
@@ -164,9 +158,9 @@ export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
getWorkingTime(time: Time): string { getWorkingTime(time: Time): string {
let res = ''; let res = '';
if (time.hours != 0) res += String(time.hours) + ' h '; if (time.hours !== 0) { res += String(time.hours) + ' h '; }
if (time.minutes != 0) res += String(time.minutes) + ' m'; if (time.minutes !== 0) { res += String(time.minutes) + ' m'; }
if (res === '') res = '-'; if (res === '') { res = '-'; }
return res; return res;
} }
+107 -112
View File
@@ -1,116 +1,111 @@
<ng-container *ngIf="idle | async;else progressBar"> <app-content-layout *ngIf="idle | async;else progressBar">
<div *ngIf="user | async as u;else progressBar" style="flex: 1 1 100%;"> <app-content-header [headerClass]="'header-transparent'">
<mat-toolbar style="margin-top:20px;background:transparent"> <div class="header-title">
<mat-icon style="margin-left:20px;">perm_identity</mat-icon> <mat-icon>perm_identity</mat-icon>
<span style="margin-left: 10px">{{ res.strings('user_title') }}</span> <span>{{ res.strings('user_title') }}</span>
</mat-toolbar> </div>
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="350" class="grid-layout"> </app-content-header>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card"> <main *ngIf="user | async as u;else progressBar" class="flex-row-wrap justify-space-evenly">
<mat-card-title-group> <mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_change_title') }}</mat-card-title> <mat-card-title-group>
<mat-card-subtitle>{{ res.strings('user_change_subtitle') }}</mat-card-subtitle> <mat-card-title>{{ res.strings('user_change_title') }}</mat-card-title>
</mat-card-title-group> <mat-card-subtitle>{{ res.strings('user_change_subtitle') }}</mat-card-subtitle>
<mat-card-content> </mat-card-title-group>
<form #userForm="ngForm"> <mat-card-content>
<app-name-field [name]="u.name" (keyup.enter)="userForm.valid && onChangeUser()"></app-name-field> <form #userForm="ngForm">
<mat-form-field style="width: 100%;"> <app-name-field [name]="u.name" (keyup.enter)="userForm.valid && onChangeUser()"></app-name-field>
<mat-select [placeholder]="res.strings('user_change_primary')" name="email" [(ngModel)]="correspondence" style="width: 100%;"> <mat-form-field style="width: 100%;">
<mat-select-trigger> <mat-select [placeholder]="res.strings('user_change_primary')" name="email" [(ngModel)]="correspondence" style="width: 100%;">
{{ correspondence.address }} <mat-select-trigger>
</mat-select-trigger> {{ correspondence.address }}
<ng-container *ngFor="let email of emails"> </mat-select-trigger>
<mat-option [value]="email" [disabled]="!email.verified"> <ng-container *ngFor="let email of emails">
<mat-icon class="icon-button">{{ email.verified?"mail":"send" }}</mat-icon>{{email.address}} <mat-option [value]="email" [disabled]="!email.verified">
</mat-option> <mat-icon class="icon-button">{{ email.verified?"mail":"send" }}</mat-icon>{{email.address}}
</ng-container> </mat-option>
</mat-select>
</mat-form-field>
</form>
</mat-card-content>
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
<button #loginButton mat-raised-button color="primary" [disabled]="userForm.pristine || userForm.invalid" (click)="onChangeUser()">
<mat-icon class="icon-button">save</mat-icon>
<span>{{ res.strings('button_save') }}</span>
</button>
</mat-card-actions>
</mat-card>
</mat-grid-tile>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_password_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_password_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<form #passwordForm="ngForm">
<app-password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></app-password-field>
<app-password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="passwordForm.valid && onChangePassword()"></app-password-field>
</form>
</mat-card-content>
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
<button mat-raised-button color="primary" (click)="onChangePassword()" [disabled]="passwordForm.pristine || passwordForm.invalid">
<mat-icon class="icon-button">lock_outline</mat-icon>
<span>{{ res.strings('button_change') }}</span>
</button>
</mat-card-actions>
</mat-card>
</mat-grid-tile>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_add_email_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_add_email_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<form #emailForm="ngForm">
<app-email-field (keyup.enter)="emailForm.valid && onAddEmail()"></app-email-field>
</form>
<div style="height:70px"></div>
</mat-card-content>
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
<button mat-raised-button color="primary" (click)="onAddEmail()" [disabled]="emailForm.pristine || emailForm.invalid">
<mat-icon class="icon-button">add</mat-icon>
<span>{{ res.strings('button_add') }}</span>
</button>
</mat-card-actions>
</mat-card>
</mat-grid-tile>
<mat-grid-tile>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_del_email_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_del_email_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<mat-list class="mat-typography">
<ng-container *ngFor="let e of emails">
<ng-container *ngIf="!e.correspondence">
<mat-list-item>
<button mat-icon-button [matTooltip]="res.strings('user_del_email_tooltip')" (click)="onDeleteEmail(e.id)">
<mat-icon>delete</mat-icon>
</button>{{ e.address }}</mat-list-item>
</ng-container>
</ng-container> </ng-container>
</mat-list> </mat-select>
</mat-card-content> </mat-form-field>
</mat-card> </form>
</mat-grid-tile> </mat-card-content>
<mat-grid-tile> <mat-card-actions class="flex-vrt-center">
<mat-card class="mat-typography" class="user-card"> <button #loginButton mat-raised-button color="primary" [disabled]="userForm.pristine || userForm.invalid" (click)="onChangeUser()">
<mat-card-title>{{ res.strings('user_delete_title') }}</mat-card-title> <mat-icon class="icon-button">save</mat-icon>
<mat-card-subtitle>{{ res.strings('user_delete_subtitle') }}</mat-card-subtitle> <span>{{ res.strings('button_save') }}</span>
<mat-card-content class="caption" style="flex:1"> </button>
<form #deleteForm="ngForm"> </mat-card-actions>
<app-password-field #deletePassword name="deletePassword" [label]="res.strings('user_delete_password')" [hint]="res.strings('user_delete_password_hint')" (keyup.enter)="deleteForm.valid && onDeleteUser()"></app-password-field> </mat-card>
</form>
<div style="height:70px"></div> <mat-card class="mat-typography" class="user-card">
</mat-card-content> <mat-card-title>{{ res.strings('user_password_title') }}</mat-card-title>
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center"> <mat-card-subtitle>{{ res.strings('user_password_subtitle') }}</mat-card-subtitle>
<button mat-raised-button color="primary" (click)="onDeleteUser()" [disabled]="deleteForm.pristine || deleteForm.invalid"> <mat-card-content class="caption" style="flex:1">
<mat-icon class="icon-button">delete</mat-icon> <form #passwordForm="ngForm">
<span>{{ res.strings('button_delete') }}</span> <app-password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></app-password-field>
</button> <app-password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="passwordForm.valid && onChangePassword()"></app-password-field>
</mat-card-actions> </form>
</mat-card> </mat-card-content>
</mat-grid-tile> <mat-card-actions class="flex-vrt-center">
</mat-grid-list> <button mat-raised-button color="primary" (click)="onChangePassword()" [disabled]="passwordForm.pristine || passwordForm.invalid">
</div> <mat-icon class="icon-button">lock_outline</mat-icon>
</ng-container> <span>{{ res.strings('button_change') }}</span>
</button>
</mat-card-actions>
</mat-card>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_add_email_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_add_email_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<form #emailForm="ngForm">
<app-email-field (keyup.enter)="emailForm.valid && onAddEmail()"></app-email-field>
</form>
<div style="height:70px"></div>
</mat-card-content>
<mat-card-actions class="flex-vrt-center">
<button mat-raised-button color="primary" (click)="onAddEmail()" [disabled]="emailForm.pristine || emailForm.invalid">
<mat-icon class="icon-button">add</mat-icon>
<span>{{ res.strings('button_add') }}</span>
</button>
</mat-card-actions>
</mat-card>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_del_email_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_del_email_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<mat-list class="mat-typography">
<ng-container *ngFor="let e of emails">
<ng-container *ngIf="!e.correspondence">
<mat-list-item>
<button mat-icon-button [matTooltip]="res.strings('user_del_email_tooltip')" (click)="onDeleteEmail(e.id)">
<mat-icon>delete</mat-icon>
</button>{{ e.address }}</mat-list-item>
</ng-container>
</ng-container>
</mat-list>
</mat-card-content>
</mat-card>
<mat-card class="mat-typography" class="user-card">
<mat-card-title>{{ res.strings('user_delete_title') }}</mat-card-title>
<mat-card-subtitle>{{ res.strings('user_delete_subtitle') }}</mat-card-subtitle>
<mat-card-content class="caption" style="flex:1">
<form #deleteForm="ngForm">
<app-password-field #deletePassword name="deletePassword" [label]="res.strings('user_delete_password')" [hint]="res.strings('user_delete_password_hint')" (keyup.enter)="deleteForm.valid && onDeleteUser()"></app-password-field>
</form>
<div style="height:70px"></div>
</mat-card-content>
<mat-card-actions class="flex-vrt-center">
<button mat-raised-button color="primary" (click)="onDeleteUser()" [disabled]="deleteForm.pristine || deleteForm.invalid">
<mat-icon class="icon-button">delete</mat-icon>
<span>{{ res.strings('button_delete') }}</span>
</button>
</mat-card-actions>
</mat-card>
</main>
</app-content-layout>
<ng-template #progressBar> <ng-template #progressBar>
<div fxFlexFill fxLayoutAlign="space-around center"> <div fxFlexFill fxLayoutAlign="space-around center">
<mat-spinner [diameter]="100"></mat-spinner> <mat-spinner [diameter]="100"></mat-spinner>
+127 -19
View File
@@ -145,10 +145,10 @@ mat-form-field {
} }
.notice-card { .notice-card {
position:relative; position: relative;
padding: 10px; padding: 10px;
width: 100%; max-width: 100%;
height: 100%; max-height: 100%;
} }
.notice-card-element { .notice-card-element {
@@ -179,20 +179,11 @@ mat-form-field {
} }
.user-card { .user-card {
flex:1;
max-width:500px;
min-height:280px;
margin:10px;
}
// TODO: Check if needed
.time-sheet-card {
flex: 1; flex: 1;
// max-width:1280px; flex-basis: 400px;
// min-height:580px; max-width: 500px;
width: 80%; min-height: 280px;
height: 85%; margin: 10px;
margin: 2px;
} }
// fab position on marker map // fab position on marker map
@@ -215,6 +206,123 @@ mat-form-field {
white-space: normal; white-space: normal;
} }
.flex-spacer {
flex-grow: 1; // Basic layout styles
} .table-page { margin: 10px; }
.header-transparent { background-color: transparent !important; }
.flex-spacer { flex-grow: 1; }
.flex {
display: flex !important;
&-row {
@extend .flex;
flex-direction: row !important;
&-wrap {
@extend .flex-row;
flex-wrap: wrap !important;
}
&-nowrap {
@extend .flex-row;
flex-wrap: nowrap !important;
}
}
&-row-reverse {
@extend .flex;
flex-direction: row-reverse !important;
&-wrap {
@extend .flex-row-reverse;
flex-wrap: wrap !important;
}
&-nowrap {
@extend .flex-row;
flex-wrap: nowrap !important;
}
}
&-col {
@extend .flex;
flex-direction: column !important;
&-wrap {
@extend .flex-col;
flex-wrap: wrap !important;
}
&-nowrap {
@extend .flex-col;
flex-wrap: nowrap !important;
}
}
}
.justify-space-evenly { justify-content: space-evenly !important; }
.justify-space-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }
.flex-vrt-center {
@extend .flex-col-nowrap;
@extend .align-center;
}
.flex-notice-card {
@extend .flex;
flex: 1 1 400px !important;
max-height: 30% !important;
padding: 8px !important;
}
$cont-padding: 8px;
app-content-layout {
div.outer-container {
@extend .flex;
@extend .flex-col-nowrap;
justify-content: flex-start;
overflow: hidden;
app-content-header {
padding-top: $cont-padding;
padding-right: $cont-padding;
padding-left: $cont-padding;
}
div.inner-container {
@extend .flex;
@extend .flex-row-reverse-wrap;
height: auto;
justify-content: space-evenly;
align-items: flex-start;
overflow: hidden;
padding-right: $cont-padding;
padding-bottom: $cont-padding;
padding-left: $cont-padding;
main {
flex: 1 1 600px;
}
aside {
flex: 0 1 350px;
}
}
}
}
app-content-header {
#content-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20px;
padding-bottom: 10px;
.header-title {
display: flex;
align-items: center;
justify-content: space-around;
> * {
margin-right: 10px;
}
}
.header-actions > * {
margin-right: 8px;
}
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentHeaderComponent } from '../../app/layouts/content-header.component';
describe('HeaderComponent', () => {
let component: ContentHeaderComponent;
let fixture: ComponentFixture<ContentHeaderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ContentHeaderComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ContentHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentLayoutComponent } from './../../app/layouts/content-layout.component';
describe('MainContentComponent', () => {
let component: ContentLayoutComponent;
let fixture: ComponentFixture<ContentLayoutComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ContentLayoutComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ContentLayoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});