-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-order the buttons on the model card, moving some infrequently used ones to an overflow menu. Modify the "Create Persistent Session" button to prompt for the connection method and then immediately create the session. Closes #1353
- Loading branch information
Showing
5 changed files
with
272 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...-session/create-persistent-session-dialog/create-persistent-session-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<div class="dialog space-y-2"> | ||
<h2 class="text-xl font-medium">Start a Persistent Workspace Session</h2> | ||
|
||
<p> | ||
Start a persistent workspace session using {{ this.data.tool.name }} ({{ | ||
this.data.toolVersion.name | ||
}}).<br /> | ||
All changes you make to models will be saved. | ||
</p> | ||
|
||
@if (this.data.tool.config.connection.methods.length > 1) { | ||
<div> | ||
<span class="text-sm">Connection method:</span> <br /> | ||
<mat-radio-group | ||
class="flex gap-2" | ||
[(ngModel)]="selectedConnectionMethod" | ||
> | ||
@for ( | ||
connectionMethod of this.data.tool.config.connection.methods; | ||
track connectionMethod.id | ||
) { | ||
<mat-radio-button [value]="connectionMethod">{{ | ||
connectionMethod.name | ||
}}</mat-radio-button> | ||
} | ||
</mat-radio-group> | ||
</div> | ||
|
||
@if (this.selectedConnectionMethod.description) { | ||
<div class="border p-2 text-sm shadow"> | ||
{{ this.selectedConnectionMethod.description }} | ||
</div> | ||
} | ||
} | ||
|
||
<div class="flex justify-between"> | ||
<button mat-stroked-button mat-dialog-close type="button">Cancel</button> | ||
<button | ||
mat-flat-button | ||
color="primary" | ||
type="button" | ||
[disabled]="requestInProgress" | ||
(click)="requestPersistentSession()" | ||
> | ||
{{ requestInProgress ? "Requesting..." : "Request session" }} | ||
</button> | ||
</div> | ||
</div> |
73 changes: 73 additions & 0 deletions
73
...nt-session/create-persistent-session-dialog/create-persistent-session-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { Component, Inject } from '@angular/core'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatButton } from '@angular/material/button'; | ||
import { | ||
MAT_DIALOG_DATA, | ||
MatDialogClose, | ||
MatDialogRef, | ||
} from '@angular/material/dialog'; | ||
import { MatRadioButton, MatRadioGroup } from '@angular/material/radio'; | ||
import { SessionType, Tool, ToolVersion } from '../../../../../openapi'; | ||
import { ConnectionMethod } from '../../../../../settings/core/tools-settings/tool.service'; | ||
import { SessionService } from '../../../../service/session.service'; | ||
import { UserSessionService } from '../../../../service/user-session.service'; | ||
|
||
export interface CreatePersistentSessionDialogData { | ||
tool: Tool; | ||
toolVersion: ToolVersion; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-create-persistent-session-dialog', | ||
imports: [ | ||
MatRadioButton, | ||
MatRadioGroup, | ||
ReactiveFormsModule, | ||
FormsModule, | ||
MatButton, | ||
MatDialogClose, | ||
], | ||
templateUrl: './create-persistent-session-dialog.component.html', | ||
}) | ||
export class CreatePersistentSessionDialogComponent { | ||
selectedConnectionMethod: ConnectionMethod; | ||
requestInProgress = false; | ||
|
||
constructor( | ||
private sessionService: SessionService, | ||
private userSessionService: UserSessionService, | ||
public dialogRef: MatDialogRef< | ||
CreatePersistentSessionDialogComponent, | ||
boolean | ||
>, | ||
@Inject(MAT_DIALOG_DATA) public data: CreatePersistentSessionDialogData, | ||
) { | ||
this.selectedConnectionMethod = data.tool.config.connection.methods[0]; | ||
} | ||
|
||
requestPersistentSession() { | ||
this.requestInProgress = true; | ||
|
||
this.sessionService | ||
.createSession({ | ||
tool_id: this.data.tool.id, | ||
version_id: this.data.toolVersion.id, | ||
connection_method_id: this.selectedConnectionMethod.id!, | ||
session_type: SessionType.Persistent, | ||
}) | ||
.subscribe({ | ||
next: () => { | ||
this.userSessionService.loadSessions(); | ||
this.requestInProgress = false; | ||
this.dialogRef.close(true); | ||
}, | ||
error: () => { | ||
this.requestInProgress = false; | ||
}, | ||
}); | ||
} | ||
} |
Oops, something went wrong.