// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
(function($, cloudStack) {
cloudStack.uiCustom.autoscaler = function(args) {
// Place outer args here as local variables
// i.e, -- var dataProvider = args.dataProvider
var forms = $.extend(true, {}, args.forms);
var topfields = forms.topFields;
var bottomfields = forms.bottomFields;
var scaleuppolicy = forms.scaleUpPolicy;
var scaledownpolicy = forms.scaleDownPolicy;
var dataProvider = cloudStack.autoscaler.dataProvider;
var actions = cloudStack.autoscaler.autoscaleActions;
var actionFilter = cloudStack.autoscaler.actionFilter;
return function(args) {
var context = args.data ?
$.extend(true, {}, args.context, {
lbRules: [args.data]
}) : args.context;
var formData = args.formData;
var $autoscalerDialog = $('
').addClass('autoscaler');
var $topFields = $('
').addClass('field-group top-fields');
var $bottomFields = $('
').addClass('field-group bottom-fields');
var $scaleUpPolicy = $('
').addClass('scale-up-policy');
var $slideScaleUp = $('').addClass('expand');
var $hideScaleUp = $('').addClass('hide');
var $scaleUpLabel = $('
Show
').addClass('slide-label');
var $scaleUpHideLabel = $('
Hide
').addClass('slide-label');
var $scaleDownHideLabel = $('
Hide
').addClass('slide-label');
var $scaleDownLabel = $('
Show
').addClass('slide-label');
var $slideScaleDown = $('').addClass('expand');
var $hideScaleDown = $('').addClass('hide');
var $scaleUpDivider = $('').addClass('policy-divider');
var $scaleDownDivider = $('').addClass('policy-divider');
var $bottomFieldDivider = $('').addClass('policy-divider');
var $scaleDownPolicy = $('
').addClass('scale-down-policy');
var $scaleUpPolicyTitle = $('
').addClass('scale-up-policy-title')
.html("Scale Up Policy");
var $scaleDownPolicyTitle = $('
').addClass('scale-down-policy-title')
.html("Scale Down Policy");
var topFieldForm, $topFieldForm,
bottomFieldForm, $bottomFieldForm,
scaleUpPolicyTitleForm, $scaleUpPolicyTitleForm,
scaleDownPolicyTitleForm, $scaleDownPolicyTitleForm,
scaleUpPolicyForm, scaleDownPolicyForm;
var renderActions = function(args) {
var targetActionFilter = args.actionFilter ? args.actionFilter : actionFilter;
var data = args.data;
var context = args.context;
var $actions = $('
').addClass('detail-group');
var $actionsTable = $('
').append('
');
var $detailActions = $('
').addClass('detail-actions');
var $buttons = $('
').addClass('buttons');
var visibleActions = targetActionFilter ?
targetActionFilter({
context: $.extend(true, {}, context, {
originalAutoscaleData: data ? [data] : null
})
}) :
$.map(actions, function(value, key) {
return key;
});
$detailActions.append($buttons);
$actionsTable.find('tr').append($detailActions);
$actions.append($actionsTable);
$(visibleActions).map(function(index, actionID) {
var action = actions[actionID];
var label = _l(action.label);
var $action = $('