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 d274ca1b8..a8887f39f 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 @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ToastrService } from 'ngx-toastr'; import { FileUploadHandlerEvent } from 'primeng/fileupload'; -import { map, Observable, shareReplay, startWith } from 'rxjs'; +import { map, Observable, shareReplay, startWith, switchMap } 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'; @@ -44,12 +44,17 @@ export class SettingsComponent { window.addEventListener('resize', this.checkDevTools); this.checkDevTools(); - - this.latestRelease$ = this.githubUpdateService.getReleases().pipe(map(releases => { - return releases[0]; - })); - this.info$ = this.systemService.getInfo().pipe(shareReplay({refCount: true, bufferSize: 1})) + + this.latestRelease$ = this.info$.pipe( + switchMap(info => { + return this.githubUpdateService.getReleases(info.ASICModel).pipe( + map(releases => releases[0]) + ); + }) + ); + + this.info$.pipe(this.loadingService.lockUIUntilComplete()) 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 index 25451c6ed..be4464073 100644 --- 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 @@ -1,8 +1,8 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; - +import { Observable, from } from 'rxjs'; +import { map, mergeMap, toArray } from 'rxjs/operators'; +import { eASICModel } from 'src/models/enum/eASICModel'; interface GithubRelease { id: number; @@ -11,22 +11,36 @@ interface GithubRelease { prerelease: boolean; } +interface ASICModelConfig { + supported_asic_models: eASICModel[]; +} + @Injectable({ providedIn: 'root' }) export class GithubUpdateService { - constructor( private httpClient: HttpClient - ) { } - + ) {} - public getReleases(): Observable { + public getReleases(currentASICModel: eASICModel): Observable { return this.httpClient.get( - 'https://api.github.com/repos/skot/esp-miner/releases' + 'https://api.github.com/repos/wantclue/esp-miner-wantclue/releases' ).pipe( - map((releases: GithubRelease[]) => releases.filter((release: GithubRelease) => !release.prerelease)) + mergeMap((releases: GithubRelease[]) => from(releases)), + mergeMap((release: GithubRelease) => + this.httpClient.get( + `https://raw.githubusercontent.com/wantclue/esp-miner-wantclue/${release.tag_name}/asic_models.json` + ).pipe( + map(config => ({ release, supported_asic_models: config.supported_asic_models })) + ) + ), + toArray(), + map((releasesWithConfig) => + releasesWithConfig.filter(({ release, supported_asic_models }) => + !release.prerelease && supported_asic_models.includes(currentASICModel) + ).map(({ release }) => release) + ) ); } - } \ No newline at end of file