');
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: _l('label.public'),
configure: {
action: actions.trafficTypeDetails('public', targetContext)
}
},
'guest': {
label: _l('label.guest'),
configure: {
action: actions.trafficTypeDetails('guest', targetContext)
}
},
'management': {
label: _l('label.management'),
configure: {
action: actions.trafficTypeDetails('management', targetContext)
}
},
'storage': {
label: _l('label.storage'),
configure: {
action: actions.trafficTypeDetails('storage', targetContext)
}
},
'providers': {
label: _l('label.network.service.providers'),
ignoreChart: true,
dependsOn: 'guest',
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) { //if it is not a valid traffic type
if(trafficType.dependsOn != null && trafficType.dependsOn.length > 0) { //if it has dependsOn
if($.inArray(trafficType.dependsOn, validTrafficTypes) == -1) { //if its dependsOn is not a valid traffic type, either
return true; //skip this item
}
//else, if its dependsOn is a valid traffic type, continue to Make list item (e.g. providers.dependsOn is 'guest')
}
else {
return true; //if it doesn't have dependsOn, skip this item
}
}
// Make list item
var $li = $('- ').addClass(id);
var $label = $('').addClass('label').html(trafficType.label);
var $configureButton = viewAllButton($.extend(trafficType.configure, {
label: _l('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;
var actionFilter = args.actionFilter;
$chart.listView({
listView: $.extend(true, {}, cloudStack.sections.system.naas.networks.listView, {
dataProvider: function(args) {
args.response.success({ actionFilter: actionFilter, data: data });
},
detailView: {
noCompact: true,
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();
}
}
});
return $chart;
},
resources: function(args) {
var $chart = $('
').addClass('dashboard admin');
var $chartItems = $('