33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { ConnectResult, WifiNetwork, WifiStatus } from '../shared/types'
|
|
|
|
export const connectToWifi = (ssid: string, password?: string): Promise<ConnectResult> =>
|
|
fetch('/api/wifi/connect', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ ssid, password }),
|
|
}).then(r => r.json())
|
|
|
|
export const getLogDates = (name: string): Promise<string[]> =>
|
|
fetch(`/api/apps/${name}/logs/dates`).then(r => r.json())
|
|
|
|
export const getLogsForDate = (name: string, date: string): Promise<string[]> =>
|
|
fetch(`/api/apps/${name}/logs?date=${date}`).then(r => r.json())
|
|
|
|
export const getWifiStatus = (): Promise<WifiStatus & { setupMode: boolean, url: string }> =>
|
|
fetch('/api/wifi/status').then(r => r.json())
|
|
|
|
export const restartApp = (name: string) => fetch(`/api/apps/${name}/restart`, { method: 'POST' })
|
|
|
|
export const scanWifiNetworks = (): Promise<WifiNetwork[]> =>
|
|
fetch('/api/wifi/scan').then(r => r.json())
|
|
|
|
export const shareApp = (name: string) =>
|
|
fetch(`/api/apps/${name}/tunnel`, { method: 'POST' })
|
|
|
|
export const startApp = (name: string) => fetch(`/api/apps/${name}/start`, { method: 'POST' })
|
|
|
|
export const stopApp = (name: string) => fetch(`/api/apps/${name}/stop`, { method: 'POST' })
|
|
|
|
export const unshareApp = (name: string) =>
|
|
fetch(`/api/apps/${name}/tunnel`, { method: 'DELETE' })
|