Commit 26b8209e authored by Filipa Lacerda's avatar Filipa Lacerda

Focus terminal on load

Use object.assign for default option
parent 0116930b
import $ from 'jquery'; import $ from 'jquery';
import { Terminal } from 'xterm'; import { Terminal } from 'xterm';
import * as fit from 'xterm/lib/addons/fit/fit'; import * as fit from 'xterm/lib/addons/fit/fit';
import * as attach from 'xterm/lib/addons/attach/attach';
export default class GLTerminal { export default class GLTerminal {
constructor(options) { constructor(options = {}) {
this.options = options || {}; this.options = Object.assign({}, {
cursorBlink: true,
if (!Object.prototype.hasOwnProperty.call(this.options, 'cursorBlink')) { screenKeys: true,
this.options.cursorBlink = true; }, options);
}
if (!Object.prototype.hasOwnProperty.call(this.options, 'screenKeys')) {
this.options.screenKeys = true;
}
this.container = document.querySelector(options.selector); this.container = document.querySelector(options.selector);
...@@ -37,16 +31,15 @@ export default class GLTerminal { ...@@ -37,16 +31,15 @@ export default class GLTerminal {
createTerminal() { createTerminal() {
Terminal.applyAddon(fit); Terminal.applyAddon(fit);
Terminal.applyAddon(attach);
this.terminal = new Terminal(this.options); 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 = new WebSocket(this.socketUrl, ['terminal.gitlab.com']);
this.socket.binaryType = 'arraybuffer'; this.socket.binaryType = 'arraybuffer';
this.terminal.open(this.container); this.terminal.open(this.container);
this.terminal.fit(); this.terminal.fit();
this.terminal.focus();
this.socket.onopen = () => { this.socket.onopen = () => {
this.runTerminal(); this.runTerminal();
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
@import "../../../node_modules/pikaday/scss/pikaday"; @import "../../../node_modules/pikaday/scss/pikaday";
/* /*
* GitLab UI framework * GitLab UI framework
*/ */
......
---
title: Move xterm to a node dependency and remove it from vendor's folder
merge_request: 20588
author:
type: other
...@@ -148,10 +148,10 @@ module Gitlab ...@@ -148,10 +148,10 @@ module Gitlab
config.assets.precompile << "icons.json" config.assets.precompile << "icons.json"
config.assets.precompile << "illustrations/*.svg" 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" config.assets.precompile << "xterm.css"
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
......
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