Skip to content
Snippets Groups Projects
Commit cb367096 authored by Lucas Roesler's avatar Lucas Roesler Committed by Alex Ellis
Browse files

Refresh function image during ui update loop


**What**
- Update the function image value during the `refreshData`

Signed-off-by: default avatarLucas Roesler <roesler.lucas@gmail.com>
parent 0ae10516
No related branches found
No related tags found
No related merge requests found
...@@ -180,29 +180,32 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f ...@@ -180,29 +180,32 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
}); });
}; };
var refreshData = function() { var refreshData = function () {
var previous = $scope.functions; var previous = $scope.functions;
var cl = function(previousItems) { var cl = function (previousItems) {
$http.get("../system/functions").then(function(response) { $http.get("../system/functions").then(function (response) {
if (response && response.data) { if (response == null || response.data == null) {
if (previousItems.length != response.data.length) { return
$scope.functions = response.data; }
// update the selected function object because the newly fetched object from the API becomes a different object if (previousItems.length != response.data.length) {
var filteredSelectedFunction = $filter('filter')($scope.functions, {name: $scope.selectedFunction.name}, true); $scope.functions = response.data;
if (filteredSelectedFunction && filteredSelectedFunction.length > 0) {
$scope.selectedFunction = filteredSelectedFunction[0]; // update the selected function object because the newly fetched object from the API becomes a different object
} else { var filteredSelectedFunction = $filter('filter')($scope.functions, { name: $scope.selectedFunction.name }, true);
$scope.selectedFunction = undefined; if (filteredSelectedFunction && filteredSelectedFunction.length > 0) {
} $scope.selectedFunction = filteredSelectedFunction[0];
} else { } else {
for (var i = 0; i < $scope.functions.length; i++) { $scope.selectedFunction = undefined;
for (var j = 0; j < response.data.length; j++) { }
if ($scope.functions[i].name == response.data[j].name) { } else {
$scope.functions[i].replicas = response.data[j].replicas; for (var i = 0; i < $scope.functions.length; i++) {
$scope.functions[i].invocationCount = response.data[j].invocationCount; for (var j = 0; j < response.data.length; j++) {
} if ($scope.functions[i].name == response.data[j].name) {
$scope.functions[i].image = response.data[j].image;
$scope.functions[i].replicas = response.data[j].replicas;
$scope.functions[i].invocationCount = response.data[j].invocationCount;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment