').addClass('loading-overlay').appendTo($autoscalerDialog);
- var success = function (args) {
- $loading.remove();
- cloudStack.dialog.notice({
- message: _l('label.task.completed') + ': ' + label
- });
-
- // Reload actions
- if (data != null) { //data is originalAutoscaleData in \ui\scripts\autoscaler.js
- data['afterActionIsComplete'] = args.data;
- }
-
- var $newActions = renderActions({
- data: data ? $.extend(data, args.data) : args.data,
- actionFilter: args.actionFilter,
- context: context
- });
-
- $actions.after($newActions);
- $actions.remove();
- };
- var error = function (message) {
- $loading.remove();
- cloudStack.dialog.notice({
- message: message
- });
- };
-
- action.action({
- context: {
- originalAutoscaleData: args.data
- },
- response: {
- success: function (args) {
- var notification = $.extend(args.notification, {
- _custom: args._custom,
- desc: label
- });
-
- cloudStack.ui.notifications.add(
- notification,
- success, {},
- error, {}
- );
- },
- error: error
- }
- });
- });
-
- $action.append($icon);
- $action.appendTo($buttons);
- });
-
- if (!visibleActions || !visibleActions.length) $actions.hide();
-
- return $actions;
- };
-
- var renderDialogContent = function (args) {
- var data = args.data ? args.data : {};
-
- // Setup default values, in case where existing data is present
- var setDefaultFields = function (fieldID, field) {
- var fieldData = data[fieldID];
-
- if (fieldData && !field.isBoolean) {
- field.defaultValue = fieldData;
- } else {
- field.isChecked = fieldData;
- }
- };
- $.each(topfields, setDefaultFields);
- $.each(bottomfields, setDefaultFields);
-
- $.extend(context, {
- originalAutoscaleData: args.data
- });
-
- // Create and append top fields
- // -- uses create form to generate fields
- topFieldForm = cloudStack.dialog.createForm({
- context: context,
- noDialog: true, // Don't render a dialog, just return $formContainer
- form: {
- title: '',
- fields: topfields
- }
- });
- $topFieldForm = topFieldForm.$formContainer;
- $topFieldForm.appendTo($topFields);
-
- scaleUpPolicyTitleForm = cloudStack.dialog.createForm({
- context: context,
- noDialog: true,
- form: {
- title: '',
- fields: {
- scaleUpDuration: {
- label: 'label.duration.in.sec',
- validation: {
- required: true
- }
- }
- }
- }
- });
- $scaleUpPolicyTitleForm = scaleUpPolicyTitleForm.$formContainer;
- $scaleUpPolicyTitleForm.appendTo($scaleUpPolicyTitle);
-
-
- scaleDownPolicyTitleForm = cloudStack.dialog.createForm({
- context: context,
- noDialog: true,
- form: {
- title: '',
- fields: {
- scaleDownDuration: {
- label: 'label.duration.in.sec',
- validation: {
- required: true
- }
- }
- }
- }
- });
- $scaleDownPolicyTitleForm = scaleDownPolicyTitleForm.$formContainer;
- $scaleDownPolicyTitleForm.appendTo($scaleDownPolicyTitle);
-
- // Make multi-edits
- //
- // Scale up policy
- if (data.scaleUpPolicy && $.isArray(data.scaleUpPolicy.conditions)) {
- $autoscalerDialog.data('autoscaler-scale-up-data',
- data.scaleUpPolicy.conditions);
- }
-
- if (data.scaleUpPolicy && data.scaleUpPolicy.duration) {
- $scaleUpPolicyTitleForm.find('input[name=scaleUpDuration]').val(
- data.scaleUpPolicy.duration
- );
- }
-
- scaleuppolicy.context = context;
- scaleUpPolicyForm = $scaleUpPolicy.multiEdit(scaleuppolicy);
-
- // Scale down policy
- if (data.scaleDownPolicy && $.isArray(data.scaleDownPolicy.conditions)) {
- $autoscalerDialog.data('autoscaler-scale-down-data',
- data.scaleDownPolicy.conditions);
- }
-
- if (data.scaleDownPolicy && data.scaleDownPolicy.duration) {
- $scaleDownPolicyTitleForm.find('input[name=scaleDownDuration]').val(
- data.scaleDownPolicy.duration
- );
- }
-
- scaledownpolicy.context = context;
- scaleDownPolicyForm = $scaleDownPolicy.multiEdit(scaledownpolicy);
-
- // Create and append bottom fields
- bottomFieldForm = cloudStack.dialog.createForm({
- context: context,
- noDialog: true, // Don't render a dialog, just return $formContainer
- form: {
- title: '',
- fields: bottomfields
- }
- });
- $bottomFieldForm = bottomFieldForm.$formContainer;
- $bottomFieldForm.appendTo($bottomFields);
-
- // Append main div elements
- $autoscalerDialog.append(
- $topFields,
- $scaleUpPolicyTitle,
- $scaleUpPolicy,
- $scaleDownPolicyTitle,
- $scaleDownPolicy,
- $bottomFields
- );
-
- // Render dialog
- //$autoscalerDialog.find('.form-item[rel=templateNames] label').hide();
- /* Duration Fields*/
- //$('div.ui-dialog div.autoscaler').find('div.scale-up-policy-title').append("
").append($inputLabel = $('