UNPKG

@deepkit/api-console-gui

Version:

API Console GUI

51 lines 1.8 kB
/* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ import { __decorate } from "tslib"; import { Injectable } from '@angular/core'; import { ApiConsoleApi } from '@deepkit/api-console-api'; import { LiveSubject } from '@deepkit/ui-library'; let ControllerClient = class ControllerClient { constructor(client) { this.client = client; this.entryPoints = new LiveSubject((subject) => { this.api.getEntryPoints().then(v => subject.next(v)); }); this.document = new LiveSubject((subject) => { this.api.getDocument().then(v => subject.next(v)); }); this.api = this.client.controller(ApiConsoleApi); this.client.transporter.reconnected.subscribe(() => { this.entryPoints.reload(); this.document.reload(); }); this.client.transporter.disconnected.subscribe(() => { this.tryToConnect(); }); } tryToConnect() { this.client.connect().catch(() => { setTimeout(() => { this.tryToConnect(); }, 1000); }); } setController(name) { this.api = this.client.controller(name); } static getServerHost() { const proto = location.protocol === 'https:' ? 'wss://' : 'ws://'; return proto + (location.port === '4200' ? location.hostname + ':8080' : location.host) + location.pathname; } }; ControllerClient = __decorate([ Injectable({ providedIn: 'root' }) ], ControllerClient); export { ControllerClient }; //# sourceMappingURL=client.js.map