Skip to content

Commit

Permalink
Add support for macOS builds
Browse files Browse the repository at this point in the history
- Update dependencies
- Small refactorings
- Add publish run scripts
  • Loading branch information
eXpl0it3r committed Apr 9, 2022
1 parent e74694b commit 782a58e
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .run/Publish for Windows.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Publish for Windows" type="DotNetFolderPublish" factoryName="Publish to folder">
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" ready_to_run="true" runtime="win-x64" self_contained="true" target_folder="$PROJECT_DIR$/bin/Publish/dev.duerrenberger.clockify.sdPlugin/Windows" target_framework="net5.0-windows" trim_unused_assemblies="true" uuid_high="3080948972394662106" uuid_low="-5338808962525310719" />
<method v="2" />
</configuration>
</component>
6 changes: 6 additions & 0 deletions .run/Publish for macOS.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Publish for macOS" type="DotNetFolderPublish" factoryName="Publish to folder">
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" ready_to_run="true" runtime="osx-x64" self_contained="true" target_folder="$PROJECT_DIR$/bin/Publish/dev.duerrenberger.clockify.sdPlugin/macOS" target_framework="net5.0-windows" trim_unused_assemblies="true" uuid_high="3080948972394662106" uuid_low="-5338808962525310719" />
<method v="2" />
</configuration>
</component>
9 changes: 5 additions & 4 deletions Clockify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<CodeAnalysisRuleSet>StyleCop.ruleset</CodeAnalysisRuleSet>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AssemblyVersion>1.3</AssemblyVersion>
<PackageVersion>1.3</PackageVersion>
<AssemblyVersion>1.4</AssemblyVersion>
<PackageVersion>1.4</PackageVersion>
<Title>Clockify</Title>
<Authors>Lukas Dürrenberger</Authors>
<Description>This plugin allows you to track, start and stop Clockify timers on your Elgato Stream Deck</Description>
Expand All @@ -34,10 +34,11 @@
<PublishDir>bin\Publish\dev.duerrenberger.clockify.sdPlugin\</PublishDir>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Clockify.Net" Version="1.14.0" />
<PackageReference Include="Clockify.Net" Version="2.0.0" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.13" />
<PackageReference Include="NLog" Version="4.7.15" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="streamdeck-client-csharp" Version="4.3.0" />
<PackageReference Include="StreamDeck-Tools" Version="3.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
Expand Down
8 changes: 4 additions & 4 deletions Clockify/ClockifyContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task ToggleTimerAsync(string workspaceName, string projectName = nu
{
UserId = _currentUser.Id,
WorkspaceId = workspace.Id,
Description = timerName,
Description = timerName ?? string.Empty,
Start = DateTimeOffset.UtcNow
};

Expand Down Expand Up @@ -113,7 +113,7 @@ public async Task<TimeEntryDtoImpl> GetRunningTimerAsync(string workspaceName, s

var workspace = _workspaces.Single(w => w.Name == workspaceName);
var timeEntries = await _clockifyClient.FindAllTimeEntriesForUserAsync(workspace.Id, _currentUser.Id, inProgress: true);
if (!timeEntries.IsSuccessful)
if (!timeEntries.IsSuccessful || timeEntries.Data == null)
{
return null;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ private async Task<string> FindOrCreateTaskAsync(WorkspaceDto workspace, Project
{
var taskResponse = await _clockifyClient.FindAllTasksAsync(workspace.Id, project.Id, name: taskName, pageSize: 5000);

if (!taskResponse.IsSuccessful)
if (!taskResponse.IsSuccessful || taskResponse.Data == null)
{
return null;
}
Expand All @@ -244,7 +244,7 @@ private async Task<string> FindOrCreateTaskAsync(WorkspaceDto workspace, Project

var creationResponse = await _clockifyClient.CreateTaskAsync(workspace.Id, project.Id, taskRequest);

if (!creationResponse.IsSuccessful)
if (!creationResponse.IsSuccessful || creationResponse.Data == null)
{
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions Clockify/ToggleAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace Clockify
[PluginActionId("dev.duerrenberger.clockify.toggle")]
public class ToggleAction : PluginBase
{
private static readonly uint InactiveState = 0;
private static readonly uint ActiveState = 1;
private const uint InactiveState = 0;
private const uint ActiveState = 1;

private readonly ClockifyContext _clockifyContext;
private readonly PluginSettings _settings;

Expand Down
38 changes: 30 additions & 8 deletions PropertyInspector/sdtools.common.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// ****************************************************************
// * EasyPI v1.3
// * EasyPI v1.3.3
// * Author: BarRaider
// *
// * JS library to simplify the communication between the
// * Stream Deck's Property Inspector and the plugin.
// *
// * Project page: https://github.com/BarRaider/streamdeck-easypi
// * Support: http://discord.barraider.com
// *
// * Initially forked from Elgato's common.js file
// ****************************************************************

var websocket = null,
Expand Down Expand Up @@ -35,6 +37,7 @@ function connectElgatoStreamDeckSocket(inPort, inUUID, inRegisterEvent, inInfo,
document.dispatchEvent(event);

loadConfiguration(actionInfo.payload.settings);
initPropertyInspector();
}

function websocketOnOpen() {
Expand All @@ -52,16 +55,12 @@ function websocketOnMessage(evt) {
// Received message from Stream Deck
var jsonObj = JSON.parse(evt.data);

if (jsonObj.event === 'sendToPropertyInspector') {
var payload = jsonObj.payload;
loadConfiguration(payload);
}
else if (jsonObj.event === 'didReceiveSettings') {
if (jsonObj.event === 'didReceiveSettings') {
var payload = jsonObj.payload;
loadConfiguration(payload.settings);
}
else {
console.log("Unhandled websocketOnMessage: " + jsonObj.event);
console.log("Ignored websocketOnMessage: " + jsonObj.event);
}
}

Expand Down Expand Up @@ -216,8 +215,31 @@ window.addEventListener('beforeunload', function (e) {
// Don't set a returnValue to the event, otherwise Chromium with throw an error.
});

function prepareDOMElements(baseElement) {
baseElement = baseElement || document;

/**
* You could add a 'label' to a textares, e.g. to show the number of charactes already typed
* or contained in the textarea. This helper updates this label for you.
*/
baseElement.querySelectorAll('textarea').forEach((e) => {
const maxl = e.getAttribute('maxlength');
e.targets = baseElement.querySelectorAll(`[for='${e.id}']`);
if (e.targets.length) {
let fn = () => {
for (let x of e.targets) {
x.textContent = maxl ? `${e.value.length}/${maxl}` : `${e.value.length}`;
}
};
fn();
e.onkeyup = fn;
}
});
}

function initPropertyInspector() {
// Place to add functions
prepareDOMElements(document);
}


Expand Down Expand Up @@ -296,4 +318,4 @@ function fadeColor(col, amt) {
const g = min(255, max((num & 0x0000FF) + amt, 0));
const b = min(255, max(((num >> 8) & 0x00FF) + amt, 0));
return '#' + (g | (b << 8) | (r << 16)).toString(16).padStart(6, 0);
}
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ https://user-images.githubusercontent.com/920861/132741561-6f9f3ff0-a920-408d-82
- Your API Key is likely incorrect
- Why am I not seeing the running timer on my button?
- Make sure you haven't set a title, as this will override any other content
- Make sure the API Key, Workspace name and optional the project and timer name match
- Make sure the API Key, Workspace name and optional the project and timer name
- Why does the timer always start with a negative number?
- This can happen when your local computer time isn't in sync with the Clockify server time
- Make sure you synchronize your clock with a time server
- Why can't I select my Workspace and Project in a dropdown menu?
- Because I was lazy 😅
- IT DOESN'T WORK, WHY?!?
Expand Down
9 changes: 7 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@
"Description": "Stream Deck integration for Clockify, the most popular free time tracker available for an unlimited numbers of users for free.",
"Icon": "Images/clockifyIcon",
"URL": "https://duerrenberger.dev",
"Version": "1.3",
"CodePath": "dev.duerrenberger.clockify",
"Version": "1.4",
"CodePathWin": "Windows/dev.duerrenberger.clockify.exe",
"CodePathMac": "macOS/dev.duerrenberger.clockify",
"Category": "Time Tracking",
"CategoryIcon": "Images/categoryTimerIcon",
"OS": [
{
"Platform": "windows",
"MinimumVersion": "10"
},
{
"Platform": "mac",
"MinimumVersion": "10.11"
}
],
"SDKVersion": 2,
Expand Down

0 comments on commit 782a58e

Please sign in to comment.