diff --git a/marketplace/code/infrastructure/active_records/CompanyService.php b/marketplace/code/infrastructure/active_records/CompanyService.php index 29d9299..a27c8a9 100644 --- a/marketplace/code/infrastructure/active_records/CompanyService.php +++ b/marketplace/code/infrastructure/active_records/CompanyService.php @@ -62,6 +62,11 @@ class CompanyService } public function isDraft() + { + return 0; + } + + public function isNotPublished() { return 0; } diff --git a/marketplace/code/infrastructure/active_records/CompanyServiceDraft.php b/marketplace/code/infrastructure/active_records/CompanyServiceDraft.php index b62a343..6ad39a4 100644 --- a/marketplace/code/infrastructure/active_records/CompanyServiceDraft.php +++ b/marketplace/code/infrastructure/active_records/CompanyServiceDraft.php @@ -16,6 +16,7 @@ class CompanyServiceDraft 'Overview' => 'HTMLText', 'Call2ActionUri' => 'Text', 'Active' => 'Boolean', + 'Published' => 'Boolean', ); static $has_one = array( @@ -56,6 +57,16 @@ class CompanyServiceDraft return 1; } + public function isNotPublished() + { + return !$this->getField('Published'); + } + + public function setPublished($published) + { + $this->setField('Published',$published); + } + public function setCompany(ICompany $company) { AssociationFactory::getInstance()->getMany2OneAssociation($this,'Company')->setTarget($company); diff --git a/marketplace/code/infrastructure/factories/ApplianceDraftFactory.php b/marketplace/code/infrastructure/factories/ApplianceDraftFactory.php index 3630cc1..d1a5103 100644 --- a/marketplace/code/infrastructure/factories/ApplianceDraftFactory.php +++ b/marketplace/code/infrastructure/factories/ApplianceDraftFactory.php @@ -14,7 +14,7 @@ final class ApplianceDraftFactory extends OpenStackImplementationDraftFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $appliance = new ApplianceDraft; $appliance->setName($name); @@ -27,6 +27,7 @@ final class ApplianceDraftFactory extends OpenStackImplementationDraftFactory { $appliance->setMarketplace($marketplace_type); $appliance->setCall2ActionUri($call_2_action_url); $appliance->setLiveServiceId($live_id); + $appliance->setPublished($published); return $appliance; } diff --git a/marketplace/code/infrastructure/factories/ApplianceFactory.php b/marketplace/code/infrastructure/factories/ApplianceFactory.php index 0633709..5a4a5e5 100644 --- a/marketplace/code/infrastructure/factories/ApplianceFactory.php +++ b/marketplace/code/infrastructure/factories/ApplianceFactory.php @@ -25,7 +25,7 @@ final class ApplianceFactory extends OpenStackImplementationFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null, $published = null) { $appliance = new Appliance; $appliance->setName($name); diff --git a/marketplace/code/infrastructure/factories/ConsultantDraftFactory.php b/marketplace/code/infrastructure/factories/ConsultantDraftFactory.php index f07db6d..35078fe 100644 --- a/marketplace/code/infrastructure/factories/ConsultantDraftFactory.php +++ b/marketplace/code/infrastructure/factories/ConsultantDraftFactory.php @@ -15,7 +15,7 @@ final class ConsultantDraftFactory * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $consultant = new ConsultantDraft; $consultant->setName($name); @@ -28,6 +28,7 @@ final class ConsultantDraftFactory $consultant->setMarketplace($marketplace_type); $consultant->setCall2ActionUri($call_2_action_url); $consultant->setLiveServiceId($live_id); + $consultant->setPublished($published); return $consultant; } diff --git a/marketplace/code/infrastructure/factories/ConsultantFactory.php b/marketplace/code/infrastructure/factories/ConsultantFactory.php index 6a34467..78e3234 100644 --- a/marketplace/code/infrastructure/factories/ConsultantFactory.php +++ b/marketplace/code/infrastructure/factories/ConsultantFactory.php @@ -27,7 +27,7 @@ final class ConsultantFactory * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $consultant = new Consultant; $consultant->setName($name); diff --git a/marketplace/code/infrastructure/factories/DistributionDraftFactory.php b/marketplace/code/infrastructure/factories/DistributionDraftFactory.php index 93182bf..cd8d6af 100644 --- a/marketplace/code/infrastructure/factories/DistributionDraftFactory.php +++ b/marketplace/code/infrastructure/factories/DistributionDraftFactory.php @@ -14,7 +14,7 @@ final class DistributionDraftFactory extends OpenStackImplementationDraftFactory * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $distribution = new DistributionDraft; $distribution->setName($name); @@ -27,6 +27,7 @@ final class DistributionDraftFactory extends OpenStackImplementationDraftFactory $distribution->setMarketplace($marketplace_type); $distribution->setCall2ActionUri($call_2_action_url); $distribution->setLiveServiceId($live_id); + $distribution->setPublished($published); return $distribution; } diff --git a/marketplace/code/infrastructure/factories/DistributionFactory.php b/marketplace/code/infrastructure/factories/DistributionFactory.php index c86d7c0..e9e4854 100644 --- a/marketplace/code/infrastructure/factories/DistributionFactory.php +++ b/marketplace/code/infrastructure/factories/DistributionFactory.php @@ -25,7 +25,7 @@ final class DistributionFactory extends OpenStackImplementationFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $distribution = new Distribution; $distribution->setName($name); diff --git a/marketplace/code/infrastructure/factories/PrivateCloudDraftFactory.php b/marketplace/code/infrastructure/factories/PrivateCloudDraftFactory.php index bbfe175..be48f74 100644 --- a/marketplace/code/infrastructure/factories/PrivateCloudDraftFactory.php +++ b/marketplace/code/infrastructure/factories/PrivateCloudDraftFactory.php @@ -13,7 +13,7 @@ final class PrivateCloudDraftFactory extends CloudDraftFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $private_cloud = new PrivateCloudServiceDraft; $private_cloud->setName($name); @@ -26,6 +26,7 @@ final class PrivateCloudDraftFactory extends CloudDraftFactory { $private_cloud->setMarketplace($marketplace_type); $private_cloud->setCall2ActionUri($call_2_action_url); $private_cloud->setLiveServiceId($live_id); + $private_cloud->setPublished($published); return $private_cloud; } diff --git a/marketplace/code/infrastructure/factories/PrivateCloudFactory.php b/marketplace/code/infrastructure/factories/PrivateCloudFactory.php index a4ac16a..37c0275 100644 --- a/marketplace/code/infrastructure/factories/PrivateCloudFactory.php +++ b/marketplace/code/infrastructure/factories/PrivateCloudFactory.php @@ -24,7 +24,7 @@ final class PrivateCloudFactory extends CloudFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null, $published = null) { $private_cloud = new PrivateCloudService; $private_cloud->setName($name); diff --git a/marketplace/code/infrastructure/factories/PublicCloudDraftFactory.php b/marketplace/code/infrastructure/factories/PublicCloudDraftFactory.php index 3d27430..8798ae3 100644 --- a/marketplace/code/infrastructure/factories/PublicCloudDraftFactory.php +++ b/marketplace/code/infrastructure/factories/PublicCloudDraftFactory.php @@ -15,7 +15,7 @@ final class PublicCloudDraftFactory * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_id = null, $published = null) { $public_cloud = new PublicCloudServiceDraft(); $public_cloud->setName($name); @@ -28,6 +28,7 @@ final class PublicCloudDraftFactory $public_cloud->setMarketplace($marketplace_type); $public_cloud->setCall2ActionUri($call_2_action_url); $public_cloud->setLiveServiceId($live_id); + $public_cloud->setPublished($published); return $public_cloud; } diff --git a/marketplace/code/infrastructure/factories/PublicCloudFactory.php b/marketplace/code/infrastructure/factories/PublicCloudFactory.php index 1c74597..da7026c 100644 --- a/marketplace/code/infrastructure/factories/PublicCloudFactory.php +++ b/marketplace/code/infrastructure/factories/PublicCloudFactory.php @@ -26,7 +26,7 @@ final class PublicCloudFactory * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null) + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type, $call_2_action_url = null, $live_service = null, $published = null) { $public_cloud = new PublicCloudService; $public_cloud->setName($name); diff --git a/marketplace/code/model/base_entities/CompanyServiceManager.php b/marketplace/code/model/base_entities/CompanyServiceManager.php index 29d766a..57ba49b 100644 --- a/marketplace/code/model/base_entities/CompanyServiceManager.php +++ b/marketplace/code/model/base_entities/CompanyServiceManager.php @@ -194,7 +194,8 @@ abstract class CompanyServiceManager { $data['active'], $getMarketPlaceType->invoke($this_var), $data['call_2_action_uri'], - $live_service_id); + $live_service_id, + $data['published']); $this_var->register($company_service); @@ -252,6 +253,8 @@ abstract class CompanyServiceManager { $company_service->setName($data['name']); if ($company_service->isDraft()) { $live_service_id = (isset($data['live_service_id'])) ? $data['live_service_id'] : 0; + $published = (isset($data['published'])) ? $data['published'] : 0; + $company_service->setPublished($published); $company_service->setLiveServiceId($live_service_id); } diff --git a/marketplace/code/model/base_entities/ICompanyServiceFactory.php b/marketplace/code/model/base_entities/ICompanyServiceFactory.php index 5c8a279..b88bb17 100644 --- a/marketplace/code/model/base_entities/ICompanyServiceFactory.php +++ b/marketplace/code/model/base_entities/ICompanyServiceFactory.php @@ -24,7 +24,7 @@ interface ICompanyServiceFactory { * @param null|string $call_2_action_url * @return ICompanyService */ - public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type,$call_2_action_url=null,$live_id=null); + public function buildCompanyService($name, $overview, ICompany $company, $active, IMarketPlaceType $marketplace_type,$call_2_action_url=null,$live_id=null,$published=null); /** * @param $id diff --git a/marketplace/code/ui/admin/js/appliance.js b/marketplace/code/ui/admin/js/appliance.js index cae718e..7ebd02a 100644 --- a/marketplace/code/ui/admin/js/appliance.js +++ b/marketplace/code/ui/admin/js/appliance.js @@ -83,6 +83,8 @@ jQuery(document).ready(function($){ hypervisors !== false && videos !== false){ + ajaxIndicatorStart('saving data.. please wait..'); + //create distribution object and POST it var appliance = {}; appliance.id = parseInt($("#id",form).val()); @@ -98,6 +100,7 @@ jQuery(document).ready(function($){ appliance.capabilities = capabilities; appliance.regional_support = regional_support; appliance.additional_resources = additional_resources; + appliance.published = 0; var type = appliance.id > 0 ?'PUT':'POST'; $('.save-appliance').prop('disabled',true); @@ -108,12 +111,90 @@ jQuery(document).ready(function($){ contentType: "application/json; charset=utf-8", dataType: "json", success: function (data,textStatus,jqXHR) { - //window.location = listing_url; - if(appliance.id < 1) $("#id",form).val(data); + ajaxIndicatorStop(); $('.publish-appliance').prop('disabled',false); $('.save-appliance').prop('disabled',false); + window.location = listing_url; }, error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); + ajaxError(jqXHR, textStatus, errorThrown); + $('.save-appliance').prop('disabled',false); + } + }); + } + return false; + }); + + $('.preview-appliance').click(function(event){ + event.preventDefault(); + event.stopPropagation(); + var button = $(this); + if(button.prop('disabled')){ + return false; + } + var form_validator = form.marketplace_type_header('getFormValidator'); + form_validator.settings.ignore = ".add-comtrol"; + var is_valid = form.valid(); + if(!is_valid) return false; + form_validator.resetForm(); + var additional_resources = $("#additional-resources-form").additional_resources('serialize'); + var regional_support = $("#support-channels-form").support_channels('serialize'); + var capabilities = $("#components_form").components('serialize'); + var guest_os = $("#guest_os_form").guest_os('serialize'); + var hypervisors = $("#hypervisors_form").hypervisors('serialize'); + var videos = $("#videos-form").videos('serialize'); + var is_pdf = $(this).hasClass('pdf'); + + if(additional_resources !== false && + regional_support !== false && + capabilities !== false && + guest_os !== false && + hypervisors !== false && + videos !== false){ + + ajaxIndicatorStart('saving data.. please wait..'); + + //create distribution object and POST it + var appliance = {}; + appliance.id = parseInt($("#id",form).val()); + appliance.live_service_id = parseInt($("#live_id",form).val()); + appliance.company_id = parseInt($("#company_id",form).val()); + appliance.name = $("#name",form).val(); + appliance.overview = $("#overview",form).val(); + appliance.call_2_action_uri = $("#call_2_action_uri",form).val(); + appliance.active = $('#active',form).is(":checked");; + appliance.videos = videos; + appliance.hypervisors = hypervisors; + appliance.guest_os = guest_os; + appliance.capabilities = capabilities; + appliance.regional_support = regional_support; + appliance.additional_resources = additional_resources; + appliance.published = 0; + + var type = appliance.id > 0 ?'PUT':'POST'; + $('.save-appliance').prop('disabled',true); + $.ajax({ + type: type, + url: 'api/v1/marketplace/appliances', + data: JSON.stringify(appliance), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data,textStatus,jqXHR) { + ajaxIndicatorStop(); + $('.publish-appliance').prop('disabled',false); + $('.save-appliance').prop('disabled',false); + var draft_id = (appliance.id > 0) ? appliance.id : data; + $("#id",form).val(draft_id); + + if (is_pdf) { + window.location = product_url+'/'+draft_id+'/draft_pdf'; + } else { + window.open(product_url+'/'+draft_id+'/draft_preview','_blank'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); ajaxError(jqXHR, textStatus, errorThrown); $('.save-appliance').prop('disabled',false); } @@ -148,6 +229,8 @@ jQuery(document).ready(function($){ hypervisors !== false && videos !== false){ + ajaxIndicatorStart('saving data.. please wait..'); + //create distribution object and POST it var appliance = {}; appliance.id = parseInt($("#id",form).val()); @@ -163,6 +246,7 @@ jQuery(document).ready(function($){ appliance.capabilities = capabilities; appliance.regional_support = regional_support; appliance.additional_resources = additional_resources; + appliance.published = 1; var url = 'api/v1/marketplace/appliances/'+appliance.live_service_id; @@ -174,9 +258,11 @@ jQuery(document).ready(function($){ contentType: "application/json; charset=utf-8", dataType: "json", success: function (data,textStatus,jqXHR) { + ajaxIndicatorStop(); window.location = listing_url; }, error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); ajaxError(jqXHR, textStatus, errorThrown); $('.publish-appliance').prop('disabled',false); } diff --git a/marketplace/code/ui/admin/js/consultant.js b/marketplace/code/ui/admin/js/consultant.js index e0e23f4..07ee958 100644 --- a/marketplace/code/ui/admin/js/consultant.js +++ b/marketplace/code/ui/admin/js/consultant.js @@ -115,7 +115,8 @@ jQuery(document).ready(function($){ languages_spoken: languages_spoken, offices: offices, videos: videos, - additional_resources: additional_resources + additional_resources: additional_resources, + published: 0 } $('.save-consultant').prop('disabled',true); var type = consultant.id > 0 ?'PUT':'POST'; @@ -186,6 +187,138 @@ jQuery(document).ready(function($){ return false; }); + $('.preview-consultant').click(function(event){ + event.preventDefault(); + event.stopPropagation(); + var button = $(this); + if(button.prop('disabled')){ + return false; + } + var form_validator = form.marketplace_type_header('getFormValidator'); + form_validator.settings.ignore = ".add-comtrol"; + var is_valid = form.valid(); + form_validator.settings.ignore = []; + if(!is_valid) return false; + form_validator.resetForm(); + + var expertise_areas = $('#expertise_areas_form').expertise_areas('serialize'); + var configuration_management = $('#configuration_management_form').configuration_management_expertise('serialize'); + var reference_clients = $('#reference_clients_form').reference_clients('serialize'); + var services_offered = $('#services_offered_form').services_offered('serialize'); + var regional_support = $('#support-channels-form').support_channels('serialize'); + var languages_spoken = $('#languages_spoken_form').spoken_languages('serialize'); + var offices = $('#offices_form').offices('serialize'); + var videos = $('#videos-form').videos('serialize'); + var additional_resources = $('#additional-resources-form').additional_resources('serialize'); + var is_pdf = $(this).hasClass('pdf'); + + if(expertise_areas!==false && + configuration_management!== false && + reference_clients!== false && + services_offered !== false && + regional_support !== false && + languages_spoken !== false && + offices !== false && + videos !== false && + additional_resources !== false ){ + + ajaxIndicatorStart('saving data.. please wait..'); + + var consultant = { + id : parseInt($("#id",form).val()), + live_service_id : parseInt($("#live_id",form).val()), + company_id : parseInt($("#company_id",form).val()), + name : $("#name",form).val().trim(), + overview : $("#overview",form).val().trim(), + call_2_action_uri : $("#call_2_action_uri",form).val().trim(), + active : $('#active',form).is(":checked"), + expertise_areas: expertise_areas, + configuration_management: configuration_management, + reference_clients: reference_clients, + services_offered: services_offered, + regional_support: regional_support, + languages_spoken: languages_spoken, + offices: offices, + videos: videos, + additional_resources: additional_resources, + published: 0 + } + $('.save-consultant').prop('disabled',true); + var type = consultant.id > 0 ?'PUT':'POST'; + + $(this).geocoding({ + requests:consultant.offices, + buildGeoRequest:function(office){ + var address = office.address_1+' '+office.address_2; + address = address.trim(); + if(address!=''){ + address+= ', '+office.city; + } + var restrictions = { + locality: office.city, + country:office.country + }; + if(office.state!=''){ + restrictions.administrativeArea = office.state; + if(address!=''){ + address+= ', '+office.state; + } + } + if(office.zip_code!=''){ + //restrictions.postalCode = office.zip_code; + if(address!=''){ + address+= ', '+office.zip_code; + } + } + var request = {componentRestrictions:restrictions}; + if(address!=''){ + request.address = address; + } + return request; + }, + postProcessRequest:function(office, lat, lng){ + office.lat = lat; + office.lng = lng; + }, + processFinished:function(){ + $.ajax({ + type: type, + url: 'api/v1/marketplace/consultants', + data: JSON.stringify(consultant), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data,textStatus,jqXHR) { + $('.publish-consultant').prop('disabled',false); + $('.save-consultant').prop('disabled',false); + ajaxIndicatorStop(); + var draft_id = (consultant.id > 0) ? consultant.id : data; + $("#id",form).val(draft_id); + + if (is_pdf) { + window.location = product_url+'/'+draft_id+'/draft_pdf'; + } else { + window.open(product_url+'/'+draft_id+'/draft_preview','_blank'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); + $('.save-consultant').prop('disabled',false); + ajaxError(jqXHR, textStatus, errorThrown); + } + }); + }, + cancelProcess:function(){ + ajaxIndicatorStop(); + $('.save-consultant').prop('disabled',false); + }, + errorMessage:function(office){ + return 'office: address ( address_1:'+office.address_1+', address_2:'+office.address_2+', city:'+office.city+',state: '+office.state+', country:'+office.country+' )'; + } + }); + } + return false; + }); + $('.publish-consultant').click(function(event){ event.preventDefault(); event.stopPropagation(); @@ -238,7 +371,8 @@ jQuery(document).ready(function($){ languages_spoken: languages_spoken, offices: offices, videos: videos, - additional_resources: additional_resources + additional_resources: additional_resources, + published: 1 } $('.publish-consultant').prop('disabled',true); diff --git a/marketplace/code/ui/admin/js/distribution.js b/marketplace/code/ui/admin/js/distribution.js index 4c3a0b7..10ee2f2 100644 --- a/marketplace/code/ui/admin/js/distribution.js +++ b/marketplace/code/ui/admin/js/distribution.js @@ -84,6 +84,8 @@ jQuery(document).ready(function($){ hypervisors !== false && videos !== false){ + ajaxIndicatorStart('saving data.. please wait..'); + //create distribution object and POST it var distribution = {}; distribution.id = parseInt($("#id",form).val()); @@ -99,6 +101,7 @@ jQuery(document).ready(function($){ distribution.capabilities = capabilities; distribution.regional_support = regional_support; distribution.additional_resources = additional_resources; + distribution.published = 0; var type = distribution.id > 0 ?'PUT':'POST'; @@ -110,11 +113,91 @@ jQuery(document).ready(function($){ contentType: "application/json; charset=utf-8", dataType: "json", success: function (data,textStatus,jqXHR) { + ajaxIndicatorStop(); $('.publish-distribution').prop('disabled',false); $('.save-distribution').prop('disabled',false); window.location = listing_url; }, error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); + $('.save-distribution').prop('disabled',false); + ajaxError(jqXHR, textStatus, errorThrown); + } + }); + } + return false; + }); + + $('.preview-distribution').click(function(event){ + event.preventDefault(); + event.stopPropagation(); + var button = $(this); + if(button.prop('disabled')){ + return false; + } + var form_validator = form.marketplace_type_header('getFormValidator'); + form_validator.settings.ignore = ".add-comtrol"; + var is_valid = form.valid(); + if(!is_valid) return false; + form_validator.resetForm(); + var additional_resources = $("#additional-resources-form").additional_resources('serialize'); + var regional_support = $("#support-channels-form").support_channels('serialize'); + var capabilities = $("#components_form").components('serialize'); + var guest_os = $("#guest_os_form").guest_os('serialize'); + var hypervisors = $("#hypervisors_form").hypervisors('serialize'); + var videos = $("#videos-form").videos('serialize'); + var is_pdf = $(this).hasClass('pdf'); + + if(additional_resources !== false && + regional_support !== false && + capabilities !== false && + guest_os !== false && + hypervisors !== false && + videos !== false){ + + ajaxIndicatorStart('saving data.. please wait..'); + + //create distribution object and POST it + var distribution = {}; + distribution.id = parseInt($("#id",form).val()); + distribution.live_service_id = parseInt($("#live_id",form).val()); + distribution.company_id = parseInt($("#company_id",form).val()); + distribution.name = $("#name",form).val(); + distribution.overview = $("#overview",form).val(); + distribution.call_2_action_uri = $("#call_2_action_uri",form).val(); + distribution.active = $('#active',form).is(":checked"); + distribution.videos = videos; + distribution.hypervisors = hypervisors; + distribution.guest_os = guest_os; + distribution.capabilities = capabilities; + distribution.regional_support = regional_support; + distribution.additional_resources = additional_resources; + distribution.published = 0; + + var type = distribution.id > 0 ?'PUT':'POST'; + + $('.save-distribution').prop('disabled',true); + $.ajax({ + type: type, + url: 'api/v1/marketplace/distributions', + data: JSON.stringify(distribution), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data,textStatus,jqXHR) { + ajaxIndicatorStop(); + $('.publish-distribution').prop('disabled',false); + $('.save-distribution').prop('disabled',false); + var draft_id = (distribution.id > 0) ? distribution.id : data; + $("#id",form).val(draft_id); + + if (is_pdf) { + window.location = product_url+'/'+draft_id+'/draft_pdf'; + } else { + window.open(product_url+'/'+draft_id+'/draft_preview','_blank'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); $('.save-distribution').prop('disabled',false); ajaxError(jqXHR, textStatus, errorThrown); } @@ -149,6 +232,8 @@ jQuery(document).ready(function($){ hypervisors !== false && videos !== false){ + ajaxIndicatorStart('saving data.. please wait..'); + //create distribution object and POST it var distribution = {}; distribution.id = parseInt($("#id",form).val()); @@ -164,6 +249,7 @@ jQuery(document).ready(function($){ distribution.capabilities = capabilities; distribution.regional_support = regional_support; distribution.additional_resources = additional_resources; + distribution.published = 1; var url = 'api/v1/marketplace/distributions/'+distribution.live_service_id; @@ -176,9 +262,11 @@ jQuery(document).ready(function($){ contentType: "application/json; charset=utf-8", dataType: "json", success: function (data,textStatus,jqXHR) { + ajaxIndicatorStop(); window.location = listing_url; }, error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); $('.publish-distribution').prop('disabled',false); ajaxError(jqXHR, textStatus, errorThrown); } diff --git a/marketplace/code/ui/admin/js/private_cloud.js b/marketplace/code/ui/admin/js/private_cloud.js index 9d9c393..bf700be 100644 --- a/marketplace/code/ui/admin/js/private_cloud.js +++ b/marketplace/code/ui/admin/js/private_cloud.js @@ -120,6 +120,7 @@ jQuery(document).ready(function($){ private_cloud.regional_support = regional_support; private_cloud.additional_resources = additional_resources; private_cloud.data_centers = data_centers; + private_cloud.published = 0; var type = private_cloud.id > 0 ?'PUT':'POST'; @@ -176,6 +177,125 @@ jQuery(document).ready(function($){ return false; }); + $('.preview-private_cloud').click(function(event){ + var button = $(this); + if(button.prop('disabled')){ + return false; + } + event.preventDefault(); + event.stopPropagation(); + var form_validator = form.marketplace_type_header('getFormValidator'); + form_validator.settings.ignore = ".add-comtrol"; + var is_valid = form.valid(); + if(!is_valid) return false; + form_validator.resetForm(); + + var additional_resources = $("#additional-resources-form").additional_resources('serialize'); + var regional_support = $("#support-channels-form").support_channels('serialize'); + var capabilities = $("#components_form").components('serialize'); + var guest_os = $("#guest_os_form").guest_os('serialize'); + var hyper_visors = $("#hypervisors_form").hypervisors('serialize'); + var videos = $("#videos-form").videos('serialize'); + var data_centers = $("#data-centers-form").datacenter_locations('serialize'); + var pricing_schemas = $("#pricing_schema_form").pricing_schemas('serialize'); + var is_pdf = $(this).hasClass('pdf'); + + if(additional_resources !== false && + regional_support !== false && + capabilities !== false && + guest_os !== false && + hyper_visors !== false && + videos !== false && + data_centers !== false && + pricing_schemas !== false + ){ + + ajaxIndicatorStart('saving data.. please wait..'); + + //create private_cloud object and POST it + var private_cloud = {}; + private_cloud.id = parseInt($("#id",form).val()); + private_cloud.live_service_id = parseInt($("#live_id",form).val()); + private_cloud.company_id = parseInt($("#company_id",form).val()); + private_cloud.name = $("#name",form).val(); + private_cloud.overview = $("#overview",form).val(); + private_cloud.call_2_action_uri = $("#call_2_action_uri",form).val(); + private_cloud.active = $('#active',form).is(":checked"); + private_cloud.videos = videos; + private_cloud.hypervisors = hyper_visors; + private_cloud.guest_os = guest_os; + private_cloud.capabilities = capabilities; + for(var i in private_cloud.capabilities){ + var c = private_cloud.capabilities[i]; + c.pricing_schemas = pricing_schemas; + } + private_cloud.regional_support = regional_support; + private_cloud.additional_resources = additional_resources; + private_cloud.data_centers = data_centers; + private_cloud.published = 0; + + var type = private_cloud.id > 0 ?'PUT':'POST'; + + $('.save-private-cloud').prop('disabled',true); + + $(this).geocoding({ + requests:private_cloud.data_centers.locations, + buildGeoRequest:function(location){ + var restrictions = { + locality: location.city, + country:location.country + }; + if(location.state!=''){ + restrictions.administrativeArea = location.state; + } + var request = {componentRestrictions:restrictions}; + return request; + }, + postProcessRequest:function(location, lat, lng){ + location.lat = lat; + location.lng = lng; + }, + processFinished:function(){ + $.ajax({ + type: type, + url: 'api/v1/marketplace/private-clouds', + data: JSON.stringify(private_cloud), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data,textStatus,jqXHR) { + $('.publish-private-cloud').prop('disabled',false); + $('.save-private-cloud').prop('disabled',false); + ajaxIndicatorStop(); + var draft_id = (private_cloud.id > 0) ? private_cloud.id : data; + $("#id",form).val(draft_id); + + if (is_pdf) { + window.location = product_url+'/'+draft_id+'/draft_pdf'; + } else { + window.open(product_url+'/'+draft_id+'/draft_preview','_blank'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); + $('.save-private-cloud').prop('disabled',false); + ajaxError(jqXHR, textStatus, errorThrown); + } + }); + }, + cancelProcess:function(){ + ajaxIndicatorStop(); + $('.save-private-cloud').prop('disabled',false); + }, + errorMessage:function(location){ + return 'data center location: address ( city:'+location.city+',state: '+location.state+', country:'+location.country+' )'; + } + }); + + + } + return false; + }); + $('.publish-private-cloud').click(function(event){ var button = $(this); if(button.prop('disabled')){ @@ -230,6 +350,7 @@ jQuery(document).ready(function($){ private_cloud.regional_support = regional_support; private_cloud.additional_resources = additional_resources; private_cloud.data_centers = data_centers; + private_cloud.published = 1; var url = 'api/v1/marketplace/private-clouds/'+private_cloud.live_service_id; diff --git a/marketplace/code/ui/admin/js/public_cloud.js b/marketplace/code/ui/admin/js/public_cloud.js index b81adaf..595fa17 100644 --- a/marketplace/code/ui/admin/js/public_cloud.js +++ b/marketplace/code/ui/admin/js/public_cloud.js @@ -120,6 +120,7 @@ jQuery(document).ready(function($){ public_cloud.regional_support = regional_support; public_cloud.additional_resources = additional_resources; public_cloud.data_centers = data_centers; + public_cloud.published = 0; var type = public_cloud.id > 0 ?'PUT':'POST'; @@ -179,6 +180,127 @@ jQuery(document).ready(function($){ return false; }); + $('.preview-public_cloud').click(function(event){ + var button = $(this); + if(button.prop('disabled')){ + return false; + } + event.preventDefault(); + event.stopPropagation(); + var form_validator = form.marketplace_type_header('getFormValidator'); + form_validator.settings.ignore = ".add-comtrol"; + var is_valid = form.valid(); + if(!is_valid) return false; + form_validator.resetForm(); + var additional_resources = $("#additional-resources-form").additional_resources('serialize'); + var regional_support = $("#support-channels-form").support_channels('serialize'); + var capabilities = $("#components_form").components('serialize'); + var guest_os = $("#guest_os_form").guest_os('serialize'); + var hyper_visors = $("#hypervisors_form").hypervisors('serialize'); + var videos = $("#videos-form").videos('serialize'); + var data_centers = $("#data-centers-form").datacenter_locations('serialize'); + var pricing_schemas = $("#pricing_schema_form").pricing_schemas('serialize'); + var is_pdf = $(this).hasClass('pdf'); + + if(additional_resources !== false && + regional_support !== false && + capabilities !== false && + guest_os !== false && + hyper_visors !== false && + videos !== false && + data_centers !== false && + pricing_schemas !== false + ){ + + ajaxIndicatorStart('saving data.. please wait..'); + + //create public_cloud object and POST it + var public_cloud = {}; + public_cloud.id = parseInt($("#id",form).val()); + public_cloud.live_service_id = parseInt($("#live_id",form).val()); + public_cloud.company_id = parseInt($("#company_id",form).val()); + public_cloud.name = $("#name",form).val(); + public_cloud.overview = $("#overview",form).val(); + public_cloud.call_2_action_uri = $("#call_2_action_uri",form).val(); + public_cloud.active = $('#active',form).is(":checked"); + public_cloud.videos = videos; + public_cloud.hypervisors = hyper_visors; + public_cloud.guest_os = guest_os; + public_cloud.capabilities = capabilities; + for(var i in public_cloud.capabilities){ + var c = public_cloud.capabilities[i]; + c.pricing_schemas = pricing_schemas; + } + public_cloud.regional_support = regional_support; + public_cloud.additional_resources = additional_resources; + public_cloud.data_centers = data_centers; + public_cloud.published = 0; + + + var type = public_cloud.id > 0 ?'PUT':'POST'; + + $('.save-public-cloud').prop('disabled',true); + + + $(this).geocoding({ + requests:public_cloud.data_centers.locations, + buildGeoRequest:function(location){ + var restrictions = { + locality: location.city, + country:location.country + }; + if(location.state!=''){ + restrictions.administrativeArea = location.state; + } + var request = {componentRestrictions:restrictions}; + return request; + }, + postProcessRequest:function(location, lat, lng){ + location.lat = lat; + location.lng = lng; + }, + processFinished:function(){ + $.ajax({ + type: type, + url: 'api/v1/marketplace/public-clouds', + data: JSON.stringify(public_cloud), + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (data,textStatus,jqXHR) { + $('.publish-public-cloud').prop('disabled',false); + $('.save-public-cloud').prop('disabled',false); + ajaxIndicatorStop(); + var draft_id = (public_cloud.id > 0) ? public_cloud.id : data; + $("#id",form).val(draft_id); + + if (is_pdf) { + window.location = product_url+'/'+draft_id+'/draft_pdf'; + } else { + window.open(product_url+'/'+draft_id+'/draft_preview','_blank'); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + ajaxIndicatorStop(); + $('.save-public-cloud').prop('disabled',false); + ajaxError(jqXHR, textStatus, errorThrown); + } + }); + }, + cancelProcess:function(){ + ajaxIndicatorStop(); + $('.save-public-cloud').prop('disabled',false); + }, + errorMessage:function(location){ + return 'data center location: address ( city:'+location.city+',state: '+location.state+', country:'+location.country+' )'; + } + }); + + + } + + return false; + }); + $('.publish-public-cloud').click(function(event){ var button = $(this); if(button.prop('disabled')){ @@ -232,6 +354,7 @@ jQuery(document).ready(function($){ public_cloud.regional_support = regional_support; public_cloud.additional_resources = additional_resources; public_cloud.data_centers = data_centers; + public_cloud.published = 0; var url = 'api/v1/marketplace/public-clouds/'+public_cloud.live_service_id; diff --git a/marketplace/code/ui/frontend/css/marketplace.css b/marketplace/code/ui/frontend/css/marketplace.css index 51a01bf..f260ed8 100644 --- a/marketplace/code/ui/frontend/css/marketplace.css +++ b/marketplace/code/ui/frontend/css/marketplace.css @@ -490,7 +490,12 @@ h1.marketplace a,h1.marketplace a.visited{ background:url("/marketplace/code/ui/frontend/images/api/full.png") no-repeat scroll center center rgba(0,0,0,0); display:inline-block; height:20px; - text-indent:-3000px; + color: black; + /*text-indent:-3000px; uncomment this to hide text inside icon*/ + font-size: 7px; + text-align: center; + line-height: 19px; + font-weight: bold; width:20px; } diff --git a/marketplace/code/ui/frontend/js/openstack.implementation.capabilities.js b/marketplace/code/ui/frontend/js/openstack.implementation.capabilities.js index 91470d6..9d0dd23 100644 --- a/marketplace/code/ui/frontend/js/openstack.implementation.capabilities.js +++ b/marketplace/code/ui/frontend/js/openstack.implementation.capabilities.js @@ -28,7 +28,7 @@ level = 'none'; else if(coverage>0 && coverage <= 50) level = 'partial'; - td.append(''+level+''); + td.append(''+coverage+'%'); }); } } diff --git a/marketplace/templates/Layout/MarketPlaceAdminPage_appliance.ss b/marketplace/templates/Layout/MarketPlaceAdminPage_appliance.ss index c323e97..2bf781a 100644 --- a/marketplace/templates/Layout/MarketPlaceAdminPage_appliance.ss +++ b/marketplace/templates/Layout/MarketPlaceAdminPage_appliance.ss @@ -3,15 +3,20 @@