update module to newer and more aligned to template structure
This commit is contained in:
@@ -15,4 +15,3 @@ jobs:
|
|||||||
uses: bitfocus/actions/.github/workflows/module-checks.yaml@main
|
uses: bitfocus/actions/.github/workflows/module-checks.yaml@main
|
||||||
# with:
|
# with:
|
||||||
# upload-artifact: true # uncomment this to upload the built package as an artifact to this workflow that you can download and share with others
|
# upload-artifact: true # uncomment this to upload the built package as an artifact to this workflow that you can download and share with others
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ name: CI
|
|||||||
on:
|
on:
|
||||||
# Triggers the workflow on push or pull request events but only for the main branch
|
# Triggers the workflow on push or pull request events but only for the main branch
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -28,4 +28,3 @@ jobs:
|
|||||||
# Runs a set of commands using the runners shell
|
# Runs a set of commands using the runners shell
|
||||||
- name: Prettier Action
|
- name: Prettier Action
|
||||||
uses: creyD/prettier_action@v3.3
|
uses: creyD/prettier_action@v3.3
|
||||||
|
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,5 +1,8 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
.nova
|
|
||||||
archive
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/pkg
|
||||||
|
/pkg.tgz
|
||||||
|
/dist
|
||||||
|
DEBUG-*
|
||||||
|
/.yarn
|
||||||
1
.yarnrc.yml
Normal file
1
.yarnrc.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
nodeLinker: node-modules
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
# companion-module-toggl-track
|
# companion-module-toggl-track
|
||||||
|
|
||||||
See [HELP.md](./HELP.md) and [LICENSE](./LICENSE)
|
See [HELP.md](./HELP.md) and [LICENSE](./LICENSE)
|
||||||
34
actions.js
34
actions.js
@@ -1,7 +1,6 @@
|
|||||||
export function updateActions() {
|
export default function (self) {
|
||||||
let actions = {}
|
self.setActionDefinitions({
|
||||||
|
startNewTimer: {
|
||||||
actions['startNewTimer'] = {
|
|
||||||
name: 'Start New Timer',
|
name: 'Start New Timer',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@@ -15,37 +14,36 @@ export function updateActions() {
|
|||||||
label: 'Project',
|
label: 'Project',
|
||||||
id: 'project',
|
id: 'project',
|
||||||
default: '0',
|
default: '0',
|
||||||
choices: this.projects,
|
choices: self.projects,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
callback: ({ options }) => {
|
callback: ({ options }) => {
|
||||||
this.startTimer(options.project, options.description)
|
self.startTimer(options.project, options.description)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
|
||||||
actions['getCurrentTimer'] = {
|
getCurrentTimer: {
|
||||||
name: 'Get Current Timer',
|
name: 'Get Current Timer',
|
||||||
options: [],
|
options: [],
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
this.getCurrentTimer()
|
self.getCurrentTimer()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
|
||||||
actions['stopCurrentTimer'] = {
|
stopCurrentTimer: {
|
||||||
name: 'Stop Current Timer',
|
name: 'Stop Current Timer',
|
||||||
options: [],
|
options: [],
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
this.stopTimer()
|
self.stopTimer()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
|
||||||
actions['refreshProjects'] = {
|
refreshProjects: {
|
||||||
name: 'Refresh Project List',
|
name: 'Refresh Project List',
|
||||||
options: [],
|
options: [],
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
this.getWorkspace()
|
self.getWorkspace()
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
})
|
||||||
this.setActionDefinitions(actions)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,15 @@ Presets are available for **Start Timer** and **Stop Timer**.
|
|||||||
## History
|
## History
|
||||||
|
|
||||||
### Version 1.0.0
|
### Version 1.0.0
|
||||||
|
|
||||||
First release
|
First release
|
||||||
|
|
||||||
### Version 1.0.1
|
### Version 1.0.1
|
||||||
|
|
||||||
Fix broken link
|
Fix broken link
|
||||||
|
|
||||||
### Version 1.0.2
|
### Version 1.0.2
|
||||||
|
|
||||||
Allow a project to be specified when starting a new timer button
|
Allow a project to be specified when starting a new timer button
|
||||||
|
|
||||||
Add an action to refresh the project list
|
Add an action to refresh the project list
|
||||||
@@ -48,16 +51,17 @@ Add an action to refresh the project list
|
|||||||
Add 'Always start' configuration option
|
Add 'Always start' configuration option
|
||||||
|
|
||||||
### Version 1.0.3
|
### Version 1.0.3
|
||||||
|
|
||||||
Add variables for timerId and timerDescription
|
Add variables for timerId and timerDescription
|
||||||
|
|
||||||
### Version 2.0.0
|
### Version 2.0.0
|
||||||
|
|
||||||
Updated for Companion version 3
|
Updated for Companion version 3
|
||||||
|
|
||||||
Updated for toggl API version 9
|
Updated for toggl API version 9
|
||||||
|
|
||||||
### Version 2.0.1
|
### Version 2.0.1
|
||||||
|
|
||||||
Make the API token config field required
|
Make the API token config field required
|
||||||
|
|
||||||
Fix manifest file
|
Fix manifest file
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
"maintainers": [
|
"maintainers": [
|
||||||
{
|
{
|
||||||
"name": "Peter Daniel"
|
"name": "Peter Daniel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Matthias Kesler"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"legacyIds": [],
|
"legacyIds": [],
|
||||||
@@ -17,13 +20,9 @@
|
|||||||
"type": "node18",
|
"type": "node18",
|
||||||
"api": "nodejs-ipc",
|
"api": "nodejs-ipc",
|
||||||
"apiVersion": "0.0.0",
|
"apiVersion": "0.0.0",
|
||||||
"entrypoint": "../index.js"
|
"entrypoint": "../main.js"
|
||||||
},
|
},
|
||||||
"manufacturer": "Toggl",
|
"manufacturer": "Toggl",
|
||||||
"products": [
|
"products": ["Track"],
|
||||||
"Track"
|
"keywords": ["Logging", "Timer", "Task Tracking", "Time Tracking", "Project Management"]
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"Logging", "Timer", "Task Tracking", "Time Tracking", "Project Management"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,16 @@
|
|||||||
// Peter Daniel
|
// Peter Daniel
|
||||||
|
|
||||||
import { InstanceBase, Regex, runEntrypoint, InstanceStatus } from '@companion-module/base'
|
import { InstanceBase, Regex, runEntrypoint, InstanceStatus } from '@companion-module/base'
|
||||||
import { updateActions } from './actions.js'
|
import UpdateActions from './actions.js'
|
||||||
import { updatePresets } from './presets.js'
|
import UpdatePresets from './presets.js'
|
||||||
import { updateVariables } from './variables.js'
|
import UpdateVariableDefinitions from './variables.js'
|
||||||
import { upgradeScripts } from './upgrades.js'
|
import UpgradeScripts from './upgrades.js'
|
||||||
|
|
||||||
import got from 'got'
|
import got from 'got'
|
||||||
|
|
||||||
class toggltrack extends InstanceBase {
|
class toggltrack extends InstanceBase {
|
||||||
constructor(internal) {
|
constructor(internal) {
|
||||||
super(internal)
|
super(internal)
|
||||||
|
|
||||||
this.updateActions = updateActions.bind(this)
|
|
||||||
this.updatePresets = updatePresets.bind(this)
|
|
||||||
this.updateVariables = updateVariables.bind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfigFields() {
|
getConfigFields() {
|
||||||
@@ -49,6 +46,8 @@ class toggltrack extends InstanceBase {
|
|||||||
|
|
||||||
this.config = config
|
this.config = config
|
||||||
|
|
||||||
|
this.updateStatus(InstanceStatus.Ok)
|
||||||
|
|
||||||
this.gotOptions = {
|
this.gotOptions = {
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
throwHttpErrors: false,
|
throwHttpErrors: false,
|
||||||
@@ -60,7 +59,7 @@ class toggltrack extends InstanceBase {
|
|||||||
this.workspaceName = null
|
this.workspaceName = null
|
||||||
this.projects = [{ id: '0', label: 'None' }]
|
this.projects = [{ id: '0', label: 'None' }]
|
||||||
|
|
||||||
this.updateVariables()
|
this.updateVariableDefinitions()
|
||||||
this.updatePresets()
|
this.updatePresets()
|
||||||
|
|
||||||
this.setVariableValues({
|
this.setVariableValues({
|
||||||
@@ -93,6 +92,21 @@ class toggltrack extends InstanceBase {
|
|||||||
this.updateActions()
|
this.updateActions()
|
||||||
this.updateVariables()
|
this.updateVariables()
|
||||||
}
|
}
|
||||||
|
updateActions() {
|
||||||
|
UpdateActions(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFeedbacks() {
|
||||||
|
UpdateFeedbacks(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePresets() {
|
||||||
|
UpdatePresets(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVariableDefinitions() {
|
||||||
|
UpdateVariableDefinitions(this)
|
||||||
|
}
|
||||||
|
|
||||||
auth() {
|
auth() {
|
||||||
if (this.config.apiToken !== null && this.config.apiToken.length > 0) {
|
if (this.config.apiToken !== null && this.config.apiToken.length > 0) {
|
||||||
@@ -355,7 +369,7 @@ class toggltrack extends InstanceBase {
|
|||||||
} else {
|
} else {
|
||||||
this.updateStatus(
|
this.updateStatus(
|
||||||
InstanceStatus.UnknownError,
|
InstanceStatus.UnknownError,
|
||||||
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`
|
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`,
|
||||||
)
|
)
|
||||||
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
||||||
return null
|
return null
|
||||||
@@ -380,7 +394,7 @@ class toggltrack extends InstanceBase {
|
|||||||
} else {
|
} else {
|
||||||
this.updateStatus(
|
this.updateStatus(
|
||||||
InstanceStatus.UnknownError,
|
InstanceStatus.UnknownError,
|
||||||
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`
|
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`,
|
||||||
)
|
)
|
||||||
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
||||||
return null
|
return null
|
||||||
@@ -405,7 +419,7 @@ class toggltrack extends InstanceBase {
|
|||||||
} else {
|
} else {
|
||||||
this.updateStatus(
|
this.updateStatus(
|
||||||
InstanceStatus.UnknownError,
|
InstanceStatus.UnknownError,
|
||||||
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`
|
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`,
|
||||||
)
|
)
|
||||||
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
||||||
return null
|
return null
|
||||||
@@ -437,7 +451,7 @@ class toggltrack extends InstanceBase {
|
|||||||
} else {
|
} else {
|
||||||
this.updateStatus(
|
this.updateStatus(
|
||||||
InstanceStatus.UnknownError,
|
InstanceStatus.UnknownError,
|
||||||
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`
|
`Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`,
|
||||||
)
|
)
|
||||||
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
this.log('warn', `Unexpected HTTP status code: ${response.statusCode} - ${response.body.error}`)
|
||||||
return null
|
return null
|
||||||
@@ -454,4 +468,4 @@ class toggltrack extends InstanceBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runEntrypoint(toggltrack, upgradeScripts)
|
runEntrypoint(toggltrack, UpgradeScripts)
|
||||||
14
package.json
14
package.json
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "toggl-track",
|
"name": "toggl-track",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"main": "index.js",
|
"main": "main.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"format": "prettier -w .",
|
||||||
|
"package": "companion-module-build",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -12,10 +14,12 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@companion-module/base": "~1.4",
|
"@companion-module/base": "~1.11",
|
||||||
"got": "~13.0.0"
|
"got": "~13.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@companion-module/tools": "~1.1"
|
"@companion-module/tools": "~2.1.0",
|
||||||
}
|
"prettier": "^3.4.2"
|
||||||
|
},
|
||||||
|
"prettier": "@companion-module/tools/.prettierrc.json"
|
||||||
}
|
}
|
||||||
16
presets.js
16
presets.js
@@ -1,9 +1,8 @@
|
|||||||
import { combineRgb } from '@companion-module/base'
|
import { combineRgb } from '@companion-module/base'
|
||||||
|
|
||||||
export function updatePresets() {
|
export default function (self) {
|
||||||
let presets = {}
|
self.setPresetDefinitions({
|
||||||
|
Start: {
|
||||||
presets['Start'] = {
|
|
||||||
type: 'button',
|
type: 'button',
|
||||||
category: 'Timer',
|
category: 'Timer',
|
||||||
name: 'Start',
|
name: 'Start',
|
||||||
@@ -28,9 +27,9 @@ export function updatePresets() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
feedbacks: [],
|
feedbacks: [],
|
||||||
}
|
},
|
||||||
|
|
||||||
presets['Stop'] = {
|
Stop: {
|
||||||
type: 'button',
|
type: 'button',
|
||||||
category: 'Timer',
|
category: 'Timer',
|
||||||
name: 'Stop',
|
name: 'Stop',
|
||||||
@@ -52,7 +51,6 @@ export function updatePresets() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
feedbacks: [],
|
feedbacks: [],
|
||||||
}
|
},
|
||||||
|
})
|
||||||
this.setPresetDefinitions(presets)
|
|
||||||
}
|
}
|
||||||
|
|||||||
20
upgrades.js
20
upgrades.js
@@ -1,7 +1,13 @@
|
|||||||
export function upgradeScripts() {
|
export default [
|
||||||
return {
|
/*
|
||||||
updatedConfig: null,
|
* Place your upgrade scripts here
|
||||||
updatedActions: [],
|
* Remember that once it has been added it cannot be removed!
|
||||||
updatedFeedbacks: [],
|
*/
|
||||||
}
|
// function (context, props) {
|
||||||
}
|
// return {
|
||||||
|
// updatedConfig: null,
|
||||||
|
// updatedActions: [],
|
||||||
|
// updatedFeedbacks: [],
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
]
|
||||||
|
|||||||
12
variables.js
12
variables.js
@@ -1,7 +1,5 @@
|
|||||||
export function updateVariables() {
|
export default function (self) {
|
||||||
let variables = []
|
self.setVariableDefinitions([
|
||||||
|
|
||||||
variables.push(
|
|
||||||
{
|
{
|
||||||
name: 'Workspace',
|
name: 'Workspace',
|
||||||
variableId: 'workspace',
|
variableId: 'workspace',
|
||||||
@@ -21,8 +19,6 @@ export function updateVariables() {
|
|||||||
{
|
{
|
||||||
name: 'Current Timer Description',
|
name: 'Current Timer Description',
|
||||||
variableId: 'timerDescription',
|
variableId: 'timerDescription',
|
||||||
}
|
},
|
||||||
)
|
])
|
||||||
|
|
||||||
this.setVariableDefinitions(variables)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user