Add Activate firmware and reboot button

Added a radio button to activate firmware and reboot the BMC.
If the "Activate firmware and reboot" option is selected, reboot
the BMC after activating the firmware. The user is then logged
out.

Resolves openbmc/openbmc#3027

Tested: When "Activate firmware and reboot" option is selected,
the BMC reboots after activating. When it is not selected,
the BMC image just activates.
Change-Id: I07293dc8a6ddfac4cf58ba2c1d1352c9afd6fa8d
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/firmware-controller.html b/app/configuration/controllers/firmware-controller.html
index 92a0083..dc85606 100644
--- a/app/configuration/controllers/firmware-controller.html
+++ b/app/configuration/controllers/firmware-controller.html
@@ -116,18 +116,23 @@
 		</div>
 		<div class="modal__content">
 			<div ng-switch on="activate_image_type">
-				<p ng-switch-when="BMC">When you activate the BMC firmware file, {{activate_image_version}}, the BMC must be rebooted before it will operate with the new firmware code.</p>
+				<p ng-switch-when="BMC">When you activate the BMC firmware file, {{activate_image_version}}, the BMC must be rebooted before it will operate with the new firmware code. Note that when you reboot the BMC, the BMC will be unavailable for several minutes and you must log in again.</p>
 				<p ng-switch-when="Host">When you activate server firmware file, {{activate_image_version}}, the new firmware will not operate until the next time the server boots.</p>
 			</div>
 			<form ng-if="activate_image_type == 'BMC'">
 				<fieldset>
 					<div class="row column">
 						<label class="control-radio bold" for="activate-without-reboot">Activate firmware file without rebooting BMC
-							<input type="radio" name="activate-without-reboot" id="activate-without-reboot" ng-checked="true" ng-model="dhcp" ng-value="true" ng-init="dhcp=true"/>
+							<input type="radio" name="activate-without-reboot" id="activate-without-reboot" ng-model="activate.reboot" ng-value="false"/>
 							<span class="control__indicator control__indicator-on"></span>
 						</label>
 					</div>
-					<!-- TODO: openbmc/openbmc#3027 Add Activate firmware and reboot selection -->
+					<div class="row column">
+						<label class="control-radio bold" for="activate-with-reboot">Activate firmware file and automatically reboot BMC
+							<input type="radio" name="activate-with-reboot" id="activate-with-reboot" ng-model="activate.reboot" ng-value="true"/>
+							<span class="control__indicator control__indicator-on"></span>
+						</label>
+					</div>
 				</fieldset>
 			</form>
 		</div>
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 8fe0e83..127a7c2 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -48,6 +48,7 @@
                     $scope.confirm_priority = false;
                     $scope.file_empty = true;
                     $scope.uploading = false;
+                    $scope.activate = { reboot: true };
 
                     var pollActivationTimer = undefined;
 
@@ -119,6 +120,17 @@
                             desc: JSON.stringify(error.data),
                             type: 'Error'
                           });
+                        }).then(function(state){
+                          if($scope.activate.reboot){
+                            APIUtils.bmcReboot(function(response){}, function(error){
+                              $scope.displayError({
+                                modal_title: 'Error during BMC reboot',
+                                title: 'Error during BMC reboot',
+                                desc: JSON.stringify(error.data),
+                                type: 'Error'
+                              });
+                            });
+                          }
                         });
                       });
                       $scope.activate_confirm = false;