Skip to content

Commit

Permalink
Modified error message when the server is not responding. Now the set…
Browse files Browse the repository at this point in the history
…tings modal doesn't refresh loaded models if the user click outside the modal or press cancel button.
  • Loading branch information
marcguillemdev committed Jun 15, 2024
1 parent 6cc0204 commit 991658a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/app/components/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ export class ChatComponent implements OnInit {
this._matDialogService.open(ConfigComponent).afterClosed()
.pipe(takeUntilDestroyed(this._destroyRef))
.subscribe({
next: () => {
this._loadAvailableModels();
next: (response: boolean) => {
if (response) {
this._loadAvailableModels();
}
}
});
}
Expand All @@ -103,10 +105,11 @@ export class ChatComponent implements OnInit {
this._closeLoadingDialog();
this._matDialogService.open(DialogMessageComponent,
{
disableClose: true,
data:
{
title: 'LMStudio API not available',
message: 'The LMStudio API is not available. Please check your configuration or try again later.'
message: 'The LMStudio API is not available. Please check your configuration or try again later. <br> You have to start the LMStudio API server to use this application and set on the CORS policy option.'
}
}).afterClosed()
.pipe(takeUntilDestroyed(this._destroyRef))
Expand All @@ -127,6 +130,8 @@ export class ChatComponent implements OnInit {
*/
private _showLoadingDialog(): void {
this._loadingDialogRef = this._matDialogService.open(LoadingComponent, {
hasBackdrop: true,
disableClose: true,
data: {
title: 'Loading...',
message: 'Please wait while the model list is being loaded.'
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/config/config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ <h4>System prompt</h4>
</mat-icon>
Cancel
</button>
<button color="primary" mat-button [mat-dialog-close]="true" (click)="setConfiguration()">
<button color="primary" mat-button (click)="setConfiguration(true)">
<mat-icon color="primary">save</mat-icon>
Save
</button>
</mat-dialog-actions>
</form>
</form>
6 changes: 4 additions & 2 deletions src/app/components/config/config.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, inject } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
Expand All @@ -25,6 +25,7 @@ import { LMSTudioAPIConfiguration } from '../../interface/configuration';
export class ConfigComponent {

private readonly configService = inject(ConfigService);
private readonly matDialogRef = inject(MatDialogRef<ConfigComponent>);
private readonly config: LMSTudioAPIConfiguration = this.configService.getConfiguration();

public formGroup = new FormGroup({
Expand All @@ -36,9 +37,10 @@ export class ConfigComponent {
this.formGroup.setValue(this.configService._defaultConfiguration);
}

public setConfiguration(): void {
public setConfiguration(reloadModelsAfterCloseThisModal: boolean): void {
if (this.formGroup.valid) {
this.configService.setConfiguration(this.formGroup.value as LMSTudioAPIConfiguration);
this.matDialogRef.close(reloadModelsAfterCloseThisModal);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
</div>
<hr>
<div class="body">
<p>
{{ injectedMatDialogData.message }}
</p>
<p [innerHTML]="injectedMatDialogData.message"></p>
</div>
<div class="footer">
<button mat-button color="warn" (click)="closeDialogWithResponse(false)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
flex-direction: column;
justify-content: flex-start;
align-items: center;
max-width: 700px;
margin: 1em;

& div.header {
Expand Down

0 comments on commit 991658a

Please sign in to comment.