Skip to content

Commit

Permalink
fix: Add restart to settings & better disabled state (#493)
Browse files Browse the repository at this point in the history
* fix: Add restart to settings & better disabled state

* fix: Correct function call and better handling

* fix: Add to network restart and form dirty check
  • Loading branch information
mrv777 authored Nov 22, 2024
1 parent 4100402 commit c745cbb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@
</div>

<div class="mt-2">
<button pButton [disabled]="form.invalid" (click)="updateSystem()"
<button pButton [disabled]="!form.dirty || form.invalid" (click)="updateSystem()"
class="btn btn-primary mr-2">Save</button>
<b style="line-height: 34px;">You must restart this device after saving for changes to take effect.</b>
</div>

<div class="mt-2">
<button pButton [disabled]="!savedChanges" (click)="restart()">Restart</button>
</div>


</form>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class EditComponent implements OnInit {
public firmwareUpdateProgress: number | null = null;
public websiteUpdateProgress: number | null = null;


public savedChanges: boolean = false;
public devToolsOpen: boolean = false;
public eASICModel = eASICModel;
public ASICModel!: eASICModel;
Expand Down Expand Up @@ -205,9 +205,11 @@ export class EditComponent implements OnInit {
.subscribe({
next: () => {
this.toastr.success('Success!', 'Saved.');
this.savedChanges = true;
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error.', `Could not save. ${err.message}`);
this.savedChanges = false;
}
});
}
Expand All @@ -232,4 +234,17 @@ export class EditComponent implements OnInit {
this.showFallbackStratumPassword = !this.showFallbackStratumPassword;
}

public restart() {
this.systemService.restart()
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
this.toastr.success('Success!', 'Bitaxe restarted');
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error', `Could not restart. ${err.message}`);
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
</div>

<div class="mt-2">
<button pButton [disabled]="form.invalid" (click)="updateSystem()"
<button pButton [disabled]="!form.dirty || form.invalid" (click)="updateSystem()"
class="btn btn-primary mr-2">Save</button>
<b style="line-height: 34px;">You must restart this device after saving for changes to take effect.</b>
</div>

<div class="mt-2">
<button pButton [disabled]="!savedChanges" (click)="restart()">Restart</button>
</div>
</form>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SystemService } from 'src/app/services/system.service';
export class NetworkEditComponent implements OnInit {

public form!: FormGroup;
public savedChanges: boolean = false;

@Input() uri = '';

Expand Down Expand Up @@ -56,9 +57,11 @@ export class NetworkEditComponent implements OnInit {
.subscribe({
next: () => {
this.toastr.success('Success!', 'Saved.');
this.savedChanges = true;
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error.', `Could not save. ${err.message}`);
this.savedChanges = false;
}
});
}
Expand All @@ -67,4 +70,17 @@ export class NetworkEditComponent implements OnInit {
toggleWifiPasswordVisibility() {
this.showWifiPassword = !this.showWifiPassword;
}

public restart() {
this.systemService.restart()
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
this.toastr.success('Success!', 'Bitaxe restarted');
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error', `Could not restart. ${err.message}`);
}
});
}
}

0 comments on commit c745cbb

Please sign in to comment.