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