Updating login structure
Updated login structure with a field where user can manually add server hostname if it is not populated automatically
Change-Id: I147c2c15869131540e327bda26c05b59d78e01d5
Signed-off-by: Iftekharul Islam <iffy.ryan@ibm.com>
diff --git a/app/configuration/controllers/firmware-controller.html b/app/configuration/controllers/firmware-controller.html
index 1f67caa..c305047 100644
--- a/app/configuration/controllers/firmware-controller.html
+++ b/app/configuration/controllers/firmware-controller.html
@@ -1,3 +1,4 @@
+<loader loading="loading"></loader>
<div class="row column">
<h1>Firmware</h1>
<div class="column small-12 page-header">
@@ -34,14 +35,14 @@
<div class="row">
<div class="column small-12 large-4">
<label for="tftp-ip">TFTP Server IP address</label>
- <input name="tftp-ip" id="tftp-ip" type="number"/>
+ <input name="tftp-ip" id="tftp-ip" type="text" ng-model="download_host"/>
</div>
<div class="column small-12 large-4">
<label for="tftp-file-name">File name</label>
- <input name="tftp-file-name" id="tftp-file-name" type="text"/>
+ <input name="tftp-file-name" id="tftp-file-name" type="text" ng-model="download_filename"/>
</div>
<div class="column small-12 large-4">
- <input type="submit" value="Download firmware" class="inline button btn-primary float-right"/>
+ <input type="button" value="Download firmware" class="inline button btn-primary float-right" ng-click="download()"/>
</div>
</div>
<div class="inline uploading" ng-show="downloading">Downloading in progress...</div>
@@ -67,6 +68,23 @@
</div>
</section>
+<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': confirm_priority}">
+ <div class="modal__tftp-unreachable" role="document">
+ <div class="screen-reader-offscreen modal-description">Update image priority</div><!-- accessibility only; used for screen readers -->
+ <div class="page-header ">
+ <span class="icon icon__warning inline"><span class="accessible-text" role="alert">Warning</span></span>
+ <h1 class="modal-title h4 inline">Change image priority</h1>
+ </div>
+ <div class="modal__content">
+ <p>Change firmware {{priority_image_id}} priority?</p>
+ </div>
+ <div class="modal__button-wrapper">
+ <button class="inline btn-secondary" ng-click="confirm_priority=false;">Cancel</button>
+ <button class="inline btn-primary" ng-click="confirmChangePriority()">Continue</button>
+ </div>
+ </div>
+</section>
+
<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': confirm_delete}">
<div class="modal__tftp-unreachable" role="document">
<div class="screen-reader-offscreen modal-description">Delete firmware image</div><!-- accessibility only; used for screen readers -->
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 66c4297..50df4f0 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -19,7 +19,8 @@
'dataService',
'$location',
'$anchorScroll',
- function ($scope, $window, APIUtils, dataService, $location, $anchorScroll) {
+ 'Constants',
+ function ($scope, $window, APIUtils, dataService, $location, $anchorScroll, Constants) {
$scope.dataService = dataService;
//Scroll to target anchor
@@ -37,6 +38,10 @@
$scope.preserve_settings_confirm = false;
$scope.delete_image_id = "";
$scope.activate_image_id = "";
+ $scope.priority_image_id = "";
+ $scope.priority_from = -1;
+ $scope.priority_to = -1;
+ $scope.confirm_priority = false;
$scope.file_empty = true;
$scope.uploading = false;
@@ -73,7 +78,7 @@
}
$scope.confirmUpload = function(){
$scope.uploading = true;
- APIUtils.uploadImage($scope.file, function(response){
+ APIUtils.uploadImage($scope.file).then(function(response){
$scope.uploading = false;
if(response.status == 'error'){
$scope.displayError({
@@ -89,6 +94,69 @@
$scope.confirm_upload_image = false;
}
+ $scope.download = function(){
+ $scope.downloading = true;
+ APIUtils.downloadImage($scope.download_host, $scope.download_filename).then(function(response){
+ var data = response.data;
+ $scope.downloading = false;
+ var headers = response.headers();
+
+ var filename = headers['x-filename'];
+ var contentType = headers['content-type'];
+
+ if(!headers['x-filename']){
+ filename = Constants.FIRMWARE.FALLBACK_DOWNLOAD_FILENAME;
+ }
+
+ var linkElement = document.createElement('a');
+ try {
+ var blob = new Blob([data], { type: contentType });
+ var url = window.URL.createObjectURL(blob);
+
+ linkElement.setAttribute('href', url);
+ linkElement.setAttribute("download", filename);
+
+ var clickEvent = new MouseEvent("click", {
+ "view": window,
+ "bubbles": true,
+ "cancelable": false
+ });
+ linkElement.dispatchEvent(clickEvent);
+ } catch (ex) {
+ console.log(ex);
+ }
+ });
+ }
+
+ $scope.changePriority = function(imageId, from, to){
+ $scope.priority_image_id = imageId;
+ $scope.priority_from = from;
+ $scope.priority_to = to;
+
+ if((from + to) == 1){
+ $scope.confirm_priority = true;
+ }else{
+ $scope.confirmChangePriority();
+ }
+ }
+
+ $scope.confirmChangePriority = function(){
+ $scope.loading = true;
+ APIUtils.changePriority($scope.priority_image_id, $scope.priority_to).then(function(response){
+ $scope.loading = false;
+ if(response.status == 'error'){
+ $scope.displayError({
+ modal_title: response.data.description,
+ title: response.data.description,
+ desc: response.data.exception,
+ type: 'Error'
+ });
+ }else{
+ $scope.loadFirmwares();
+ }
+ });
+ $scope.confirm_priority = false;
+ }
$scope.deleteImage = function(imageId){
$scope.delete_image_id = imageId;
$scope.confirm_delete = true;