mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 18:27:25 +08:00
Focus terminal when switching instances
This commit is contained in:
parent
1d550aaa46
commit
991594c35c
@ -62,9 +62,11 @@
|
|||||||
$scope.showInstance = function(instance) {
|
$scope.showInstance = function(instance) {
|
||||||
$scope.selectedInstance = instance;
|
$scope.selectedInstance = instance;
|
||||||
if (!instance.isAttached) {
|
if (!instance.isAttached) {
|
||||||
$timeout(function() {createTerminal(instance.name)});
|
$timeout(function() {instance.term = createTerminal(instance.name);});
|
||||||
instance.isAttached = true;
|
instance.isAttached = true;
|
||||||
}
|
} else {
|
||||||
|
$timeout(function() {instance.term.focus()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.deleteInstance = function(instance) {
|
$scope.deleteInstance = function(instance) {
|
||||||
|
@ -37,7 +37,7 @@ function createTerminal(name) {
|
|||||||
while (terminalContainer.children.length) {
|
while (terminalContainer.children.length) {
|
||||||
terminalContainer.removeChild(terminalContainer.children[0]);
|
terminalContainer.removeChild(terminalContainer.children[0]);
|
||||||
}
|
}
|
||||||
term = new Terminal({
|
var term = new Terminal({
|
||||||
cursorBlink: false
|
cursorBlink: false
|
||||||
});
|
});
|
||||||
var sessionId = location.pathname.substr(location.pathname.lastIndexOf("/")+1);
|
var sessionId = location.pathname.substr(location.pathname.lastIndexOf("/")+1);
|
||||||
@ -47,12 +47,14 @@ function createTerminal(name) {
|
|||||||
term.open(terminalContainer);
|
term.open(terminalContainer);
|
||||||
|
|
||||||
socket = new WebSocket(socketURL);
|
socket = new WebSocket(socketURL);
|
||||||
socket.onopen = runRealTerminal;
|
socket.onopen = runRealTerminal(term);
|
||||||
|
|
||||||
|
return term;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function runRealTerminal() {
|
function runRealTerminal(term) {
|
||||||
term.attach(socket);
|
term.attach(socket);
|
||||||
term._initialized = true;
|
term._initialized = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user