1/** 2 * Controller for firmware 3 * 4 * @module app/configuration 5 * @exports firmwareController 6 * @name firmwareController 7 * @version 0.1.0 8 */ 9 10window.angular && (function (angular) { 11 'use strict'; 12 13 angular 14 .module('app.configuration') 15 .controller('firmwareController', [ 16 '$scope', 17 '$window', 18 'APIUtils', 19 'dataService', 20 '$location', 21 '$anchorScroll', 22 function ($scope, $window, APIUtils, dataService, $location, $anchorScroll) { 23 $scope.dataService = dataService; 24 25 //Scroll to target anchor 26 $scope.gotoAnchor = function () { 27 $location.hash('upload'); 28 $anchorScroll(); 29 }; 30 31 $scope.firmwares = []; 32 $scope.bmcActiveVersion = ""; 33 $scope.hostActiveVersion = ""; 34 $scope.display_error = false; 35 $scope.confirm_upload_image = false; 36 $scope.reboot_confirm = false; 37 $scope.preserve_settings_confirm = false; 38 $scope.delete_image_id = ""; 39 $scope.activate_image_id = ""; 40 $scope.file_empty = true; 41 $scope.uploading = false; 42 43 $scope.error = { 44 modal_title: "", 45 title: "", 46 desc: "", 47 type: "warning" 48 }; 49 50 $scope.activateImage = function(imageId){ 51 $scope.activate_image_id = imageId; 52 $scope.preserve_settings_confirm = true; 53 } 54 55 $scope.displayError = function(data){ 56 $scope.error = data; 57 $scope.display_error = true; 58 } 59 60 $scope.preserveSettingsConfirmed = function(){ 61 //show progress..callapi..hide..iferror..show error 62 $scope.preserve_settings_confirm = false; 63 } 64 65 $scope.confirmWarmReboot = function(){ 66 $scope.reboot_confirm = false; 67 } 68 69 $scope.upload = function(){ 70 if(!$scope.file_empty){ 71 $scope.confirm_upload_image = true; 72 } 73 } 74 $scope.confirmUpload = function(){ 75 $scope.uploading = true; 76 APIUtils.uploadImage($scope.file, function(response){ 77 $scope.uploading = false; 78 if(response.status == 'error'){ 79 $scope.displayError({ 80 modal_title: response.data.description, 81 title: response.data.description, 82 desc: response.data.exception, 83 type: 'Error' 84 }); 85 }else{ 86 $scope.loadFirmwares(); 87 } 88 }); 89 $scope.confirm_upload_image = false; 90 } 91 92 $scope.deleteImage = function(imageId){ 93 $scope.delete_image_id = imageId; 94 $scope.confirm_delete = true; 95 } 96 $scope.confirmDeleteImage = function(imageId){ 97 $scope.confirm_delete = false; 98 } 99 100 $scope.fileNameChanged = function(){ 101 $scope.file_empty = false; 102 } 103 104 $scope.uploading = false; 105 $scope.filters = { 106 bmc: { 107 imageType: 'BMC' 108 }, 109 host: { 110 imageType: 'Host' 111 } 112 }; 113 114 $scope.loadFirmwares = function(){ 115 APIUtils.getFirmwares(function(data, bmcActiveVersion, hostActiveVersion){ 116 $scope.firmwares = data; 117 $scope.bmcActiveVersion = bmcActiveVersion; 118 $scope.hostActiveVersion = hostActiveVersion; 119 }); 120 } 121 122 $scope.loadFirmwares(); 123 } 124 ] 125 ); 126 127})(angular); 128