Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Core/Resgrid.Config/LinksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public static class LinksConfig

public static string PolrAccessToken = "";
public static string PolrApi = @"";

public static string KuttAccessToken = "";
public static string KuttApi = @"";
}

/// <summary>
Expand All @@ -15,6 +18,7 @@ public static class LinksConfig
public enum LinksProviderTypes
{
Bitly = 0,
Polr = 1
Polr = 1,
Kutt = 2
}
}
44 changes: 44 additions & 0 deletions Providers/Resgrid.Providers.Marketing/ShortenUrlProvider.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
//https://github.com/sonnd9x/Bitly.Net/blob/master/Bitly.Net/BitlyAPI.cs

using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using MongoDB.Driver;
using Newtonsoft.Json;
using Resgrid.Framework;
using Resgrid.Model.Providers;

namespace Resgrid.Providers.Marketing
Expand Down Expand Up @@ -96,6 +99,47 @@ public async Task<string> Shorten(string long_url)
}
}
}
else if (Config.SystemBehaviorConfig.LinkProviderType == Config.LinksProviderTypes.Kutt)
{
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("X-API-KEY", Config.LinksConfig.KuttAccessToken);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

var requestBody = new
{
target = long_url,
reuse = true, // resuse the same short url for the same target
//customSlug = customSlug,
//domain = domain
};

var jsonContent = JsonConvert.SerializeObject(requestBody);
var content = new StringContent(jsonContent, System.Text.Encoding.UTF8, "application/json");

// Make POST request to the Kutt API
var response = await client.PostAsync(Config.LinksConfig.KuttApi + "/api/v2/links", content);

if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
dynamic result = JsonConvert.DeserializeObject(responseContent);
return result.link; // Assuming the API returns the short URL in a 'link' property
}
else
{
var error = await response.Content.ReadAsStringAsync();
Logging.LogError($"Failed to create Kutt short URL: {error}");
}
}
}
catch (Exception ex)
{
Logging.LogException(ex);
}
}

return "Can not short URL";
}
Expand Down
11 changes: 0 additions & 11 deletions Web/Resgrid.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@
{
@RenderSection("Styles", required: false)
}

@if (!String.IsNullOrWhiteSpace(Resgrid.Config.TelemetryConfig.PostHogUrl) && !String.IsNullOrWhiteSpace(Resgrid.Config.TelemetryConfig.PostHogApiKey))
{
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug getPageViewId captureTraceFeedback captureTraceMetric".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('@Resgrid.Config.TelemetryConfig.PostHogApiKey', {
api_host: '@Resgrid.Config.TelemetryConfig.PostHogUrl',
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
})
</script>
}
</head>
<body id="page-top" class="landing-page">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var resgrid;

$('.table').DataTable();
$('#tree').bstreeview({ data: treeData });
$('input[type="checkbox"]').click(evaluate);
$('#TreeGroup_-1').css("font-weight", "bold");

$(document).on('click', '.list-group-item', function (e) {
Expand Down
Loading