Skip to content

Commit

Permalink
Merge pull request #2034 from jeff-phillips-18/applications
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Sep 16, 2017
2 parents 3826410 + 2e78f9f commit 1466f66
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 227 deletions.
56 changes: 5 additions & 51 deletions app/scripts/directives/addSecretToApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'$filter',
'$scope',
'APIService',
'ApplicationsService',
'DataService',
'Navigate',
'NotificationsService',
Expand All @@ -21,63 +22,16 @@
templateUrl: 'views/directives/add-secret-to-application.html'
});

function AddSecretToApplication($filter, $scope, APIService, DataService, Navigate, NotificationsService, StorageService) {
function AddSecretToApplication($filter, $scope, APIService, ApplicationsService, DataService, Navigate, NotificationsService, StorageService) {
var ctrl = this;
var deploymentConfigs;
var deployments;
var replicationControllers;
var replicaSets;
var statefulSets;

var sortApplications = function() {
// Don't waste time sorting on each data load, just sort when we have them all
if (deploymentConfigs && deployments && replicationControllers && replicaSets && statefulSets) {
var apiObjects = deploymentConfigs.concat(deployments)
.concat(replicationControllers)
.concat(replicaSets)
.concat(statefulSets);
ctrl.applications = _.sortBy(apiObjects, ['metadata.name', 'kind']);
ctrl.updating = false;
}
};

var getApplications = function() {
var hasDeploymentFilter = $filter('hasDeployment');
var hasDeploymentConfigFilter = $filter('hasDeploymentConfig');

ctrl.updating = true;
var context = {
namespace: ctrl.project.metadata.name
};
// Load all the "application" types
DataService.list('deploymentconfigs', context).then(function(deploymentConfigData) {
deploymentConfigs = _.toArray(deploymentConfigData.by('metadata.name'));
sortApplications();
});
DataService.list('replicationcontrollers', context).then(function(replicationControllerData) {
replicationControllers = _.reject(replicationControllerData.by('metadata.name'), hasDeploymentConfigFilter);
sortApplications();
});
DataService.list({
group: 'apps',
resource: 'deployments'
}, context).then(function(deploymentData) {
deployments = _.toArray(deploymentData.by('metadata.name'));
sortApplications();
});
DataService.list({
group: 'extensions',
resource: 'replicasets'
}, context).then(function(replicaSetData) {
replicaSets = _.reject(replicaSetData.by('metadata.name'), hasDeploymentFilter);
sortApplications();
});
DataService.list({
group: 'apps',
resource: 'statefulsets'
}, context).then(function(statefulSetData) {
statefulSets = _.toArray(statefulSetData.by('metadata.name'));
sortApplications();
ApplicationsService.getApplications(context).then(function(applications) {
ctrl.applications = applications;
ctrl.updating = false;
});
};

Expand Down
50 changes: 5 additions & 45 deletions app/scripts/directives/bindService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
controller: [
'$scope',
'$filter',
'ApplicationsService',
'DataService',
'BindingService',
BindService
Expand All @@ -20,6 +21,7 @@

function BindService($scope,
$filter,
ApplicationsService,
DataService,
BindingService) {
var ctrl = this;
Expand Down Expand Up @@ -59,20 +61,6 @@
}
};

var deploymentConfigs, deployments, replicationControllers, replicaSets, statefulSets;
var sortApplications = function() {
// Don't waste time sorting on each data load, just sort when we have them all
if (deploymentConfigs && deployments && replicationControllers && replicaSets && statefulSets) {
var apiObjects = [].concat(deploymentConfigs)
.concat(deployments)
.concat(replicationControllers)
.concat(replicaSets)
.concat(statefulSets);
ctrl.applications = _.sortBy(apiObjects, ['metadata.name', 'kind']);
ctrl.bindType = ctrl.applications.length ? "application" : "secret-only";
}
};

var showBind = function() {
ctrl.nextTitle = bindParametersStep.hidden ? 'Bind' : 'Next >';
if (ctrl.podPresets && !selectionValidityWatcher) {
Expand Down Expand Up @@ -106,41 +94,13 @@
ctrl.bindService();
};


var loadApplications = function() {
var context = {
namespace: _.get(ctrl.target, 'metadata.namespace')
};

// Load all the "application" types
DataService.list('deploymentconfigs', context).then(function(deploymentConfigData) {
deploymentConfigs = _.toArray(deploymentConfigData.by('metadata.name'));
sortApplications();
});
DataService.list('replicationcontrollers', context).then(function(replicationControllerData) {
replicationControllers = _.reject(replicationControllerData.by('metadata.name'), $filter('hasDeploymentConfig'));
sortApplications();
});
DataService.list({
group: 'apps',
resource: 'deployments'
}, context).then(function(deploymentData) {
deployments = _.toArray(deploymentData.by('metadata.name'));
sortApplications();
});
DataService.list({
group: 'extensions',
resource: 'replicasets'
}, context).then(function(replicaSetData) {
replicaSets = _.reject(replicaSetData.by('metadata.name'), $filter('hasDeployment'));
sortApplications();
});
DataService.list({
group: 'apps',
resource: 'statefulsets'
}, context).then(function(statefulSetData) {
statefulSets = _.toArray(statefulSetData.by('metadata.name'));
sortApplications();
ApplicationsService.getApplications(context).then(function(applications) {
ctrl.applications = applications;
ctrl.bindType = ctrl.applications.length ? "application" : "secret-only";
});
};

Expand Down
Loading

0 comments on commit 1466f66

Please sign in to comment.