From 2364af1b98b857e17437779589a966dc073b7530 Mon Sep 17 00:00:00 2001 From: Evgeny Stepanovych Date: Thu, 21 Dec 2023 14:02:26 +0100 Subject: [PATCH] Revert "Revert "NAS-124392: Remove web shell (#8967)" (#9032)" (#9357) This reverts commit 8743934c307ef3bf018d16de23339b2d019789b7. --- src/app/app.routes.ts | 5 - src/app/pages/shell/index.ts | 1 - src/app/pages/shell/shell.component.css | 13 -- src/app/pages/shell/shell.component.html | 33 ----- src/app/pages/shell/shell.component.ts | 140 ------------------ src/app/pages/shell/shell.module.ts | 18 --- src/app/pages/shell/shell.routing.ts | 11 -- .../services/navigation/navigation.service.ts | 7 - 8 files changed, 228 deletions(-) delete mode 100644 src/app/pages/shell/index.ts delete mode 100644 src/app/pages/shell/shell.component.css delete mode 100644 src/app/pages/shell/shell.component.html delete mode 100644 src/app/pages/shell/shell.component.ts delete mode 100644 src/app/pages/shell/shell.module.ts delete mode 100644 src/app/pages/shell/shell.routing.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 0caf912ea1c..34f4ad9baea 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -100,11 +100,6 @@ export const rootRouterConfig: Routes = [{ loadChildren: 'app/pages/systemprocesses/system-processes.module#SystemProcessesModule', data: { title: 'System Processes', breadcrumb: 'System Processes' }, }, - { - path: 'shell', - loadChildren: './pages/shell/shell.module#ShellModule', - data: { title: 'Shell', breadcrumb: 'Shell' }, - }, { path: 'guide', loadChildren: './pages/guide/guide.module#GuideModule', diff --git a/src/app/pages/shell/index.ts b/src/app/pages/shell/index.ts deleted file mode 100644 index a263bff0b5c..00000000000 --- a/src/app/pages/shell/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shell.component'; diff --git a/src/app/pages/shell/shell.component.css b/src/app/pages/shell/shell.component.css deleted file mode 100644 index 7862615e86b..00000000000 --- a/src/app/pages/shell/shell.component.css +++ /dev/null @@ -1,13 +0,0 @@ -.shellTooltip { - position: absolute !important; - right: 20px; -} - -#terminal { - margin-bottom: 10px; - overflow: hidden; -} - -mat-card { - min-width: 700px; -} \ No newline at end of file diff --git a/src/app/pages/shell/shell.component.html b/src/app/pages/shell/shell.component.html deleted file mode 100644 index eb5e1e9e852..00000000000 --- a/src/app/pages/shell/shell.component.html +++ /dev/null @@ -1,33 +0,0 @@ - - -
- {{"Shell" | translate}} -
-
- -
- - - - {{"Set font size" | translate}}: - - - - - - - - - -
diff --git a/src/app/pages/shell/shell.component.ts b/src/app/pages/shell/shell.component.ts deleted file mode 100644 index 22c61935a34..00000000000 --- a/src/app/pages/shell/shell.component.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { - Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChange, ViewChild, -} from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; -import { MatDialog } from '@angular/material/dialog'; -import { ShellService, WebSocketService } from '../../services'; -import helptext from '../../helptext/shell/shell'; -import { CopyPasteMessageComponent } from './copy-paste-message.component'; - -@Component({ - selector: 'app-shell', - templateUrl: './shell.component.html', - styleUrls: ['./shell.component.css'], - providers: [ShellService], -}) -export class ShellComponent implements OnInit, OnChanges, OnDestroy { - // sets the shell prompt - @Input() prompt = ''; - // xter container - @ViewChild('terminal', { static: true }) container: ElementRef; - // xterm variables - cols: string; - rows: string; - font_size = 14; - token: any; - xterm: any; - resize_terminal = true; - private shellSubscription: any; - - usage_tooltip = helptext.usage_tooltip; - - clearLine = '\u001b[2K\r'; - shellConnected = false; - - ngOnInit() { - this.getAuthToken().subscribe((res) => { - this.initializeWebShell(res); - this.shellSubscription = this.ss.shellOutput.subscribe((value) => { - if (value !== undefined) { - this.xterm.write(value); - } - }); - this.initializeTerminal(); - }); - } - - ngOnDestroy() { - if (this.ss.connected) { - this.ss.socket.close(); - } - if (this.shellSubscription) { - this.shellSubscription.unsubscribe(); - } - } - - onResize(event) { - // this.resizeTerm(); - } - - resetDefault() { - this.font_size = 14; - } - - ngOnChanges(changes: { - [propKey: string]: SimpleChange; - }) { - const log: string[] = []; - for (const propName in changes) { - const changedProp = changes[propName]; - // reprint prompt - if (propName === 'prompt' && this.xterm != null) { - this.xterm.write(this.clearLine + this.prompt); - } - } - } - - onRightClick(): false { - this.dialog.open(CopyPasteMessageComponent); - return false; - } - - initializeTerminal() { - const domHeight = document.body.offsetHeight; - const domWidth = document.body.offsetWidth; - let colNum = (domWidth * 0.75 - 104) / 10; - if (colNum < 80) { - colNum = 80; - } - let rowNum = (domHeight * 0.75 - 104) / 21; - if (rowNum < 10) { - rowNum = 10; - } - - this.xterm = new (window).Terminal({ - cursorBlink: false, - tabStopWidth: 8, - // 'cols': parseInt(colNum.toFixed(),10), - // 'rows': parseInt(rowNum.toFixed(),10), - focus: true, - }); - this.xterm.open(this.container.nativeElement, true); - this.xterm.attach(this.ss); - this.xterm._initialized = true; - } - - resizeTerm() { - const domHeight = document.body.offsetHeight; - const domWidth = document.body.offsetWidth; - let colNum = (domWidth * 0.75 - 104) / 10; - if (colNum < 80) { - colNum = 80; - } - let rowNum = (domHeight * 0.75 - 104) / 21; - if (rowNum < 10) { - rowNum = 10; - } - this.xterm.resize(colNum, rowNum); - return true; - } - - initializeWebShell(res: string) { - this.ss.token = res; - this.ss.connect(); - - this.ss.shellConnected.subscribe((res) => { - this.shellConnected = res; - }); - } - - getAuthToken() { - return this.ws.call('auth.generate_token'); - } - - reconnect() { - this.ss.connect(); - } - - constructor(private ws: WebSocketService, public ss: ShellService, public translate: TranslateService, private dialog: MatDialog) { - } -} diff --git a/src/app/pages/shell/shell.module.ts b/src/app/pages/shell/shell.module.ts deleted file mode 100644 index 9c5061b1514..00000000000 --- a/src/app/pages/shell/shell.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Common Modules -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { MaterialModule } from '../../appMaterial.module'; -import { EntityModule } from '../common/entity/entity.module'; -import { CommonDirectivesModule } from '../../directives/common/common-directives.module'; -// Component Modules -import { ShellComponent } from './shell.component'; -import { routing } from './shell.routing'; -import { TranslateModule } from '@ngx-translate/core'; -import { CoreComponents } from 'app/core/components/corecomponents.module'; - -@NgModule({ - imports: [CommonModule, FormsModule, EntityModule, routing, MaterialModule, TranslateModule, CoreComponents, CommonDirectivesModule], - declarations: [ShellComponent], -}) -export class ShellModule {} diff --git a/src/app/pages/shell/shell.routing.ts b/src/app/pages/shell/shell.routing.ts deleted file mode 100644 index f4f68169457..00000000000 --- a/src/app/pages/shell/shell.routing.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ModuleWithProviders } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { ShellComponent } from './shell.component'; - -export const routes: Routes = [{ - path: '', - component: ShellComponent, -}]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/src/app/services/navigation/navigation.service.ts b/src/app/services/navigation/navigation.service.ts index 515e23fa9c0..7c7fdff9f4b 100644 --- a/src/app/services/navigation/navigation.service.ts +++ b/src/app/services/navigation/navigation.service.ts @@ -221,13 +221,6 @@ export class NavigationService { icon: 'perm_data_setting', state: 'systemprocesses', }, - { - name: T('Shell'), - type: 'link', - tooltip: T('Shell'), - icon: 'console-line', - state: 'shell', - }, { name: T('Guide'), type: 'extLink',