blob: 7da4526def889ed96106cc4c3b87aa131f3849c8 [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
7 * @version 0.1.0
8 */
9
Ed Tanousbbcf6702017-10-06 13:53:06 -070010import {hterm, lib} from 'hterm-umdjs';
11
Iftekharul Islamcd789502017-04-19 14:37:55 -050012window.angular && (function (angular) {
13 'use strict';
14
15 angular
16 .module('app.serverControl')
17 .controller('remoteConsoleController', [
Gunnar Millseedefd32018-02-28 17:02:34 -060018 '$scope',
19 '$window',
20 'APIUtils',
Iftekharul Islamcd789502017-04-19 14:37:55 -050021 'dataService',
22 function($scope, $window, APIUtils, dataService){
23 $scope.dataService = dataService;
Michael Davis8b522062017-05-05 09:21:07 -050024
25 // See https://github.com/macton/hterm for available hterm options
Gunnar Millseedefd32018-02-28 17:02:34 -060026
Michael Davis8b522062017-05-05 09:21:07 -050027 //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 Tanous879481e2017-11-06 15:54:03 -080052 term.io.print('root@OpenBmc:');
Gunnar Millseedefd32018-02-28 17:02:34 -060053
Michael Davis8b522062017-05-05 09:21:07 -050054 //Allows keyboard input
55 term.installKeyboard();
Iftekharul Islamc4172b52017-09-06 10:43:20 -050056
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 Islamcd789502017-04-19 14:37:55 -050061 }
62 ]
63 );
64
65})(angular);