blob: d20115e3b6854a5968e19151349040ea732eaa7b [file] [log] [blame]
Iftekharul Islamcd789502017-04-19 14:37:55 -05001/**
2 * Controller for server
3 *
4 * @module app/serverControl
5 * @exports remoteConsoleController
6 * @name remoteConsoleController
Iftekharul Islamcd789502017-04-19 14:37:55 -05007 */
8
Ed Tanousbbcf6702017-10-06 13:53:06 -07009import {hterm, lib} from 'hterm-umdjs';
10
Iftekharul Islamcd789502017-04-19 14:37:55 -050011window.angular && (function (angular) {
12 'use strict';
13
14 angular
15 .module('app.serverControl')
16 .controller('remoteConsoleController', [
Gunnar Millseedefd32018-02-28 17:02:34 -060017 '$scope',
18 '$window',
19 'APIUtils',
Iftekharul Islamcd789502017-04-19 14:37:55 -050020 'dataService',
21 function($scope, $window, APIUtils, dataService){
22 $scope.dataService = dataService;
Michael Davis8b522062017-05-05 09:21:07 -050023
24 // See https://github.com/macton/hterm for available hterm options
Gunnar Millseedefd32018-02-28 17:02:34 -060025
Michael Davis8b522062017-05-05 09:21:07 -050026 //Storage
27 hterm.defaultStorage = new lib.Storage.Local();
28
29 var term = new hterm.Terminal("foo");
30 term.onTerminalReady = function() {
31 var io = term.io.push();
32 io.onVTKeystroke = function(str) {
33 console.log(str)
34 term.io.print(str);
35 };
36 io.sendString = function(str) {
37 console.log(str)
38 };
39 };
40 term.decorate(document.querySelector('#terminal'));
41
42 //Set cursor color
43 term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
44
45 //Set background color
46 term.prefs_.set('background-color', '#19273c');
47
48 //Print to console window
49 term.io.println('OpenBMC ver.00');
50 term.io.println('This is not an actual live connection.');
Ed Tanous879481e2017-11-06 15:54:03 -080051 term.io.print('root@OpenBmc:');
Gunnar Millseedefd32018-02-28 17:02:34 -060052
Michael Davis8b522062017-05-05 09:21:07 -050053 //Allows keyboard input
54 term.installKeyboard();
Iftekharul Islamc4172b52017-09-06 10:43:20 -050055
56 $scope.openTerminalWindow = function(){
57 dataService.setRemoteWindowActive();
58 $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');
59 }
Iftekharul Islamcd789502017-04-19 14:37:55 -050060 }
61 ]
62 );
63
64})(angular);