Skip to content

Commit f47e280

Browse files
author
Warren Buckley
authored
Merge pull request #1 from umbraco/feature/tidy-up-and-tweaks
Moved API key to config and a few other minor updates
2 parents 0fd1d3e + a312ebc commit f47e280

26 files changed

+1378
-208
lines changed

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,14 @@ FodyWeavers.xsd
385385

386386
# JetBrains Rider
387387
.idea/
388-
*.sln.iml
388+
*.sln.iml
389+
390+
# Solution specific
391+
src/Umbraco.Forms.Extensions.TestSite/App_Data
392+
src/Umbraco.Forms.Extensions.TestSite/App_Plugins
393+
src/Umbraco.Forms.Extensions.TestSite/config
394+
src/Umbraco.Forms.Extensions.TestSite/css
395+
src/Umbraco.Forms.Extensions.TestSite/Media
396+
src/Umbraco.Forms.Extensions.TestSite/scripts
397+
src/Umbraco.Forms.Extensions.TestSite/Umbraco
398+
src/Umbraco.Forms.Extensions.TestSite/Views

src/Umbraco.Forms.Extensions.Crm.Hubspot/App_Plugins/UmbracoFormsExtensions/Hubspot/hubspot-field-mapper-template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div>
2+
<!--
23
<pre>{{ vm.setting | json }}</pre>
34
<pre>{{ vm.mappings | json }}</pre>
5+
-->
46

57
<div class="umb-forms-mappings" ng-if="vm.mappings.length > 0 && vm.hubspotFields.length > 0">
68

@@ -18,7 +20,6 @@
1820
ng-options="field.id as field.value for field in vm.fields"
1921
ng-model="mapping.formField"
2022
ng-change="vm.stringifyValue()">
21-
<option value="">Map form field</option>
2223
</select>
2324
</div>
2425

@@ -27,7 +28,6 @@
2728
ng-options="field.value as field.name for field in vm.hubspotFields track by field.value"
2829
ng-model="mapping.hubspotField"
2930
ng-change="vm.stringifyValue()">
30-
<option value="">Map hubspot field</option>
3131
</select>
3232
</div>
3333

src/Umbraco.Forms.Extensions.Crm.Hubspot/App_Plugins/UmbracoFormsExtensions/Hubspot/hubspot.resource.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
[{ packageGuid: id }])),
1111
'Failed to download package with guid ' + id);
1212
},
13-
getAllProperties: function (apiKey) {
13+
getAllProperties: function () {
1414
return umbRequestHelper.resourcePromise(
1515
$http.get(
1616
umbRequestHelper.getApiUrl(
1717
"umbracoFormsExtensionsHubspotBaseUrl",
18-
"GetAllProperties",
19-
[{ apiKey: apiKey }])),
18+
"GetAllProperties")),
2019
'Failed to get Hubspot Properties');
2120
},
2221
};

src/Umbraco.Forms.Extensions.Crm.Hubspot/App_Plugins/UmbracoFormsExtensions/Hubspot/hubspotfields.component.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,8 @@ function HubSpotFieldsController($scope, $compile, $element, $routeParams, hubsp
3838
vm.fields = response.data;
3939
});
4040

41-
// TODO: Remove hard coded API key & remember to revoke it later on
42-
// Need to get API key from other field
43-
// May need to do parent.parent scope traversal - YUK :S
44-
45-
// Niels recommendation that this is a component & be able to get the data from a parent item
46-
// Using require (but finding which one it is I have no idea)
47-
48-
hubspotResource.getAllProperties('6a488b25-b7e7-489d-ad45-2da52a878ff9').then(function (response) {
49-
vm.hubspotFields = response.map(x =>{
41+
hubspotResource.getAllProperties().then(function (response) {
42+
vm.hubspotFields = response.map(x => {
5043
return {
5144
value: x.name,
5245
name: x.label,
@@ -62,7 +55,7 @@ function HubSpotFieldsController($scope, $compile, $element, $routeParams, hubsp
6255
return x.value === value;
6356
});
6457

65-
if(item){
58+
if (item) {
6659
return item.description;
6760
}
6861

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Umbraco.Forms.Extensions.Crm.Hubspot.Models.Responses;
4+
using Umbraco.Forms.Extensions.Crm.Hubspot.Services;
5+
using Umbraco.Web.Editors;
6+
using Umbraco.Web.Mvc;
7+
8+
namespace Umbraco.Forms.Extensions.Crm.Hubspot.Controllers
9+
{
10+
[PluginController("FormsExtensions")]
11+
public class HubspotController : UmbracoAuthorizedJsonController
12+
{
13+
private readonly IContactService _contactService;
14+
15+
public HubspotController(IContactService contactService)
16+
{
17+
_contactService = contactService;
18+
}
19+
20+
/// <summary>
21+
/// ~/Umbraco/[YourAreaName]/[YourControllerName]
22+
/// ~/Umbraco/FormsExtensions/Hubspot/GetAllProperties
23+
/// </summary>
24+
/// <returns></returns>
25+
public async Task<IEnumerable<Property>> GetAllProperties() => await _contactService.GetContactProperties();
26+
}
27+
}

src/Umbraco.Forms.Extensions.Crm.Hubspot/HubspotComponent.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
using System.Web.Mvc;
55
using System.Web.Routing;
66
using Umbraco.Core.Composing;
7+
using Umbraco.Forms.Extensions.Crm.Hubspot.Controllers;
78
using Umbraco.Web;
89
using Umbraco.Web.JavaScript;
910

1011
namespace Umbraco.Forms.Extensions.Crm.Hubspot
1112
{
12-
public class HubspotComposer : ComponentComposer<HubspotComponent>, IUserComposer { }
13-
1413
public class HubspotComponent : IComponent
1514
{
1615
public void Initialize()
@@ -33,7 +32,7 @@ private void ServerVariablesParser_Parsing(object sender, Dictionary<string, obj
3332
if (HttpContext.Current == null) throw new InvalidOperationException("HttpContext is null");
3433
var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));
3534

36-
umbracoUrls["umbracoFormsExtensionsHubspotBaseUrl"] = urlHelper.GetUmbracoApiServiceBaseUrl<HubspotController>(controller => controller.GetAllProperties(null));
35+
umbracoUrls["umbracoFormsExtensionsHubspotBaseUrl"] = urlHelper.GetUmbracoApiServiceBaseUrl<HubspotController>(controller => controller.GetAllProperties());
3736
}
3837

3938
public void Terminate()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Umbraco.Core;
2+
using Umbraco.Core.Composing;
3+
using Umbraco.Forms.Extensions.Crm.Hubspot.Services;
4+
5+
namespace Umbraco.Forms.Extensions.Crm.Hubspot
6+
{
7+
public class HubspotComposer : IUserComposer
8+
{
9+
public void Compose(Composition composition)
10+
{
11+
composition.Register<IContactService, HubspotContactService>(Lifetime.Singleton);
12+
13+
composition.Components().Append<HubspotComponent>();
14+
}
15+
}
16+
}

src/Umbraco.Forms.Extensions.Crm.Hubspot/HubspotController.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)