Make UI block until function reports readiness

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis 2018-03-03 17:38:27 +00:00
parent 936beb2166
commit ccfb8f7be4
2 changed files with 35 additions and 3 deletions

View File

@ -90,10 +90,16 @@
</div>
<div layout-gt-sm="row">
<md-input-container class="md-icon-float md-block">
<label>Status</label>
<input ng-model="isReady(function)" type="text" readonly="readonly">
</md-input-container>
<md-input-container class="md-icon-float md-block">
<label>Replicas</label>
<input ng-model="function.replicas" type="text" readonly="readonly">
</md-input-container>
<md-input-container class="md-block" flex-gt-sm>
<label>Invocation count</label>
<input ng-model="function.invocationCount" type="text" readonly="readonly">
@ -124,7 +130,7 @@
</span>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<button ng-click="fireRequest()" class="md-raised md-button md-ink-ripple" type="button" ng-disabled="invocationInProgress">
<button ng-click="fireRequest()" class="md-raised md-button md-ink-ripple" type="button" ng-disabled="invocationInProgress || (selectedFunction && !selectedFunction.ready)">
<span class="ng-scope">Invoke</span><div class="md-ripple-container"></div>
</button>
</md-input-container>

View File

@ -31,11 +31,37 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$timeout', '$md
labels: {}
};
$scope.isReady = function(selectedFunction) {
if(selectedFunction.ready != undefined && selectedFunction.ready) {
return "Ready";
}
return "Querying..";
}
$scope.invocation.request = "";
setInterval(function() {
$scope.fetchFunctionsDelay = 3500;
$scope.queryFunctionDelay = 2500;
$scope.fetchFunctionsInterval = setInterval(function() {
refreshData();
}, 1000);
}, $scope.fetchFunctionsDelay);
$scope.queryFunctionInterval = setInterval(function() {
if($scope.selectedFunction && $scope.selectedFunction.name) {
refreshFunction($scope.selectedFunction);
}
}, $scope.queryFunctionDelay);
var refreshFunction = function(functionInstance) {
$http.get("../system/function/" + functionInstance.name)
.then(function(response) {
functionInstance.ready = (response.data && response.data.availableReplicas && response.data.availableReplicas >0);
})
.catch(function(err) {
console.error(err);
});
};
var showPostInvokedToast = function(message, duration) {
$mdToast.show(