Skip to content

Commit fa89b8a

Browse files
Merge pull request #97 from CentreForDigitalHumanities/feature/parse-and-prove-request-status
Feature/parse and prove request status
2 parents 240cecf + de109fa commit fa89b8a

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

frontend/src/app/annotate/annotation-input/annotation-input.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@let appMode = appMode$ | async;
33
@let userProblem = isUserProblem$ | async;
44
@let editingOrAdding = appMode === 'edit' || appMode === 'add';
5+
@let inProgress = inProgress$ | async;
56
@if (problem) {
67
<div class="card">
78
<div class="card-body">
@@ -13,12 +14,21 @@
1314
<la-knowledge-base-form [form]="form" />
1415
</div>
1516
<div class="d-flex justify-content-between mt-3">
17+
@if (!inProgress) {
1618
<la-icon-button
1719
buttonStyle="success"
1820
[icon]="faTree"
1921
label="Parse and prove"
2022
(click)="startParse()"
2123
/>
24+
} @else {
25+
<la-icon-button
26+
buttonStyle="success"
27+
[icon]="faHourglass"
28+
label="Parsing and proving..."
29+
disabled="true"
30+
/>
31+
}
2232
@if (appMode === 'browse' && (canCopyProblem$ | async)) {
2333
<a
2434
class="btn btn-secondary d-flex align-items-center justify-content-center"

frontend/src/app/annotate/annotation-input/annotation-input.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { PremisesFormComponent } from "./premises-form/premises-form.component";
1212
import { KnowledgeBaseFormComponent } from "./knowledge-base-form/knowledge-base-form.component";
1313
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
1414
import { Dataset, KnowledgeBaseAnnotation, KnowledgeBaseRelationship, Problem } from "../../types";
15-
import { faCheck, faCopy, faExclamationCircle, faFloppyDisk, faTrash, faTree, faWrench } from "@fortawesome/free-solid-svg-icons";
15+
import { faCheck, faCopy, faExclamationCircle, faFloppyDisk, faHourglass, faTrash, faTree, faWrench } from "@fortawesome/free-solid-svg-icons";
1616
import { ProblemDetailsComponent } from "./problem-details/problem-details.component";
1717
import { map, Subject } from "rxjs";
1818
import { ActivatedRoute, Router, RouterLinkWithHref } from "@angular/router";
@@ -73,13 +73,16 @@ export class AnnotationInputComponent implements OnInit {
7373

7474
public submit$ = new Subject<void>();
7575

76+
public inProgress$ = this.parseService.inProgress$;
77+
7678
public faCopy = faCopy;
7779
public faCheck = faCheck;
7880
public faTree = faTree;
7981
public faFloppyDisk = faFloppyDisk;
8082
public faExclamationCircle = faExclamationCircle;
8183
public faTrash = faTrash;
8284
public faWrench = faWrench;
85+
public faHourglass = faHourglass;
8386

8487
public appMode$ = this.problemService.appMode$;
8588
public isUserProblem$ = this.problem$.pipe(

frontend/src/app/services/parse.service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HttpClient } from '@angular/common/http';
22
import { inject, Injectable } from '@angular/core';
3-
import { Subject, switchMap, catchError, of, merge, map, share } from 'rxjs';
3+
import { Subject, switchMap, catchError, of, merge, map, share, startWith } from 'rxjs';
44
import { ParseInput } from '@/annotate/annotation-input/annotation-input.component';
55
import { ProblemService } from './problem.service';
66
import {
@@ -9,6 +9,7 @@ import {
99
ProofNode,
1010
ProofTree,
1111
} from '@/types';
12+
import { ToastService } from './toast.service';
1213

1314

1415
@Injectable({
@@ -17,6 +18,7 @@ import {
1718
export class ParseService {
1819
private http = inject(HttpClient);
1920
private problemService = inject(ProblemService);
21+
private toastService = inject(ToastService);
2022

2123
// Sink for triggering parse-and-prove requests to the backend.
2224
public submit$ = new Subject<ParseInput>();
@@ -30,13 +32,24 @@ export class ParseService {
3032
this.http.post<ParseResponse>("/api/problem/parse", form).pipe(
3133
catchError((error) => {
3234
console.error(`Error parsing problem:`, error);
35+
this.toastService.show({
36+
header: $localize`Error parsing problem`,
37+
body: error.message || $localize`An error occurred while parsing the problem.`,
38+
type: 'danger',
39+
});
3340
return of({ data: null, error: error.message || "An error occurred while parsing the problem." });
3441
}),
3542
)
3643
),
3744
share()
3845
);
3946

47+
public inProgress$ = merge(
48+
this.submit$.pipe(map(() => true)),
49+
this.parseResults$.pipe(map(() => false)),
50+
this.clearOnNewProblem$.pipe(map(() => false)),
51+
).pipe(startWith(false));
52+
4053
public parse$ = merge(
4154
this.parseResults$,
4255
this.clearOnNewProblem$

0 commit comments

Comments
 (0)