-Add provider-wide action support

-Support defaultValue for create forms
-Fix formatting on panel create forms (for providers)
This commit is contained in:
Brian Federle 2011-11-18 14:59:42 -08:00
parent aae3f4a13f
commit 85f1e56ce1
4 changed files with 392 additions and 27 deletions

View File

@ -1946,7 +1946,9 @@ div.toolbar div.button.search:hover {
}
div.toolbar div.button.add,
div.toolbar div.button.refresh {
div.toolbar div.button.refresh,
div.toolbar div.button.add,
div.toolbar div.button.main-action {
/*+placement:shift 0px 5px;*/
position: relative;
left: 0px;
@ -1971,24 +1973,42 @@ div.toolbar div.button.refresh {
-webkit-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px 4px 4px 4px;
height: 12px;
}
div.toolbar div.button.add:hover,
div.toolbar div.button.refresh:hover {
div.toolbar div.button.refresh:hover,
div.toolbar div.button.main-action:hover {
background-position: 0 -132px;
border-left: 1px solid #585D60;
}
div.toolbar div.button.main-action span.icon {
background-image: url(../images/sprites.png);
display: block;
cursor: pointer;
width: 34px;
height: 20px;
float: left;
/*+placement:shift 0px -7px;*/
position: relative;
left: 0px;
top: -7px;
}
div.toolbar div.button.refresh {
float: right;
margin: 0 15px 0 0;
}
div.toolbar div.button.refresh span {
background-position: -628px -234px;
background-image: url(../images/icons.png);
padding: 1px 1px 1px 16px;
background-position: -629px -232px;
background-repeat: no-repeat;
}
div.toolbar div.button span {
div.toolbar div.button.add span {
padding: 0px 0 0px 18px;
background: url(../images/icons.png) no-repeat -626px -209px;
/*+placement:shift 0px 1px;*/
@ -3708,9 +3728,10 @@ Dialogs*/
.panel .add-first-network-resource .form-item {
width: 409px;
height: 39px;
display: inline-block;
padding: 5px;
position: relative;
margin: 0 0 2px;
}
.panel .add-first-network-resource .form-item label {
@ -3736,10 +3757,23 @@ Dialogs*/
border: 1px solid #B7B7B7;
}
.panel .add-first-network-resource .form-item input[type=text] {
.panel .add-first-network-resource .form-item input[type=checkbox] {
float: right;
margin: 0 266px 0 0;
}
.panel .add-first-network-resource .form-item input[type=text],
.panel .add-first-network-resource .form-item input[type=password],
.panel .add-first-network-resource .form-item input[type=text],
.panel .add-first-network-resource .form-item select {
width: 276px;
}
.panel .add-first-network-resource .form-item select {
width: 280px;
margin: 0 0 0 20px;
}
.panel .add-first-network-resource .button {
padding: 11px 23px 11px 21px;
cursor: pointer;
@ -3764,7 +3798,7 @@ Dialogs*/
padding: 12px;
clear: both;
width: 383px;
margin: 3px 0 0;
margin: 3px 0 10px;
/*+border-radius:7px;*/
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
@ -6620,7 +6654,7 @@ div.panel.ui-dialog div.list-view div.fixed-header {
background-position: -138px -96px;
}
.disable .icon:hover,
.disable:hover .icon,
.disableStaticNAT:hover .icon {
background-position: -138px -678px;
}

View File

@ -1,4 +1,16 @@
(function($, cloudStack) {
var testProviderActionFilter = function(args) {
if (!cloudStack._testProviderStatus) cloudStack._testProviderStatus = 'disabled';
if (cloudStack._testProviderStatus == 'disabled') {
cloudStack._testProviderStatus = 'enabled';
return ['enable', 'start'];
} else {
cloudStack._testProviderStatus = 'disabled';
return ['disable', 'stop'];
}
};
cloudStack.sections.system = {
title: 'System',
id: 'system',
@ -239,17 +251,6 @@
};
},
// Actions performed on entire net. provider type
actions: {
enable: function(args) {
args.response.success();
},
disable: function(args) {
args.response.success();
}
},
types: {
// Virtual router list view
virtualRouter: {
@ -259,6 +260,49 @@
ipaddress: { label: 'IP Address' },
state: { label: 'Status' }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: {
label: 'Disable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Disabled virtual router provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
enable: {
label: 'Enable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Enable virtual router provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
stop: {
label: 'Shutdown',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Shutdown virtual router provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
start: {
label: 'Start',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Started virtual router provider'; }
},
notification: { poll: testData.notifications.testPoll }
}
},
dataProvider: function(args) {
setTimeout(function() {
args.response.success({
@ -292,6 +336,49 @@
ipaddress: { label: 'IP Address' },
state: { label: 'Status' }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: {
label: 'Disable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Disabled NetScaler provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
enable: {
label: 'Enable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Enable NetScaler provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
stop: {
label: 'Shutdown',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Shutdown NetScaler provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
start: {
label: 'Start',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Started NetScaler provider'; }
},
notification: { poll: testData.notifications.testPoll }
}
},
actions: {
add: {
label: 'Add new NetScaler',
@ -301,7 +388,8 @@
fields: {
name: {
label: 'Name',
validation: { required: true }
validation: { required: true },
defaultValue: 'New_NetScaler'
},
ipaddress: {
label: 'IP Address',
@ -315,6 +403,36 @@
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
}
}
},
@ -354,6 +472,49 @@
ipaddress: { label: 'IP Address' },
state: { label: 'Status' }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: {
label: 'Disable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Disabled F5 provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
enable: {
label: 'Enable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Enable F5 provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
stop: {
label: 'Shutdown',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Shutdown F5 provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
start: {
label: 'Start',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Started F5 provider'; }
},
notification: { poll: testData.notifications.testPoll }
}
},
dataProvider: function(args) {
setTimeout(function() {
args.response.success({
@ -387,6 +548,49 @@
ipaddress: { label: 'IP Address' },
state: { label: 'Status' }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: {
label: 'Disable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Disabled SRX provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
enable: {
label: 'Enable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Enable SRX provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
stop: {
label: 'Shutdown',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Shutdown SRX provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
start: {
label: 'Start',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Started SRX provider'; }
},
notification: { poll: testData.notifications.testPoll }
}
},
dataProvider: function(args) {
setTimeout(function() {
args.response.success({
@ -420,6 +624,49 @@
ipaddress: { label: 'IP Address' },
state: { label: 'Status' }
},
providerActionFilter: testProviderActionFilter,
providerActions: {
disable: {
label: 'Disable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Disabled security group provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
enable: {
label: 'Enable',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Enable security group provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
stop: {
label: 'Shutdown',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Shutdown security group provider'; }
},
notification: { poll: testData.notifications.testPoll }
},
start: {
label: 'Start',
action: function(args) {
setTimeout(args.response.success, 100);
},
messages: {
notification: function() { return 'Started security group provider'; }
},
notification: { poll: testData.notifications.testPoll }
}
},
dataProvider: function(args) {
setTimeout(function() {
args.response.success({

View File

@ -9,7 +9,50 @@
var $charts = $('<div>').addClass('system-charts');
var context = listViewArgs.context;
// Renders individual network's chart
/**
* Generates provider-wide actions
*/
var providerActions = function(actions, options) {
if (!options) options = {};
var $actions = $('<div>').addClass('main-actions');
var allowedActions = options.actionFilter ? options.actionFilter({
actions: $.map(actions, function(value, key) { return key; })
}) : null;
$.each(actions, function(actionID, action) {
if (allowedActions && $.inArray(actionID, allowedActions) == -1)
return true;
var $action = $('<div>').addClass('button action main-action');
$action.addClass(actionID);
$action.append($('<span>').addClass('icon'));
$action.append($('<span>').html(action.label));
$action.click(function() {
action.action({
context: { zones: listViewArgs.context.physicalResources },
response: {
success: function(args) {
if (options.success) options.success($.extend(args, {
action: action
}));
}
}
});
});
$action.appendTo($actions);
return true;
});
return $actions;
};
/**
* Render specified network's system chart
*/
var chartView = function(network) {
var $chartView = $('<div>').addClass('system-chart-view')
.append($('#template').find('div.zone-chart').clone());
@ -122,7 +165,7 @@
desc: action.messages.notification({}),
interval: 1000,
poll: action.notification.poll,
_custom: args._custom
_custom: args ? args._custom : null
});
}
}
@ -268,6 +311,39 @@
var createForm = action ? networkProviderArgs.actions.add.createForm : null;
var itemName = networkProviderArgs.label;
/**
* Generate provider-wide actions
*/
var loadProviderActions = function($listView) {
$listView.find('.toolbar .main-actions').remove();
var $providerActions = providerActions(
networkProviderArgs.providerActions ?
networkProviderArgs.providerActions : {},
{
success: function(args) {
var action = args.action;
$loading.appendTo($listView);
$('div.notifications').notifications('add', {
desc: action.messages.notification({}),
interval: 2000,
poll: action.notification.poll,
_custom: args ? args._custom : null,
complete: function(args) {
$loading.remove();
loadProviderActions($listView);
}
});
},
actionFilter: networkProviderArgs.providerActionFilter
}
);
$providerActions.appendTo($listView.find('.toolbar'));
};
$browser.cloudBrowser('addPanel', {
title: itemName + ' details',
maximizeIfSelected: true,
@ -286,12 +362,14 @@
desc: action.messages.notification({}),
interval: 1000,
poll: action.notification.poll,
_custom: args._custom,
_custom: args ? args._custom : null,
complete: function(args) {
refreshChart();
$newPanel.html('').listView({
var $listView = $newPanel.html('').listView({
listView: naas.networkProviders.types[itemID]
});
});
loadProviderActions($listView);
}
});
}
@ -318,13 +396,15 @@
if ($form.valid()) {
completeAction($formContainer);
}
})
})
)
);
} else {
$newPanel.listView({
var $listView = $newPanel.listView({
listView: naas.networkProviders.types[itemID]
});
loadProviderActions($listView);
}
}
});

View File

@ -197,6 +197,10 @@
name: key,
type: this.password || this.isPassword ? 'password' : 'text'
}).appendTo($value);
if (this.defaultValue) {
$input.val(this.defaultValue);
}
}
$input.data('validation-rules', this.validation);