From 708e43ca9485f4045c12c18667de551360b0a69f Mon Sep 17 00:00:00 2001 From: Valentyn Berezin Date: Mon, 5 Apr 2021 10:03:20 +0300 Subject: [PATCH] Update UI to support project editing --- .../persistence/entity/projects/Project.java | 10 +++++----- .../restapi/dto/project/ProjectDto.java | 2 +- time-tracker-ui/src/app/app.module.ts | 2 ++ .../add-or-edit-project-dialog.component.html | 18 +++++++++++++++++ .../add-or-edit-project-dialog.component.ts | 20 +++++++++++++++++-- .../service/admin-api/admin-api-service.ts | 3 +++ 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/shared/src/main/java/ua/timetracker/shared/persistence/entity/projects/Project.java b/shared/src/main/java/ua/timetracker/shared/persistence/entity/projects/Project.java index dcbc308..ff8e91f 100644 --- a/shared/src/main/java/ua/timetracker/shared/persistence/entity/projects/Project.java +++ b/shared/src/main/java/ua/timetracker/shared/persistence/entity/projects/Project.java @@ -9,7 +9,6 @@ import org.neo4j.springframework.data.core.schema.Node; import ua.timetracker.shared.restapi.dto.project.ProjectCreateOrUpdate; -import java.time.Duration; import java.util.Set; import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE; @@ -34,9 +33,10 @@ public class Project { private String description; private Set activities; // screenshot related - private boolean screenshots; - private float quality; - private Duration interval; + private Boolean screenshots; + private Float quality; + // FIXME java.lang.ClassCastException: Cannot cast org.neo4j.driver.internal.InternalIsoDuration to java.time.Duration + private Long intervalM; // SDN / RX Neo4J currently does not work properly with abstract relationship classes. Omitting them and using queries. @@ -50,7 +50,7 @@ public interface Merge { default void update(ProjectCreateOrUpdate updated, Project result) { doUpdate(updated, result); if (null != updated.getIntervalminutes()) { - result.setInterval(Duration.ofMinutes(updated.getIntervalminutes())); + result.setIntervalM(updated.getIntervalminutes()); } } diff --git a/shared/src/main/java/ua/timetracker/shared/restapi/dto/project/ProjectDto.java b/shared/src/main/java/ua/timetracker/shared/restapi/dto/project/ProjectDto.java index 6c7da22..c60ae03 100644 --- a/shared/src/main/java/ua/timetracker/shared/restapi/dto/project/ProjectDto.java +++ b/shared/src/main/java/ua/timetracker/shared/restapi/dto/project/ProjectDto.java @@ -30,7 +30,7 @@ public interface FromEntity { default ProjectDto map(Project project) { ProjectDto mapped = map(project, new ProjectDto()); - mapped.setIntervalminutes(null == project.getInterval() ? 0 : project.getInterval().toMinutes()); + mapped.setIntervalminutes(null == project.getIntervalM() ? 0 : project.getIntervalM()); return mapped; } } diff --git a/time-tracker-ui/src/app/app.module.ts b/time-tracker-ui/src/app/app.module.ts index 2b66e4d..c8d501f 100644 --- a/time-tracker-ui/src/app/app.module.ts +++ b/time-tracker-ui/src/app/app.module.ts @@ -30,6 +30,7 @@ import {MatMomentDateModule} from "@angular/material-moment-adapter"; import {MAT_DATE_FORMATS} from "@angular/material/core"; import {MatToolbarModule} from "@angular/material/toolbar"; import {MatSidenavModule} from "@angular/material/sidenav"; +import {MatSliderModule} from "@angular/material/slider"; import {MatListModule} from "@angular/material/list"; import {MainScreenComponent} from './main-screen/main-screen.component'; import {MyProfileComponent} from './my-profile/my-profile.component'; @@ -107,6 +108,7 @@ export const AppDateFormats = { MatCardModule, MatTreeModule, MatCheckboxModule, + MatSliderModule, MatProgressBarModule, MatButtonModule, MatMenuModule, diff --git a/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.html b/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.html index d0ef206..70f251f 100644 --- a/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.html +++ b/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.html @@ -63,6 +63,24 @@
Project activities:
cdkAutosizeMinRows="3" cdkAutosizeMaxRows="10"> +
+ +
Screenshot settings:
+
+ + Do track screenshots + +
+
+
+ Screenshot quality: + +
+
+
+ Screenshot interval, minutes: + +
diff --git a/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.ts b/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.ts index 52e103a..1a3007c 100644 --- a/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.ts +++ b/time-tracker-ui/src/app/management/dialogs/add-or-edit-project-dialog/add-or-edit-project-dialog.component.ts @@ -25,10 +25,17 @@ export class AddOrEditProjectDialogComponent implements OnInit { projectDescriptionControl = new FormControl('', []); + trackScreenShots = new FormControl(false, []); + screenShotQuality = new FormControl(0.5, [Validators.required, Validators.min(0), Validators.max(1)]); + screenShotIntervalM = new FormControl(10, []); + newProjectForm = this.fb.group({ username: this.projectCodeControl, fullname: this.projectNameControl, activities: this.fb.array([]), + trackScreenShots: this.trackScreenShots, + screenShotQuality: this.screenShotQuality, + screenShotIntervalM: this.screenShotIntervalM }, {validator: AddOrEditProjectDialogComponent.checkActivities}); fieldMatcher = new FieldErrorStateMatcher(); @@ -50,6 +57,10 @@ export class AddOrEditProjectDialogComponent implements OnInit { } this.projectDescriptionControl.setValue(data.description) + + this.trackScreenShots.setValue(data.screenshots); + this.screenShotQuality.setValue(data.quality); + this.screenShotIntervalM.setValue(data.intervalminutes); } ngOnInit() { @@ -79,6 +90,8 @@ export class AddOrEditProjectDialogComponent implements OnInit { } onSaveClick(): void { + console.log(this.newProjectForm.valid) + console.log(this.newProjectForm.errors) if (!this.newProjectForm.valid || this.activitiesControl.controls.filter(it => !it.valid).length > 0) { return } @@ -88,8 +101,11 @@ export class AddOrEditProjectDialogComponent implements OnInit { code: this.projectCodeControl.value, name: this.projectNameControl.value, activities: this.activitiesControl.controls.map(it => it.value), - description: this.projectDescriptionControl.value} - ); + description: this.projectDescriptionControl.value, + screenshots: this.trackScreenShots.value, + quality: this.screenShotQuality.value, + intervalminutes: this.screenShotIntervalM.value + }); } onNoClick(): void { diff --git a/time-tracker-ui/src/app/service/admin-api/admin-api-service.ts b/time-tracker-ui/src/app/service/admin-api/admin-api-service.ts index 1c140b8..cae3dc4 100644 --- a/time-tracker-ui/src/app/service/admin-api/admin-api-service.ts +++ b/time-tracker-ui/src/app/service/admin-api/admin-api-service.ts @@ -273,6 +273,9 @@ export interface ProjectCreateOrUpdateDto { name: string; activities: Set; description: string; + screenshots?: boolean; + quality?: number; + intervalminutes?: number; } export class RoleDetailsDto {