From 782a58e960917e69b9629d630f3b7b5b27cd9fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sat, 9 Apr 2022 13:18:25 +0200 Subject: [PATCH] Add support for macOS builds - Update dependencies - Small refactorings - Add publish run scripts --- .run/Publish for Windows.run.xml | 6 +++++ .run/Publish for macOS.run.xml | 6 +++++ Clockify.csproj | 9 ++++--- Clockify/ClockifyContext.cs | 8 +++--- Clockify/ToggleAction.cs | 5 ++-- PropertyInspector/sdtools.common.js | 38 +++++++++++++++++++++++------ README.md | 5 +++- manifest.json | 9 +++++-- 8 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 .run/Publish for Windows.run.xml create mode 100644 .run/Publish for macOS.run.xml diff --git a/.run/Publish for Windows.run.xml b/.run/Publish for Windows.run.xml new file mode 100644 index 0000000..5b44495 --- /dev/null +++ b/.run/Publish for Windows.run.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.run/Publish for macOS.run.xml b/.run/Publish for macOS.run.xml new file mode 100644 index 0000000..d4bafef --- /dev/null +++ b/.run/Publish for macOS.run.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Clockify.csproj b/Clockify.csproj index 13d2894..6a279b0 100644 --- a/Clockify.csproj +++ b/Clockify.csproj @@ -11,8 +11,8 @@ StyleCop.ruleset false AllEnabledByDefault - 1.3 - 1.3 + 1.4 + 1.4 Clockify Lukas Dürrenberger This plugin allows you to track, start and stop Clockify timers on your Elgato Stream Deck @@ -34,10 +34,11 @@ bin\Publish\dev.duerrenberger.clockify.sdPlugin\ - + - + + diff --git a/Clockify/ClockifyContext.cs b/Clockify/ClockifyContext.cs index af1d7b9..15f1680 100644 --- a/Clockify/ClockifyContext.cs +++ b/Clockify/ClockifyContext.cs @@ -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 }; @@ -113,7 +113,7 @@ public async Task 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; } @@ -227,7 +227,7 @@ private async Task 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; } @@ -244,7 +244,7 @@ private async Task 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; } diff --git a/Clockify/ToggleAction.cs b/Clockify/ToggleAction.cs index 1013e3e..4361755 100644 --- a/Clockify/ToggleAction.cs +++ b/Clockify/ToggleAction.cs @@ -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; diff --git a/PropertyInspector/sdtools.common.js b/PropertyInspector/sdtools.common.js index c5c6458..1a47181 100644 --- a/PropertyInspector/sdtools.common.js +++ b/PropertyInspector/sdtools.common.js @@ -1,5 +1,5 @@ // **************************************************************** -// * EasyPI v1.3 +// * EasyPI v1.3.3 // * Author: BarRaider // * // * JS library to simplify the communication between the @@ -7,6 +7,8 @@ // * // * Project page: https://github.com/BarRaider/streamdeck-easypi // * Support: http://discord.barraider.com +// * +// * Initially forked from Elgato's common.js file // **************************************************************** var websocket = null, @@ -35,6 +37,7 @@ function connectElgatoStreamDeckSocket(inPort, inUUID, inRegisterEvent, inInfo, document.dispatchEvent(event); loadConfiguration(actionInfo.payload.settings); + initPropertyInspector(); } function websocketOnOpen() { @@ -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); } } @@ -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); } @@ -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); -} +} \ No newline at end of file diff --git a/README.md b/README.md index f7f5ff1..7d78fd9 100644 --- a/README.md +++ b/README.md @@ -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?!? diff --git a/manifest.json b/manifest.json index 590455b..be4e8db 100644 --- a/manifest.json +++ b/manifest.json @@ -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,