refresh LAN and more

This commit is contained in:
Matt Hill
2021-02-26 14:32:58 -07:00
committed by Aiden McClelland
parent 3e3097945f
commit 6585d91816
42 changed files with 119 additions and 284 deletions

View File

@@ -63,6 +63,7 @@ export abstract class ApiService {
abstract shutdownServer (): Promise<Unit>
abstract ejectExternalDisk (logicalName: string): Promise<Unit>
abstract serviceAction (appId: string, serviceAction: ServiceAction): Promise<ReqRes.ServiceActionResponse>
abstract refreshLAN (): Promise<Unit>
}
export function isRpcFailure<Error, Result> (arg: { error: Error } | { result: Result}): arg is { error: Error } {

View File

@@ -13,6 +13,7 @@ import { modulateTime } from 'src/app/util/misc.util'
import { Observable, of, throwError } from 'rxjs'
import { catchError, mapTo } from 'rxjs/operators'
import * as uuid from 'uuid'
import { METHODS } from 'http'
@Injectable()
export class LiveApiService extends ApiService {
@@ -276,6 +277,10 @@ export class LiveApiService extends ApiService {
return this.authRequest({ method: Method.POST, url: `apps/${appId}/actions`, data })
}
async refreshLAN (): Promise<Unit> {
return this.authRequest({ method: Method.POST, url: '/network/lan/reset' })
}
private async authRequest<T> (opts: HttpOptions, overrides: Partial<{ version: string }> = { }): Promise<T> {
if (!this.authenticatedRequestsEnabled) throw new Error(`Authenticated requests are not enabled. Do you need to login?`)

View File

@@ -242,6 +242,10 @@ export class MockApiService extends ApiService {
},
}
}
refreshLAN (): Promise<Unit> {
return mockRefreshLAN()
}
}
async function mockGetServer (): Promise<ReqRes.GetServerRes> {
@@ -406,6 +410,11 @@ async function mockShutdownServer (): Promise<Unit> {
return { }
}
async function mockRefreshLAN (): Promise<Unit> {
await pauseFor(1000)
return { }
}
const mockApiNotifications: ReqRes.GetNotificationsRes = [
{
id: '123e4567-e89b-12d3-a456-426655440000',