Fix SoL and KVM refresh bug
Clicking the refresh button in the app header on the SoL and
KVM pages would fail to reload because the wrong element reference
is passed to the contructor after the reload. Angular recommends
using directives for any DOM manipulation.
- Use the $element ref availble in serial-console.js directive to
select DOM element to open the terminal
- Switch kvm controller to directive to be able to use element ref
in the link function to select DOM element to pass as target
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: Ia7391e42bf335b8c3558d25df15c052db245ee3d
diff --git a/app/common/directives/serial-console.js b/app/common/directives/serial-console.js
index 045503d..0a821db 100644
--- a/app/common/directives/serial-console.js
+++ b/app/common/directives/serial-console.js
@@ -55,8 +55,8 @@
'template': require('./serial-console.html'),
'scope': {'path': '=', 'showTabBtn': '=?'},
'controller': [
- '$scope', '$window', 'dataService',
- function($scope, $window, dataService) {
+ '$scope', '$window', 'dataService', '$element',
+ function($scope, $window, dataService, $element) {
$scope.dataService = dataService;
// See https://github.com/xtermjs/xterm.js/ for available xterm
@@ -67,7 +67,8 @@
var border = 10;
var term = new Terminal();
- var terminal = document.getElementById('terminal');
+ // Should be a reference to <div id="terminal"></div>
+ var terminal = $element[0].firstElementChild.firstElementChild;
var customConsole;
var charSize;
var termContainer;