mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-04-12 22:09:18 +02:00
edge case of joining two swarms
This commit is contained in:
parent
6cd5e2c950
commit
185ecf497f
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"idf.flashType": "UART",
|
||||
"idf.portWin": "COM36",
|
||||
"idf.portWin": "COM30",
|
||||
"idf.adapterTargetName": "esp32s3",
|
||||
"idf.openOcdConfigs": [
|
||||
"interface/ftdi/esp32_devkitj_v1.cfg",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { BehaviorSubject, catchError, forkJoin, map, Observable, of, startWith, switchMap } from 'rxjs';
|
||||
import { BehaviorSubject, catchError, combineLatest, forkJoin, map, Observable, of, startWith, switchMap } from 'rxjs';
|
||||
import { SystemService } from 'src/app/services/system.service';
|
||||
|
||||
@Component({
|
||||
@ -60,11 +60,11 @@ export class SwarmComponent {
|
||||
public add() {
|
||||
const newIp = this.form.value.ip;
|
||||
|
||||
this.systemService.getSwarmInfo().pipe(
|
||||
switchMap((swarmInfo) => {
|
||||
combineLatest([this.systemService.getSwarmInfo('http://' + newIp), this.systemService.getSwarmInfo()]).pipe(
|
||||
switchMap(([newSwarmInfo, swarmInfo]) => {
|
||||
|
||||
const swarmUpdate = swarmInfo.map(({ ip }) => {
|
||||
return this.systemService.updateSwarm('http://' + ip, [{ ip: newIp }, ...swarmInfo])
|
||||
return this.systemService.updateSwarm('http://' + ip, [{ ip: newIp }, ...newSwarmInfo, ...swarmInfo])
|
||||
});
|
||||
|
||||
const newAxeOs = this.systemService.updateSwarm('http://' + newIp, [{ ip: newIp }, ...swarmInfo])
|
||||
|
@ -100,8 +100,8 @@ export class SystemService {
|
||||
}
|
||||
|
||||
|
||||
public getSwarmInfo(): Observable<{ ip: string }[]> {
|
||||
return this.httpClient.get(`/api/swarm/info`) as Observable<{ ip: string }[]>;
|
||||
public getSwarmInfo(uri: string = ''): Observable<{ ip: string }[]> {
|
||||
return this.httpClient.get(`${uri}/api/swarm/info`) as Observable<{ ip: string }[]>;
|
||||
}
|
||||
|
||||
public updateSwarm(uri: string = '', swarmConfig: any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user