-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into simplify_i2c_screen
- Loading branch information
Showing
37 changed files
with
539 additions
and
212 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
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
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
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
main/http_server/axe-os/src/app/components/network-edit/network.edit.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,34 @@ | ||
<ng-container *ngIf="form != null"> | ||
<form [formGroup]="form"> | ||
|
||
<div class="field grid p-fluid"> | ||
<label htmlFor="hostname" class="col-12 mb-2 md:col-2 md:mb-0">Hostname:</label> | ||
<div class="col-12 md:col-10"> | ||
<input pInputText id="hostname" type="text" formControlName="hostname" /> | ||
</div> | ||
</div> | ||
<div class="field grid p-fluid"> | ||
<label htmlFor="ssid" class="col-12 mb-2 md:col-2 md:mb-0">WiFi SSID:</label> | ||
<div class="col-12 md:col-10"> | ||
<input pInputText id="ssid" type="text" formControlName="ssid" /> | ||
</div> | ||
</div> | ||
<div class="field grid p-fluid"> | ||
<label htmlFor="wifiPass" class="col-12 mb-2 md:col-2 md:mb-0">WiFi Password:</label> | ||
<div class="col-12 md:col-10 p-input-icon-right"> | ||
<i *ngIf="form.get('wifiPass')?.dirty" class="pi" | ||
[ngClass]="{'pi-eye': !showWifiPassword, 'pi-eye-slash': showWifiPassword}" | ||
(click)="toggleWifiPasswordVisibility()" style="cursor: pointer;"></i> | ||
<input pInputText id="wifiPass" formControlName="wifiPass" | ||
[type]="showWifiPassword ? 'text' : 'password'" | ||
placeholder="Enter WiFi password" /> | ||
</div> | ||
</div> | ||
|
||
<div class="mt-2"> | ||
<button pButton [disabled]="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> | ||
</form> | ||
</ng-container> |
5 changes: 5 additions & 0 deletions
5
main/http_server/axe-os/src/app/components/network-edit/network.edit.component.scss
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,5 @@ | ||
.pi { | ||
right: 1rem; | ||
font-size: 1.5rem; | ||
top: 1rem; | ||
} |
21 changes: 21 additions & 0 deletions
21
main/http_server/axe-os/src/app/components/network-edit/network.edit.component.spec.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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { NetworkEditComponent } from './network.edit.component'; | ||
|
||
describe('NetworkEditComponent', () => { | ||
let component: NetworkEditComponent; | ||
let fixture: ComponentFixture<NetworkEditComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [NetworkEditComponent] | ||
}); | ||
fixture = TestBed.createComponent(NetworkEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
70 changes: 70 additions & 0 deletions
70
main/http_server/axe-os/src/app/components/network-edit/network.edit.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,70 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
import { ToastrService } from 'ngx-toastr'; | ||
import { startWith } from 'rxjs'; | ||
import { LoadingService } from 'src/app/services/loading.service'; | ||
import { SystemService } from 'src/app/services/system.service'; | ||
|
||
@Component({ | ||
selector: 'app-network-edit', | ||
templateUrl: './network.edit.component.html', | ||
styleUrls: ['./network.edit.component.scss'] | ||
}) | ||
export class NetworkEditComponent implements OnInit { | ||
|
||
public form!: FormGroup; | ||
|
||
@Input() uri = ''; | ||
|
||
constructor( | ||
private fb: FormBuilder, | ||
private systemService: SystemService, | ||
private toastr: ToastrService, | ||
private toastrService: ToastrService, | ||
private loadingService: LoadingService | ||
) { | ||
|
||
} | ||
ngOnInit(): void { | ||
this.systemService.getInfo(this.uri) | ||
.pipe(this.loadingService.lockUIUntilComplete()) | ||
.subscribe(info => { | ||
this.form = this.fb.group({ | ||
hostname: [info.hostname, [Validators.required]], | ||
ssid: [info.ssid, [Validators.required]], | ||
wifiPass: ['*****'], | ||
}); | ||
|
||
}); | ||
} | ||
|
||
|
||
public updateSystem() { | ||
|
||
const form = this.form.getRawValue(); | ||
|
||
// Allow an empty wifi password | ||
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass; | ||
|
||
if (form.wifiPass === '*****') { | ||
delete form.wifiPass; | ||
} | ||
|
||
this.systemService.updateSystem(this.uri, form) | ||
.pipe(this.loadingService.lockUIUntilComplete()) | ||
.subscribe({ | ||
next: () => { | ||
this.toastr.success('Success!', 'Saved.'); | ||
}, | ||
error: (err: HttpErrorResponse) => { | ||
this.toastr.error('Error.', `Could not save. ${err.message}`); | ||
} | ||
}); | ||
} | ||
|
||
showWifiPassword: boolean = false; | ||
toggleWifiPasswordVisibility() { | ||
this.showWifiPassword = !this.showWifiPassword; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
main/http_server/axe-os/src/app/components/network/network.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,5 @@ | ||
<div class="card"> | ||
<h2>Network Configuration</h2> | ||
|
||
<app-network-edit></app-network-edit> | ||
</div> |
Oops, something went wrong.