issue-20 #46
@ -41,7 +41,7 @@ public class ScheduleController {
|
|||||||
@GetMapping("/schedules/{taskID}")
|
@GetMapping("/schedules/{taskID}")
|
||||||
public ResponseEntity<?> loadAllSchedulesOfTask(@PathVariable long taskID) {
|
public ResponseEntity<?> loadAllSchedulesOfTask(@PathVariable long taskID) {
|
||||||
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class ScheduleController {
|
|||||||
@DeleteMapping("/schedules/{scheduleID}")
|
@DeleteMapping("/schedules/{scheduleID}")
|
||||||
public ResponseEntity<?> deleteSchedule(@PathVariable long scheduleID) {
|
public ResponseEntity<?> deleteSchedule(@PathVariable long scheduleID) {
|
||||||
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public class ScheduleController {
|
|||||||
@PostMapping("/schedules/{taskID}/now")
|
@PostMapping("/schedules/{taskID}/now")
|
||||||
public ResponseEntity<?> scheduleNow(@PathVariable long taskID) {
|
public ResponseEntity<?> scheduleNow(@PathVariable long taskID) {
|
||||||
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ public class ScheduleController {
|
|||||||
@PostMapping("/schedules/{scheduleID}/activate")
|
@PostMapping("/schedules/{scheduleID}/activate")
|
||||||
public ResponseEntity<?> activateSchedule(@PathVariable long scheduleID) {
|
public ResponseEntity<?> activateSchedule(@PathVariable long scheduleID) {
|
||||||
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ public class ScheduleController {
|
|||||||
@PostMapping("/schedules/{scheduleID}/stop/{finish}")
|
@PostMapping("/schedules/{scheduleID}/stop/{finish}")
|
||||||
public ResponseEntity<?> stopSchedule(@PathVariable long scheduleID, @PathVariable boolean finish) {
|
public ResponseEntity<?> stopSchedule(@PathVariable long scheduleID, @PathVariable boolean finish) {
|
||||||
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ public class ScheduleController {
|
|||||||
@PostMapping("/schedules/{taskID}/forgotten")
|
@PostMapping("/schedules/{taskID}/forgotten")
|
||||||
public ResponseEntity<?> registerForgottenSchedule(@PathVariable long taskID, @RequestBody @Valid ForgottenScheduleInfo forgottenScheduleInfo) {
|
public ResponseEntity<?> registerForgottenSchedule(@PathVariable long taskID, @RequestBody @Valid ForgottenScheduleInfo forgottenScheduleInfo) {
|
||||||
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<Task> permissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ public class ScheduleController {
|
|||||||
List<PermissionResult<AbstractSchedule>> permissionResults = new ArrayList<>();
|
List<PermissionResult<AbstractSchedule>> permissionResults = new ArrayList<>();
|
||||||
for(long scheduleID: scheduleIDs) {
|
for(long scheduleID: scheduleIDs) {
|
||||||
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
if(permissionResult.isHasPermissions()) {
|
if(!permissionResult.isHasPermissions()) {
|
||||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,3 +12,7 @@
|
|||||||
.scheduleContainer {
|
.scheduleContainer {
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.advanced-info {
|
||||||
|
color: #6e6e6e;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<mat-card *ngFor="let schedule of schedules" class="scheduleContainer">
|
<mat-card *ngFor="let schedule of schedules" class="scheduleContainer">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<ng-container *ngIf="schedule.scheduleType == 'BASIC'">
|
<div *ngIf="schedule.scheduleType == 'BASIC'">
|
||||||
<div class="basicScheduleContainer">
|
<div class="basicScheduleContainer">
|
||||||
<p class="basicScheduleContent">{{ toBasicSchedule(schedule).scheduleDate | date:'EEEE, d MMM. y'}}</p>
|
<p class="basicScheduleContent">{{ toBasicSchedule(schedule).scheduleDate | date:'EEEE, d MMM. y'}}</p>
|
||||||
<div class="basicScheduleContent">
|
<div class="basicScheduleContent">
|
||||||
@ -8,8 +8,23 @@
|
|||||||
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
|
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</ng-container>
|
<div *ngIf="schedule.scheduleType == 'ADVANCED'">
|
||||||
|
<div class="basicScheduleContainer">
|
||||||
|
<div class="basicScheduleContent">
|
||||||
|
<p>
|
||||||
|
<span>{{ toAdvancedSchedule(schedule).scheduleStartTime | date:'EEEE, d MMM. y'}}</span>
|
||||||
|
<span> to </span>
|
||||||
|
<span>{{ toAdvancedSchedule(schedule).scheduleStopTime | date:'EEEE, d MMM. y'}}</span>
|
||||||
|
</p>
|
||||||
|
<p class="advanced-info">Minutes: {{calcDurationOfAdvancedSchedule(schedule)}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="basicScheduleContent">
|
||||||
|
<button mat-icon-button color="primary" [routerLink]="['/taskgroups', taskgroup!.taskgroupID, 'tasks', task!.taskID, 'schedule', schedule.scheduleID]"><mat-icon>edit</mat-icon></button>
|
||||||
|
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
|
AdvancedScheduleInfo,
|
||||||
BasicScheduleEntityInfo, BasicScheduleInfo,
|
BasicScheduleEntityInfo, BasicScheduleInfo,
|
||||||
ScheduleInfo,
|
ScheduleInfo,
|
||||||
ScheduleService,
|
ScheduleService,
|
||||||
@ -7,6 +8,7 @@ import {
|
|||||||
TaskgroupEntityInfo
|
TaskgroupEntityInfo
|
||||||
} from "../../../api";
|
} from "../../../api";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
|
import {AdvancedSchedulerComponent} from "../advanced-scheduler/advanced-scheduler.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-schedule-dashboard',
|
selector: 'app-schedule-dashboard',
|
||||||
@ -57,4 +59,14 @@ export class ScheduleDashboardComponent implements OnInit{
|
|||||||
toBasicSchedule(schedule: ScheduleInfo) {
|
toBasicSchedule(schedule: ScheduleInfo) {
|
||||||
return schedule as BasicScheduleInfo
|
return schedule as BasicScheduleInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toAdvancedSchedule(schedule: ScheduleInfo) {
|
||||||
|
return schedule as AdvancedScheduleInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
calcDurationOfAdvancedSchedule(schedule: ScheduleInfo) {
|
||||||
|
const advancedSchedule = schedule as AdvancedScheduleInfo
|
||||||
|
const diffMs = new Date(advancedSchedule.scheduleStopTime).getTime() - new Date(advancedSchedule.scheduleStartTime).getTime();
|
||||||
|
return Math.floor((diffMs / 1000) / 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user