|
27 | 27 | $browser: $browser, |
28 | 28 | context: $.extend(true, {}, context, { |
29 | 29 | networks: [tier] |
30 | | - }) |
| 30 | + }), |
| 31 | + onActionComplete: function() { |
| 32 | + $tier.closest('.vpc-network-chart').trigger('reload'); |
| 33 | + } |
31 | 34 | }) |
32 | 35 | ); |
33 | 36 |
|
|
92 | 95 | // Success |
93 | 96 | function(args) { |
94 | 97 | $loading.remove(); |
| 98 | + $placeholder.closest('.vpc-network-chart').trigger('reload'); |
| 99 | + |
95 | 100 | // addNewTier({ |
96 | 101 | // ipAddresses: ipAddresses, |
97 | 102 | // $browser: $browser, |
|
181 | 186 | var vpcChart = function(args) { |
182 | 187 | var context = args.context; |
183 | 188 | var vpcItem = context.vpc[0]; |
184 | | - var $chart = $('<div>').addClass('vpc-network-chart'); |
185 | | - var $tiers = $('<div>').addClass('tiers'); |
186 | | - var $toolbar = $('<div>').addClass('toolbar'); |
187 | | - |
188 | | - $toolbar.appendTo($chart); |
189 | | - $tiers.appendTo($chart); |
190 | 189 |
|
191 | | - // Get tiers |
192 | | - vpc.tiers.dataProvider({ |
193 | | - context: context, |
194 | | - response: { |
195 | | - success: function(data) { |
196 | | - var tiers = data.tiers; |
197 | | - |
198 | | - $(tiers).map(function(index, tier) { |
199 | | - var $tier = elems.tier({ |
200 | | - context: context, |
201 | | - tier: tier, |
202 | | - dashboardItems: [ |
203 | | - { |
204 | | - id: 'tierLoadBalancers', |
205 | | - name: 'Load balancers', |
206 | | - total: 5 |
207 | | - }, |
208 | | - { |
209 | | - id: 'tierPortForwarders', |
210 | | - name: 'Port forwarders', |
211 | | - total: 4 |
212 | | - }, |
213 | | - { |
214 | | - id: 'tierStaticNATs', |
215 | | - name: 'Static NATs', |
216 | | - total: 3 |
217 | | - }, |
218 | | - { |
219 | | - id: 'tierVMs', |
220 | | - name: 'Virtual Machines', |
221 | | - total: 300 |
222 | | - } |
223 | | - ] |
| 190 | + var chart = function(args) { |
| 191 | + args = args ? args : {}; |
| 192 | + |
| 193 | + var $chart = $('<div>').addClass('vpc-network-chart'); |
| 194 | + var $tiers = $('<div>').addClass('tiers'); |
| 195 | + var $toolbar = $('<div>').addClass('toolbar'); |
| 196 | + var $refresh = $('<div>').addClass('button refresh'); |
| 197 | + |
| 198 | + $refresh.appendTo($toolbar); |
| 199 | + $toolbar.appendTo($chart); |
| 200 | + $tiers.appendTo($chart); |
| 201 | + |
| 202 | + $refresh.click(function() { |
| 203 | + $('.vpc-network-chart').trigger('reload'); |
| 204 | + }); |
| 205 | + |
| 206 | + // Get tiers |
| 207 | + var $loading = $('<div>').addClass('loading-overlay').prependTo($chart); |
| 208 | + vpc.tiers.dataProvider({ |
| 209 | + context: context, |
| 210 | + response: { |
| 211 | + success: function(data) { |
| 212 | + var tiers = data.tiers; |
| 213 | + |
| 214 | + $(tiers).map(function(index, tier) { |
| 215 | + var $tier = elems.tier({ |
| 216 | + context: context, |
| 217 | + tier: tier, |
| 218 | + dashboardItems: [ |
| 219 | + { |
| 220 | + id: 'tierLoadBalancers', |
| 221 | + name: 'Load balancers', |
| 222 | + total: 5 |
| 223 | + }, |
| 224 | + { |
| 225 | + id: 'tierPortForwarders', |
| 226 | + name: 'Port forwarders', |
| 227 | + total: 4 |
| 228 | + }, |
| 229 | + { |
| 230 | + id: 'tierStaticNATs', |
| 231 | + name: 'Static NATs', |
| 232 | + total: 3 |
| 233 | + }, |
| 234 | + { |
| 235 | + id: 'tierVMs', |
| 236 | + name: 'Virtual Machines', |
| 237 | + total: 300 |
| 238 | + } |
| 239 | + ] |
| 240 | + }); |
| 241 | + |
| 242 | + $tier.appendTo($tiers); |
224 | 243 | }); |
225 | 244 |
|
226 | | - $tier.appendTo($tiers); |
227 | | - }); |
| 245 | + // Add placeholder tier |
| 246 | + $tiers.append(elems.tierPlaceholder({ |
| 247 | + context: context |
| 248 | + })); |
228 | 249 |
|
229 | | - // Add placeholder tier |
230 | | - $tiers.append(elems.tierPlaceholder({ |
231 | | - context: context |
232 | | - })); |
| 250 | + $loading.remove(); |
| 251 | + |
| 252 | + if (args.complete) { |
| 253 | + args.complete($chart); |
| 254 | + } |
| 255 | + } |
233 | 256 | } |
234 | | - } |
235 | | - }); |
| 257 | + }); |
| 258 | + |
| 259 | + // Router |
| 260 | + $router = elems.router({ |
| 261 | + context: context, |
| 262 | + dashboardItems: [ |
| 263 | + { |
| 264 | + id: 'privateGateways', |
| 265 | + name: 'Private gateways', |
| 266 | + total: 1 |
| 267 | + }, |
| 268 | + { |
| 269 | + id: 'publicIPs', |
| 270 | + name: 'Public IP addresses', |
| 271 | + total: 2 |
| 272 | + }, |
| 273 | + { |
| 274 | + id: 'siteToSiteVPNs', |
| 275 | + name: 'Site-to-site VPNs', |
| 276 | + total: 3 |
| 277 | + }, |
| 278 | + { |
| 279 | + id: 'networkACLLists', |
| 280 | + name: 'Network ACL lists', |
| 281 | + total: 2 |
| 282 | + } |
| 283 | + ] |
| 284 | + }).appendTo($chart); |
| 285 | + |
| 286 | + $chart.bind('reload', function() { |
| 287 | + chart({ |
| 288 | + complete: function($newChart) { |
| 289 | + $chart.replaceWith($newChart); |
| 290 | + } |
| 291 | + }); |
| 292 | + }); |
| 293 | + |
| 294 | + return $chart; |
| 295 | + }; |
236 | 296 |
|
237 | | - // Router |
238 | | - $router = elems.router({ |
239 | | - context: context, |
240 | | - dashboardItems: [ |
241 | | - { |
242 | | - id: 'privateGateways', |
243 | | - name: 'Private gateways', |
244 | | - total: 1 |
245 | | - }, |
246 | | - { |
247 | | - id: 'publicIPs', |
248 | | - name: 'Public IP addresses', |
249 | | - total: 2 |
250 | | - }, |
251 | | - { |
252 | | - id: 'siteToSiteVPNs', |
253 | | - name: 'Site-to-site VPNs', |
254 | | - total: 3 |
255 | | - }, |
256 | | - { |
257 | | - id: 'networkACLLists', |
258 | | - name: 'Network ACL lists', |
259 | | - total: 2 |
260 | | - } |
261 | | - ] |
262 | | - }).appendTo($chart); |
263 | | - |
264 | 297 | $('#browser .container').cloudBrowser('addPanel', { |
265 | 298 | title: vpcItem.displaytext ? vpcItem.displaytext : vpcItem.name, |
266 | 299 | maximizeIfSelected: true, |
267 | 300 | complete: function($panel) { |
| 301 | + var $chart = chart(); |
| 302 | + |
268 | 303 | $chart.appendTo($panel); |
269 | 304 | } |
270 | 305 | }); |
|
0 commit comments