Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit da67ec2

Browse files
authored
feat: display weekly limit and remaining time in timer (#132)
1 parent 6fe45bf commit da67ec2

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

packages/ui-core/core/src/lib/services/time-tracker/time-tracker.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ export class TimeTrackerService implements OnDestroy {
230230
} else if (error.status == 403 && error.error?.message === TimeErrorsEnum.INVALID_PROJECT_PERMISSIONS) {
231231
this.turnOffTimer();
232232
this.toastrService.danger('TIMER_TRACKER.PROJECT_PROJECT_PERMISSION_ERROR');
233+
} else if (error.status === 409 && error.error?.message === TimeErrorsEnum.WEEKLY_LIMIT_REACHED) {
234+
this.turnOffTimer();
235+
this.updateTimerStore({
236+
workedThisWeek: 0,
237+
reWeeklyLimit: 0
238+
});
239+
this.toastrService.danger('TIMER_TRACKER.WEEKLY_LIMIT_EXCEEDED');
240+
241+
return Promise.reject(error);
233242
} else {
234243
console.error(error);
235244
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import * as moment from 'moment';
3+
import 'moment-duration-format';
4+
5+
@Pipe({
6+
name: 'humanDuration',
7+
standalone: false
8+
})
9+
export class HumanDurationPipe implements PipeTransform {
10+
transform(
11+
value: number,
12+
format?: string,
13+
settings?: moment.DurationFormatSettings,
14+
unitOfTime?: moment.unitOfTime.DurationConstructor
15+
): string {
16+
return moment.duration(value, unitOfTime || 'seconds').format(
17+
format || 'HH:mm:ss',
18+
settings || {
19+
trim: false,
20+
trunc: true
21+
}
22+
);
23+
}
24+
}

packages/ui-core/shared/src/lib/pipes/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { UtcToLocalPipe } from './utc-to-local.pipe';
1313
import { HashNumberPipe } from './hash-number.pipe';
1414
import { UtcToTimezone } from './utc-to-timezone.pipe';
1515
import { HoursDurationFormatPipe } from './duration-to-hours-format.pipe';
16+
import { HumanDurationPipe } from './human-duration.pipe';
1617

1718
export { CurrencyPositionPipe } from './currency-position.pipe';
1819
export { DateFormatPipe } from './date-format.pipe';
@@ -29,6 +30,7 @@ export { UtcToLocalPipe } from './utc-to-local.pipe';
2930
export { HashNumberPipe } from './hash-number.pipe';
3031
export { UtcToTimezone } from './utc-to-timezone.pipe';
3132
export { HoursDurationFormatPipe } from './duration-to-hours-format.pipe';
33+
export { HumanDurationPipe } from './human-duration.pipe';
3234

3335
export const Pipes = [
3436
CurrencyPositionPipe,
@@ -47,5 +49,6 @@ export const Pipes = [
4749
UtcToLocalPipe,
4850
UtcToTimezone,
4951
HashNumberPipe,
50-
HoursDurationFormatPipe
52+
HoursDurationFormatPipe,
53+
HumanDurationPipe
5154
];

packages/ui-core/shared/src/lib/time-tracker/time-tracker/time-tracker.component.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@ <h6 *ngIf="isExpanded">
6464
{{ currentSessionTime }}
6565
</span>
6666
<span class="today-time mt-2">
67-
{{ 'TIMER_TRACKER.TODAY' | translate }}
67+
{{ 'TIMER_TRACKER.TODAY' | translate }}:
6868
{{ todaySessionTime }}
6969
</span>
70+
<span class="today-time mt-2">
71+
{{ 'TIMESHEET.WEEKLY' | translate }}:
72+
73+
{{ (workedThisWeek$ | async) || 0 | humanDuration : 'HH:mm' }}
74+
/
75+
{{ (reWeeklyLimit$ | async) * 3600 || 0 | humanDuration : 'HH:mm' }}
76+
</span>
7077
</div>
7178
<span *ngIf="limitReached" class="today-time mt-2 invalid-feedback d-block">
7279
{{ 'TOASTR.TITLE.MAX_LIMIT_REACHED' | translate }}

0 commit comments

Comments
 (0)