Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mschout/gitlab-toggl-timer-api

Microservice to start my toggl timer from a gitlabl issue page
https://github.com/mschout/gitlab-toggl-timer-api

Last synced: about 1 month ago
JSON representation

Microservice to start my toggl timer from a gitlabl issue page

Awesome Lists containing this project

README

        

# What Is This

This is a microservice that can take a URL for a GitLab issue page, figures out the issue number, and starts your Toggl
timer using a project that has a name like: `12345 - Issue Title`. Where the gitlab issue number is `12345`, and the
title of the issue in gitlab is `Issue Title`.

If no such project exists in toggl that starts with `12345 -`, then a new toggle project will be created automatically.
This can be paird with a bookmarklet to make it easy to start your toggl timer from a gitlab issue page. This is
possibly not useful to anyone except myself.

# Requirements

Docker, Docker Compose.

If you want to compile this outside of docker you need Java 22.

# How to run it

1. Clone the repo
2. Build the docker image with `./scripts/build-docker-image`
3. Define the necessary environment variables for your toggl and gitlab accounts (see below)
4. Run `docker compose up -d`

The API will be available at http://localhost:8080 and the Swagger UI is available at
http://localhost:8080/swagger-ui.html

# Environment Variables

You must set the following environment variables for `docker compose up` to work:

- `GITLAB_ACCESS_TOKEN` - Your GitLab personal access token
- `TOGGL_API_KEY` - Your Toggl API key

# Bookmarklets

In all bookmarks, you must use your own Toggl `workspaceId` and `clientId`
values.

The following bookmarklet will create a toggle project for the current gitlab
issue page, or return the existing project if it already exists:

```
javascript:(function(){
window.open("http://localhost:8080/timer/create-project?issueUrl="
+ encodeURIComponent(window.location.href)
+ "&workspaceId=12345&clientId=12345",
"_blank");
})();
```

The following bookmarklet will start a timer for the current gitlab issue page, creating the issue on toggl if
necessary:

```
javascript:(function(){
window.open("http://localhost:8080/timer/start?issueUrl="
+ encodeURIComponent(window.location.href)
+ "&workspaceId=12345&clientId=12345",
"_blank");
})();
```

# Dev Notes

This project uses AspectJ, mainly so we can use things like `@Cacheable` on
internal self-invocations. In IntelliJ, you will likely get compile failures
unless you do do the following:

- Open File > Project Structure
- In the dialog that opens, go to Modules > AspectJ
- Under Compiler tick the box for "Post-compile weave mode". This ensures
lombok runs before the AspectJ compiler