mirror of
https://github.com/openfaas/faas.git
synced 2025-06-19 20:46:41 +00:00
Display function creation error in UI
Signed-off-by: Alex Young <alex@heuris.io>
This commit is contained in:
57
gateway/assets/script/bootstrap.js
vendored
57
gateway/assets/script/bootstrap.js
vendored
@ -31,12 +31,12 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
|
||||
refreshData();
|
||||
}, 1000);
|
||||
|
||||
$scope.showPostInvokedToast = function(val) {
|
||||
var showPostInvokedToast = function(message, duration) {
|
||||
$mdToast.show(
|
||||
$mdToast.simple()
|
||||
.textContent(val)
|
||||
.textContent(message)
|
||||
.position("top right")
|
||||
.hideDelay(500)
|
||||
.hideDelay(duration || 500)
|
||||
);
|
||||
};
|
||||
|
||||
@ -56,17 +56,16 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
|
||||
.then(function(response) {
|
||||
if($scope.invocation && $scope.invocation.contentType == "json") {
|
||||
$scope.invocationResponse = JSON.stringify(response.data, -1, " ");
|
||||
|
||||
} else {
|
||||
$scope.invocationResponse = response.data;
|
||||
$scope.invocationResponse = response.data;
|
||||
}
|
||||
$scope.invocationStatus = response.status;
|
||||
$scope.showPostInvokedToast("Success");
|
||||
showPostInvokedToast("Success");
|
||||
}).catch(function(error1) {
|
||||
$scope.invocationResponse = error1.statusText + "\n" + error1.data;
|
||||
$scope.invocationStatus = error1.status;
|
||||
|
||||
$scope.showPostInvokedToast("Error");
|
||||
showPostInvokedToast("Error");
|
||||
});
|
||||
};
|
||||
|
||||
@ -110,17 +109,17 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
|
||||
}
|
||||
};
|
||||
|
||||
var showDialog=function($event) {
|
||||
var parentEl = angular.element(document.body);
|
||||
$mdDialog.show({
|
||||
parent: parentEl,
|
||||
targetEvent: $event,
|
||||
templateUrl: "newfunction.html",
|
||||
locals: {
|
||||
item: $scope.functionTemplate
|
||||
},
|
||||
controller: DialogController
|
||||
});
|
||||
var showDialog = function($event) {
|
||||
var parentEl = angular.element(document.body);
|
||||
$mdDialog.show({
|
||||
parent: parentEl,
|
||||
targetEvent: $event,
|
||||
templateUrl: "newfunction.html",
|
||||
locals: {
|
||||
item: $scope.functionTemplate
|
||||
},
|
||||
controller: DialogController
|
||||
});
|
||||
};
|
||||
|
||||
var DialogController = function($scope, $mdDialog, item) {
|
||||
@ -134,20 +133,22 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
|
||||
url: "/system/functions",
|
||||
data: $scope.item,
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json"},
|
||||
responseType: "json"
|
||||
headers: { "Content-Type": "application/json" },
|
||||
responseType: "text"
|
||||
};
|
||||
|
||||
$http(options)
|
||||
.then(function(response) {
|
||||
$scope.invocationResponse = response.data;
|
||||
$scope.invocationStatus = response.status;
|
||||
item.image = "";
|
||||
item.service = "";
|
||||
item.envProcess = "";
|
||||
item.network = "";
|
||||
$scope.validationError = "";
|
||||
$scope.closeDialog();
|
||||
showPostInvokedToast("Function created");
|
||||
}).catch(function(error1) {
|
||||
$scope.invocationResponse = error1;
|
||||
$scope.invocationStatus = null;
|
||||
$scope.validationError = error1.data;
|
||||
});
|
||||
console.log($scope.item);
|
||||
$scope.closeDialog();
|
||||
};
|
||||
};
|
||||
|
||||
@ -178,12 +179,12 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
|
||||
|
||||
return $http(options);
|
||||
}).then(function(){
|
||||
$scope.showPostInvokedToast("Success");
|
||||
showPostInvokedToast("Success");
|
||||
}).catch(function(err) {
|
||||
if (err) {
|
||||
// show error toast only if there actually is an err.
|
||||
// because hitting 'Cancel' also rejects the promise.
|
||||
$scope.showPostInvokedToast("Error");
|
||||
showPostInvokedToast("Error");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user