Give feedback via toast in UI.

This commit is contained in:
Alex Ellis 2017-09-08 10:43:44 +01:00
parent 5a58db2c50
commit d127dc7cb0
2 changed files with 19 additions and 4 deletions

View File

@ -4,8 +4,8 @@
var app = angular.module('faasGateway', ['ngMaterial']); var app = angular.module('faasGateway', ['ngMaterial']);
app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$mdDialog', app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$mdDialog', '$mdToast',
function($scope, $log, $http, $location, $timeout, $mdDialog) { function($scope, $log, $http, $location, $timeout, $mdDialog, $mdToast) {
$scope.functions = []; $scope.functions = [];
$scope.invocationRequest = ""; $scope.invocationRequest = "";
$scope.invocationResponse = ""; $scope.invocationResponse = "";
@ -22,10 +22,20 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
}; };
$scope.invocation.request = "" $scope.invocation.request = ""
setInterval(function() { setInterval(function() {
refreshData(); refreshData();
}, 1000); }, 1000);
$scope.showPostInvokedToast = function(val) {
$mdToast.show(
$mdToast.simple()
.textContent(val)
.position("top right")
.hideDelay(500)
);
};
$scope.fireRequest = function() { $scope.fireRequest = function() {
var options = { var options = {
@ -35,18 +45,24 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
headers: { "Content-Type": $scope.invocation.contentType == "json" ? "application/json" : "text/plain" }, headers: { "Content-Type": $scope.invocation.contentType == "json" ? "application/json" : "text/plain" },
responseType: $scope.invocation.contentType responseType: $scope.invocation.contentType
}; };
$scope.invocationResponse = "";
$scope.invocationStatus = null;
$http(options) $http(options)
.then(function(response) { .then(function(response) {
if($scope.invocation && $scope.invocation.contentType == "json") { if($scope.invocation && $scope.invocation.contentType == "json") {
$scope.invocationResponse = JSON.stringify(response.data, -1, " "); $scope.invocationResponse = JSON.stringify(response.data, -1, " ");
} else { } else {
$scope.invocationResponse = response.data; $scope.invocationResponse = response.data;
} }
$scope.invocationStatus = response.status; $scope.invocationStatus = response.status;
$scope.showPostInvokedToast("Success");
}).catch(function(error1) { }).catch(function(error1) {
$scope.invocationResponse = error1.statusText + "\n" + error1.data; $scope.invocationResponse = error1.statusText + "\n" + error1.data;
$scope.invocationStatus = error1.status; $scope.invocationStatus = error1.status;
$scope.showPostInvokedToast("Error");
}); });
}; };

View File

@ -3,7 +3,6 @@
export eTAG="latest-dev" export eTAG="latest-dev"
echo $1 echo $1
if [ $1 ] ; then if [ $1 ] ; then
echo "set this"
eTAG=$1 eTAG=$1
fi fi