Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add restart to settings & better disabled state #493

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`);
}
});
}
}