Skip to content

Commit

Permalink
fixed wifi password, added links to latest firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-wilson committed Jan 8, 2024
1 parent a78045d commit 205fbe9
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 7 deletions.
3 changes: 2 additions & 1 deletion main/http_server/axe-os/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -40,6 +40,7 @@ const components = [
AppRoutingModule,
HttpClientModule,
ReactiveFormsModule,
FormsModule,
ToastrModule.forRoot({
positionClass: 'toast-bottom-right'
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ <h2>Settings</h2>
<app-edit></app-edit>


</div>

<div class="card" *ngIf="latestRelease$ | async as latestRelease">
<h2>Latest Release: {{latestRelease.name}}</h2>



<div *ngFor="let asset of latestRelease.assets">
<div *ngIf="asset.name == 'esp-miner.bin'">
<a target="_blank" [href]="asset.browser_download_url">esp-miner.bin</a>
</div>
<div *ngIf="asset.name == 'www.bin'">
<a target="_blank" [href]="asset.browser_download_url">www.bin</a>
</div>
</div>


</div>

<div class="card">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ select {
select {
min-width: 518px
}
}

a {
color: white;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,17 +25,26 @@ export class SettingsComponent {
public eASICModel = eASICModel;
public ASICModel!: eASICModel;

public latestRelease$: Observable<any>;

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 => {
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
19 changes: 19 additions & 0 deletions main/http_server/axe-os/src/app/services/github-update.service.ts
Original file line number Diff line number Diff line change
@@ -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<any[]>;
}

}
9 changes: 5 additions & 4 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SystemService {
}


private otaUpdate(file: File, url: string) {
private otaUpdate(file: File | Blob, url: string) {
return new Observable<HttpEvent<string>>((subscriber) => {
const reader = new FileReader();

Expand All @@ -78,12 +78,13 @@ export class SystemService {
},
}).subscribe({
next: (e) => {
subscriber.next(e)

},
error: (err) => {
subscriber.error(err)
},
complete: () => {
subscriber.next()
subscriber.complete();
}
});
Expand All @@ -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`);
}

Expand Down

0 comments on commit 205fbe9

Please sign in to comment.