summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/components/pods/podsController.js
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2018-04-15 22:14:39 +0530
committerthuva4 <tharma.thuva@gmail.com>2018-04-20 15:46:31 +0530
commitd491fc95409e78d2a28e82487144b3686c680f55 (patch)
treed48ff93eb53158230181702d3db757e4bb846c90 /testapi/opnfv_testapi/ui/components/pods/podsController.js
parentc77cf76cbf31e65aa599f71f33d59abc267b4e50 (diff)
Add toast message in pods page
User can view the error/success message in any part of the web page. JIRA: RELENG-392 Change-Id: If2564bec92b17cecb847bccfee8a57979d23b45c Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/pods/podsController.js')
-rw-r--r--testapi/opnfv_testapi/ui/components/pods/podsController.js35
1 files changed, 25 insertions, 10 deletions
diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js
index c50fa5a..3a94338 100644
--- a/testapi/opnfv_testapi/ui/components/pods/podsController.js
+++ b/testapi/opnfv_testapi/ui/components/pods/podsController.js
@@ -21,7 +21,7 @@
PodsController.$inject = [
'$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert',
- 'confirmModal', 'keepState', 'sortService'
+ 'confirmModal', 'keepState', 'sortService', '$timeout'
];
/**
@@ -30,7 +30,7 @@
* through pods declared in TestAPI.
*/
function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl,
- raiseAlert, confirmModal, keepState, sortService) {
+ raiseAlert, confirmModal, keepState, sortService, $timeout) {
var ctrl = this;
ctrl.url = testapiApiUrl + '/pods';
ctrl.checkBox = []
@@ -48,6 +48,18 @@
ctrl.batchDelete = batchDelete;
ctrl.viewPod = viewPod
ctrl.sortBy = sortBy
+ ctrl.toastError = toastError
+ ctrl.toastSuccess = toastSuccess
+
+ function toastError() {
+ ctrl.showError = true
+ $timeout(function(){ ctrl.showError = false;}, 3000);
+ }
+
+ function toastSuccess() {
+ ctrl.showSuccess = true
+ $timeout(function(){ ctrl.showSuccess = false;}, 3000);
+ }
function sortBy(field){
ctrl.data.pods = sortService.sortFunction(ctrl.data.pods, field , ctrl.sorting[field] )
@@ -84,17 +96,19 @@
};
ctrl.podsRequest =
$http.post(pods_url, body).success(function (data) {
- ctrl.showSuccess = true ;
ctrl.success = "Create Success"
+ ctrl.toastSuccess()
ctrl.listPods();
+ return true;
}).catch(function (data) {
- ctrl.showError = true;
ctrl.error = data.statusText;
+ ctrl.toastError()
+ return false;
});
}
else{
- ctrl.showError = true;
ctrl.error = 'Name is missing.'
+ ctrl.toastError()
}
}
@@ -124,8 +138,8 @@
}
}).catch(function (data) {
ctrl.data = null;
- ctrl.showError = true;
ctrl.error = data.statusText;
+ ctrl.toastError()
});
}
@@ -139,12 +153,12 @@
function podDelete(podName){
var pods_url = ctrl.url + "/" + podName
$http.delete(pods_url).success(function(){
- ctrl.showSuccess = true ;
ctrl.success = "Delete Success"
+ ctrl.toastSuccess()
ctrl.listPods();
}).catch(function (data) {
- ctrl.showError = true;
ctrl.error = data.statusText;
+ ctrl.toastError()
});
}
@@ -247,9 +261,10 @@
* inputs.
*/
function confirm() {
- $uibModalInstance.close();
if (angular.isDefined(ctrl.data.successHandler)) {
- ctrl.data.successHandler(ctrl.pod);
+ if(ctrl.data.successHandler(ctrl.pod)){
+ $uibModalInstance.close();
+ }
}
}