Commit 5eb3afd5 authored by Filipa Lacerda's avatar Filipa Lacerda

Focus terminal on load

Use object.assign for default option
parent 6f694f24
import $ from 'jquery';
import { Terminal } from 'xterm';
import * as fit from 'xterm/lib/addons/fit/fit';
import * as attach from 'xterm/lib/addons/attach/attach';
export default class GLTerminal {
constructor(options) {
this.options = options || {};
if (!Object.prototype.hasOwnProperty.call(this.options, 'cursorBlink')) {
this.options.cursorBlink = true;
}
if (!Object.prototype.hasOwnProperty.call(this.options, 'screenKeys')) {
this.options.screenKeys = true;
}
constructor(options = {}) {
this.options = Object.assign({}, {
cursorBlink: true,
screenKeys: true,
}, options);
this.container = document.querySelector(options.selector);
......@@ -37,16 +31,15 @@ export default class GLTerminal {
createTerminal() {
Terminal.applyAddon(fit);
Terminal.applyAddon(attach);
this.terminal = new Terminal(this.options);
//TODO - CHECK IF WE SHOULD USE `attach` instead
this.socket = new WebSocket(this.socketUrl, ['terminal.gitlab.com']);
this.socket.binaryType = 'arraybuffer';
this.terminal.open(this.container);
this.terminal.fit();
this.terminal.focus();
this.socket.onopen = () => {
this.runTerminal();
......
......@@ -19,7 +19,6 @@
@import "../../../node_modules/pikaday/scss/pikaday";
/*
* GitLab UI framework
*/
......
---
title: Move xterm to a node dependency and remove it from vendor's folder
merge_request: 20588
author:
type: other
......@@ -162,7 +162,8 @@ module Gitlab
config.assets.precompile << "icons.json"
config.assets.precompile << "illustrations/*.svg"
config.assets.paths<< "#{config.root}/node_modules/xterm/src/"
# Import css for xterm
config.assets.paths << "#{config.root}/node_modules/xterm/src/"
config.assets.precompile << "xterm.css"
## EE-specific assets config START
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment