// 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.lbCertificatePolicy = { dialog: function(args) { return function(args) { var success = args.response.success; var context = args.context; var certid = { certificate: { label: 'label.certificate.name', select: function(args) { var data = {}; var item = {}; if (context != null) { if (context.networks != null) { $.extend(data, {account: context.networks[0].account}); $.extend(data, {domain: context.networks[0].domain}); } } $.extend(data, { details: 'min' }); $.ajax({ url: createURL('listAccounts'), async: false, data: data, success: function(json) { var items = json.listaccountsresponse.account; $.extend(item, {accountid: items[0].id}); } }); $.ajax({ url: createURL('listSslCerts'), async: false, data: item, success: function(json) { if(!json.listsslcertsresponse || !json.listsslcertsresponse.sslcert){ args.response.success({ data: {id: 'No certificates ID', description: 'No certificates found'} }); return; } var items = json.listsslcertsresponse.sslcert; args.response.success({ data: $.map(items, function(item) { return { id: item.id, description: item.id }; }) }); } }); } } }; var $item = args.$item; cloudStack.dialog.createForm({ form: { title: 'Configure Certificate', desc: 'Please complete the following fields', fields: certid }, after: function(args) { // Remove fields not applicable to sticky method args.$form.find('.form-item:hidden').remove(); var data = cloudStack.serializeForm(args.$form); /* $item indicates that this is an existing sticky rule; re-create sticky rule with new parameters */ if ($item) { var $loading = $('