diff --git a/Clockify.csproj b/Clockify.csproj
index c492c1e..eee9871 100644
--- a/Clockify.csproj
+++ b/Clockify.csproj
@@ -10,8 +10,8 @@
StyleCop.ruleset
false
AllEnabledByDefault
- 1.4
- 1.4
+ 1.5
+ 1.5
Clockify
Lukas Dürrenberger
This plugin allows you to track, start and stop Clockify timers on your Elgato Stream Deck
diff --git a/Clockify/ClockifyContext.cs b/Clockify/ClockifyContext.cs
index 15f1680..42eae7d 100644
--- a/Clockify/ClockifyContext.cs
+++ b/Clockify/ClockifyContext.cs
@@ -15,6 +15,7 @@ namespace Clockify
public class ClockifyContext
{
private string _apiKey = string.Empty;
+ private string _serverUrl = string.Empty;
private ClockifyClient _clockifyClient;
private CurrentUserDto _currentUser = new ();
private Dictionary> _projects = new ();
@@ -127,18 +128,25 @@ public async Task GetRunningTimerAsync(string workspaceName, s
return string.IsNullOrEmpty(timeName) ? timeEntries.Data.FirstOrDefault(t => t.ProjectId == project.Id) : timeEntries.Data.FirstOrDefault(t => t.ProjectId == project.Id && t.Description == timeName);
}
- public async Task SetApiKeyAsync(string apiKey)
+ public async Task SetApiKeyAsync(string serverUrl, string apiKey)
{
- if (_clockifyClient == null || apiKey != _apiKey)
+ if (_clockifyClient == null || apiKey != _apiKey || serverUrl != _serverUrl)
{
+ if (!Uri.IsWellFormedUriString(serverUrl, UriKind.Absolute))
+ {
+ Logger.Instance.LogMessage(TracingLevel.WARN, "Server URL is invalid");
+ return false;
+ }
+
if (apiKey.Length != 48)
{
Logger.Instance.LogMessage(TracingLevel.WARN, "Invalid API key format");
return false;
}
+ _serverUrl = serverUrl;
_apiKey = apiKey;
- _clockifyClient = new ClockifyClient(_apiKey);
+ _clockifyClient = new ClockifyClient(_apiKey, serverUrl);
}
if (await TestConnectionAsync())
diff --git a/Clockify/PluginSettings.cs b/Clockify/PluginSettings.cs
index d27d765..93fc038 100644
--- a/Clockify/PluginSettings.cs
+++ b/Clockify/PluginSettings.cs
@@ -18,5 +18,8 @@ public class PluginSettings
[JsonProperty(PropertyName = "timerName")]
public string TimeName { get; set; } = string.Empty;
+
+ [JsonProperty(PropertyName = "serverUrl")]
+ public string ServerUrl { get; set; } = "https://api.clockify.me/api/v1";
}
}
\ No newline at end of file
diff --git a/Clockify/ToggleAction.cs b/Clockify/ToggleAction.cs
index 4361755..46c53dd 100644
--- a/Clockify/ToggleAction.cs
+++ b/Clockify/ToggleAction.cs
@@ -77,7 +77,7 @@ public override async void OnTick()
}
else if (_settings.ApiKey.Length == 48)
{
- await _clockifyContext.SetApiKeyAsync(_settings.ApiKey);
+ await _clockifyContext.SetApiKeyAsync(_settings.ServerUrl, _settings.ApiKey);
}
}
@@ -86,7 +86,7 @@ public override async void ReceivedSettings(ReceivedSettingsPayload payload)
Tools.AutoPopulateSettings(_settings, payload.Settings);
Logger.Instance.LogMessage(TracingLevel.INFO, $"Settings Received: {_settings}");
await SaveSettings();
- await _clockifyContext.SetApiKeyAsync(_settings.ApiKey);
+ await _clockifyContext.SetApiKeyAsync(_settings.ServerUrl, _settings.ApiKey);
}
public override void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload)
diff --git a/PropertyInspector/PluginActionPI.html b/PropertyInspector/PluginActionPI.html
index 03d9f29..14dac19 100644
--- a/PropertyInspector/PluginActionPI.html
+++ b/PropertyInspector/PluginActionPI.html
@@ -32,6 +32,10 @@
Timer Name
+