Add staff playtime feature, including backend services, API endpoint, and frontend integration.
WIP
This commit is contained in:
@@ -14,6 +14,14 @@ export const routes: Routes = [
|
||||
requiredAuthorizations: ['SCOPE_head_mod']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'staff-pt',
|
||||
loadComponent: () => import('./pages/particles/particles.component').then(m => m.ParticlesComponent),
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
requiredAuthorizations: ['SCOPE_head_mod']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'map',
|
||||
loadComponent: () => import('./pages/features/map/map.component').then(m => m.MapComponent)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<p>staff-pt works!</p>
|
||||
@@ -0,0 +1,34 @@
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {SiteService, StaffPlaytime} from '@api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-staff-pt',
|
||||
imports: [],
|
||||
templateUrl: './staff-pt.component.html',
|
||||
styleUrl: './staff-pt.component.scss'
|
||||
})
|
||||
export class StaffPtComponent implements OnInit {
|
||||
siteService = inject(SiteService);
|
||||
staffPt = signal<StaffPlaytime[]>([])
|
||||
|
||||
ngOnInit(): void {
|
||||
const firstDayOfWeek = new Date();
|
||||
firstDayOfWeek.setDate(firstDayOfWeek.getDate() - firstDayOfWeek.getDay());
|
||||
firstDayOfWeek.setHours(0, 0, 0, 0);
|
||||
const lastDayOfWeek = new Date(firstDayOfWeek);
|
||||
lastDayOfWeek.setDate(firstDayOfWeek.getDate() + 6);
|
||||
lastDayOfWeek.setHours(23, 59, 59, 999);
|
||||
|
||||
this.loadStaffData(firstDayOfWeek, lastDayOfWeek);
|
||||
}
|
||||
|
||||
loadStaffData(from: Date, to: Date) {
|
||||
this.siteService.getStaffPlaytime(from.toISOString(), to.toISOString())
|
||||
.subscribe({
|
||||
next: data => {
|
||||
this.staffPt.set(data);
|
||||
},
|
||||
error: err => console.error('Error getting staff playtime:', err)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,7 @@
|
||||
<ul class="dropdown">
|
||||
@if (hasAccess([PermissionClaim.HEAD_MOD])) {
|
||||
<li class="nav_li"><a class="nav_link2" [routerLink]="['/particles']">Particles</a></li>
|
||||
<li class="nav_li"><a class="nav_link2" [routerLink]="['/staff-pt']">StaffPlaytime</a></li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user