').addClass('button refresh');
+
+ $refresh.appendTo($toolbar);
+ $toolbar.appendTo($chart);
+ $tiers.appendTo($chart);
+
+ $refresh.click(function() {
+ $('.vpc-network-chart').trigger('reload');
+ });
+
+ // Get tiers
+ var $loading = $('
').addClass('loading-overlay').prependTo($chart);
+ vpc.tiers.dataProvider({
+ context: context,
+ response: {
+ success: function(data) {
+ var tiers = data.tiers;
+
+ $(tiers).map(function(index, tier) {
+ var $tier = elems.tier({
+ context: context,
+ tier: tier,
+ dashboardItems: [
+ {
+ id: 'tierLoadBalancers',
+ name: 'Load balancers',
+ total: 5
+ },
+ {
+ id: 'tierPortForwarders',
+ name: 'Port forwarders',
+ total: 4
+ },
+ {
+ id: 'tierStaticNATs',
+ name: 'Static NATs',
+ total: 3
+ },
+ {
+ id: 'tierVMs',
+ name: 'Virtual Machines',
+ total: 300
+ }
+ ]
+ });
+
+ $tier.appendTo($tiers);
});
- $tier.appendTo($tiers);
- });
+ // Add placeholder tier
+ $tiers.append(elems.tierPlaceholder({
+ context: context
+ }));
- // Add placeholder tier
- $tiers.append(elems.tierPlaceholder({
- context: context
- }));
+ $loading.remove();
+
+ if (args.complete) {
+ args.complete($chart);
+ }
+ }
}
- }
- });
+ });
+
+ // Router
+ $router = elems.router({
+ context: context,
+ dashboardItems: [
+ {
+ id: 'privateGateways',
+ name: 'Private gateways',
+ total: 1
+ },
+ {
+ id: 'publicIPs',
+ name: 'Public IP addresses',
+ total: 2
+ },
+ {
+ id: 'siteToSiteVPNs',
+ name: 'Site-to-site VPNs',
+ total: 3
+ },
+ {
+ id: 'networkACLLists',
+ name: 'Network ACL lists',
+ total: 2
+ }
+ ]
+ }).appendTo($chart);
+
+ $chart.bind('reload', function() {
+ chart({
+ complete: function($newChart) {
+ $chart.replaceWith($newChart);
+ }
+ });
+ });
+
+ return $chart;
+ };
- // Router
- $router = elems.router({
- context: context,
- dashboardItems: [
- {
- id: 'privateGateways',
- name: 'Private gateways',
- total: 1
- },
- {
- id: 'publicIPs',
- name: 'Public IP addresses',
- total: 2
- },
- {
- id: 'siteToSiteVPNs',
- name: 'Site-to-site VPNs',
- total: 3
- },
- {
- id: 'networkACLLists',
- name: 'Network ACL lists',
- total: 2
- }
- ]
- }).appendTo($chart);
-
$('#browser .container').cloudBrowser('addPanel', {
title: vpcItem.displaytext ? vpcItem.displaytext : vpcItem.name,
maximizeIfSelected: true,
complete: function($panel) {
+ var $chart = chart();
+
$chart.appendTo($panel);
}
});