Skip to content

Commit 1466f66

Browse files
author
OpenShift Bot
authored
Merge pull request #2034 from jeff-phillips-18/applications
Merged by openshift-bot
2 parents 3826410 + 2e78f9f commit 1466f66

File tree

3 files changed

+95
-227
lines changed

3 files changed

+95
-227
lines changed

app/scripts/directives/addSecretToApplication.js

+5-51
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'$filter',
66
'$scope',
77
'APIService',
8+
'ApplicationsService',
89
'DataService',
910
'Navigate',
1011
'NotificationsService',
@@ -21,63 +22,16 @@
2122
templateUrl: 'views/directives/add-secret-to-application.html'
2223
});
2324

24-
function AddSecretToApplication($filter, $scope, APIService, DataService, Navigate, NotificationsService, StorageService) {
25+
function AddSecretToApplication($filter, $scope, APIService, ApplicationsService, DataService, Navigate, NotificationsService, StorageService) {
2526
var ctrl = this;
26-
var deploymentConfigs;
27-
var deployments;
28-
var replicationControllers;
29-
var replicaSets;
30-
var statefulSets;
31-
32-
var sortApplications = function() {
33-
// Don't waste time sorting on each data load, just sort when we have them all
34-
if (deploymentConfigs && deployments && replicationControllers && replicaSets && statefulSets) {
35-
var apiObjects = deploymentConfigs.concat(deployments)
36-
.concat(replicationControllers)
37-
.concat(replicaSets)
38-
.concat(statefulSets);
39-
ctrl.applications = _.sortBy(apiObjects, ['metadata.name', 'kind']);
40-
ctrl.updating = false;
41-
}
42-
};
4327

4428
var getApplications = function() {
45-
var hasDeploymentFilter = $filter('hasDeployment');
46-
var hasDeploymentConfigFilter = $filter('hasDeploymentConfig');
47-
48-
ctrl.updating = true;
4929
var context = {
5030
namespace: ctrl.project.metadata.name
5131
};
52-
// Load all the "application" types
53-
DataService.list('deploymentconfigs', context).then(function(deploymentConfigData) {
54-
deploymentConfigs = _.toArray(deploymentConfigData.by('metadata.name'));
55-
sortApplications();
56-
});
57-
DataService.list('replicationcontrollers', context).then(function(replicationControllerData) {
58-
replicationControllers = _.reject(replicationControllerData.by('metadata.name'), hasDeploymentConfigFilter);
59-
sortApplications();
60-
});
61-
DataService.list({
62-
group: 'apps',
63-
resource: 'deployments'
64-
}, context).then(function(deploymentData) {
65-
deployments = _.toArray(deploymentData.by('metadata.name'));
66-
sortApplications();
67-
});
68-
DataService.list({
69-
group: 'extensions',
70-
resource: 'replicasets'
71-
}, context).then(function(replicaSetData) {
72-
replicaSets = _.reject(replicaSetData.by('metadata.name'), hasDeploymentFilter);
73-
sortApplications();
74-
});
75-
DataService.list({
76-
group: 'apps',
77-
resource: 'statefulsets'
78-
}, context).then(function(statefulSetData) {
79-
statefulSets = _.toArray(statefulSetData.by('metadata.name'));
80-
sortApplications();
32+
ApplicationsService.getApplications(context).then(function(applications) {
33+
ctrl.applications = applications;
34+
ctrl.updating = false;
8135
});
8236
};
8337

app/scripts/directives/bindService.js

+5-45
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
controller: [
66
'$scope',
77
'$filter',
8+
'ApplicationsService',
89
'DataService',
910
'BindingService',
1011
BindService
@@ -20,6 +21,7 @@
2021

2122
function BindService($scope,
2223
$filter,
24+
ApplicationsService,
2325
DataService,
2426
BindingService) {
2527
var ctrl = this;
@@ -59,20 +61,6 @@
5961
}
6062
};
6163

62-
var deploymentConfigs, deployments, replicationControllers, replicaSets, statefulSets;
63-
var sortApplications = function() {
64-
// Don't waste time sorting on each data load, just sort when we have them all
65-
if (deploymentConfigs && deployments && replicationControllers && replicaSets && statefulSets) {
66-
var apiObjects = [].concat(deploymentConfigs)
67-
.concat(deployments)
68-
.concat(replicationControllers)
69-
.concat(replicaSets)
70-
.concat(statefulSets);
71-
ctrl.applications = _.sortBy(apiObjects, ['metadata.name', 'kind']);
72-
ctrl.bindType = ctrl.applications.length ? "application" : "secret-only";
73-
}
74-
};
75-
7664
var showBind = function() {
7765
ctrl.nextTitle = bindParametersStep.hidden ? 'Bind' : 'Next >';
7866
if (ctrl.podPresets && !selectionValidityWatcher) {
@@ -106,41 +94,13 @@
10694
ctrl.bindService();
10795
};
10896

109-
11097
var loadApplications = function() {
11198
var context = {
11299
namespace: _.get(ctrl.target, 'metadata.namespace')
113100
};
114-
115-
// Load all the "application" types
116-
DataService.list('deploymentconfigs', context).then(function(deploymentConfigData) {
117-
deploymentConfigs = _.toArray(deploymentConfigData.by('metadata.name'));
118-
sortApplications();
119-
});
120-
DataService.list('replicationcontrollers', context).then(function(replicationControllerData) {
121-
replicationControllers = _.reject(replicationControllerData.by('metadata.name'), $filter('hasDeploymentConfig'));
122-
sortApplications();
123-
});
124-
DataService.list({
125-
group: 'apps',
126-
resource: 'deployments'
127-
}, context).then(function(deploymentData) {
128-
deployments = _.toArray(deploymentData.by('metadata.name'));
129-
sortApplications();
130-
});
131-
DataService.list({
132-
group: 'extensions',
133-
resource: 'replicasets'
134-
}, context).then(function(replicaSetData) {
135-
replicaSets = _.reject(replicaSetData.by('metadata.name'), $filter('hasDeployment'));
136-
sortApplications();
137-
});
138-
DataService.list({
139-
group: 'apps',
140-
resource: 'statefulsets'
141-
}, context).then(function(statefulSetData) {
142-
statefulSets = _.toArray(statefulSetData.by('metadata.name'));
143-
sortApplications();
101+
ApplicationsService.getApplications(context).then(function(applications) {
102+
ctrl.applications = applications;
103+
ctrl.bindType = ctrl.applications.length ? "application" : "secret-only";
144104
});
145105
};
146106

0 commit comments

Comments
 (0)