Skip to content

Commit

Permalink
Update UI to support project editing
Browse files Browse the repository at this point in the history
  • Loading branch information
valb3r committed Apr 5, 2021
1 parent 0d1bd9c commit 708e43c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,9 +33,10 @@ public class Project {
private String description;
private Set<String> 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.

Expand All @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions time-tracker-ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -107,6 +108,7 @@ export const AppDateFormats = {
MatCardModule,
MatTreeModule,
MatCheckboxModule,
MatSliderModule,
MatProgressBarModule,
MatButtonModule,
MatMenuModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ <h5>Project activities:</h5>
cdkAutosizeMinRows="3"
cdkAutosizeMaxRows="10"></textarea>
</mat-form-field>
<br/>

<h5>Screenshot settings:</h5>
<div>
<mat-checkbox [formControl]="trackScreenShots">
Do track screenshots
</mat-checkbox>
</div>
<br/>
<div>
Screenshot quality:
<mat-slider min="0" max="1" step="0.1" [formControl]="screenShotQuality" thumbLabel="true"></mat-slider>
</div>
<br/>
<div>
Screenshot interval, minutes:
<mat-slider min="1" max="30" step="1" [formControl]="screenShotIntervalM" thumbLabel="true"></mat-slider>
</div>
</form>
</mat-card-content>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ export interface ProjectCreateOrUpdateDto {
name: string;
activities: Set<string>;
description: string;
screenshots?: boolean;
quality?: number;
intervalminutes?: number;
}

export class RoleDetailsDto {
Expand Down

0 comments on commit 708e43c

Please sign in to comment.