* maintenance by year passed correclty in frontend

This commit is contained in:
Danyi Dávid 2019-01-28 12:42:46 +01:00
parent 0ddd7c719d
commit 9d07b8ad82
7 changed files with 12 additions and 5 deletions

View File

@ -28,7 +28,7 @@
<i class="file pdf outline icon"></i> <i class="file pdf outline icon"></i>
</a> </a>
<i *ngIf="!hasPdf(task)" class="icon {{taskIcon(task)}}"></i> <i *ngIf="!hasPdf(task)" class="icon {{taskIcon(task)}}"></i>
<a *ngIf="canModify()" [routerLink]="['/karbantartas/szerkesztes', task.hash]" <a *ngIf="canModify()" [routerLink]="['/karbantartas/szerkesztes', year, task.hash]"
title="Szerkesztés">{{task?.shouldStartAt}}</a> title="Szerkesztés">{{task?.shouldStartAt}}</a>
<ng-container *ngIf="!canModify()">{{task?.shouldStartAt}}</ng-container> <ng-container *ngIf="!canModify()">{{task?.shouldStartAt}}</ng-container>
</div> </div>

View File

@ -15,7 +15,7 @@ import { RoleGuardService } from "../../auth/role-guard.service";
}) })
export class ListAllMaintenancesComponent implements OnInit { export class ListAllMaintenancesComponent implements OnInit {
public year: number = 2018; public year: number = 2019;
private today: string = ""; private today: string = "";
constructor(private maintenanceManager: MaintenanceManagerService, constructor(private maintenanceManager: MaintenanceManagerService,

View File

@ -51,6 +51,10 @@ export class MaintenanceManagerService {
return this.httpClient.get<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${hash}`); return this.httpClient.get<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${hash}`);
} }
public getByIdAndYear(hash: string, year: number): Observable<MaintenanceEntity> {
return this.httpClient.get<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${year}/${hash}`);
}
public update(maintenance: MaintenanceEntity) { public update(maintenance: MaintenanceEntity) {
return this.httpClient.put<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${maintenance.hash}`, maintenance); return this.httpClient.put<MaintenanceEntity>(`${MaintenanceManagerService.apiEndpoint}/${maintenance.hash}`, maintenance);
} }

View File

@ -17,6 +17,7 @@ export class MaintenanceResolverService {
* @returns {Promise<MaintenanceEntity>} * @returns {Promise<MaintenanceEntity>}
*/ */
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<MaintenanceEntity> { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<MaintenanceEntity> {
return this.maintenanceManager.get(route.params.id).toPromise(); // return this.maintenanceManager.get(route.params.id).toPromise();
return this.maintenanceManager.getByIdAndYear(route.params.id, route.params.year).toPromise();
} }
} }

View File

@ -72,7 +72,7 @@ const routes: Routes = [
filter: 'calendar', filter: 'calendar',
}, },
}, { }, {
path: 'karbantartas/szerkesztes/:id', path: 'karbantartas/szerkesztes/:year/:id',
component: EditMaintenanceComponent, component: EditMaintenanceComponent,
canActivate: [AuthGuardService, RoleGuardService], canActivate: [AuthGuardService, RoleGuardService],
resolve: { resolve: {

View File

@ -18,7 +18,7 @@
<td *ngIf="canModify()" class="collapsing icon"> <td *ngIf="canModify()" class="collapsing icon">
<a *ngIf="hasMaintenanceSheet(task)" title="PDF letöltés" <a *ngIf="hasMaintenanceSheet(task)" title="PDF letöltés"
[href]="maintenancePdfUrl(task)" target="_blank"><i class="file pdf outline icon"></i></a> [href]="maintenancePdfUrl(task)" target="_blank"><i class="file pdf outline icon"></i></a>
<a [routerLink]="['/karbantartas/szerkesztes', task.hash]" <a [routerLink]="['/karbantartas/szerkesztes', year, task.hash]"
title="Szerkesztés"><i class="fitted pencil icon"></i></a> title="Szerkesztés"><i class="fitted pencil icon"></i></a>
</td> </td>
<td class="collapsing">{{device.name}}</td> <td class="collapsing">{{device.name}}</td>

View File

@ -17,12 +17,14 @@ export class UpcomingMaintenancesComponent implements OnInit {
@Input() warnWhenPast: boolean = true; @Input() warnWhenPast: boolean = true;
@Input() maintenances: Array<DeviceGroup> = []; @Input() maintenances: Array<DeviceGroup> = [];
private today: string = ""; private today: string = "";
public year: number;
constructor( constructor(
private roleGuard: RoleGuardService, private roleGuard: RoleGuardService,
private maintenanceManager: MaintenanceManagerService private maintenanceManager: MaintenanceManagerService
) { ) {
this.today = (new Date()).toISOString().substring(0, 10); this.today = (new Date()).toISOString().substring(0, 10);
this.year = new Date().getFullYear();
} }
ngOnInit() { ngOnInit() {