incremental
diff --git a/static/CMakeLists.txt b/static/CMakeLists.txt
index 3450531..645db9a 100644
--- a/static/CMakeLists.txt
+++ b/static/CMakeLists.txt
@@ -65,7 +65,7 @@
set(STATIC_ASSETS_OUT "")
foreach(JAVASCRIPT_ASSET ${JAVASCRIPT_ASSETS})
# if it's a debug build, don't minify
- if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET})
else()
set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
@@ -76,17 +76,36 @@
COMMAND closure-compiler --language_in=ECMASCRIPT5
--js "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
--js_output_file "${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET}"
-
+ --compilation_level SIMPLE_OPTIMIZATIONS
+ --angular_pass
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${JAVASCRIPT_ASSET}"
COMMENT "Minifying ${JAVASCRIPT_ASSET}"
)
list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_BINARY_DIR}/${JAVASCRIPT_ASSET})
- endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ endif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
endforeach(JAVASCRIPT_ASSET)
# for now CSS is included as is
foreach(CSS_ASSET ${CSS_ASSETS})
- list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
+ # if it's a debug build, don't minify
+ if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET})
+ else()
+ set(OUTPUT_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
+ get_filename_component(FOLDERNAME ${OUTPUT_FILENAME} DIRECTORY)
+ file(MAKE_DIRECTORY "${FOLDERNAME}")
+ # TODO only minify if not a debug build
+ add_custom_command(OUTPUT ${OUTPUT_FILENAME}
+ COMMAND cssnano
+ "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET}"
+
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${CSS_ASSET}"
+ COMMENT "Minifying ${CSS_ASSET}"
+ )
+ list(APPEND STATIC_ASSETS_OUT ${CMAKE_CURRENT_BINARY_DIR}/${CSS_ASSET})
+ endif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+
endforeach(CSS_ASSET)
# for now HTML is included as is
diff --git a/static/img/logo.png b/static/img/logo.png
index 86f6af7..723e815 100644
--- a/static/img/logo.png
+++ b/static/img/logo.png
Binary files differ
diff --git a/static/index.html b/static/index.html
index e1bb874..0c640d3 100644
--- a/static/index.html
+++ b/static/index.html
@@ -29,6 +29,18 @@
<script src="static/js/angular-websocket.js"></script>
<script src="static/js/kvm-controller.js"></script>
<script src="static/noVNC/include/util.js"></script>
+ <script src="static/noVNC/include/webutil.js"></script>
+ <script src="static/noVNC/include/base64.js"></script>
+ <script src="static/noVNC/include/websock.js"></script>
+ <script src="static/noVNC/include/des.js"></script>
+ <script src="static/noVNC/include/keysymdef.js"></script>
+ <script src="static/noVNC/include/xtscancodes.js"></script>
+ <script src="static/noVNC/include/keyboard.js"></script>
+ <script src="static/noVNC/include/input.js"></script>
+ <script src="static/noVNC/include/display.js"></script>
+ <script src="static/noVNC/include/inflator.js"></script>
+ <script src="static/noVNC/include/rfb.js"></script>
+ <script src="static/noVNC/include/keysym.js"></script>
<script type="text/javascript">
var INCLUDE_URI= "static/noVNC/include/";
diff --git a/static/js/bmcApp.js b/static/js/bmcApp.js
index 1c91e8f..64a480a 100644
--- a/static/js/bmcApp.js
+++ b/static/js/bmcApp.js
@@ -1,8 +1,13 @@
'use strict';
angular.module('Authentication', []);
var app = angular.module('bmcApp', [
- 'Authentication', 'ngCookies', 'ui.bootstrap', 'ui.router',
- 'ngSanitize', 'ngWebSocket', 'ngResource'
+ 'Authentication',
+ 'ngCookies',
+ 'ui.bootstrap',
+ 'ui.router',
+ 'ngSanitize',
+ 'ngWebSocket',
+ 'ngResource'
]);
@@ -10,35 +15,62 @@
});
-app.service('loginInterceptor', function($q, $state) {
+app.service('loginInterceptor', ["$injector",
+ function($injector) {
var service = this;
service.responseError = function(response) {
+ var $state = $injector.get('$state');
+ var AuthenticationService = $injector.get('AuthenticationService');
if (response.status == 401){
console.log("Login required... ");
var invalidate_reason = "Your user was logged out.";
- var continue_promise_chain = false;
// if we're attempting to log in, we need to
// continue the promise chain to make sure the user is informed
if ($state.current.name === "login") {
invalidate_reason = "Your username and password was incorrect";
- continue_promise_chain = true
} else {
$state.after_login_state = $state.current.name;
$state.go('login');
}
AuthenticationService.ClearCredentials(invalidate_reason);
}
- //return $q.reject(response);
+
};
-})
+}])
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push('loginInterceptor');
}]);
+app.directive('windowSize', function ($window) {
+ return function (scope, element) {
+ var w = angular.element($window);
+ scope.getWindowDimensions = function () {
+ return {
+ 'h': w.height(),
+ 'w': w.width()
+ };
+ };
+ scope.$watch(scope.getWindowDimensions, function (newValue, oldValue) {
+ scope.windowHeight = newValue.h;
+ scope.windowWidth = newValue.w;
+ scope.style = function () {
+ return {
+ 'height': (newValue.h - 100) + 'px',
+ 'width': (newValue.w - 100) + 'px'
+ };
+ };
+ }, true);
+
+ w.bind('resize', function () {
+ scope.$apply();
+ });
+ }
+});
+
app.run(['$rootScope', '$cookieStore', '$state', '$resource', 'AuthenticationService',
function($rootScope, $cookieStore, $state, $resource, AuthenticationService) {
if ($rootScope.globals == undefined){
@@ -52,7 +84,8 @@
'$stateChangeStart',
function(event, toState, toParams, fromState, fromParams, options) {
// redirect to login page if not logged in
- if (toState.name !== 'login' && !$rootScope.globals.currentUser) {
+ // unless we're already trying to go to the login page (prevent a loop)
+ if (!$rootScope.globals.currentUser && toState.name !== 'login') {
// If logged out and transitioning to a logged in page:
event.preventDefault();
$state.go('login');
@@ -61,7 +94,8 @@
}
]);
-app.config(function($stateProvider, $urlRouterProvider) {
+app.config(['$stateProvider', '$urlRouterProvider',
+ function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/systeminfo');
@@ -99,9 +133,9 @@
})
-});
+}]);
-app.controller('PaginationDemoCtrl', function($scope, $log) {
+app.controller('PaginationDemoCtrl', ['$scope', '$log', function($scope, $log) {
$scope.totalItems = 64;
$scope.currentPage = 4;
@@ -114,14 +148,12 @@
$scope.maxSize = 5;
$scope.bigTotalItems = 175;
$scope.bigCurrentPage = 1;
-});
+}]);
-angular.module('Authentication')
-
- .factory(
+angular.module('Authentication').factory(
'AuthenticationService',
- ['$cookieStore', '$rootScope', '$timeout', '$resource', '$log',
- function($cookieStore, $rootScope, $timeout, $resource, $log) {
+ ['$cookieStore', '$rootScope', '$timeout', '$resource', '$log', '$http',
+ function($cookieStore, $rootScope, $timeout, $resource, $log, $http) {
var service = {};
service.Login = function(username, password, success_callback, fail_callback) {
@@ -136,8 +168,7 @@
service.SetCredentials = function(username, token) {
$rootScope.globals["currentUser"] = {username: username, authdata: token};
- Restangular.setDefaultHeaders(
- {'Authorization': 'Token ' + token});
+ $http.defaults.headers.common['Authorization'] = 'Token ' + token;
$cookieStore.put('globals', $rootScope.globals);
};
@@ -147,7 +178,7 @@
service.logoutreason = reason;
}
$cookieStore.remove('globals');
- Restangular.setDefaultHeaders({});
+ $http.defaults.headers.common['Authorization'] = '';
};
service.RestoreCredientials = function() {
@@ -163,23 +194,6 @@
}
])
- .factory('Websocket_URI',
- function($rootScope, $http) {
- var loc = window.location, websocket_uri;
- if (loc.protocol === "https:") {
- websocket_uri = "wss:";
- } else {
- websocket_uri = "ws:";
- }
- websocket_uri += "//" + loc.hostname + ":9000";
- // Append the authentication token
- websocket_uri += "?token="
- websocket_uri += $rootScope.globals["currentUser"]["authdata"]
- var methods = {
- uri: websocket_uri
- }
- return methods;
- })
.factory('Base64', function() {
/* jshint ignore:start */
diff --git a/static/js/kvm-controller.js b/static/js/kvm-controller.js
index 3c6af2b..87427b6 100644
--- a/static/js/kvm-controller.js
+++ b/static/js/kvm-controller.js
@@ -1,25 +1,44 @@
-angular.module('bmcApp').controller('KvmController', function($scope, $location) {
+angular.module('bmcApp').controller('KvmController', function($scope, $location, $window) {
/*jslint white: false */
/*global window, $, Util, RFB, */
"use strict";
- var INCLUDE_URI = "noVNC/"
- // Load supporting scripts
- Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
- "keysymdef.js", "xtscancodes.js", "keyboard.js",
- "input.js", "display.js", "inflator.js", "rfb.js",
- "keysym.js"]);
var rfb;
- var resizeTimeout;
+ var host = $location.host();
+ var port = $location.port();
+ var encrypt = $location.protocol() === 'https:';
+ var password = "";
+ var token = "1234";
+ var path = "kvmws";
+ var target = angular.element(document.querySelector('#noVNC_canvas'))[0];
+ try {
+ rfb = new RFB({'target': target,
+ 'encrypt': encrypt,
+ 'local_cursor': true,
+ 'onUpdateState': updateState,
+ //'onXvpInit': xvpInit,
+ 'onFBUComplete': FBUComplete,
+ 'resize': true});
+ rfb.connect(host, port, password, path);
+ } catch (exc) {
+ updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc);
+ return; // don't continue trying to connect
+ }
+
+
+ $scope.$on("$destroy", function() {
+ if (rfb) {
+ rfb.disconnect();
+ }
+ });
function UIresize() {
if (WebUtil.getConfigVar('resize', false)) {
- var innerW = window.innerWidth;
- var innerH = window.innerHeight;
- var controlbarH = $D('noVNC_status_bar').offsetHeight;
+ var innerW = $window.innerWidth;
+ var innerH = $window.innerHeight;
var padding = 5;
if (innerW !== undefined && innerH !== undefined)
rfb.requestDesktopSize(innerW, innerH - controlbarH - padding);
@@ -33,23 +52,11 @@
rfb.sendCtrlAltDel();
return false;
}
- function xvpShutdown() {
- rfb.xvpShutdown();
- return false;
- }
- function xvpReboot() {
- rfb.xvpReboot();
- return false;
- }
- function xvpReset() {
- rfb.xvpReset();
- return false;
- }
+
function updateState(rfb, state, oldstate, msg) {
var s, sb, cad, level;
- s = $D('noVNC_status');
- sb = $D('noVNC_status_bar');
- cad = $D('sendCtrlAltDelButton');
+ s = angular.element(document.querySelector('#noVNC_status'))[0];
+ sb = angular.element(document.querySelector('#noVNC_status_bar'))[0];
switch (state) {
case 'failed': level = "error"; break;
case 'fatal': level = "error"; break;
@@ -59,20 +66,20 @@
default: level = "warn"; break;
}
- if (state === "normal") {
- cad.disabled = false;
- } else {
- cad.disabled = true;
- xvpInit(0);
- }
-
if (typeof(msg) !== 'undefined') {
- sb.setAttribute("class", "noVNC_status_" + level);
- s.innerHTML = msg;
+ // at this point, it's possible the window has already been destroyed, so make sure
+ // the handles exist before writing.
+ if (typeof(sb) !== 'undefined'){
+ sb.setAttribute("class", "noVNC_status_" + level);
+ }
+ if (typeof(sb) !== 'undefined'){
+ s.innerHTML = msg;
+ }
}
}
- window.onresize = function () {
+ var resizeTimeout;
+ $window.onresize = function () {
// When the window has been resized, wait until the size remains
// the same for 0.5 seconds before sending the request for changing
// the resolution of the session
@@ -80,45 +87,5 @@
resizeTimeout = setTimeout(function(){
UIresize();
}, 500);
- };
-
- function xvpInit(ver) {
- var xvpbuttons;
- xvpbuttons = $D('noVNC_xvp_buttons');
- if (ver >= 1) {
- xvpbuttons.style.display = 'inline';
- } else {
- xvpbuttons.style.display = 'none';
- }
- }
-
- window.onscriptsload = function () {
- var host, port, password, path, token;
-
- $D('sendCtrlAltDelButton').style.display = "inline";
- $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
- $D('xvpShutdownButton').onclick = xvpShutdown;
- $D('xvpRebootButton').onclick = xvpReboot;
- $D('xvpResetButton').onclick = xvpReset;
-
- host = $location.host();
- port = 9000;
- password = "";
- token = "1234";
- path = "/";
-
- try {
- rfb = new RFB({'target': $D('noVNC_canvas'),
- 'encrypt': true,
- 'local_cursor': true,
- 'onUpdateState': updateState,
- 'onXvpInit': xvpInit,
- 'onFBUComplete': FBUComplete});
- } catch (exc) {
- updateState(null, 'fatal', null, 'Unable to create RFB client -- ' + exc);
- return; // don't continue trying to connect
- }
-
- rfb.connect(host, port, password, path);
- };
+ };
});
\ No newline at end of file
diff --git a/static/js/versionController.js b/static/js/versionController.js
index b77f9b4..c104602 100644
--- a/static/js/versionController.js
+++ b/static/js/versionController.js
@@ -1,16 +1,19 @@
-angular.module('bmcApp').controller('versionController', function($scope) {
+angular.module('bmcApp').controller('versionController', function($scope, $resource) {
- var system_status = Restangular.one('systeminfo').get().then(function(system_status) {
- $scope.system_status = system_status;
+
+ var systeminfo = $resource("/systeminfo");
+ systeminfo.get(function(systeminfo){
+ $scope.host_power_on= true;
+ $scope.rmm_module_installed= true;
+ $scope.bmc_available= true;
+ $scope.bmc_build_date= new Date(2016, 0, 1, 2, 3, 4, 567);
+ $scope.bios_build_number = "D0191";
+ $scope.bmc_build_number = "96.37";
+ $scope.bmc_build_extended = "e04989f7";
+ $scope.bmc_backup_build_number = "96.37";
+ $scope.bmc_backup_build_extended = "e04989f7";
});
- $scope.host_power_on= true;
- $scope.rmm_module_installed= true;
- $scope.bmc_available= true;
- $scope.bmc_build_date= new Date(2016, 0, 1, 2, 3, 4, 567);
- $scope.bios_build_number = "D0191";
- $scope.bmc_build_number = "96.37";
- $scope.bmc_build_extended = "e04989f7";
- $scope.bmc_backup_build_number = "96.37";
- $scope.bmc_backup_build_extended = "e04989f7";
+
+
});
\ No newline at end of file
diff --git a/static/websocket.html b/static/websocket.html
index f21bd6a..5589d14 100644
--- a/static/websocket.html
+++ b/static/websocket.html
@@ -75,7 +75,7 @@
<div id="controls">
<div id="server">
- <input type="text" name="server_url" id="server_url" value="wss://localhost:9000?session_id=foobar" /><br />
+ <input type="text" name="server_url" id="server_url" value="wss://localhost?session_id=foobar" /><br />
<button id="toggle_connect" onclick="toggle_connect();">Connect</button>
</div>
</div>