bug 12277

-Update example files for system chart, to make provider details a
 detailView widget

-Cleanup/refactor zone chart widget to support new changes
This commit is contained in:
Brian Federle 2011-12-12 13:03:41 -08:00
parent 6746e84958
commit b65a411386
2 changed files with 360 additions and 200 deletions

View File

@ -382,15 +382,79 @@
// NetScaler list view // NetScaler list view
netscaler: { netscaler: {
type: 'detailView',
id: 'netscaler-providers', id: 'netscaler-providers',
label: 'NetScaler', label: 'NetScaler',
fields: { viewAll: { label: 'NetScaler Providers', path: '_zone.netscalerProviders' },
name: { label: 'Name' }, actions: {
ipaddress: { label: 'IP Address' }, add: {
state: { label: 'Status', indicator: { 'Enabled': 'on' } } label: 'Add new NetScaler',
}, createForm: {
providerActionFilter: testProviderActionFilter, title: 'Add NetScaler Device',
providerActions: { desc: 'Please enter your NetScaler device\'s information to add it to your network.',
fields: {
name: {
label: 'Name',
validation: { required: true },
defaultValue: 'New_NetScaler'
},
ipaddress: {
label: 'IP Address',
validation: { required: true }
},
supportedServices: {
label: 'Supported Services',
isBoolean: true,
multiArray: {
serviceA: { label: 'Service A' },
serviceB: { label: 'Service B' },
serviceC: { label: 'Service C' }
}
},
username: {
label: 'Username',
validation: { required: true }
},
password: {
label: 'Password',
isPassword: true,
validation: { required: true }
},
type: {
label: 'NetScaler Model',
select: function(args) {
args.response.success({
data: [
{
id: 'mpx',
description: 'NetScaler MPX'
},
{
id: 'adc',
description: 'NetScaler ADC'
}
]
});
}
},
enabled: {
label: 'Enable',
isBoolean: true
}
}
},
action: function(args) {
args.response.success();
},
messages: {
notification: function(args) {
return 'Added new NetScaler';
}
},
notification: {
poll: testData.notifications.testPoll
}
},
disable: { disable: {
label: 'Disable', label: 'Disable',
action: function(args) { action: function(args) {
@ -432,102 +496,38 @@
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
} }
}, },
actions: { tabs: {
add: { details: {
label: 'Add new NetScaler', title: 'Details',
createForm: { fields: [
title: 'Add NetScaler Device', {
desc: 'Please enter your NetScaler device\'s information to add it to your network.', name: { label: 'Name' }
fields: { },
name: { {
label: 'Name', state: { label: 'Status' }
validation: { required: true },
defaultValue: 'New_NetScaler'
},
ipaddress: {
label: 'IP Address',
validation: { required: true }
},
supportedServices: {
label: 'Supported Services',
isBoolean: true,
multiArray: {
serviceA: { label: 'Service A' },
serviceB: { label: 'Service B' },
serviceC: { label: 'Service C' }
}
},
username: {
label: 'Username',
validation: { required: true }
},
password: {
label: 'Password',
isPassword: true,
validation: { required: true }
},
type: {
label: 'NetScaler Model',
select: function(args) {
args.response.success({
data: [
{
id: 'mpx',
description: 'NetScaler MPX'
},
{
id: 'adc',
description: 'NetScaler ADC'
}
]
});
}
},
enabled: {
label: 'Enable',
isBoolean: true
}
} }
}, ],
action: function(args) { dataProvider: function(args) {
args.response.success(); setTimeout(function() {
}, args.response.success({
messages: { data: {
notification: function(args) { name: 'NetScaler Provider',
return 'Added new NetScaler'; state: 'Enabled'
} }
}, });
notification: { }, 500);
poll: testData.notifications.testPoll
} }
} }
},
dataProvider: function(args) {
setTimeout(function() {
args.response.success({
data: [
{
name: 'Router0001S',
ipaddress: '192.168.1.1',
state: 'Enabled'
}
]
});
}, 500);
} }
}, },
// F5 list view // F5 list view
f5: { f5: {
type: 'detailView',
id: 'f5-providers', id: 'f5-providers',
label: 'F5', label: 'F5',
fields: { viewAll: { label: 'F5 Providers', path: '_zone.f5Providers' },
name: { label: 'Name' }, actions: {
ipaddress: { label: 'IP Address' },
state: { label: 'Status', indicator: { 'Enabled': 'on' } }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: { disable: {
label: 'Disable', label: 'Disable',
action: function(args) { action: function(args) {
@ -569,42 +569,38 @@
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
} }
}, },
dataProvider: function(args) { tabs: {
setTimeout(function() { details: {
args.response.success({ title: 'Details',
data: [ fields: [
{ {
name: 'Router0001S', name: { label: 'Name' }
ipaddress: '192.168.1.1', },
state: 'Enabled' {
}, state: { label: 'Status' }
{ }
name: 'Router0001B', ],
ipaddress: '192.168.1.155', dataProvider: function(args) {
state: 'Enabled' setTimeout(function() {
}, args.response.success({
{ data: {
name: 'Router0002', name: 'F5 Provider',
ipaddress: '192.168.1.13', state: 'Enabled'
state: 'Enabled' }
} });
] }, 500);
}); }
}, 500); }
} }
}, },
// SRX list view // SRX list view
srx: { srx: {
type: 'detailView',
id: 'srx-providers', id: 'srx-providers',
label: 'SRX', label: 'SRX',
fields: { viewAll: { label: 'SRX Providers', path: '_zone.srxProviders' },
name: { label: 'Name' }, actions: {
ipaddress: { label: 'IP Address' },
state: { label: 'Status', indicator: { 'Enabled': 'on' } }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: { disable: {
label: 'Disable', label: 'Disable',
action: function(args) { action: function(args) {
@ -646,49 +642,45 @@
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
} }
}, },
dataProvider: function(args) { tabs: {
setTimeout(function() { details: {
args.response.success({ title: 'Details',
data: [ fields: [
{ {
name: 'Router0001S', name: { label: 'Name' }
ipaddress: '192.168.1.1', },
state: 'Enabled' {
}, state: { label: 'Status' }
{ }
name: 'Router0001B', ],
ipaddress: '192.168.1.155', dataProvider: function(args) {
state: 'Enabled' setTimeout(function() {
}, args.response.success({
{ data: {
name: 'Router0002', name: 'SRX Provider',
ipaddress: '192.168.1.13', state: 'Enabled'
state: 'Enabled' }
} });
] }, 500);
}); }
}); }
} }
}, },
// Security groups list view // Security groups list view
securityGroups: { securityGroups: {
id: 'securityGroup-providers', type: 'detailView',
id: 'securityGroups-providers',
label: 'Security Groups', label: 'Security Groups',
fields: { viewAll: { label: 'Security Groups', path: 'network.securityGroups' },
name: { label: 'Name' }, actions: {
ipaddress: { label: 'IP Address' },
state: { label: 'Status', indicator: { 'Enabled': 'on' } }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: { disable: {
label: 'Disable', label: 'Disable',
action: function(args) { action: function(args) {
setTimeout(args.response.success, 100); setTimeout(args.response.success, 100);
}, },
messages: { messages: {
notification: function() { return 'Disabled security group provider'; } notification: function() { return 'Disabled Security Groups provider'; }
}, },
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
}, },
@ -698,7 +690,7 @@
setTimeout(args.response.success, 100); setTimeout(args.response.success, 100);
}, },
messages: { messages: {
notification: function() { return 'Enable security group provider'; } notification: function() { return 'Enable Security Groups provider'; }
}, },
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
}, },
@ -708,7 +700,7 @@
setTimeout(args.response.success, 100); setTimeout(args.response.success, 100);
}, },
messages: { messages: {
notification: function() { return 'Shutdown security group provider'; } notification: function() { return 'Shutdown Security Groups provider'; }
}, },
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
}, },
@ -718,35 +710,35 @@
setTimeout(args.response.success, 100); setTimeout(args.response.success, 100);
}, },
messages: { messages: {
notification: function() { return 'Started security group provider'; } notification: function() { return 'Started Security Groups provider'; }
}, },
notification: { poll: testData.notifications.testPoll } notification: { poll: testData.notifications.testPoll }
} }
}, },
dataProvider: function(args) { tabs: {
setTimeout(function() { details: {
args.response.success({ title: 'Details',
data: [ fields: [
{ {
name: 'Router0001S', name: { label: 'Name' }
ipaddress: '192.168.1.1', },
state: 'Enabled' {
}, state: { label: 'Status' }
{ }
name: 'Router0001B', ],
ipaddress: '192.168.1.155', dataProvider: function(args) {
state: 'Enabled' setTimeout(function() {
}, args.response.success({
{ data: {
name: 'Router0002', name: 'SRX Provider',
ipaddress: '192.168.1.13', state: 'Enabled'
state: 'Enabled' }
} });
] }, 500);
}); }
}); }
} }
} },
} }
} }
}, },
@ -932,7 +924,172 @@
} }
} }
}), }),
subsections: { subsections: {
// Provider list views
netscalerProviders: {
id: 'netscalerProviders',
title: 'NetScaler Providers',
listView: {
label: 'NetScaler Providers',
fields: {
name: { label: 'Name' },
ipAddress: { label: 'IP Address' },
gateway: { label: 'Gateway' },
netmask: { label: 'Netmask' }
},
actions: {
add: {
label: 'Add new NetScaler',
createForm: {
title: 'Add NetScaler Device',
desc: 'Please enter your NetScaler device\'s information to add it to your network.',
fields: {
name: {
label: 'Name',
validation: { required: true },
defaultValue: 'New_NetScaler'
},
ipaddress: {
label: 'IP Address',
validation: { required: true }
},
supportedServices: {
label: 'Supported Services',
isBoolean: true,
multiArray: {
serviceA: { label: 'Service A' },
serviceB: { label: 'Service B' },
serviceC: { label: 'Service C' }
}
},
username: {
label: 'Username',
validation: { required: true }
},
password: {
label: 'Password',
isPassword: true,
validation: { required: true }
},
type: {
label: 'NetScaler Model',
select: function(args) {
args.response.success({
data: [
{
id: 'mpx',
description: 'NetScaler MPX'
},
{
id: 'adc',
description: 'NetScaler ADC'
}
]
});
}
},
enabled: {
label: 'Enable',
isBoolean: true
}
}
},
action: function(args) {
args.response.success();
},
messages: {
notification: function(args) {
return 'Added new NetScaler';
}
},
notification: {
poll: testData.notifications.testPoll
}
}
},
dataProvider: function(args) {
args.response.success({
data: [
{
name: 'ns-1',
ipAddress: '192.168.1.10',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
},
{
name: 'ns-2',
ipAddress: '192.168.1.11',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
}
]
});
}
}
},
f5Providers: {
id: 'f5Provider',
title: 'F5 Providers',
listView: {
label: 'F5 Providers',
fields: {
name: { label: 'Name' },
ipAddress: { label: 'IP Address' },
gateway: { label: 'Gateway' },
netmask: { label: 'Netmask' }
},
dataProvider: function(args) {
args.response.success({
data: [
{
name: 'f5-1',
ipAddress: '192.168.1.10',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
},
{
name: 'f5-2',
ipAddress: '192.168.1.11',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
}
]
});
}
}
},
srxProviders: {
id: 'srxProviders',
title: 'SRX Providers',
listView: {
label: 'SRX Providers',
fields: {
name: { label: 'Name' },
ipAddress: { label: 'IP Address' },
gateway: { label: 'Gateway' },
netmask: { label: 'Netmask' }
},
dataProvider: function(args) {
args.response.success({
data: [
{
name: 'srx-1',
ipAddress: '192.168.1.10',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
},
{
name: 'srx-2',
ipAddress: '192.168.1.11',
gateway: '192.168.1.1',
netmask: '255.255.255.0'
}
]
});
}
}
},
systemVMs: { systemVMs: {
type: 'select', type: 'select',
title: 'System VMs', title: 'System VMs',

View File

@ -349,6 +349,23 @@
$providerActions.appendTo($listView.find('.toolbar')); $providerActions.appendTo($listView.find('.toolbar'));
}; };
var loadProviderDetails = function($container) {
var provider = naas.networkProviders.types[itemID];
if (provider.type == 'detailView') {
var $detailView = $container.detailView($.extend(true, {}, provider, {
$browser: $browser
}));
} else {
var $listView = $container.listView({
listView: provider
});
loadProviderActions($listView);
}
};
$browser.cloudBrowser('addPanel', { $browser.cloudBrowser('addPanel', {
title: itemName + ' details', title: itemName + ' details',
maximizeIfSelected: true, maximizeIfSelected: true,
@ -370,11 +387,9 @@
_custom: args ? args._custom : null, _custom: args ? args._custom : null,
complete: function(args) { complete: function(args) {
refreshChart(); refreshChart();
var $listView = $newPanel.html('').listView({ $newPanel.html('');
listView: naas.networkProviders.types[itemID] $loading.remove();
}); loadProviderDetails($newPanel);
loadProviderActions($listView);
} }
}); });
} }
@ -405,19 +420,7 @@
) )
); );
} else { } else {
var provider = naas.networkProviders.types[itemID]; loadProviderDetails($newPanel);
if (provider.type == 'detailView') {
var $detailView = $newPanel.detailView($.extend(true, {}, provider, {
$browser: $browser
}));
} else {
var $listView = $newPanel.listView({
listView: provider
});
loadProviderActions($listView);
}
} }
} }
}); });