aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/modals
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/modals')
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js30
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html2
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js64
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js107
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js63
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js104
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.css4
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html35
8 files changed, 409 insertions, 0 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index 2eaa7513e..eea501f15 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -26,8 +26,10 @@
function newChangeManagementModalController($uibModalInstance, $uibModal,$q, AaiService, changeManagementService, Upload, $log, $scope, _, COMPONENT, VIDCONFIGURATION, DataService, featureFlags) {
+
var vm = this;
vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL;
+ vm.errorMsg='';
vm.wizardStep = 1;
vm.nextStep = function(){
@@ -43,6 +45,24 @@
var attuid;
+ $scope.showReportWindow = function() {
+ const modalWindow = $uibModal.open({
+ templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
+ controller: 'reportModalController',
+ controllerAs: 'vm',
+ resolve: {
+ errorMsg: function () {
+ return vm.errorMsg.message;
+ }
+ }
+ });
+
+ };
+
+ $scope.isShowErrorReport = function() {
+ return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);
+ };
+
function fetchAttUid() {
var defer = $q.defer();
if (attuid) {
@@ -54,6 +74,7 @@
},
function (err) {
defer.reject(err);
+ vm.errorMsg = err;
});
}
return defer.promise;
@@ -75,6 +96,7 @@
})
.catch(function (error) {
$log.error(error);
+ vm.errorMsg = err;
})
};
@@ -132,6 +154,7 @@
newVNFName.availableVersions = _.sortBy(_.uniq(versions, response.data.service, true),"modelInfo.modelVersion");
}).catch(function (error) {
$log.error(error);
+ vm.errorMsg = error;
});
});
}
@@ -372,6 +395,7 @@
}
}catch(err){
$log.error('SchedulerCtrl::extractChangeManagementCallbackDataStr error: ' + err);
+ vm.errorMsg = err;
}
result.requestDetails.push(data);
@@ -475,6 +499,7 @@
})
.catch(function (error) {
$log.error(error);
+ vm.errorMsg = error;
});
};
@@ -602,6 +627,7 @@
})
.catch(function (error) {
reject(error);
+ vm.errorMsg = error;
});
});
}
@@ -708,6 +734,7 @@
vm.localWorkflows = response.data.workflows || [];
}).catch(function (error) {
$log.error(error);
+ vm.errorMsg = error;
});
};
@@ -718,6 +745,7 @@
vm.remoteWorkflows = response.data || [];
}).catch(function (error) {
$log.error(error);
+ vm.errorMsg = error;
});
};
@@ -734,6 +762,7 @@
})
.catch(function (error) {
$log.error(error);
+ vm.errorMsg = error;
});
};
@@ -826,6 +855,7 @@
vnfName[0].selectedFile = JSON.parse(lines);
} catch (error) {
$log.error(error);
+ vm.errorMsg = error;
}
};
fileReader.readAsText(file);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
index 611b8e5ef..7ccddbafd 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
@@ -22,6 +22,7 @@
<div class="modal-header">
<h3 class="modal-title" id="modal-title">New VNF Change</h3>
<span ng-click="vm.close()" class="pull-right modal-close" aria-hidden="true">&times;</span>
+ <div ng-if="vm.errorMsg!==''"><font color='red'>{{vm.errorMsg.message}}</font></div>
</div>
<form class="form-create" name="newChangeManagement" ng-submit="vm.openModal();vm.close();" novalidate>
<div class="modal-body step1" ng-show="vm.wizardStep === 1" >
@@ -156,6 +157,7 @@
<button type="button" id="cancel" name="cancel" class="btn btn-white" ng-click="vm.close()">Cancel</button>
<button ng-if="!vm.isScaleOut() || (vm.isScaleOut() && vm.wizardStep === 2)" type="submit" id="submit" name="submit" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">{{vm.hasScheduler ? "Schedule" : "Confirm"}}</button>
<button ng-if="vm.isScaleOut() && vm.wizardStep === 1" ng-click="vm.nextStep();" type="button" id="next" name="next" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">Next</button>
+ <button ng-if="isShowErrorReport() && vm.errorMsg!==''" ng-click="showReportWindow()" type="button" class="btn btn-danger" >Create report</button>
</div>
</div>
</form>
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
new file mode 100644
index 000000000..bee3a4c27
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+(function () {
+ 'use strict';
+
+ appDS2.controller("reportModalInstanceController", ["$uibModalInstance", "$scope", "$window", "ReportService", "errorMsg", "requestInfo", reportModalInstanceController]);
+
+ function reportModalInstanceController($uibModalInstance, $scope, $window, ReportService, errorMsg, requestInfo) {
+ const vm = this;
+
+ const init = function() {
+ vm.timestamp = ReportService.getReportTimeStamp();
+ vm.downloadEnable = false;
+ ReportService.getReportData(requestInfo).then(
+ response => {
+ vm.saveReportData(response);
+ }, response => {
+ vm.printReportFail(response);
+ });
+ };
+
+ vm.saveReportData = function(response) {
+ vm.report = 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 );
+ vm.downloadEnable = true;
+ };
+
+ vm.printReportFail = function(response) {
+ vm.downloadEnable = false;
+ vm.report = errorMsg + "\n\n API error:\n" + JSON.stringify(response.data, null, "\t") ;
+ };
+
+
+ vm.close = function () {
+ $uibModalInstance.close();
+ };
+
+ vm.ok = function () {
+ $uibModalInstance.close(true);
+ };
+
+ init();
+ }
+})();
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
new file mode 100644
index 000000000..87edca319
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.test.js
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+require('./report-modal-request.controller');
+const jestMock = require('jest-mock');
+
+describe('Testing error report creation', () => {
+ let $notNeeded;
+ let $controller;
+
+ let mockHttp;
+
+ let mockModalInstance;
+ let mockWindow;
+ let mockReportService;
+ let testErrorMsg;
+
+ let correctResponse;
+ let failResponse;
+
+ let mockInfo;
+
+ beforeEach(
+ angular.mock.module('app')
+ );
+
+ beforeEach(inject(function (_$controller_) {
+ $notNeeded = jestMock.fn();
+ mockHttp = jestMock.fn();
+
+ mockModalInstance = {};
+ mockWindow = {
+ webkitURL: {
+ createObjectURL: function (blob) {
+ return blob;
+ }
+ }
+ };
+
+ correctResponse = {data:{report:"test-error-report",status:202}};
+ failResponse = {data:{report:"test-fail-report",status:404}};
+
+ mockReportService = {
+
+ getReportData: function(info) {
+ return Promise.resolve(correctResponse);
+ },
+ getReportTimeStamp: function () {
+ return "testTime";
+ }
+ };
+
+ testErrorMsg = 'testing message';
+
+ $controller = _$controller_('reportModalInstanceController',{
+ $uibModalInstance: mockModalInstance,
+ $scope: $notNeeded,
+ $window: mockWindow,
+ ReportService: mockReportService,
+ errorMsg: testErrorMsg,
+ requestInfo: mockInfo
+ });
+ }));
+
+ test('Verify close will call close in modal instance', () => {
+ mockModalInstance.close = jestMock.fn();
+
+ $controller.close();
+
+ expect(mockModalInstance.close).toHaveBeenCalled();
+ });
+
+ test('Verify report was constructed properly', () => {
+
+ $controller.saveReportData(correctResponse);
+
+ expect($controller.report).toEqual(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' }));
+ });
+
+ test('Verify report contains error if API did not respond', () => {
+
+ $controller.printReportFail(failResponse);
+
+ expect($controller.report).toEqual(testErrorMsg + "\n\n API error:\n" + JSON.stringify(failResponse.data, null, "\t"));
+ expect($controller.downloadEnable).toBeFalsy();
+ });
+
+});
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
new file mode 100644
index 000000000..6ec5c4154
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+(function () {
+ 'use strict';
+
+ appDS2.controller("reportModalController", ["$uibModalInstance", "$scope", "$window", "ReportService", "errorMsg", reportModalController]);
+
+ function reportModalController($uibModalInstance, $scope, $window, ReportService, errorMsg) {
+ const vm = this;
+
+ const init = function() {
+ vm.timestamp = ReportService.getReportTimeStamp();
+ vm.downloadEnable = false;
+ ReportService.getReportData({}).then(
+ response => {
+ vm.saveReportData(response);
+ }, response => {
+ vm.printReportFail(response);
+ });
+ };
+
+ vm.saveReportData = function(response) {
+ vm.report = 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 );
+ vm.downloadEnable = true;
+ };
+
+ vm.printReportFail = function(response) {
+ vm.downloadEnable = false;
+ vm.report = errorMsg + "\n\n API error:\n" + JSON.stringify(response.data, null, "\t") ;
+ };
+
+ vm.close = function () {
+ $uibModalInstance.close();
+ };
+
+ vm.ok = function () {
+ $uibModalInstance.close(true);
+ };
+
+ init();
+ }
+})();
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
new file mode 100644
index 000000000..da834ba69
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.test.js
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+require('./report-modal.controller');
+const jestMock = require('jest-mock');
+
+describe('Testing error report creation', () => {
+ let $notNeeded;
+ let $controller;
+
+ let mockHttp;
+
+ let mockModalInstance;
+ let mockWindow;
+ let mockReportService;
+ let testErrorMsg;
+
+ let correctResponse;
+ let failResponse;
+
+ beforeEach(
+ angular.mock.module('app')
+ );
+
+ beforeEach(inject(function (_$controller_) {
+ $notNeeded = jestMock.fn();
+ mockHttp = jestMock.fn();
+
+ mockModalInstance = {};
+ mockWindow = {
+ webkitURL: {
+ createObjectURL: function (blob) {
+ return blob;
+ }
+ }
+ };
+
+ correctResponse = {data:{report:"test-error-report",status:202}};
+ failResponse = {data:{report:"test-fail-report",status:404}};
+
+ mockReportService = {
+
+ getReportData: function() {
+ return Promise.resolve(correctResponse);
+ },
+ getReportTimeStamp: function () {
+ return "testTime";
+ }
+ };
+
+ testErrorMsg = 'testing message';
+
+ $controller = _$controller_('reportModalController',{
+ $uibModalInstance: mockModalInstance,
+ $scope: $notNeeded,
+ $window: mockWindow,
+ ReportService: mockReportService,
+ errorMsg: testErrorMsg
+ });
+ }));
+
+ test('Verify close will call close in modal instance', () => {
+ mockModalInstance.close = jestMock.fn();
+
+ $controller.close();
+
+ expect(mockModalInstance.close).toHaveBeenCalled();
+ });
+
+ test('Verify report was constructed properly', () => {
+
+ $controller.saveReportData(correctResponse);
+
+ expect($controller.report).toEqual(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' }));
+ });
+
+ test('Verify report contains error if API did not respond', () => {
+
+ $controller.printReportFail(failResponse);
+
+ expect($controller.report).toEqual(testErrorMsg + "\n\n API error:\n" + JSON.stringify(failResponse.data, null, "\t"));
+ expect($controller.downloadEnable).toBeFalsy();
+ });
+
+});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.css b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.css
new file mode 100644
index 000000000..77b935413
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.css
@@ -0,0 +1,4 @@
+.download-button{
+ text-decoration: none !important;
+ text-underline: none;
+} \ No newline at end of file
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
new file mode 100644
index 000000000..58e4c499e
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.html
@@ -0,0 +1,35 @@
+<!--
+ ============LICENSE_START=======================================================
+ VID
+ ================================================================================
+ Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<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>
+</div>
+<div class="modal-body">
+ <textarea style="height: 500px">{{vm.report}}</textarea>
+</div>
+<div class="modal-footer">
+ <a ngx-enabled="{{vm.downloadEnable}}" att-button download="VID_fault_report_{{vm.timestamp}}.txt" ng-href="{{vm.download}}" btn-type="primary" size="small" class="download-button" >Download report</a>
+ <button type="button" data-tests-id="cancelButton" ng-click="vm.close();" att-button
+ btn-type="primary" size="small" >Close</button>
+</div>