Added the ability to reset the plan to the starting node when selecting a previously played plan.

Oggje/RestartRun
Oggje 2 months ago
parent d3ef66e498
commit 3ad37570da

42
src-tauri/Cargo.lock generated

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "Inflector"
@ -592,10 +592,11 @@ dependencies = [
[[package]]
name = "deranged"
version = "0.3.7"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc"
dependencies = [
"powerfmt",
"serde",
]
@ -2011,6 +2012,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-integer"
version = "0.1.45"
@ -2449,6 +2456,12 @@ dependencies = [
"serde_json",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
@ -2881,18 +2894,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.183"
version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.183"
version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [
"proc-macro2",
"quote",
@ -3592,14 +3605,16 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.25"
version = "0.3.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
dependencies = [
"deranged",
"itoa 1.0.9",
"libc",
"num-conv",
"num_threads",
"powerfmt",
"serde",
"time-core",
"time-macros",
@ -3607,16 +3622,17 @@ dependencies = [
[[package]]
name = "time-core"
version = "0.1.1"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
[[package]]
name = "time-macros"
version = "0.2.11"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
dependencies = [
"num-conv",
"time-core",
]

@ -97,7 +97,10 @@ export class Plan {
private directSelfSave() {
invoke('save_plan_at_path', { path: this.path, plan: this.toInterface() });
}
public resetPlan() {
this.current = 0;
this.requestSelfSave();
}
}
export interface PlanElement {

@ -81,6 +81,8 @@ export class TimeTrackerService {
private start?: Date;
private latest?: Date;
private newRun: Subject<void> = new Subject<void>();
private active: boolean = false;
private storedHistoriesSubject: Subject<Map<string, RunHistoryMetadata>> = new ReplaySubject<Map<string, RunHistoryMetadata>>(1);
@ -129,7 +131,9 @@ export class TimeTrackerService {
public get storedHistories(): Observable<Map<string, RunHistoryMetadata>> {
return this.storedHistoriesSubject;
}
public getNewRunSubject(): Observable<void>{
return this.newRun.asObservable();
}
onNewRun(plan: Plan) {
if (this.timerSubscription && !this.timerSubscription.closed) this.timerSubscription.unsubscribe();
if (this.debouncedSaveStopwatch && !this.debouncedSaveStopwatch.closed) this.debouncedSaveStopwatch.unsubscribe();
@ -339,10 +343,19 @@ export class TimeTrackerService {
this.resumeOnNext = true;
plan.requestSelfSave();
break;
case Resume.NewRun:
this.setCurrentRunHistory(this.createNew(plan.name));
this.loadReachedCheckpoints();
plan.last_stored_time = this.currentRunHistory!.uuid;
this.resumeOnNext = true;
plan.requestSelfSave();
this.newRun.next();
break;
}
})
}
loadReachedCheckpoints() {
if (!this.currentRunHistory || !this.currentRunHistory.plan || !this.configService.config.runCompareHistory) return;

@ -64,7 +64,12 @@ export class PlanDisplayComponent implements OnInit {
setTimeout(() => this.setIndex(plan.current), 0);
})
this.timeTrackerService.getNewRunSubject().subscribe(() => {
this.currentSlides?.setIndex(0);
this.zoneSlides?.setIndex(0);
this.slideIndex = 0;
this.currentPlan?.resetPlan();
})
this.registerOnZoneEnter();
}
@ -270,6 +275,7 @@ export class PlanDisplayComponent implements OnInit {
return `${waypoint} ${trial}`;
}
clampedOffset(): number {
return Math.min(this.configService.config.numVisible - 1, this.configService.config.offset);
}

@ -3,4 +3,6 @@ You have an ongoing run history <b>(time tracking)</b> going, would you like to
<button mat-raised-button color="color-resume-instant" (click)="instant()">Resume instantaneously</button>
<button mat-raised-button color="color-resume-next" (click)="next()" cdkFocusInitial>Resume on entering next zone</button>
<button mat-raised-button color="color-resume-no" (click)="discard()" cdkFocusInitial>Start new</button>
<button mat-raised-button color="color-resume-no" (click)="newRun()" cdkFocusInitial>Start new run</button>
</div>

@ -8,7 +8,8 @@ import { MatInputModule } from "@angular/material/input";
export enum Resume {
Discard,
Next,
Instant
Instant,
NewRun,
}
@Component({
@ -28,6 +29,9 @@ export class ResumeDialog {
discard() {
this.dialogRef.close(Resume.Discard);
}
newRun(){
this.dialogRef.close(Resume.NewRun);
}
constructor(public dialogRef: MatDialogRef<ResumeDialog>) {}
}
Loading…
Cancel
Save