reflow machines from k/v
This commit is contained in:
@ -1,13 +1,11 @@
|
|||||||
import { isDesktop } from './isDesktop'
|
import { isDesktop } from './isDesktop'
|
||||||
import { components } from './machine-api'
|
import { components } from './machine-api'
|
||||||
|
|
||||||
export type MachinesListing = {
|
export type MachinesListing = Array<components['schemas']['Machine']>
|
||||||
[key: string]: components['schemas']['Machine']
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MachineManager {
|
export class MachineManager {
|
||||||
private _isDesktop: boolean = isDesktop()
|
private _isDesktop: boolean = isDesktop()
|
||||||
private _machines: MachinesListing = {}
|
private _machines: MachinesListing = []
|
||||||
private _machineApiIp: string | null = null
|
private _machineApiIp: string | null = null
|
||||||
private _currentMachine: components['schemas']['Machine'] | null = null
|
private _currentMachine: components['schemas']['Machine'] | null = null
|
||||||
|
|
||||||
@ -44,7 +42,7 @@ export class MachineManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
machineCount(): number {
|
machineCount(): number {
|
||||||
return Object.keys(this._machines).length
|
return this._machines.length
|
||||||
}
|
}
|
||||||
|
|
||||||
get machineApiIp(): string | null {
|
get machineApiIp(): string | null {
|
||||||
|
@ -52,7 +52,7 @@ const kittycad = (access: string, args: any) =>
|
|||||||
// bite our butts.
|
// bite our butts.
|
||||||
const listMachines = async (): Promise<MachinesListing> => {
|
const listMachines = async (): Promise<MachinesListing> => {
|
||||||
const machineApi = await ipcRenderer.invoke('find_machine_api')
|
const machineApi = await ipcRenderer.invoke('find_machine_api')
|
||||||
if (!machineApi) return {}
|
if (!machineApi) return []
|
||||||
|
|
||||||
return fetch(`http://${machineApi}/machines`).then((resp) => resp.json())
|
return fetch(`http://${machineApi}/machines`).then((resp) => resp.json())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user