incremental
diff --git a/static/js/bmcApp.js b/static/js/bmcApp.js
index 7575e34..55e4a42 100644
--- a/static/js/bmcApp.js
+++ b/static/js/bmcApp.js
@@ -1,88 +1,79 @@
'use strict';
angular.module('Authentication', []);
var app = angular.module('bmcApp', [
- 'Authentication',
- 'ngCookies',
- 'ui.bootstrap',
- 'ui.router',
- 'ngSanitize',
- 'ngWebSocket',
- 'ngResource'
+ 'ngCookies', 'ngAnimate', 'ngSanitize', 'ui.bootstrap',
+ 'ui.router', 'ngWebSocket', 'Authentication', 'ui.router.modal',
]);
-
-
-app.controller('MainCtrl', ['$scope', function($scope) {
-
-}]);
-
-app.service('loginInterceptor', ["$injector",
+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 $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 invalidate_reason = 'Your user was logged out.';
- // 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";
- } else {
- $state.after_login_state = $state.current.name;
- $state.go('login');
- }
- AuthenticationService.ClearCredentials(invalidate_reason);
+ // 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';
+ } else {
+ $state.after_login_state = $state.current.name;
+ $state.go('login');
}
- return response;
+ AuthenticationService.ClearCredentials(invalidate_reason);
+ }
+ return response;
};
-}])
-
-app.config(['$httpProvider', function ($httpProvider) {
- $httpProvider.interceptors.push('loginInterceptor');
-}]);
-
-app.directive('windowSize', ['$window', 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', '$http', '$templateCache',
- function($rootScope, $cookieStore, $state, $resource, AuthenticationService, $http, $templateCache) {
+app.config([
+ '$httpProvider',
+ function($httpProvider) {
+ $httpProvider.interceptors.push('loginInterceptor');
+ }
+]);
- $http.get('static/partial-login.html', {cache:$templateCache});
- $http.get('static/partial-kvm.html', {cache: $templateCache});
+app.directive('windowSize', [
+ '$window',
+ 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);
- if ($rootScope.globals == undefined){
- $rootScope.globals = {};
+ w.bind('resize', function() { scope.$apply(); });
+ }
+ }
+]);
+
+app.run([
+ '$rootScope', '$cookieStore', '$state', 'AuthenticationService', '$http',
+ '$templateCache',
+ function($rootScope, $cookieStore, $state, AuthenticationService, $http,
+ $templateCache) {
+
+ if ($rootScope.globals == undefined) {
+ $rootScope.globals = {};
}
-
// keep user logged in after page refresh
AuthenticationService.RestoreCredientials();
@@ -90,7 +81,8 @@
'$stateChangeStart',
function(event, toState, toParams, fromState, fromParams, options) {
// redirect to login page if not logged in
- // unless we're already trying to go to the login page (prevent a loop)
+ // 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();
@@ -101,108 +93,137 @@
}
]);
-app.config(['$stateProvider', '$urlRouterProvider',
- function($stateProvider, $urlRouterProvider) {
+app.config([
+ '$stateProvider', '$urlRouterProvider',
+ function($stateProvider, $urlRouterProvider) {
- $urlRouterProvider.otherwise('/systeminfo');
+ $urlRouterProvider.otherwise('/systeminfo');
- $stateProvider
- // nested list with just some random string data
- .state('login', {
- url: '/login',
- templateUrl: 'static/partial-login.html',
- controller: 'LoginController',
- })
- // systeminfo view ========================================
- .state(
- 'systeminfo',
- {url: '/systeminfo', templateUrl: 'static/partial-systeminfo.html'})
+ $stateProvider
+ .state('login', {
+ url : '/login',
+ templateUrl : 'static/partial-login.html',
+ controller : 'LoginController',
+ })
+ .state('systeminfo', {
+ url : '/systeminfo',
+ templateUrl : 'static/partial-systeminfo.html'
+ })
+ .state(
+ 'eventlog',
+ {url : '/eventlog', templateUrl : 'static/partial-eventlog.html'})
+ .state('kvm', {url : '/kvm', templateUrl : 'static/partial-kvm.html'})
- // HOME STATES AND NESTED VIEWS ========================================
- .state(
- 'eventlog', {url: '/eventlog', templateUrl: 'static/partial-eventlog.html'})
+ .state('ipmi',
+ {url : '/ipmi', templateUrl : 'static/partial-ipmi.html'})
+ .state('sensor',
+ {url : '/sensor', templateUrl : 'static/partial-sensor.html'})
- .state(
- 'kvm', {url: '/kvm', templateUrl: 'static/partial-kvm.html'})
+ .state(
+ 'fwupdate',
+ {url : '/fwupdate', templateUrl : 'static/partial-fwupdate.html'})
+ // nested list with custom controller
+ .state('fwupdate.confirm', {
+ url : '/confirm',
+ templateUrl : 'static/partial-fwupdateconfirm.html',
+ modal: true
+ })
+ // ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
+ .state('about',
+ {url : '/about', templateUrl : 'static/partial-fruinfo.html'})
- .state(
- 'ipmi', {url: '/ipmi', templateUrl: 'static/partial-ipmi.html'})
-
- .state(
- 'sensor', {url: '/sensor', templateUrl: 'static/partial-sensor.html'})
-
- // ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
- .state('about', {url: '/about', templateUrl: 'static/partial-fruinfo.html'})
-
- // nested list with custom controller
- .state('about.list', {
- url: '/list',
- templateUrl: 'static/partial-home-list.html',
- controller: function($scope) {
- $scope.dogs = ['Bernese', 'Husky', 'Goldendoodle'];
- }
- })
-
-
-}]);
-
-app.controller('PaginationDemoCtrl', ['$scope', '$log', function($scope, $log) {
- $scope.totalItems = 64;
- $scope.currentPage = 4;
-
- $scope.setPage = function(pageNo) { $scope.currentPage = pageNo; };
-
- $scope.pageChanged = function() {
- $log.log('Page changed to: ' + $scope.currentPage);
- };
-
- $scope.maxSize = 5;
- $scope.bigTotalItems = 175;
- $scope.bigCurrentPage = 1;
-}]);
-
-angular.module('Authentication').factory(
- 'AuthenticationService',
- ['$cookieStore', '$rootScope', '$timeout', '$resource', '$log', '$http',
- function($cookieStore, $rootScope, $timeout, $resource, $log, $http) {
- var service = {};
-
- service.Login = function(username, password, success_callback, fail_callback) {
-
- var user = {"username": username, "password": password};
- var UserLogin = $resource("/login");
- var this_login = new UserLogin();
- this_login.data = {"username": username, "password": password};
- UserLogin.save(user, success_callback, fail_callback);
-
- };
-
- service.SetCredentials = function(username, token) {
- $rootScope.globals["currentUser"] = {username: username, authdata: token};
- $http.defaults.headers.common['Authorization'] = 'Token ' + token;
- $cookieStore.put('globals', $rootScope.globals);
- };
-
- service.ClearCredentials = function(reason) {
- $rootScope.globals["currentUser"] = null;
- if (reason !== null) {
- service.logoutreason = reason;
- }
- $cookieStore.remove('globals');
- $http.defaults.headers.common['Authorization'] = '';
- };
-
- service.RestoreCredientials = function() {
- var globals = $cookieStore.get('globals') || {};
- if (globals.currentUser) {
- service.SetCredentials(
- globals.currentUser.username, globals.currentUser.authdata);
- }
- };
-
- service.logoutreason = "";
- return service;
+ // nested list with custom controller
+ .state('about.list', {
+ url : '/list',
+ templateUrl : 'static/partial-home-list.html',
+ controller : function($scope) {
+ $scope.dogs = [ 'Bernese', 'Husky', 'Goldendoodle' ];
}
- ]);
+ });
+
+ }
+]);
+
+app.directive('fileread', [ function() {
+ return {
+ scope: {fileread : '='},
+ link: function(scope, element, attributes) {
+ element.bind('change', function(changeEvent) {
+ scope.$apply(function() {
+ scope.fileread = changeEvent.target.files[0];
+ // or all selected files:
+ // scope.fileread = changeEvent.target.files;
+ });
+ });
+ }
+ }
+ } ]);
+
+app.controller('PaginationDemoCtrl', [
+ '$scope', '$log',
+ function($scope, $log) {
+ $scope.totalItems = 64;
+ $scope.currentPage = 4;
+
+ $scope.setPage = function(pageNo) { $scope.currentPage = pageNo; };
+
+ $scope.pageChanged = function() {
+ $log.log('Page changed to: ' + $scope.currentPage);
+ };
+
+ $scope.maxSize = 5;
+ $scope.bigTotalItems = 175;
+ $scope.bigCurrentPage = 1;
+ }
+]);
+
+angular.module('Authentication').factory('AuthenticationService', [
+ '$cookieStore', '$rootScope', '$timeout', '$log', '$http',
+ function($cookieStore, $rootScope, $timeout, $log, $http) {
+ var service = {};
+
+ service.Login = function(username, password) {
+ var user = {'username' : username, 'password' : password};
+ return $http.post('/login', user);
+ };
+
+ service.SetCredentials = function(username, token) {
+ $rootScope.globals['currentUser'] = {
+ username : username,
+ authdata : token
+ };
+ $http.defaults.headers.common['Authorization'] = 'Token ' + token;
+ $cookieStore.put('globals', $rootScope.globals);
+ };
+
+ service.ClearCredentials = function(reason) {
+ $rootScope.globals['currentUser'] = null;
+ if (reason !== null) {
+ service.logoutreason = reason;
+ }
+ $cookieStore.remove('globals');
+ $http.defaults.headers.common['Authorization'] = '';
+ };
+
+ service.RestoreCredientials = function() {
+ var globals = $cookieStore.get('globals') || {};
+ if (globals.currentUser) {
+ service.SetCredentials(globals.currentUser.username,
+ globals.currentUser.authdata);
+ }
+ };
+
+ service.IsLoggedIn = function() {
+ if ($rootScope.globals['currentUser']){
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ service.logoutreason = '';
+ return service;
+ }
+]);