');
var $browser = $('#browser .container');
var context = args.context;
// Resource items
var computeResources = {
zone: {
label: 'Zone'
},
pods: {
label: 'Pods',
viewAll: {
action: actions.listView('pods', context)
}
},
clusters: {
label: 'Clusters',
viewAll: {
action: actions.listView('clusters', context)
}
},
hosts: {
label: 'Hosts',
viewAll: {
action: actions.listView('hosts', context)
}
},
primaryStorage: {
label: 'Primary Storage',
viewAll: {
action: actions.listView('primary-storage', context)
}
},
secondaryStorage: {
label: 'Secondary Storage',
viewAll: {
action: actions.listView('secondary-storage', context)
}
}
};
var $computeResources = $('
').addClass('resources');
// Make resource items
$.each(computeResources, function(id, resource) {
var $li = $('- ');
var $label = $('').addClass('label');
$li.addClass(id);
$label.html(resource.label);
$label.appendTo($li);
// View all
if (resource.viewAll) {
viewAllButton($.extend(resource.viewAll, {
title: resource.label,
$browser: $browser,
context: context
})).appendTo($li);
}
$li.appendTo($computeResources);
});
$chart.append($computeResources);
return $chart;
},
network: function(args) {
var $chart = $('
');
var $browser = $('#browser .container');
var $loading = $('
').addClass('loading-overlay');
var context = args.context;
var networkDataProvider = cloudStack.sections.system.naas.networks.dataProvider;
var trafficTypeDataProvider = cloudStack.sections.system.naas.trafficTypes.dataProvider;
$loading.appendTo($chart);
var renderChart = function(args) {
var $targetChart = args.$chart ? args.$chart : $chart;
var targetContext = $.extend(true, {}, context, {
physicalNetworks: [args.data]
});
// Get traffic type data
trafficTypeDataProvider({
context: targetContext,
response: {
success: function(args) {
var $networkChart = $('
').addClass('system-network-chart');
var $trafficTypes = $('
').addClass('resources traffic-types');
$loading.remove();
var trafficTypes = {
'public': {
label: 'Public',
configure: {
action: actions.trafficTypeDetails('public', targetContext)
}
},
'guest': {
label: 'Guest',
configure: {
action: actions.trafficTypeDetails('guest', targetContext)
}
},
'management': {
label: 'Management',
configure: {
action: actions.trafficTypeDetails('management', targetContext)
}
},
'storage': {
label: 'Storage',
configure: {
action: actions.trafficTypeDetails('storage', targetContext)
}
},
'providers': {
label: 'Network Service Providers',
ignoreChart: true,
configure: {
action: actions.providerListView(targetContext)
}
}
};
var validTrafficTypes = $.map(args.data, function(trafficType) {
return trafficType.name.toLowerCase();
});
// Make traffic type elems
$.each(trafficTypes, function(id, trafficType) {
if ($.inArray(id, validTrafficTypes) == -1 && !trafficType.ignoreChart) return true;
// Make list item
var $li = $('- ').addClass(id);
var $label = $('').addClass('label').html(trafficType.label);
var $configureButton = viewAllButton($.extend(trafficType.configure, {
label: 'Configure',
title: trafficType.label,
$browser: $browser,
targetContext: targetContext
}));
$li.append($label, $configureButton);
$li.appendTo($trafficTypes);
// Make chart
if (trafficType.ignoreChart) return true;
var $targetChartItem = $('
').addClass('network-chart-item').addClass(id);
$targetChartItem.appendTo($networkChart);
});
var $switchIcon = $('
').addClass('network-switch-icon').append(
$('
').html('L2/L3 switch')
);
var $circleIcon = $('').addClass('base-circle-icon');
$targetChart.append($trafficTypes, $switchIcon, $networkChart, $circleIcon);
}
}
});
};
// Get network data
networkDataProvider({
context: context,
response: {
success: function(args) {
var data = args.data;
if (data.length > 1) {
// Render list view first
$chart.listView({
listView: $.extend(true, {}, cloudStack.sections.system.naas.networks.listView, {
dataProvider: function(args) {
args.response.success({ data: data });
},
detailView: {
tabs: {
network: {
title: 'Network',
custom: function(args) {
var $chart = $('
').addClass('system-chart network');
renderChart({
$chart: $chart,
data: args.context.physicalNetworks[0]
});
return $chart;
}
}
}
}
})
});
$loading.remove();
} else {
renderChart({
$chart: $chart,
data: data[0]
});
}
}
}
});
return $chart;
},
resources: function(args) {
var $chart = $('
').addClass('dashboard admin');
var $chartItems = $('