Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for server |
| 3 | * |
| 4 | * @module app/serverControl |
| 5 | * @exports remoteConsoleController |
| 6 | * @name remoteConsoleController |
| 7 | * @version 0.1.0 |
| 8 | */ |
| 9 | |
Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 10 | import {hterm, lib} from 'hterm-umdjs'; |
| 11 | |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 12 | window.angular && (function (angular) { |
| 13 | 'use strict'; |
| 14 | |
| 15 | angular |
| 16 | .module('app.serverControl') |
| 17 | .controller('remoteConsoleController', [ |
Gunnar Mills | eedefd3 | 2018-02-28 17:02:34 -0600 | [diff] [blame^] | 18 | '$scope', |
| 19 | '$window', |
| 20 | 'APIUtils', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 21 | 'dataService', |
| 22 | function($scope, $window, APIUtils, dataService){ |
| 23 | $scope.dataService = dataService; |
Michael Davis | 8b52206 | 2017-05-05 09:21:07 -0500 | [diff] [blame] | 24 | |
| 25 | // See https://github.com/macton/hterm for available hterm options |
Gunnar Mills | eedefd3 | 2018-02-28 17:02:34 -0600 | [diff] [blame^] | 26 | |
Michael Davis | 8b52206 | 2017-05-05 09:21:07 -0500 | [diff] [blame] | 27 | //Storage |
| 28 | hterm.defaultStorage = new lib.Storage.Local(); |
| 29 | |
| 30 | var term = new hterm.Terminal("foo"); |
| 31 | term.onTerminalReady = function() { |
| 32 | var io = term.io.push(); |
| 33 | io.onVTKeystroke = function(str) { |
| 34 | console.log(str) |
| 35 | term.io.print(str); |
| 36 | }; |
| 37 | io.sendString = function(str) { |
| 38 | console.log(str) |
| 39 | }; |
| 40 | }; |
| 41 | term.decorate(document.querySelector('#terminal')); |
| 42 | |
| 43 | //Set cursor color |
| 44 | term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)'); |
| 45 | |
| 46 | //Set background color |
| 47 | term.prefs_.set('background-color', '#19273c'); |
| 48 | |
| 49 | //Print to console window |
| 50 | term.io.println('OpenBMC ver.00'); |
| 51 | term.io.println('This is not an actual live connection.'); |
Ed Tanous | 879481e | 2017-11-06 15:54:03 -0800 | [diff] [blame] | 52 | term.io.print('root@OpenBmc:'); |
Gunnar Mills | eedefd3 | 2018-02-28 17:02:34 -0600 | [diff] [blame^] | 53 | |
Michael Davis | 8b52206 | 2017-05-05 09:21:07 -0500 | [diff] [blame] | 54 | //Allows keyboard input |
| 55 | term.installKeyboard(); |
Iftekharul Islam | c4172b5 | 2017-09-06 10:43:20 -0500 | [diff] [blame] | 56 | |
| 57 | $scope.openTerminalWindow = function(){ |
| 58 | dataService.setRemoteWindowActive(); |
| 59 | $window.open('#/server-control/remote-console-window','Remote Console Window','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=400'); |
| 60 | } |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 61 | } |
| 62 | ] |
| 63 | ); |
| 64 | |
| 65 | })(angular); |