@spinnaker/amazon 0.11.1 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/domain/IAmazonLaunchTemplate.d.ts +1 -1
  3. package/dist/domain/IAmazonServerGroup.d.ts +10 -0
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/instance/awsInstanceType.service.d.ts +10 -2
  7. package/dist/instance/awsInstanceTypes.d.ts +10 -0
  8. package/dist/instance/details/CostFactor.d.ts +6 -0
  9. package/dist/reactShims/aws.react.injector.d.ts +2 -1
  10. package/dist/search/searchResultFormatter.d.ts +2 -2
  11. package/dist/serverGroup/configure/serverGroupCommandBuilder.service.d.ts +17 -2
  12. package/dist/serverGroup/configure/serverGroupConfiguration.service.d.ts +39 -0
  13. package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +3 -4
  14. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +9 -0
  15. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +13 -0
  16. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +9 -0
  17. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +11 -0
  18. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +14 -0
  19. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +12 -0
  20. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +15 -0
  21. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +8 -0
  22. package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +8 -0
  23. package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +9 -6
  24. package/dist/serverGroup/serverGroup.transformer.d.ts +2 -1
  25. package/package.json +5 -5
  26. package/src/domain/IAmazonLaunchTemplate.ts +1 -1
  27. package/src/domain/IAmazonServerGroup.ts +11 -0
  28. package/src/function/details/FunctionActions.spec.tsx +10 -9
  29. package/src/help/amazon.help.ts +9 -6
  30. package/src/image/image.reader.spec.ts +75 -0
  31. package/src/instance/awsInstanceType.service.spec.js +37 -71
  32. package/src/instance/awsInstanceType.service.ts +191 -0
  33. package/src/instance/awsInstanceTypes.ts +311 -0
  34. package/src/instance/details/CostFactor.tsx +29 -0
  35. package/src/instance/details/InstanceInformation.spec.tsx +2 -1
  36. package/src/instance/details/instance.details.controller.js +471 -473
  37. package/src/loadBalancer/details/loadBalancerDetails.controller.spec.ts +5 -3
  38. package/src/reactShims/aws.react.injector.ts +2 -1
  39. package/src/search/{searchResultFormatter.js → searchResultFormatter.ts} +5 -4
  40. package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +10 -7
  41. package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +302 -1
  42. package/src/serverGroup/configure/{serverGroupCommandBuilder.service.js → serverGroupCommandBuilder.service.ts} +182 -73
  43. package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +25 -8
  44. package/src/serverGroup/configure/serverGroupConfiguration.service.spec.ts +6 -13
  45. package/src/serverGroup/configure/serverGroupConfiguration.service.ts +53 -0
  46. package/src/serverGroup/configure/wizard/AmazonCloneServerGroupModal.tsx +1 -1
  47. package/src/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.tsx +31 -31
  48. package/src/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.tsx +133 -0
  49. package/src/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.tsx +99 -0
  50. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.tsx +36 -0
  51. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.tsx +144 -0
  52. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.tsx +138 -0
  53. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.tsx +135 -0
  54. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.tsx +137 -0
  55. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.less +5 -0
  56. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.tsx +108 -0
  57. package/src/serverGroup/configure/wizard/instanceType/advancedMode/advancedMode.less +110 -0
  58. package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.tsx +62 -0
  59. package/src/serverGroup/configure/wizard/pages/ServerGroupInstanceType.tsx +107 -62
  60. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +1 -1
  61. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.ts +6 -2
  62. package/src/serverGroup/details/scalingProcesses/AutoScalingProcessService.spec.ts +1 -2
  63. package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +8 -5
  64. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +8 -5
  65. package/src/serverGroup/serverGroup.transformer.spec.ts +5 -3
  66. package/src/serverGroup/serverGroup.transformer.ts +24 -22
  67. package/src/subnet/SubnetSelectInput.spec.tsx +7 -4
  68. package/src/vpc/{VpcReader.spec.js → VpcReader.spec.ts} +2 -10
  69. package/src/vpc/VpcTag.spec.tsx +37 -0
  70. package/src/vpc/vpc.module.ts +6 -2
  71. package/dist/vpc/vpcTag.directive.d.ts +0 -2
  72. package/src/image/image.reader.spec.js +0 -123
  73. package/src/instance/awsInstanceType.service.js +0 -437
  74. package/src/vpc/vpcTag.directive.js +0 -34
  75. package/src/vpc/vpcTag.directive.spec.js +0 -60
@@ -17,152 +17,133 @@ import {
17
17
  import { AmazonInstanceWriter } from '../amazon.instance.write.service';
18
18
  import { AWSProviderSettings } from '../../aws.settings';
19
19
  import { applyHealthCheckInfoToTargetGroups, getAllTargetGroups } from './utils';
20
- import { AMAZON_VPC_VPCTAG_DIRECTIVE } from '../../vpc/vpcTag.directive';
21
20
 
22
21
  export const AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER = 'spinnaker.amazon.instance.details.controller';
23
22
  export const name = AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER; // for backwards compatibility
24
- module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [
25
- UIROUTER_ANGULARJS,
26
- ANGULAR_UI_BOOTSTRAP,
27
- AMAZON_VPC_VPCTAG_DIRECTIVE,
28
- ]).controller('awsInstanceDetailsCtrl', [
29
- '$scope',
30
- '$state',
31
- 'instance',
32
- 'app',
33
- 'moniker',
34
- 'environment',
35
- '$q',
36
- 'overrides',
37
- function ($scope, $state, instance, app, moniker, environment, $q, overrides) {
38
- $scope.isDisabled = !AWSProviderSettings.adHocInfraWritesEnabled;
39
-
40
- // needed for standalone instances
41
- $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('aws', 'instance.detailsTemplateUrl');
42
-
43
- $scope.state = {
44
- loading: true,
45
- standalone: app.isStandalone,
46
- instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80,
47
- };
48
-
49
- $scope.application = app;
50
- $scope.moniker = moniker;
51
- $scope.environment = environment;
52
-
53
- $scope.securityGroupsLabel = FirewallLabels.get('Firewalls');
54
-
55
- function extractHealthMetrics(instance, latest) {
56
- // do not backfill on standalone instances
57
- if (app.isStandalone) {
58
- instance.health = latest.health;
59
- }
23
+ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP]).controller(
24
+ 'awsInstanceDetailsCtrl',
25
+ [
26
+ '$scope',
27
+ '$state',
28
+ 'instance',
29
+ 'app',
30
+ 'moniker',
31
+ 'environment',
32
+ '$q',
33
+ 'overrides',
34
+ function ($scope, $state, instance, app, moniker, environment, $q, overrides) {
35
+ $scope.isDisabled = !AWSProviderSettings.adHocInfraWritesEnabled;
36
+
37
+ // needed for standalone instances
38
+ $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('aws', 'instance.detailsTemplateUrl');
39
+
40
+ $scope.state = {
41
+ loading: true,
42
+ standalone: app.isStandalone,
43
+ instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80,
44
+ };
60
45
 
61
- instance.health = instance.health || [];
62
- const displayableMetrics = instance.health.filter(function (metric) {
63
- return metric.type !== 'Amazon' || metric.state !== 'Unknown';
64
- });
46
+ $scope.application = app;
47
+ $scope.moniker = moniker;
48
+ $scope.environment = environment;
65
49
 
66
- if (!app.isStandalone) {
67
- // augment with target group healthcheck data
68
- const targetGroups = getAllTargetGroups(
69
- app.loadBalancers.data.filter(function (loadBalancer) {
70
- return loadBalancer.cloudProvider === 'aws';
71
- }),
72
- );
73
- applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups, instance.account);
74
- }
50
+ $scope.securityGroupsLabel = FirewallLabels.get('Firewalls');
75
51
 
76
- // backfill details where applicable
77
- if (latest.health) {
78
- displayableMetrics.forEach(function (metric) {
79
- const detailsMatch = latest.health.filter(function (latestHealth) {
80
- return latestHealth.type === metric.type;
81
- });
82
- if (detailsMatch.length) {
83
- _.defaults(metric, detailsMatch[0]);
84
- }
52
+ function extractHealthMetrics(instance, latest) {
53
+ // do not backfill on standalone instances
54
+ if (app.isStandalone) {
55
+ instance.health = latest.health;
56
+ }
57
+
58
+ instance.health = instance.health || [];
59
+ const displayableMetrics = instance.health.filter(function (metric) {
60
+ return metric.type !== 'Amazon' || metric.state !== 'Unknown';
85
61
  });
86
- }
87
- $scope.healthMetrics = displayableMetrics;
88
- }
89
-
90
- function retrieveInstance() {
91
- const extraData = {};
92
- let instanceSummary, loadBalancers, targetGroups, account, region, vpcId, serverGroupDisabled;
93
- if (!app.serverGroups) {
94
- // standalone instance
95
- instanceSummary = { id: instance.instanceId }; // terminate call expects `id` to be populated
96
- loadBalancers = [];
97
- targetGroups = [];
98
- account = instance.account;
99
- region = instance.region;
100
- } else {
101
- app.serverGroups.data.some(function (serverGroup) {
102
- return serverGroup.instances.some(function (possibleInstance) {
103
- if (possibleInstance.id === instance.instanceId) {
104
- instanceSummary = possibleInstance;
105
- loadBalancers = serverGroup.loadBalancers;
106
- targetGroups = serverGroup.targetGroups;
107
- account = serverGroup.account;
108
- region = serverGroup.region;
109
- vpcId = serverGroup.vpcId;
110
- serverGroupDisabled = serverGroup.isDisabled;
111
- extraData.serverGroup = serverGroup.name;
112
- extraData.vpcId = serverGroup.vpcId;
113
- return true;
62
+
63
+ if (!app.isStandalone) {
64
+ // augment with target group healthcheck data
65
+ const targetGroups = getAllTargetGroups(
66
+ app.loadBalancers.data.filter(function (loadBalancer) {
67
+ return loadBalancer.cloudProvider === 'aws';
68
+ }),
69
+ );
70
+ applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups, instance.account);
71
+ }
72
+
73
+ // backfill details where applicable
74
+ if (latest.health) {
75
+ displayableMetrics.forEach(function (metric) {
76
+ const detailsMatch = latest.health.filter(function (latestHealth) {
77
+ return latestHealth.type === metric.type;
78
+ });
79
+ if (detailsMatch.length) {
80
+ _.defaults(metric, detailsMatch[0]);
114
81
  }
115
82
  });
116
- });
117
- if (!instanceSummary) {
118
- // perhaps it is in a server group that is part of another app
119
- app.loadBalancers.data.some(function (loadBalancer) {
120
- return (
121
- loadBalancer.instances.some(function (possibleInstance) {
122
- if (possibleInstance.id === instance.instanceId) {
123
- instanceSummary = possibleInstance;
124
- loadBalancers = [loadBalancer.name];
125
- account = loadBalancer.account;
126
- region = loadBalancer.region;
127
- vpcId = loadBalancer.vpcId;
128
- return true;
129
- }
130
- }) ||
131
- loadBalancer.targetGroups.some(function (targetGroup) {
132
- return targetGroup.instances.some(function (possibleInstance) {
83
+ }
84
+ $scope.healthMetrics = displayableMetrics;
85
+ }
86
+
87
+ function retrieveInstance() {
88
+ const extraData = {};
89
+ let instanceSummary, loadBalancers, targetGroups, account, region, vpcId, serverGroupDisabled;
90
+ if (!app.serverGroups) {
91
+ // standalone instance
92
+ instanceSummary = { id: instance.instanceId }; // terminate call expects `id` to be populated
93
+ loadBalancers = [];
94
+ targetGroups = [];
95
+ account = instance.account;
96
+ region = instance.region;
97
+ } else {
98
+ app.serverGroups.data.some(function (serverGroup) {
99
+ return serverGroup.instances.some(function (possibleInstance) {
100
+ if (possibleInstance.id === instance.instanceId) {
101
+ instanceSummary = possibleInstance;
102
+ loadBalancers = serverGroup.loadBalancers;
103
+ targetGroups = serverGroup.targetGroups;
104
+ account = serverGroup.account;
105
+ region = serverGroup.region;
106
+ vpcId = serverGroup.vpcId;
107
+ serverGroupDisabled = serverGroup.isDisabled;
108
+ extraData.serverGroup = serverGroup.name;
109
+ extraData.vpcId = serverGroup.vpcId;
110
+ return true;
111
+ }
112
+ });
113
+ });
114
+ if (!instanceSummary) {
115
+ // perhaps it is in a server group that is part of another app
116
+ app.loadBalancers.data.some(function (loadBalancer) {
117
+ return (
118
+ loadBalancer.instances.some(function (possibleInstance) {
133
119
  if (possibleInstance.id === instance.instanceId) {
134
120
  instanceSummary = possibleInstance;
135
- targetGroups = [targetGroup.name];
121
+ loadBalancers = [loadBalancer.name];
136
122
  account = loadBalancer.account;
137
123
  region = loadBalancer.region;
138
124
  vpcId = loadBalancer.vpcId;
139
125
  return true;
140
126
  }
141
- });
142
- })
143
- );
144
- });
145
- if (!instanceSummary) {
146
- // perhaps it is in a disabled server group via a load balancer
147
- app.loadBalancers.data.some(function (loadBalancer) {
148
- return (
149
- loadBalancer.serverGroups.some(function (serverGroup) {
150
- if (!serverGroup.isDisabled) {
151
- return false;
152
- }
153
- return serverGroup.instances.some(function (possibleInstance) {
127
+ }) ||
128
+ loadBalancer.targetGroups.some(function (targetGroup) {
129
+ return targetGroup.instances.some(function (possibleInstance) {
154
130
  if (possibleInstance.id === instance.instanceId) {
155
131
  instanceSummary = possibleInstance;
156
- loadBalancers = [loadBalancer.name];
132
+ targetGroups = [targetGroup.name];
157
133
  account = loadBalancer.account;
158
134
  region = loadBalancer.region;
159
135
  vpcId = loadBalancer.vpcId;
160
136
  return true;
161
137
  }
162
138
  });
163
- }) ||
164
- loadBalancer.targetGroups.some(function (targetGroup) {
165
- targetGroup.serverGroups.some(function (serverGroup) {
139
+ })
140
+ );
141
+ });
142
+ if (!instanceSummary) {
143
+ // perhaps it is in a disabled server group via a load balancer
144
+ app.loadBalancers.data.some(function (loadBalancer) {
145
+ return (
146
+ loadBalancer.serverGroups.some(function (serverGroup) {
166
147
  if (!serverGroup.isDisabled) {
167
148
  return false;
168
149
  }
@@ -176,413 +157,430 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [
176
157
  return true;
177
158
  }
178
159
  });
179
- });
180
- })
181
- );
182
- });
160
+ }) ||
161
+ loadBalancer.targetGroups.some(function (targetGroup) {
162
+ targetGroup.serverGroups.some(function (serverGroup) {
163
+ if (!serverGroup.isDisabled) {
164
+ return false;
165
+ }
166
+ return serverGroup.instances.some(function (possibleInstance) {
167
+ if (possibleInstance.id === instance.instanceId) {
168
+ instanceSummary = possibleInstance;
169
+ loadBalancers = [loadBalancer.name];
170
+ account = loadBalancer.account;
171
+ region = loadBalancer.region;
172
+ vpcId = loadBalancer.vpcId;
173
+ return true;
174
+ }
175
+ });
176
+ });
177
+ })
178
+ );
179
+ });
180
+ }
183
181
  }
184
182
  }
185
- }
186
183
 
187
- if (instanceSummary && account && region) {
188
- instanceSummary.account = account;
189
- extraData.account = account;
190
- extraData.region = region;
191
- RecentHistoryService.addExtraDataToLatest('instances', extraData);
192
- return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then((details) => {
193
- if ($scope.$$destroyed) {
194
- return;
195
- }
196
- $scope.state.loading = false;
197
- extractHealthMetrics(instanceSummary, details);
198
- $scope.instance = _.defaults(details, instanceSummary);
199
- $scope.instance.account = account;
200
- $scope.instance.region = region;
201
- $scope.instance.vpcId = vpcId;
202
- $scope.instance.serverGroupDisabled = serverGroupDisabled;
203
- $scope.instance.loadBalancers = loadBalancers;
204
- $scope.instance.targetGroups = targetGroups;
205
- if ($scope.instance.networkInterfaces) {
206
- $scope.instance.ipv6Addresses = _.flatMap($scope.instance.networkInterfaces, (i) =>
207
- i.ipv6Addresses.map((a) => ({
208
- ip: a.ipv6Address,
209
- url: `http://${a.ipv6Address}:${$scope.state.instancePort}`,
210
- })),
211
- );
212
-
213
- const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter(
214
- (f) => f.attachment.deleteOnTermination === false,
215
- );
216
- if (permanentNetworkInterfaces.length) {
217
- $scope.instance.permanentIps = permanentNetworkInterfaces.map((f) => f.privateIpAddress);
184
+ if (instanceSummary && account && region) {
185
+ instanceSummary.account = account;
186
+ extraData.account = account;
187
+ extraData.region = region;
188
+ RecentHistoryService.addExtraDataToLatest('instances', extraData);
189
+ return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then((details) => {
190
+ if ($scope.$$destroyed) {
191
+ return;
218
192
  }
219
- }
220
- $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress;
221
- if (overrides.instanceDetailsLoaded) {
222
- overrides.instanceDetailsLoaded();
223
- }
224
- }, autoClose);
225
- }
193
+ $scope.state.loading = false;
194
+ extractHealthMetrics(instanceSummary, details);
195
+ $scope.instance = _.defaults(details, instanceSummary);
196
+ $scope.instance.account = account;
197
+ $scope.instance.region = region;
198
+ $scope.instance.vpcId = vpcId;
199
+ $scope.instance.serverGroupDisabled = serverGroupDisabled;
200
+ $scope.instance.loadBalancers = loadBalancers;
201
+ $scope.instance.targetGroups = targetGroups;
202
+ if ($scope.instance.networkInterfaces) {
203
+ $scope.instance.ipv6Addresses = _.flatMap($scope.instance.networkInterfaces, (i) =>
204
+ i.ipv6Addresses.map((a) => ({
205
+ ip: a.ipv6Address,
206
+ url: `http://${a.ipv6Address}:${$scope.state.instancePort}`,
207
+ })),
208
+ );
226
209
 
227
- if (!instanceSummary) {
228
- $scope.instanceIdNotFound = instance.instanceId;
229
- $scope.state.loading = false;
230
- }
210
+ const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter(
211
+ (f) => f.attachment.deleteOnTermination === false,
212
+ );
213
+ if (permanentNetworkInterfaces.length) {
214
+ $scope.instance.permanentIps = permanentNetworkInterfaces.map((f) => f.privateIpAddress);
215
+ }
216
+ }
217
+ $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress;
218
+ if (overrides.instanceDetailsLoaded) {
219
+ overrides.instanceDetailsLoaded();
220
+ }
221
+ }, autoClose);
222
+ }
231
223
 
232
- return $q.when(null);
233
- }
224
+ if (!instanceSummary) {
225
+ $scope.instanceIdNotFound = instance.instanceId;
226
+ $scope.state.loading = false;
227
+ }
234
228
 
235
- function autoClose() {
236
- if ($scope.$$destroyed) {
237
- return;
238
- }
239
- if (app.isStandalone) {
240
- $scope.state.loading = false;
241
- $scope.instanceIdNotFound = instance.instanceId;
242
- $scope.state.notFoundStandalone = true;
243
- RecentHistoryService.removeLastItem('instances');
244
- } else {
245
- $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' });
229
+ return $q.when(null);
246
230
  }
247
- }
248
-
249
- this.canDeregisterFromLoadBalancer = function () {
250
- const healthMetrics = $scope.instance.health || [];
251
- return healthMetrics.some(function (health) {
252
- return health.type === 'LoadBalancer';
253
- });
254
- };
255
231
 
256
- this.canRegisterWithLoadBalancer = function () {
257
- const instance = $scope.instance;
258
- const healthMetrics = instance.health || [];
259
- if (!instance.loadBalancers || !instance.loadBalancers.length) {
260
- return false;
232
+ function autoClose() {
233
+ if ($scope.$$destroyed) {
234
+ return;
235
+ }
236
+ if (app.isStandalone) {
237
+ $scope.state.loading = false;
238
+ $scope.instanceIdNotFound = instance.instanceId;
239
+ $scope.state.notFoundStandalone = true;
240
+ RecentHistoryService.removeLastItem('instances');
241
+ } else {
242
+ $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' });
243
+ }
261
244
  }
262
- const outOfService = healthMetrics.some(function (health) {
263
- return health.type === 'LoadBalancer' && health.state === 'OutOfService';
264
- });
265
- const hasLoadBalancerHealth = healthMetrics.some(function (health) {
266
- return health.type === 'LoadBalancer';
267
- });
268
- return outOfService || !hasLoadBalancerHealth;
269
- };
270
-
271
- this.canDeregisterFromTargetGroup = function () {
272
- const healthMetrics = $scope.instance.health || [];
273
- return healthMetrics.some(function (health) {
274
- return health.type === 'TargetGroup' && health.state !== 'OutOfService';
275
- });
276
- };
277
245
 
278
- this.canRegisterWithTargetGroup = function () {
279
- const instance = $scope.instance;
280
- const healthMetrics = instance.health || [];
281
- if (!instance.targetGroups || !instance.targetGroups.length) {
282
- return false;
283
- }
284
- const outOfService = healthMetrics.some(function (health) {
285
- return health.type === 'TargetGroup' && health.state === 'OutOfService';
286
- });
287
- const hasTargetGroupHealth = healthMetrics.some(function (health) {
288
- return health.type === 'TargetGroup';
289
- });
290
- return outOfService || !hasTargetGroupHealth;
291
- };
292
-
293
- this.canRegisterWithDiscovery = function () {
294
- const instance = $scope.instance;
295
- const healthMetrics = instance.health || [];
296
- const discoveryHealth = healthMetrics.filter(function (health) {
297
- return health.type === 'Discovery';
298
- });
299
- return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false;
300
- };
301
-
302
- this.terminateInstance = function terminateInstance() {
303
- const instance = $scope.instance;
304
-
305
- const taskMonitor = {
306
- application: app,
307
- title: 'Terminating ' + instance.instanceId,
308
- onTaskComplete: function () {
309
- if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
310
- $state.go('^');
311
- }
312
- },
246
+ this.canDeregisterFromLoadBalancer = function () {
247
+ const healthMetrics = $scope.instance.health || [];
248
+ return healthMetrics.some(function (health) {
249
+ return health.type === 'LoadBalancer';
250
+ });
313
251
  };
314
252
 
315
- const submitMethod = function () {
316
- return AmazonInstanceWriter.terminateInstance(instance, app);
253
+ this.canRegisterWithLoadBalancer = function () {
254
+ const instance = $scope.instance;
255
+ const healthMetrics = instance.health || [];
256
+ if (!instance.loadBalancers || !instance.loadBalancers.length) {
257
+ return false;
258
+ }
259
+ const outOfService = healthMetrics.some(function (health) {
260
+ return health.type === 'LoadBalancer' && health.state === 'OutOfService';
261
+ });
262
+ const hasLoadBalancerHealth = healthMetrics.some(function (health) {
263
+ return health.type === 'LoadBalancer';
264
+ });
265
+ return outOfService || !hasLoadBalancerHealth;
317
266
  };
318
267
 
319
- ConfirmationModalService.confirm({
320
- header: 'Really terminate ' + instance.instanceId + '?',
321
- buttonText: 'Terminate ' + instance.instanceId,
322
- account: instance.account,
323
- taskMonitorConfig: taskMonitor,
324
- submitMethod: submitMethod,
325
- });
326
- };
327
-
328
- this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() {
329
- const instance = $scope.instance;
330
-
331
- const taskMonitor = {
332
- application: app,
333
- title: 'Terminating ' + instance.instanceId + ' and shrinking server group',
334
- onTaskComplete: function () {
335
- if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
336
- $state.go('^');
337
- }
338
- },
268
+ this.canDeregisterFromTargetGroup = function () {
269
+ const healthMetrics = $scope.instance.health || [];
270
+ return healthMetrics.some(function (health) {
271
+ return health.type === 'TargetGroup' && health.state !== 'OutOfService';
272
+ });
339
273
  };
340
274
 
341
- const submitMethod = function () {
342
- return AmazonInstanceWriter.terminateInstanceAndShrinkServerGroup(instance, app);
275
+ this.canRegisterWithTargetGroup = function () {
276
+ const instance = $scope.instance;
277
+ const healthMetrics = instance.health || [];
278
+ if (!instance.targetGroups || !instance.targetGroups.length) {
279
+ return false;
280
+ }
281
+ const outOfService = healthMetrics.some(function (health) {
282
+ return health.type === 'TargetGroup' && health.state === 'OutOfService';
283
+ });
284
+ const hasTargetGroupHealth = healthMetrics.some(function (health) {
285
+ return health.type === 'TargetGroup';
286
+ });
287
+ return outOfService || !hasTargetGroupHealth;
343
288
  };
344
289
 
345
- ConfirmationModalService.confirm({
346
- header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?',
347
- buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup,
348
- account: instance.account,
349
- taskMonitorConfig: taskMonitor,
350
- submitMethod: submitMethod,
351
- });
352
- };
353
-
354
- this.rebootInstance = function rebootInstance() {
355
- const instance = $scope.instance;
356
-
357
- const taskMonitor = {
358
- application: app,
359
- title: 'Rebooting ' + instance.instanceId,
290
+ this.canRegisterWithDiscovery = function () {
291
+ const instance = $scope.instance;
292
+ const healthMetrics = instance.health || [];
293
+ const discoveryHealth = healthMetrics.filter(function (health) {
294
+ return health.type === 'Discovery';
295
+ });
296
+ return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false;
360
297
  };
361
298
 
362
- const submitMethod = (params = {}) => {
363
- if (app.attributes && app.attributes.platformHealthOnlyShowOverride && app.attributes.platformHealthOnly) {
364
- params.interestingHealthProviderNames = ['Amazon'];
365
- }
299
+ this.terminateInstance = function terminateInstance() {
300
+ const instance = $scope.instance;
366
301
 
367
- return AmazonInstanceWriter.rebootInstance(instance, app, params);
302
+ const taskMonitor = {
303
+ application: app,
304
+ title: 'Terminating ' + instance.instanceId,
305
+ onTaskComplete: function () {
306
+ if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
307
+ $state.go('^');
308
+ }
309
+ },
310
+ };
311
+
312
+ const submitMethod = function () {
313
+ return AmazonInstanceWriter.terminateInstance(instance, app);
314
+ };
315
+
316
+ ConfirmationModalService.confirm({
317
+ header: 'Really terminate ' + instance.instanceId + '?',
318
+ buttonText: 'Terminate ' + instance.instanceId,
319
+ account: instance.account,
320
+ taskMonitorConfig: taskMonitor,
321
+ submitMethod: submitMethod,
322
+ });
368
323
  };
369
324
 
370
- ConfirmationModalService.confirm({
371
- header: 'Really reboot ' + instance.instanceId + '?',
372
- buttonText: 'Reboot ' + instance.instanceId,
373
- account: instance.account,
374
- platformHealthOnlyShowOverride: app.attributes.platformHealthOnlyShowOverride,
375
- platformHealthType: 'Amazon',
376
- taskMonitorConfig: taskMonitor,
377
- submitMethod: submitMethod,
378
- });
379
- };
325
+ this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() {
326
+ const instance = $scope.instance;
380
327
 
381
- this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() {
382
- const instance = $scope.instance;
383
- const loadBalancerNames = instance.loadBalancers.join(' and ');
384
-
385
- const taskMonitor = {
386
- application: app,
387
- title: 'Registering ' + instance.instanceId + ' with ' + loadBalancerNames,
328
+ const taskMonitor = {
329
+ application: app,
330
+ title: 'Terminating ' + instance.instanceId + ' and shrinking server group',
331
+ onTaskComplete: function () {
332
+ if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) {
333
+ $state.go('^');
334
+ }
335
+ },
336
+ };
337
+
338
+ const submitMethod = function () {
339
+ return AmazonInstanceWriter.terminateInstanceAndShrinkServerGroup(instance, app);
340
+ };
341
+
342
+ ConfirmationModalService.confirm({
343
+ header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?',
344
+ buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup,
345
+ account: instance.account,
346
+ taskMonitorConfig: taskMonitor,
347
+ submitMethod: submitMethod,
348
+ });
388
349
  };
389
350
 
390
- const submitMethod = function () {
391
- return AmazonInstanceWriter.registerInstanceWithLoadBalancer(instance, app);
392
- };
351
+ this.rebootInstance = function rebootInstance() {
352
+ const instance = $scope.instance;
393
353
 
394
- ConfirmationModalService.confirm({
395
- header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?',
396
- buttonText: 'Register ' + instance.instanceId,
397
- account: instance.account,
398
- taskMonitorConfig: taskMonitor,
399
- submitMethod: submitMethod,
400
- });
401
- };
354
+ const taskMonitor = {
355
+ application: app,
356
+ title: 'Rebooting ' + instance.instanceId,
357
+ };
402
358
 
403
- this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() {
404
- const instance = $scope.instance;
405
- const loadBalancerNames = instance.loadBalancers.join(' and ');
359
+ const submitMethod = (params = {}) => {
360
+ if (app.attributes && app.attributes.platformHealthOnlyShowOverride && app.attributes.platformHealthOnly) {
361
+ params.interestingHealthProviderNames = ['Amazon'];
362
+ }
406
363
 
407
- const taskMonitor = {
408
- application: app,
409
- title: 'Deregistering ' + instance.instanceId + ' from ' + loadBalancerNames,
364
+ return AmazonInstanceWriter.rebootInstance(instance, app, params);
365
+ };
366
+
367
+ ConfirmationModalService.confirm({
368
+ header: 'Really reboot ' + instance.instanceId + '?',
369
+ buttonText: 'Reboot ' + instance.instanceId,
370
+ account: instance.account,
371
+ platformHealthOnlyShowOverride: app.attributes.platformHealthOnlyShowOverride,
372
+ platformHealthType: 'Amazon',
373
+ taskMonitorConfig: taskMonitor,
374
+ submitMethod: submitMethod,
375
+ });
410
376
  };
411
377
 
412
- const submitMethod = function () {
413
- return AmazonInstanceWriter.deregisterInstanceFromLoadBalancer(instance, app);
378
+ this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() {
379
+ const instance = $scope.instance;
380
+ const loadBalancerNames = instance.loadBalancers.join(' and ');
381
+
382
+ const taskMonitor = {
383
+ application: app,
384
+ title: 'Registering ' + instance.instanceId + ' with ' + loadBalancerNames,
385
+ };
386
+
387
+ const submitMethod = function () {
388
+ return AmazonInstanceWriter.registerInstanceWithLoadBalancer(instance, app);
389
+ };
390
+
391
+ ConfirmationModalService.confirm({
392
+ header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?',
393
+ buttonText: 'Register ' + instance.instanceId,
394
+ account: instance.account,
395
+ taskMonitorConfig: taskMonitor,
396
+ submitMethod: submitMethod,
397
+ });
414
398
  };
415
399
 
416
- ConfirmationModalService.confirm({
417
- header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?',
418
- buttonText: 'Deregister ' + instance.instanceId,
419
- account: instance.account,
420
- taskMonitorConfig: taskMonitor,
421
- submitMethod: submitMethod,
422
- });
423
- };
424
-
425
- this.registerInstanceWithTargetGroup = function registerInstanceWithTargetGroup() {
426
- const instance = $scope.instance;
427
- const targetGroupNames = instance.targetGroups.join(' and ');
428
-
429
- const taskMonitor = {
430
- application: app,
431
- title: 'Registering ' + instance.instanceId + ' with ' + targetGroupNames,
400
+ this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() {
401
+ const instance = $scope.instance;
402
+ const loadBalancerNames = instance.loadBalancers.join(' and ');
403
+
404
+ const taskMonitor = {
405
+ application: app,
406
+ title: 'Deregistering ' + instance.instanceId + ' from ' + loadBalancerNames,
407
+ };
408
+
409
+ const submitMethod = function () {
410
+ return AmazonInstanceWriter.deregisterInstanceFromLoadBalancer(instance, app);
411
+ };
412
+
413
+ ConfirmationModalService.confirm({
414
+ header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?',
415
+ buttonText: 'Deregister ' + instance.instanceId,
416
+ account: instance.account,
417
+ taskMonitorConfig: taskMonitor,
418
+ submitMethod: submitMethod,
419
+ });
432
420
  };
433
421
 
434
- const submitMethod = function () {
435
- return AmazonInstanceWriter.registerInstanceWithTargetGroup(instance, app);
422
+ this.registerInstanceWithTargetGroup = function registerInstanceWithTargetGroup() {
423
+ const instance = $scope.instance;
424
+ const targetGroupNames = instance.targetGroups.join(' and ');
425
+
426
+ const taskMonitor = {
427
+ application: app,
428
+ title: 'Registering ' + instance.instanceId + ' with ' + targetGroupNames,
429
+ };
430
+
431
+ const submitMethod = function () {
432
+ return AmazonInstanceWriter.registerInstanceWithTargetGroup(instance, app);
433
+ };
434
+
435
+ ConfirmationModalService.confirm({
436
+ header: 'Really register ' + instance.instanceId + ' with ' + targetGroupNames + '?',
437
+ buttonText: 'Register ' + instance.instanceId,
438
+ account: instance.account,
439
+ taskMonitorConfig: taskMonitor,
440
+ submitMethod: submitMethod,
441
+ });
436
442
  };
437
443
 
438
- ConfirmationModalService.confirm({
439
- header: 'Really register ' + instance.instanceId + ' with ' + targetGroupNames + '?',
440
- buttonText: 'Register ' + instance.instanceId,
441
- account: instance.account,
442
- taskMonitorConfig: taskMonitor,
443
- submitMethod: submitMethod,
444
- });
445
- };
446
-
447
- this.deregisterInstanceFromTargetGroup = function deregisterInstanceFromTargetGroup() {
448
- const instance = $scope.instance;
449
- const targetGroupNames = instance.targetGroups.join(' and ');
450
-
451
- const taskMonitor = {
452
- application: app,
453
- title: 'Deregistering ' + instance.instanceId + ' from ' + targetGroupNames,
444
+ this.deregisterInstanceFromTargetGroup = function deregisterInstanceFromTargetGroup() {
445
+ const instance = $scope.instance;
446
+ const targetGroupNames = instance.targetGroups.join(' and ');
447
+
448
+ const taskMonitor = {
449
+ application: app,
450
+ title: 'Deregistering ' + instance.instanceId + ' from ' + targetGroupNames,
451
+ };
452
+
453
+ const submitMethod = function () {
454
+ return AmazonInstanceWriter.deregisterInstanceFromTargetGroup(instance, app);
455
+ };
456
+
457
+ ConfirmationModalService.confirm({
458
+ header: 'Really deregister ' + instance.instanceId + ' from ' + targetGroupNames + '?',
459
+ buttonText: 'Deregister ' + instance.instanceId,
460
+ account: instance.account,
461
+ taskMonitorConfig: taskMonitor,
462
+ submitMethod: submitMethod,
463
+ });
454
464
  };
455
465
 
456
- const submitMethod = function () {
457
- return AmazonInstanceWriter.deregisterInstanceFromTargetGroup(instance, app);
458
- };
466
+ this.enableInstanceInDiscovery = function enableInstanceInDiscovery() {
467
+ const instance = $scope.instance;
459
468
 
460
- ConfirmationModalService.confirm({
461
- header: 'Really deregister ' + instance.instanceId + ' from ' + targetGroupNames + '?',
462
- buttonText: 'Deregister ' + instance.instanceId,
463
- account: instance.account,
464
- taskMonitorConfig: taskMonitor,
465
- submitMethod: submitMethod,
466
- });
467
- };
469
+ const taskMonitor = {
470
+ application: app,
471
+ title: 'Enabling ' + instance.instanceId + ' in discovery',
472
+ };
468
473
 
469
- this.enableInstanceInDiscovery = function enableInstanceInDiscovery() {
470
- const instance = $scope.instance;
474
+ const submitMethod = function () {
475
+ return AmazonInstanceWriter.enableInstanceInDiscovery(instance, app);
476
+ };
471
477
 
472
- const taskMonitor = {
473
- application: app,
474
- title: 'Enabling ' + instance.instanceId + ' in discovery',
478
+ ConfirmationModalService.confirm({
479
+ header: 'Really enable ' + instance.instanceId + ' in discovery?',
480
+ buttonText: 'Enable ' + instance.instanceId,
481
+ account: instance.account,
482
+ taskMonitorConfig: taskMonitor,
483
+ submitMethod: submitMethod,
484
+ });
475
485
  };
476
486
 
477
- const submitMethod = function () {
478
- return AmazonInstanceWriter.enableInstanceInDiscovery(instance, app);
479
- };
487
+ this.disableInstanceInDiscovery = function disableInstanceInDiscovery() {
488
+ const instance = $scope.instance;
480
489
 
481
- ConfirmationModalService.confirm({
482
- header: 'Really enable ' + instance.instanceId + ' in discovery?',
483
- buttonText: 'Enable ' + instance.instanceId,
484
- account: instance.account,
485
- taskMonitorConfig: taskMonitor,
486
- submitMethod: submitMethod,
487
- });
488
- };
490
+ const taskMonitor = {
491
+ application: app,
492
+ title: 'Disabling ' + instance.instanceId + ' in discovery',
493
+ };
489
494
 
490
- this.disableInstanceInDiscovery = function disableInstanceInDiscovery() {
491
- const instance = $scope.instance;
495
+ const submitMethod = function () {
496
+ return AmazonInstanceWriter.disableInstanceInDiscovery(instance, app);
497
+ };
492
498
 
493
- const taskMonitor = {
494
- application: app,
495
- title: 'Disabling ' + instance.instanceId + ' in discovery',
499
+ ConfirmationModalService.confirm({
500
+ header: 'Really disable ' + instance.instanceId + ' in discovery?',
501
+ buttonText: 'Disable ' + instance.instanceId,
502
+ account: instance.account,
503
+ taskMonitorConfig: taskMonitor,
504
+ submitMethod: submitMethod,
505
+ });
496
506
  };
497
507
 
498
- const submitMethod = function () {
499
- return AmazonInstanceWriter.disableInstanceInDiscovery(instance, app);
508
+ this.hasHealthState = function hasHealthState(healthProviderType, state) {
509
+ const instance = $scope.instance;
510
+ const healthMetrics = instance.health || [];
511
+ return healthMetrics.some(function (health) {
512
+ return health.type === healthProviderType && health.state === state;
513
+ });
500
514
  };
501
515
 
502
- ConfirmationModalService.confirm({
503
- header: 'Really disable ' + instance.instanceId + ' in discovery?',
504
- buttonText: 'Disable ' + instance.instanceId,
505
- account: instance.account,
506
- taskMonitorConfig: taskMonitor,
507
- submitMethod: submitMethod,
508
- });
509
- };
516
+ const constructInstanceActions = (instance) => {
517
+ const constantActions = [
518
+ { label: 'Reboot', triggerAction: this.rebootInstance },
519
+ { label: 'Terminate', triggerAction: this.terminateInstance },
520
+ { label: 'Terminate and Shrink Server Group', triggerAction: this.terminateInstanceAndShrinkServerGroup },
521
+ ];
522
+ const conditionalActions = [];
523
+
524
+ if (this.canRegisterWithDiscovery() && !instance.serverGroupDisabled) {
525
+ conditionalActions.push({
526
+ label: 'Enable In Discovery',
527
+ triggerAction: this.enableInstanceInDiscovery,
528
+ });
529
+ }
510
530
 
511
- this.hasHealthState = function hasHealthState(healthProviderType, state) {
512
- const instance = $scope.instance;
513
- const healthMetrics = instance.health || [];
514
- return healthMetrics.some(function (health) {
515
- return health.type === healthProviderType && health.state === state;
516
- });
517
- };
518
-
519
- const constructInstanceActions = (instance) => {
520
- const constantActions = [
521
- { label: 'Reboot', triggerAction: this.rebootInstance },
522
- { label: 'Terminate', triggerAction: this.terminateInstance },
523
- { label: 'Terminate and Shrink Server Group', triggerAction: this.terminateInstanceAndShrinkServerGroup },
524
- ];
525
- const conditionalActions = [];
526
-
527
- if (this.canRegisterWithDiscovery() && !instance.serverGroupDisabled) {
528
- conditionalActions.push({
529
- label: 'Enable In Discovery',
530
- triggerAction: this.enableInstanceInDiscovery,
531
- });
532
- }
531
+ if (this.hasHealthState('Discovery', 'Up') || this.hasHealthState('Discovery', 'Down')) {
532
+ conditionalActions.push({
533
+ label: 'Disable in Discovery',
534
+ triggerAction: this.disableInstanceInDiscovery,
535
+ });
536
+ }
533
537
 
534
- if (this.hasHealthState('Discovery', 'Up') || this.hasHealthState('Discovery', 'Down')) {
535
- conditionalActions.push({
536
- label: 'Disable in Discovery',
537
- triggerAction: this.disableInstanceInDiscovery,
538
- });
539
- }
538
+ if (this.canRegisterWithLoadBalancer()) {
539
+ conditionalActions.push({
540
+ label: 'Register with Load Balancer',
541
+ triggerAction: this.registerInstanceWithLoadBalancer,
542
+ });
543
+ }
540
544
 
541
- if (this.canRegisterWithLoadBalancer()) {
542
- conditionalActions.push({
543
- label: 'Register with Load Balancer',
544
- triggerAction: this.registerInstanceWithLoadBalancer,
545
- });
546
- }
545
+ if (this.canDeregisterFromLoadBalancer()) {
546
+ conditionalActions.push({
547
+ label: 'Deregister from Load Balancer',
548
+ triggerAction: this.deregisterInstanceFromLoadBalancer,
549
+ });
550
+ }
547
551
 
548
- if (this.canDeregisterFromLoadBalancer()) {
549
- conditionalActions.push({
550
- label: 'Deregister from Load Balancer',
551
- triggerAction: this.deregisterInstanceFromLoadBalancer,
552
- });
553
- }
552
+ if (this.canRegisterWithTargetGroup()) {
553
+ conditionalActions.push({
554
+ label: 'Register with Target Group',
555
+ triggerAction: this.registerInstanceWithTargetGroup,
556
+ });
557
+ }
554
558
 
555
- if (this.canRegisterWithTargetGroup()) {
556
- conditionalActions.push({
557
- label: 'Register with Target Group',
558
- triggerAction: this.registerInstanceWithTargetGroup,
559
- });
560
- }
559
+ if (this.canDeregisterFromTargetGroup()) {
560
+ conditionalActions.push({
561
+ label: 'Deregister from Target Group',
562
+ triggerAction: this.deregisterInstanceFromTargetGroup,
563
+ });
564
+ }
565
+ return conditionalActions.concat(constantActions);
566
+ };
561
567
 
562
- if (this.canDeregisterFromTargetGroup()) {
563
- conditionalActions.push({
564
- label: 'Deregister from Target Group',
565
- triggerAction: this.deregisterInstanceFromTargetGroup,
566
- });
567
- }
568
- return conditionalActions.concat(constantActions);
569
- };
570
-
571
- const initialize = app.isStandalone
572
- ? retrieveInstance()
573
- : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance);
574
-
575
- initialize.then(() => {
576
- $scope.instanceActions = constructInstanceActions($scope.instance);
577
- // Two things to look out for here:
578
- // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there
579
- // is no point in subscribing to the refresh
580
- // 2. If this is a standalone instance, there is no application that will refresh
581
- if (!$scope.$$destroyed && !app.isStandalone) {
582
- app.serverGroups.onRefresh($scope, retrieveInstance);
583
- }
584
- });
568
+ const initialize = app.isStandalone
569
+ ? retrieveInstance()
570
+ : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance);
571
+
572
+ initialize.then(() => {
573
+ $scope.instanceActions = constructInstanceActions($scope.instance);
574
+ // Two things to look out for here:
575
+ // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there
576
+ // is no point in subscribing to the refresh
577
+ // 2. If this is a standalone instance, there is no application that will refresh
578
+ if (!$scope.$$destroyed && !app.isStandalone) {
579
+ app.serverGroups.onRefresh($scope, retrieveInstance);
580
+ }
581
+ });
585
582
 
586
- $scope.account = instance.account;
587
- },
588
- ]);
583
+ $scope.account = instance.account;
584
+ },
585
+ ],
586
+ );