edge case of joining two swarms

This commit is contained in:
Ben 2023-11-25 23:06:51 -05:00
parent 6cd5e2c950
commit 185ecf497f
3 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{
"idf.flashType": "UART",
"idf.portWin": "COM36",
"idf.portWin": "COM30",
"idf.adapterTargetName": "esp32s3",
"idf.openOcdConfigs": [
"interface/ftdi/esp32_devkitj_v1.cfg",

View File

@ -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])

View File

@ -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) {