diff options
author | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-07-09 12:43:14 +0200 |
---|---|---|
committer | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-07-09 12:43:32 +0200 |
commit | 302b02a847e7aa8ccf3ff4bc14ff8a9cf67511b0 (patch) | |
tree | 0496572d97db4c3facc169869cc6f217717f36d0 /vid-app-common/src/main | |
parent | e2d01234b37dc286604f96b2274b51a7b14fe910 (diff) |
adding test API information and spinner indicating report loading
Change-Id: Ibbf6280496863c60c42dc9bce82d7b8ec4dcc8bf
Issue-ID: VID-488
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Diffstat (limited to 'vid-app-common/src/main')
5 files changed, 53 insertions, 9 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js index bee3a4c27..6b69a08fe 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js @@ -21,24 +21,31 @@ (function () { 'use strict'; - appDS2.controller("reportModalInstanceController", ["$uibModalInstance", "$scope", "$window", "ReportService", "errorMsg", "requestInfo", reportModalInstanceController]); + appDS2.controller("reportModalInstanceController", ["$uibModalInstance", "$scope", "$window", "DataService", "ReportService", "errorMsg", "requestInfo", reportModalInstanceController]); - function reportModalInstanceController($uibModalInstance, $scope, $window, ReportService, errorMsg, requestInfo) { + function reportModalInstanceController($uibModalInstance, $scope, $window, DataService, ReportService, errorMsg, requestInfo) { const vm = this; const init = function() { vm.timestamp = ReportService.getReportTimeStamp(); vm.downloadEnable = false; + $scope.isSpinnerVisible = true; + ReportService.getReportData(requestInfo).then( response => { + $scope.isSpinnerVisible = false; vm.saveReportData(response); }, response => { + $scope.isSpinnerVisible = false; vm.printReportFail(response); }); }; vm.saveReportData = function(response) { - vm.report = errorMsg + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ; + vm.report = + "Selected test API: \n" + DataService.getMsoRequestParametersTestApi() + + "\n\n Data from GUI:\n" + errorMsg + + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ; const blob = new Blob([ vm.report ], { type : 'text/plain' }); vm.download = ($window.URL || $window.webkitURL).createObjectURL( blob ); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js index 87edca319..b62d5e117 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js @@ -22,6 +22,8 @@ require('./report-modal-request.controller'); const jestMock = require('jest-mock'); describe('Testing error report creation', () => { + const mockAPI = "testAPI"; + let $notNeeded; let $controller; @@ -31,6 +33,7 @@ describe('Testing error report creation', () => { let mockWindow; let mockReportService; let testErrorMsg; + let mockDataService; let correctResponse; let failResponse; @@ -44,6 +47,11 @@ describe('Testing error report creation', () => { beforeEach(inject(function (_$controller_) { $notNeeded = jestMock.fn(); mockHttp = jestMock.fn(); + mockDataService = jestMock.fn(); + + mockDataService.getMsoRequestParametersTestApi = function() { + return mockAPI; + }; mockModalInstance = {}; mockWindow = { @@ -74,6 +82,7 @@ describe('Testing error report creation', () => { $scope: $notNeeded, $window: mockWindow, ReportService: mockReportService, + DataService: mockDataService, errorMsg: testErrorMsg, requestInfo: mockInfo }); @@ -91,7 +100,10 @@ describe('Testing error report creation', () => { $controller.saveReportData(correctResponse); - expect($controller.report).toEqual(testErrorMsg + "\n\n Collected data from API:\n" + JSON.stringify(correctResponse.data, null, "\t")); + expect($controller.report).toEqual( + "Selected test API: \n" + mockAPI + + "\n\n Data from GUI:\n" + testErrorMsg + + "\n\n Collected data from API:\n" + JSON.stringify(correctResponse.data, null, "\t")); expect($controller.downloadEnable).toBeTruthy(); expect($controller.download).toEqual(new Blob([ $controller.report ], { type : 'text/plain' })); }); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js index 6ec5c4154..eff029175 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js @@ -21,24 +21,32 @@ (function () { 'use strict'; - appDS2.controller("reportModalController", ["$uibModalInstance", "$scope", "$window", "ReportService", "errorMsg", reportModalController]); + appDS2.controller("reportModalController", ["$uibModalInstance", "$scope", "$window", "DataService", "ReportService", "errorMsg", reportModalController]); - function reportModalController($uibModalInstance, $scope, $window, ReportService, errorMsg) { + function reportModalController($uibModalInstance, $scope, $window, DataService, ReportService, errorMsg) { const vm = this; const init = function() { vm.timestamp = ReportService.getReportTimeStamp(); vm.downloadEnable = false; + $scope.isSpinnerVisible = true; + ReportService.getReportData({}).then( response => { + $scope.isSpinnerVisible = false; vm.saveReportData(response); }, response => { + $scope.isSpinnerVisible = false; vm.printReportFail(response); }); }; vm.saveReportData = function(response) { - vm.report = errorMsg + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ; + vm.report = + "Selected test API: \n" + DataService.getMsoRequestParametersTestApi() + + "\n\n Data from GUI:\n" + errorMsg + + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ; + const blob = new Blob([ vm.report ], { type : 'text/plain' }); vm.download = ($window.URL || $window.webkitURL).createObjectURL( blob ); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js index da834ba69..65a12a935 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js @@ -22,6 +22,8 @@ require('./report-modal.controller'); const jestMock = require('jest-mock'); describe('Testing error report creation', () => { + const mockAPI = "testAPI"; + let $notNeeded; let $controller; @@ -31,6 +33,7 @@ describe('Testing error report creation', () => { let mockWindow; let mockReportService; let testErrorMsg; + let mockDataService; let correctResponse; let failResponse; @@ -42,6 +45,11 @@ describe('Testing error report creation', () => { beforeEach(inject(function (_$controller_) { $notNeeded = jestMock.fn(); mockHttp = jestMock.fn(); + mockDataService = jestMock.fn(); + + mockDataService.getMsoRequestParametersTestApi = function() { + return mockAPI; + }; mockModalInstance = {}; mockWindow = { @@ -72,7 +80,8 @@ describe('Testing error report creation', () => { $scope: $notNeeded, $window: mockWindow, ReportService: mockReportService, - errorMsg: testErrorMsg + errorMsg: testErrorMsg, + DataService: mockDataService }); })); @@ -88,7 +97,11 @@ describe('Testing error report creation', () => { $controller.saveReportData(correctResponse); - expect($controller.report).toEqual(testErrorMsg + "\n\n Collected data from API:\n" + JSON.stringify(correctResponse.data, null, "\t")); + expect($controller.report).toEqual( + "Selected test API: \n" + mockAPI + + "\n\n Data from GUI:\n" + testErrorMsg + + "\n\n Collected data from API:\n" + JSON.stringify(correctResponse.data, null, "\t")); + expect($controller.downloadEnable).toBeTruthy(); expect($controller.download).toEqual(new Blob([ $controller.report ], { type : 'text/plain' })); }); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html index 58e4c499e..c725222c6 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html @@ -18,12 +18,16 @@ ============LICENSE_END========================================================= --> +<link rel="stylesheet" type="text/css" href="app/vid/styles/serviceModels.css" /> <link rel="stylesheet" type="text/css" href="app/vid/styles/modals.css"> <link rel="stylesheet" type="text/css" href="app/vid/styles/modal-create-new.css" /> <link rel="stylesheet" type="text/css" href="app/vid/scripts/modals/report-modal/report-modal.css" /> <div class="modal-header"> <h3 id="modal-title">Error report</h3> + <span class="statusLine" ng-hide="!isSpinnerVisible"> + <img src="app/vid/images/spinner.gif"> + </span> </div> <div class="modal-body"> <textarea style="height: 500px">{{vm.report}}</textarea> |