Skip to content

Commit 2006f15

Browse files
authored
feat: display instance information (#83)
1 parent 9774cbd commit 2006f15

File tree

38 files changed

+348
-117
lines changed

38 files changed

+348
-117
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<h1 mat-dialog-title style="text-align: center">Instance not allocated</h1>
2+
<div mat-dialog-content>
3+
There is no analysis instance allocated for the project. Having an instance is required for running analysis
4+
<br />
5+
<p>Do you want to allocate it now ?</p>
6+
7+
@if (allocateInstanceHandler.isLoading()) {
8+
<app-loading-progress-bar title="Allocating instance..."></app-loading-progress-bar>
9+
}
10+
11+
@if (allocateInstanceHandler.error()) {
12+
<app-error-state [error]="allocateInstanceHandler.error()!"></app-error-state>
13+
}
14+
</div>
15+
<div mat-dialog-actions>
16+
<button mat-button (click)="onAllocateClick()">ALLOCATE</button>
17+
<button mat-button (click)="onCloseClick()">CLOSE</button>
18+
</div>

ScriptBeeClient/src/app/components/dialogs/instance-not-allocated-dialog/instance-not-allocated-dialog.component.scss

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Component, Inject } from '@angular/core';
2+
import { MAT_DIALOG_DATA, MatDialogActions, MatDialogContent, MatDialogRef, MatDialogTitle } from '@angular/material/dialog';
3+
import { MatExpansionModule } from '@angular/material/expansion';
4+
import { MatButtonModule } from '@angular/material/button';
5+
import { MatSelectModule } from '@angular/material/select';
6+
import { FormsModule } from '@angular/forms';
7+
import { InstanceService } from '../../../services/instances/instance.service';
8+
import { ErrorStateComponent } from '../../error-state/error-state.component';
9+
import { LoadingProgressBarComponent } from '../../loading-progress-bar/loading-progress-bar.component';
10+
import { apiHandler } from '../../../utils/apiHandler';
11+
12+
export interface InstanceNotAllocatedDialogData {
13+
projectId: string;
14+
}
15+
16+
@Component({
17+
selector: 'app-instance-not-allocated-dialog',
18+
templateUrl: './instance-not-allocated-dialog.component.html',
19+
styleUrls: ['./instance-not-allocated-dialog.component.scss'],
20+
imports: [
21+
MatDialogTitle,
22+
MatDialogContent,
23+
MatDialogActions,
24+
MatExpansionModule,
25+
MatSelectModule,
26+
MatButtonModule,
27+
FormsModule,
28+
ErrorStateComponent,
29+
LoadingProgressBarComponent,
30+
],
31+
})
32+
export class InstanceNotAllocatedDialog {
33+
allocateInstanceHandler = apiHandler(
34+
(params: { projectId: string }) => this.instanceService.allocateInstance(params.projectId),
35+
() => {
36+
this.dialogRef.close();
37+
}
38+
);
39+
40+
constructor(
41+
@Inject(MAT_DIALOG_DATA)
42+
public data: InstanceNotAllocatedDialogData,
43+
public dialogRef: MatDialogRef<InstanceNotAllocatedDialog>,
44+
private instanceService: InstanceService
45+
) {}
46+
47+
onCloseClick(): void {
48+
this.dialogRef.close();
49+
}
50+
51+
onAllocateClick(): void {
52+
this.allocateInstanceHandler.execute({
53+
projectId: this.data.projectId,
54+
});
55+
}
56+
}

ScriptBeeClient/src/app/pages/projects/project-details/analysis/analysis.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
</as-split-area>
1414

1515
<as-split-area size="35">
16-
<app-analysis-output [projectId]="projectId()!" [analysisId]="analysisId()!" />
16+
@if (analysisId()) {
17+
<app-analysis-output [projectId]="projectId()!" [analysisId]="analysisId()!" />
18+
} @else {
19+
<div>There are no results since no analysis was run yet</div>
20+
}
1721
</as-split-area>
1822
</as-split>
1923
</div>

ScriptBeeClient/src/app/pages/projects/project-details/analysis/analysis.component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AnalysisOutputComponent } from './output/analysis-output.component';
66
import { ActivatedRoute, Router } from '@angular/router';
77
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
88
import { TreeNode } from '../../../../types/tree-node';
9+
import { InstanceService } from '../../../../services/instances/instance.service';
910

1011
@Component({
1112
selector: 'app-analysis',
@@ -16,6 +17,7 @@ import { TreeNode } from '../../../../types/tree-node';
1617
export class AnalysisComponent {
1718
projectId = signal<string | undefined>(undefined);
1819
analysisId = signal<string | undefined>(undefined);
20+
instanceId = signal<string | undefined>(undefined);
1921

2022
selectedFileId = signal<string | null>(null);
2123

@@ -24,15 +26,25 @@ export class AnalysisComponent {
2426

2527
constructor(
2628
private route: ActivatedRoute,
27-
private router: Router
29+
private router: Router,
30+
private instanceService: InstanceService
2831
) {
2932
route.queryParamMap.subscribe((params) => {
3033
this.selectedFileId.set(params.get('fileId'));
3134
});
3235

3336
route.parent?.paramMap.pipe(takeUntilDestroyed()).subscribe({
3437
next: (paramMap) => {
35-
this.projectId.set(paramMap.get('id') ?? undefined);
38+
const id = paramMap.get('id');
39+
this.projectId.set(id ?? undefined);
40+
41+
if (id) {
42+
this.instanceService.getCurrentInstance(id).subscribe({
43+
next: (instanceInfo) => {
44+
this.instanceId.set(instanceInfo.id);
45+
},
46+
});
47+
}
3648
},
3749
});
3850
}

ScriptBeeClient/src/app/pages/projects/project-details/model/currently-loaded-models/currently-loaded-models.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<div class="currently-loaded-models-content">
44
<span>Used Linkers: </span>
5-
@for (linker of instanceInfo().linkers; track linker) {
5+
<!-- TODO FIXIT(#70): populate from api-->
6+
@for (linker of []; track linker) {
67
{{ linker }}
78
}
89
<div>

ScriptBeeClient/src/app/pages/projects/project-details/model/currently-loaded-models/currently-loaded-models.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class CurrentlyLoadedModelsComponent {
1313
instanceInfo = input.required<InstanceInfo>();
1414

1515
loadedFiles = computed<TreeNode[]>(() => {
16-
return convertToTreeNodes(this.instanceInfo().loadedModels);
16+
// TODO FIXIT(#70): populate from api
17+
return convertToTreeNodes({});
1718
});
1819
}
1920

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="project-model-section-title project-model-content-after-divider">Instance Information</div>
2+
3+
<div class="instance-info-div">
4+
<div>Instance Id: {{ instanceInfo().id }}</div>
5+
<div>Creation Date: {{ instanceInfo().creationDate | date }}</div>
6+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.instance-info-div {
2+
margin-left: 8px;
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, input } from '@angular/core';
2+
import { InstanceInfo } from '../../../../../types/instance';
3+
import { DatePipe } from '@angular/common';
4+
5+
@Component({
6+
selector: 'app-instance-info',
7+
templateUrl: './instance-info.component.html',
8+
styleUrls: ['./instance-info.component.scss'],
9+
imports: [DatePipe],
10+
})
11+
export class InstanceInfoComponent {
12+
instanceInfo = input.required<InstanceInfo>();
13+
}

0 commit comments

Comments
 (0)