Enable client response time in the UI

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis 2017-11-17 17:39:52 +00:00
parent b19bf0a136
commit 9783f96f7b
2 changed files with 189 additions and 173 deletions

View File

@ -137,11 +137,16 @@
<textarea ng-model="invocation.request" class="monospace" cols="80" rows="4"></textarea>
</md-input-container>
</div>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<label>Response status</label>
<input ng-model="invocationStatus" type="text" readonly="readonly">
</md-input-container>
<md-input-container class="md-block" flex-gt-sm>
<label>Round-trip (s)</label>
<input ng-model="roundTripDuration" type="text" readonly="readonly">
</md-input-container>
</div>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>

View File

@ -11,6 +11,8 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
$scope.invocationRequest = "";
$scope.invocationResponse = "";
$scope.invocationStatus = "";
$scope.invocationStart = new Date().getTime();
$scope.roundTripDuration = "";
$scope.invocation = {
contentType: "text"
};
@ -26,7 +28,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
service: ""
};
$scope.invocation.request = ""
$scope.invocation.request = "";
setInterval(function() {
refreshData();
@ -52,6 +54,8 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
$scope.invocationInProgress = true;
$scope.invocationResponse = "";
$scope.invocationStatus = null;
$scope.roundTripDuration = "";
$scope.invocationStart = new Date().getTime()
$http(options)
.then(function(response) {
@ -62,11 +66,16 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
}
$scope.invocationInProgress = false;
$scope.invocationStatus = response.status;
var now = new Date().getTime();
$scope.roundTripDuration = (now - $scope.invocationStart) / 1000;
showPostInvokedToast("Success");
}).catch(function(error1) {
$scope.invocationInProgress = false;
$scope.invocationResponse = error1.statusText + "\n" + error1.data;
$scope.invocationStatus = error1.status;
var now = new Date().getTime();
$scope.roundTripDuration = (now - $scope.invocationStart) / 1000;
showPostInvokedToast("Error");
});
@ -110,6 +119,7 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
$scope.invocationStatus = "";
$scope.invocationInProgress = false;
$scope.invocation.contentType = "text";
$scope.invocation.roundTripDuration = "";
}
};
@ -194,4 +204,5 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
};
fetch();
}]);
}
]);