diff --git a/main/http_server/axe-os/src/app/app.module.ts b/main/http_server/axe-os/src/app/app.module.ts index 1587610b..741af511 100644 --- a/main/http_server/axe-os/src/app/app.module.ts +++ b/main/http_server/axe-os/src/app/app.module.ts @@ -1,7 +1,7 @@ import { CommonModule, HashLocationStrategy, LocationStrategy } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ToastrModule } from 'ngx-toastr'; @@ -40,6 +40,7 @@ const components = [ AppRoutingModule, HttpClientModule, ReactiveFormsModule, + FormsModule, ToastrModule.forRoot({ positionClass: 'toast-bottom-right' }), diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.ts b/main/http_server/axe-os/src/app/components/edit/edit.component.ts index 3d88da76..1da53380 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.ts +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.ts @@ -104,6 +104,10 @@ export class EditComponent implements OnInit { form.invertfanpolarity = form.invertfanpolarity == true ? 1 : 0; form.autofanspeed = form.autofanspeed == true ? 1 : 0; + if (form.wifiPass === 'password') { + delete form.wifiPass; + } + this.systemService.updateSystem(this.uri, form) .pipe(this.loadingService.lockUIUntilComplete()) .subscribe({ diff --git a/main/http_server/axe-os/src/app/components/settings/settings.component.html b/main/http_server/axe-os/src/app/components/settings/settings.component.html index 8311164b..e15016d1 100644 --- a/main/http_server/axe-os/src/app/components/settings/settings.component.html +++ b/main/http_server/axe-os/src/app/components/settings/settings.component.html @@ -4,6 +4,23 @@

Settings

+ + +
+

Latest Release: {{latestRelease.name}}

+ + + +
+
+ esp-miner.bin +
+
+ www.bin +
+
+ +
diff --git a/main/http_server/axe-os/src/app/components/settings/settings.component.scss b/main/http_server/axe-os/src/app/components/settings/settings.component.scss index aeb89d19..bb58d6e3 100644 --- a/main/http_server/axe-os/src/app/components/settings/settings.component.scss +++ b/main/http_server/axe-os/src/app/components/settings/settings.component.scss @@ -28,4 +28,8 @@ select { select { min-width: 518px } +} + +a { + color: white; } \ No newline at end of file diff --git a/main/http_server/axe-os/src/app/components/settings/settings.component.ts b/main/http_server/axe-os/src/app/components/settings/settings.component.ts index 9d387fcd..74e8baeb 100644 --- a/main/http_server/axe-os/src/app/components/settings/settings.component.ts +++ b/main/http_server/axe-os/src/app/components/settings/settings.component.ts @@ -2,7 +2,8 @@ import { HttpErrorResponse, HttpEventType } from '@angular/common/http'; import { Component } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ToastrService } from 'ngx-toastr'; -import { startWith } from 'rxjs'; +import { map, Observable, startWith } from 'rxjs'; +import { GithubUpdateService } from 'src/app/services/github-update.service'; import { LoadingService } from 'src/app/services/loading.service'; import { SystemService } from 'src/app/services/system.service'; import { eASICModel } from 'src/models/enum/eASICModel'; @@ -24,17 +25,26 @@ export class SettingsComponent { public eASICModel = eASICModel; public ASICModel!: eASICModel; + public latestRelease$: Observable; + constructor( private fb: FormBuilder, private systemService: SystemService, private toastr: ToastrService, private toastrService: ToastrService, - private loadingService: LoadingService + private loadingService: LoadingService, + private githubUpdateService: GithubUpdateService ) { + + window.addEventListener('resize', this.checkDevTools); this.checkDevTools(); + this.latestRelease$ = this.githubUpdateService.getReleases().pipe(map(releases => { + return releases[0]; + })) + this.systemService.getInfo() .pipe(this.loadingService.lockUIUntilComplete()) .subscribe(info => { @@ -99,6 +109,10 @@ export class SettingsComponent { form.invertfanpolarity = form.invertfanpolarity == true ? 1 : 0; form.autofanspeed = form.autofanspeed == true ? 1 : 0; + if (form.wifiPass === 'password') { + delete form.wifiPass; + } + this.systemService.updateSystem(undefined, form) .pipe(this.loadingService.lockUIUntilComplete()) .subscribe({ diff --git a/main/http_server/axe-os/src/app/services/github-update.service.spec.ts b/main/http_server/axe-os/src/app/services/github-update.service.spec.ts new file mode 100644 index 00000000..43f5df9d --- /dev/null +++ b/main/http_server/axe-os/src/app/services/github-update.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { GithubUpdateService } from './github-update.service'; + +describe('GithubUpdateService', () => { + let service: GithubUpdateService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(GithubUpdateService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/main/http_server/axe-os/src/app/services/github-update.service.ts b/main/http_server/axe-os/src/app/services/github-update.service.ts new file mode 100644 index 00000000..e3784205 --- /dev/null +++ b/main/http_server/axe-os/src/app/services/github-update.service.ts @@ -0,0 +1,19 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class GithubUpdateService { + + constructor( + private httpClient: HttpClient + ) { } + + + public getReleases() { + return this.httpClient.get(`https://api.github.com/repos/skot/esp-miner/releases`) as Observable; + } + +} \ No newline at end of file diff --git a/main/http_server/axe-os/src/app/services/system.service.ts b/main/http_server/axe-os/src/app/services/system.service.ts index cc607b8d..d380918d 100644 --- a/main/http_server/axe-os/src/app/services/system.service.ts +++ b/main/http_server/axe-os/src/app/services/system.service.ts @@ -62,7 +62,7 @@ export class SystemService { } - private otaUpdate(file: File, url: string) { + private otaUpdate(file: File | Blob, url: string) { return new Observable>((subscriber) => { const reader = new FileReader(); @@ -78,12 +78,13 @@ export class SystemService { }, }).subscribe({ next: (e) => { - subscriber.next(e) + }, error: (err) => { subscriber.error(err) }, complete: () => { + subscriber.next() subscriber.complete(); } }); @@ -92,10 +93,10 @@ export class SystemService { }); } - public performOTAUpdate(file: File) { + public performOTAUpdate(file: File | Blob) { return this.otaUpdate(file, `/api/system/OTA`); } - public performWWWOTAUpdate(file: File) { + public performWWWOTAUpdate(file: File | Blob) { return this.otaUpdate(file, `/api/system/OTAWWW`); }