Skip to content

Commit 6fe4b18

Browse files
authored
Merge pull request #52 from umbraco/v10/feature/activecampaign-integration
V10/feature/activecampaign integration
2 parents 77b0994 + 05e2ecb commit 6fe4b18

27 files changed

+652
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
using Umbraco.Cms.Core.Composing;
4+
using Umbraco.Cms.Core.DependencyInjection;
5+
using Umbraco.Cms.Integrations.Crm.ActiveCampaign.Configuration;
6+
7+
namespace Umbraco.Cms.Integrations.Crm.ActiveCampaign
8+
{
9+
public class ActiveCampaignComposer : IComposer
10+
{
11+
public void Compose(IUmbracoBuilder builder)
12+
{
13+
var options = builder.Services.AddOptions<ActiveCampaignSettings>()
14+
.Bind(builder.Config.GetSection(Constants.SettingsPath));
15+
16+
builder.Services
17+
.AddHttpClient(Constants.FormsHttpClient, client =>
18+
{
19+
client.BaseAddress = new Uri(
20+
$"{builder.Config.GetSection(Constants.SettingsPath)[nameof(ActiveCampaignSettings.BaseUrl)]}/api/3/forms");
21+
client.DefaultRequestHeaders
22+
.Add("Api-Token", builder.Config.GetSection(Constants.SettingsPath)[nameof(ActiveCampaignSettings.ApiKey)]);
23+
});
24+
25+
}
26+
27+
}
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Umbraco.Cms.Core.PropertyEditors;
2+
3+
namespace Umbraco.Cms.Integrations.Crm.ActiveCampaign
4+
{
5+
public class ActiveCampaignFormPickerConfiguration
6+
{
7+
[ConfigurationField("configuration",
8+
name: "Configuration",
9+
view: "~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/views/configuration.html",
10+
Description = "API Access")]
11+
public bool IsAccessGranted { get; set; }
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Umbraco.Cms.Core.IO;
2+
using Umbraco.Cms.Core.PropertyEditors;
3+
using Umbraco.Cms.Core.Services;
4+
5+
namespace Umbraco.Cms.Integrations.Crm.ActiveCampaign
6+
{
7+
public class ActiveCampaignFormPickerConfigurationEditor : ConfigurationEditor<ActiveCampaignFormPickerConfiguration>
8+
{
9+
public ActiveCampaignFormPickerConfigurationEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser)
10+
: base(ioHelper, editorConfigurationParser)
11+
{
12+
13+
}
14+
}
15+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Umbraco.Cms.Core.IO;
2+
using Umbraco.Cms.Core.PropertyEditors;
3+
using Umbraco.Cms.Core.Services;
4+
5+
namespace Umbraco.Cms.Integrations.Crm.ActiveCampaign
6+
{
7+
[DataEditor(
8+
alias: Constants.PropertyEditorAlias,
9+
name: "ActiveCampaign Form Picker",
10+
view: "~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/views/formpicker.html",
11+
Group = Core.Constants.PropertyEditors.Groups.Pickers,
12+
Icon = "icon-activecampaign")]
13+
public class ActiveCampaignFormPickerPropertyEditor : DataEditor
14+
{
15+
private readonly IIOHelper _ioHelper;
16+
17+
private readonly IEditorConfigurationParser _editorConfigurationParser;
18+
19+
public ActiveCampaignFormPickerPropertyEditor(
20+
IDataValueEditorFactory dataValueEditorFactory,
21+
IIOHelper ioHelper,
22+
IEditorConfigurationParser editorConfigurationParser)
23+
: base(dataValueEditorFactory)
24+
{
25+
_ioHelper = ioHelper;
26+
27+
_editorConfigurationParser = editorConfigurationParser;
28+
}
29+
30+
protected override IConfigurationEditor CreateConfigurationEditor() =>
31+
new ActiveCampaignFormPickerConfigurationEditor(_ioHelper, _editorConfigurationParser);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@using Umbraco.Cms.Integrations.Crm.ActiveCampaign.Models.ViewModels;
2+
3+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<FormViewModel>
4+
5+
6+
<div class="[email protected]"></div>
7+
<script src="https://@(Model.Account).activehosted.com/f/[email protected]" type="text/javascript" charset="utf-8"></script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.acOverlayGroup {
2+
margin-bottom: 1rem;
3+
}
4+
5+
.acFormsList {
6+
list-style-type: none;
7+
margin: 0;
8+
margin-top: 10px;
9+
}
10+
11+
.acFormsList a {
12+
display: block;
13+
position: relative;
14+
padding: .25rem .375rem .25rem 1.5rem;
15+
}
16+
17+
.acFormsList a:hover {
18+
text-decoration: none;
19+
background-color: #eee;
20+
}
21+
22+
.acFormsList a i {
23+
position: absolute;
24+
top: .4rem;
25+
left: .25rem;
26+
}
27+
28+
.acFormsList .formLine {
29+
display: block;
30+
}
31+
32+
.acSettings {
33+
padding-top: 4px;
34+
}
35+
36+
.acFormSelected {
37+
background: #fee4e1;
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
angular.module('umbraco.resources').factory('umbracoCmsIntegrationsCrmActiveCampaignResource',
2+
function ($http, umbRequestHelper) {
3+
4+
const apiEndpoint = "backoffice/UmbracoCmsIntegrationsCrmActiveCampaign/Forms";
5+
6+
return {
7+
checkApiAccess: function () {
8+
return umbRequestHelper.resourcePromise(
9+
$http.get(`${apiEndpoint}/CheckApiAccess`),
10+
"Failed");
11+
},
12+
getForms: function () {
13+
return umbRequestHelper.resourcePromise(
14+
$http.get(`${apiEndpoint}/GetForms`),
15+
"Failed");
16+
},
17+
getForm: function (id) {
18+
return umbRequestHelper.resourcePromise(
19+
$http.get(`${apiEndpoint}/GetForm?id=${id}`),
20+
"Failed");
21+
}
22+
};
23+
}
24+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function configurationController($scope, notificationsService, umbracoCmsIntegrationsCrmActiveCampaignResource) {
2+
var vm = this;
3+
4+
umbracoCmsIntegrationsCrmActiveCampaignResource.checkApiAccess().then(function (response) {
5+
6+
if (response.isApiConfigurationValid)
7+
vm.account = response.account;
8+
9+
vm.status = response.isApiConfigurationValid
10+
? "Connected. Account name: "
11+
: "Invalid API configuration."
12+
});
13+
}
14+
15+
angular.module("umbraco")
16+
.controller("Umbraco.Cms.Integrations.Crm.ActiveCampaign.ConfigurationController", configurationController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
function formPickerController($scope, editorService, notificationsService, umbracoCmsIntegrationsCrmActiveCampaignResource) {
2+
3+
var vm = this;
4+
5+
vm.loading = false;
6+
vm.searchTerm = "";
7+
8+
vm.selectedForm = {};
9+
10+
vm.status = "";
11+
12+
umbracoCmsIntegrationsCrmActiveCampaignResource.checkApiAccess().then(function (response) {
13+
vm.isApiConfigurationValid = response.isApiConfigurationValid;
14+
if (response.isApiConfigurationValid) {
15+
if ($scope.model.value) {
16+
getFormDetails($scope.model.value);
17+
}
18+
19+
loadForms();
20+
}
21+
else {
22+
vm.status = "Invalid API configuration.";
23+
}
24+
});
25+
26+
vm.saveForm = function (formId) {
27+
$scope.model.value = formId;
28+
29+
getFormDetails(formId);
30+
}
31+
32+
vm.removeForm = function () {
33+
$scope.model.value = null;
34+
vm.selectedForm = {};
35+
}
36+
37+
vm.openActiveCampaignFormPickerOverlay = function () {
38+
39+
var options = {
40+
title: "ActiveCampaign Forms",
41+
subtitle: "Select a form",
42+
view: "/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/views/formpickereditor.html",
43+
size: "medium",
44+
selectForm: function (form) {
45+
46+
if (form.id !== undefined) {
47+
vm.saveForm(form.id);
48+
}
49+
50+
editorService.close();
51+
},
52+
close: function () {
53+
editorService.close();
54+
}
55+
};
56+
57+
editorService.open(options);
58+
};
59+
60+
function getFormDetails(id) {
61+
vm.loading = true;
62+
umbracoCmsIntegrationsCrmActiveCampaignResource.getForm(id).then(function (response) {
63+
if (response.message && response.message.length > 0)
64+
vm.status = response.message;
65+
else
66+
vm.selectedForm = response.form;
67+
68+
vm.loading = false;
69+
});
70+
}
71+
72+
function loadForms() {
73+
vm.loading = true;
74+
umbracoCmsIntegrationsCrmActiveCampaignResource.getForms().then(function (response) {
75+
vm.formsList = [];
76+
77+
if (response.forms != null) {
78+
response.forms.forEach(item => {
79+
vm.formsList.push({
80+
id: item.id,
81+
name: item.name
82+
});
83+
});
84+
}
85+
else vm.status = response.message;
86+
87+
vm.loading = false;
88+
});
89+
}
90+
}
91+
92+
angular.module("umbraco")
93+
.controller("Umbraco.Cms.Integrations.Crm.ActiveCampaign.FormPickerController", formPickerController);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"javascript": [
3+
"~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/js/configuration.controller.js",
4+
"~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/js/formpicker.controller.js",
5+
"~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/js/activecampaign.resource.js",
6+
"~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/js/configuration.directive.js"
7+
],
8+
"css": [
9+
"~/App_Plugins/UmbracoCms.Integrations/Crm/ActiveCampaign/css/styles.css"
10+
]
11+
}

0 commit comments

Comments
 (0)