UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

80 lines (76 loc) 3.63 kB
import * as i0 from '@angular/core'; import { Injectable } from '@angular/core'; import { gettext, hookRoute, ViewContext, hookService } from '@c8y/ngx-components'; import * as i1 from '@c8y/ngx-components/remote-access/data'; import { canActivateRemoteAccess } from '@c8y/ngx-components/remote-access/data'; import * as i2 from 'ngx-bootstrap/modal'; class SSHRemoteAccessProtocolProviderService { constructor(remoteAccess, bsModalService) { this.remoteAccess = remoteAccess; this.bsModalService = bsModalService; this.protocolName = 'SSH'; this.protocolLabel = gettext('SSH'); this.protocolDescription = gettext('Allows to connect to an SSH service.'); this.protocolIcon = 'laptop'; } async addEndpoint(deviceId) { const modalResult = await this.openSSHEndpointModal({}); if (!modalResult) { return modalResult; } return this.remoteAccess.addConfiguration(deviceId, modalResult); } removeEndpoint(deviceId, currentEndpointConfig) { return this.remoteAccess.deleteConfiguration(deviceId, currentEndpointConfig.id); } async editEndpoint(deviceId, currentEndpointConfig) { const modalResult = await this.openSSHEndpointModal(currentEndpointConfig); if (!modalResult) { return modalResult; } return this.remoteAccess.updateConfiguration(deviceId, modalResult); } async connectEndpointHref(deviceId, configuration) { return `/device/${deviceId}/ssh/${configuration.id}`; } async getDefaultEndpointConfiguration() { return { hostname: '127.0.0.1', port: 22 }; } async openSSHEndpointModal(currentConfiguration) { const { RemoteAccessSshEndpointModalComponent } = await import('@c8y/ngx-components/remote-access/ssh/remote-access-ssh-endpoint-modal'); try { const modalRef = this.bsModalService.show(RemoteAccessSshEndpointModalComponent, { initialState: { currentValue: currentConfiguration } }); return (await modalRef.content.result); } catch (e) { // modal closed return null; } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SSHRemoteAccessProtocolProviderService, deps: [{ token: i1.RemoteAccessService }, { token: i2.BsModalService }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SSHRemoteAccessProtocolProviderService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SSHRemoteAccessProtocolProviderService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1.RemoteAccessService }, { type: i2.BsModalService }] }); const remoteAccessSSHProviders = [ hookRoute({ loadComponent: () => import('@c8y/ngx-components/remote-access/terminal-viewer').then(m => m.TerminalViewerComponent), path: 'ssh/:configurationId', context: ViewContext.Device, tabs: [], canActivate: [canActivateRemoteAccess] }), hookService('remoteAccessProtocolHook', SSHRemoteAccessProtocolProviderService) ]; /** * Generated bundle index. Do not edit. */ export { SSHRemoteAccessProtocolProviderService, remoteAccessSSHProviders }; //# sourceMappingURL=c8y-ngx-components-remote-access-ssh.mjs.map