Skip to content

Commit

Permalink
Merge pull request #2259 from rhamilto/issue-109
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Replacing empty tables with empty state message

Fixes #109
Replaces #497

HACK DAY!

Before:
![127 0 0 1-8443-console-project-my-project-dc-browse-deployments](https://user-images.githubusercontent.com/895728/31518381-10aab73c-af6d-11e7-81e0-a650c802b9d7.png)
![127 0 0 1-8443-console-project-my-project-dc-browse-deployments 1](https://user-images.githubusercontent.com/895728/31518396-19db6d7e-af6d-11e7-8c53-949714425d25.png)

After:
![localhost-9000-dev-console-project-my-project-empty-quota](https://user-images.githubusercontent.com/895728/31667665-20f0674a-b31e-11e7-8e83-8b0a047220ba.png)
![localhost-9000-dev-console-project-my-project-delete-browse-config-maps-labelfilter 7b 22matchexpressions 22- 5b 7b 22key 22- 22foo 22 22operator 22- 22exists 22 22values 22- 5b 5d 7d 5d 7d](https://user-images.githubusercontent.com/895728/31666705-2eb4f31c-b31b-11e7-98fe-96d86d643a2a.png)
  • Loading branch information
openshift-merge-robot committed Oct 17, 2017
2 parents c7bba0e + 5d681a3 commit 075822b
Show file tree
Hide file tree
Showing 32 changed files with 891 additions and 749 deletions.
27 changes: 9 additions & 18 deletions app/scripts/controllers/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ angular.module('openshiftConsole')
$scope.unfilteredBuildConfigs = {};
$scope.buildConfigs = undefined;
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Loading...";
$scope.latestByConfig = {};
$scope.clearFilter = function() {
LabelFilter.clear();
};

var buildConfigForBuild = $filter('buildConfigForBuild');

Expand All @@ -43,9 +44,9 @@ angular.module('openshiftConsole')
var isPipeline = $filter('isJenkinsPipelineStrategy');

watches.push(DataService.watch(buildsVersion, context, function(builds) {
$scope.buildsLoaded = true;
// Filter out pipeline builds, which have a separate page.
$scope.builds = _.omitBy(builds.by("metadata.name"), isPipeline);
$scope.emptyMessage = "No builds to show";
associateBuildsToBuildConfig();
LabelFilter.addLabelSuggestionsFromResources($scope.builds, $scope.labelSuggestions);

Expand All @@ -59,7 +60,7 @@ angular.module('openshiftConsole')
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
$scope.buildConfigs = LabelFilter.getLabelSelector().select($scope.unfilteredBuildConfigs);
associateBuildsToBuildConfig();
updateFilterWarning();
updateFilterMessage();
Logger.log("buildconfigs (subscribe)", $scope.buildConfigs);
}));

Expand Down Expand Up @@ -113,27 +114,17 @@ angular.module('openshiftConsole')
});
}

function updateFilterWarning() {
function updateFilterMessage() {
var visibleBuilds = _.omitBy($scope.latestByConfig, _.isNull);
if (!LabelFilter.getLabelSelector().isEmpty() &&
_.isEmpty($scope.buildConfigs) &&
_.isEmpty(visibleBuilds)) {
$scope.alerts["builds"] = {
type: "warning",
details: "The active filters are hiding all builds."
};
}
else {
delete $scope.alerts["builds"];
}
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.buildConfigs) && _.isEmpty(visibleBuilds);
}

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
// trigger a digest loop
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.buildConfigs = labelSelector.select($scope.unfilteredBuildConfigs);
associateBuildsToBuildConfig();
updateFilterWarning();
updateFilterMessage();
});
});

Expand Down
21 changes: 7 additions & 14 deletions app/scripts/controllers/configMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ angular.module('openshiftConsole')
LabelFilter,
ProjectsService) {
$scope.projectName = $routeParams.project;
$scope.alerts = $scope.alerts || {};
$scope.loaded = false;
$scope.labelSuggestions = {};
$scope.configMapsVersion = APIService.getPreferredVersion('configmaps');
$scope.clearFilter = function () {
LabelFilter.clear();
};
var watches = [];
var configMaps;

var updateFilterWarning = function() {
if (!LabelFilter.getLabelSelector().isEmpty() &&
_.isEmpty($scope.configMaps) &&
!_.isEmpty(configMaps)) {
$scope.alerts["config-maps"] = {
type: "warning",
details: "The active filters are hiding all config maps."
};
} else {
delete $scope.alerts["config-maps"];
}
var updateFilterMessage = function() {
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.configMaps) && !_.isEmpty(configMaps);
};

var updateLabelSuggestions = function() {
Expand All @@ -44,7 +37,7 @@ angular.module('openshiftConsole')
var updateConfigMaps = function() {
var filteredConfigMaps = LabelFilter.getLabelSelector().select(configMaps);
$scope.configMaps = _.sortBy(filteredConfigMaps, 'metadata.name');
updateFilterWarning();
updateFilterMessage();
};

ProjectsService
Expand All @@ -60,7 +53,7 @@ angular.module('openshiftConsole')
}));

LabelFilter.onActiveFiltersChanged(function() {
$scope.$apply(updateConfigMaps);
$scope.$evalAsync(updateConfigMaps);
});

$scope.$on('$destroy', function(){
Expand Down
82 changes: 34 additions & 48 deletions app/scripts/controllers/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ angular.module('openshiftConsole')
$scope.unfilteredDeployments = {};
$scope.replicationControllersByDC = {};
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Loading...";
$scope.expandedDeploymentConfigRow = {};
$scope.unfilteredReplicaSets = {};
$scope.unfilteredReplicationControllers = {};
$scope.showEmptyState = true;
$scope.clearFilter = function() {
LabelFilter.clear();
};

var replicaSets, deploymentsByUID;
var annotation = $filter('annotation');
Expand All @@ -38,6 +41,26 @@ angular.module('openshiftConsole')
var replicationControllersVersion = APIService.getPreferredVersion('replicationcontrollers');
var replicaSetsVersion = APIService.getPreferredVersion('replicasets');

function updateFilterMessage() {

var unfilteredDeploymentsEmpty =
_.isEmpty($scope.unfilteredDeploymentConfigs) &&
_.isEmpty($scope.unfilteredReplicationControllers) &&
_.isEmpty($scope.unfilteredDeployments) &&
_.isEmpty($scope.unfilteredReplicaSets);

var isFiltering = !LabelFilter.getLabelSelector().isEmpty();

var filteredDeploymentsEmpty =
_.isEmpty($scope.deploymentConfigs) &&
_.isEmpty($scope.replicationControllersByDC['']) &&
_.isEmpty($scope.deployments) &&
_.isEmpty($scope.replicaSets);

$scope.showEmptyState = unfilteredDeploymentsEmpty;
$scope.filterWithZeroResults = isFiltering && filteredDeploymentsEmpty && !unfilteredDeploymentsEmpty;
}

var groupReplicaSets = function() {
if (!replicaSets || !deploymentsByUID) {
return;
Expand All @@ -58,6 +81,7 @@ angular.module('openshiftConsole')
$scope.latestReplicaSetByDeploymentUID[deploymentUID] =
DeploymentsService.getActiveReplicaSet(replicaSets, deploymentsByUID[deploymentUID]);
});
updateFilterMessage();
};

var watches = [];
Expand All @@ -82,7 +106,7 @@ angular.module('openshiftConsole')
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
$scope.replicationControllersByDC[''] = LabelFilter.getLabelSelector().select($scope.replicationControllersByDC['']);
}
updateFilterWarning();
updateFilterMessage();

if (!action) {
// Loading of the page that will create deploymentConfigDeploymentsInProgress structure, which will associate running deployment to his deploymentConfig.
Expand Down Expand Up @@ -121,6 +145,7 @@ angular.module('openshiftConsole')
}));

watches.push(DataService.watch(deploymentConfigsVersion, context, function(deploymentConfigs) {
$scope.deploymentConfigsLoaded = true;
$scope.unfilteredDeploymentConfigs = deploymentConfigs.by("metadata.name");
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredDeploymentConfigs, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
Expand All @@ -131,7 +156,7 @@ angular.module('openshiftConsole')
$scope.unfilteredReplicationControllers = $scope.replicationControllersByDC[''];
$scope.replicationControllersByDC[''] = LabelFilter.getLabelSelector().select($scope.replicationControllersByDC['']);
}
updateFilterWarning();
updateFilterMessage();
Logger.log("deploymentconfigs (subscribe)", $scope.deploymentConfigs);
}));

Expand All @@ -144,54 +169,15 @@ angular.module('openshiftConsole')
Logger.log("deployments (subscribe)", $scope.unfilteredDeployments);
}));

function updateFilterWarning() {
var isFiltering = !LabelFilter.getLabelSelector().isEmpty();
if (!isFiltering) {
delete $scope.alerts["deployments"];
return;
}

var unfilteredDeploymentsEmpty =
_.isEmpty($scope.unfilteredDeploymentConfigs) &&
_.isEmpty($scope.unfilteredReplicationControllers) &&
_.isEmpty($scope.unfilteredDeployments) &&
_.isEmpty($scope.unfilteredReplicaSets);
if (unfilteredDeploymentsEmpty) {
delete $scope.alerts["deployments"];
return;
}

var filteredDeploymentsEmpty =
_.isEmpty($scope.deploymentConfigs) &&
_.isEmpty($scope.replicationControllersByDC['']) &&
_.isEmpty($scope.deployments) &&
_.isEmpty($scope.replicaSets);
if (!filteredDeploymentsEmpty) {
delete $scope.alerts["deployments"];
return;
}

$scope.alerts["deployments"] = {
type: "warning",
details: "The active filters are hiding all deployments."
};
}

$scope.showEmptyMessage = function() {
if ($filter('hashSize')($scope.replicationControllersByDC) === 0) {
return true;
}

if ($filter('hashSize')($scope.replicationControllersByDC) === 1 && $scope.replicationControllersByDC['']) {
return true;
}

return false;
// Does the deployment config table have content?
$scope.showDeploymentConfigTable = function() {
var size = _.size($scope.replicationControllersByDC);
return size > 1 || (size === 1 && !$scope.replicationControllersByDC['']);
};

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
// trigger a digest loop
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.deploymentConfigs = labelSelector.select($scope.unfilteredDeploymentConfigs);
$scope.replicationControllersByDC = DeploymentsService.associateDeploymentsToDeploymentConfig($scope.replicationControllers, $scope.deploymentConfigs, true);
if ($scope.replicationControllersByDC['']) {
Expand All @@ -200,7 +186,7 @@ angular.module('openshiftConsole')
}
$scope.deployments = labelSelector.select($scope.unfilteredDeployments);
$scope.replicaSets = labelSelector.select($scope.unfilteredReplicaSets);
updateFilterWarning();
updateFilterMessage();
});
});

Expand Down
25 changes: 9 additions & 16 deletions app/scripts/controllers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ angular.module('openshiftConsole')
$scope.missingStatusTagsByImageStream = {};
$scope.builds = {};
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Loading...";
$scope.clearFilter = function() {
LabelFilter.clear();
};

var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');

Expand All @@ -35,13 +36,13 @@ angular.module('openshiftConsole')
.then(_.spread(function(project, context) {
$scope.project = project;
watches.push(DataService.watch(imageStreamsVersion, context, function(imageStreams) {
$scope.imageStreamsLoaded = true;
$scope.unfilteredImageStreams = imageStreams.by("metadata.name");
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredImageStreams, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
$scope.imageStreams = LabelFilter.getLabelSelector().select($scope.unfilteredImageStreams);
$scope.emptyMessage = "No image streams to show";
updateMissingStatusTags();
updateFilterWarning();
updateFilterMessage();
Logger.log("image streams (subscribe)", $scope.imageStreams);
}));

Expand Down Expand Up @@ -71,23 +72,15 @@ angular.module('openshiftConsole')
});
}

function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.imageStreams) && !$.isEmptyObject($scope.unfilteredImageStreams)) {
$scope.alerts["imageStreams"] = {
type: "warning",
details: "The active filters are hiding all image streams."
};
}
else {
delete $scope.alerts["imageStreams"];
}
function updateFilterMessage() {
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.imageStreams) && !_.isEmpty($scope.unfilteredImageStreams);
}

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
// trigger a digest loop
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.imageStreams = labelSelector.select($scope.unfilteredImageStreams);
updateFilterWarning();
updateFilterMessage();
});
});

Expand Down
27 changes: 10 additions & 17 deletions app/scripts/controllers/otherResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ angular.module('openshiftConsole')
APIService) {
$scope.projectName = $routeParams.project;
$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Select a resource from the list above ...";
$scope.kindSelector = {disabled: true};
$scope.kinds = _.filter(APIService.availableKinds(), function(kind) {
switch (kind.kind) {
Expand Down Expand Up @@ -47,6 +45,9 @@ angular.module('openshiftConsole')
return true;
}
});
$scope.clearFilter = function () {
LabelFilter.clear();
};

var isListable = function(kind) {
if(!kind) {
Expand Down Expand Up @@ -125,16 +126,8 @@ angular.module('openshiftConsole')
}
}));

function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.resources) && !$.isEmptyObject($scope.unfilteredResources)) {
$scope.alerts["resources"] = {
type: "warning",
details: "The active filters are hiding all " + APIService.kindToResource($scope.kindSelector.selected.kind, true) + "."
};
}
else {
delete $scope.alerts["resources"];
}
function updateFilterMessage() {
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.resources) && !_.isEmpty($scope.unfilteredResources);
}

function loadKind() {
Expand All @@ -158,13 +151,13 @@ angular.module('openshiftConsole')
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredResources, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
$scope.resources = LabelFilter.getLabelSelector().select($scope.unfilteredResources);
$scope.emptyMessage = "No " + APIService.kindToResource(selected.kind, true) + " to show";
updateFilterWarning();
$scope.resourceName = APIService.kindToResource(selected.kind, true);
updateFilterMessage();
});
}
$scope.loadKind = loadKind;
$scope.$watch("kindSelector.selected", function() {
$scope.alerts = {};
LabelFilter.clear();
loadKind();
});

Expand All @@ -175,9 +168,9 @@ angular.module('openshiftConsole')

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
// trigger a digest loop
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.resources = labelSelector.select($scope.unfilteredResources);
updateFilterWarning();
updateFilterMessage();
});
});
});
Loading

0 comments on commit 075822b

Please sign in to comment.