mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Minor improvements to Clockify-Node
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as moment from 'moment-timezone';
|
||||
|
||||
import {IPollFunctions} from 'n8n-core';
|
||||
import { IPollFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
@@ -69,16 +69,16 @@ export class ClockifyTrigger implements INodeType {
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async listWorkspaces(this: ILoadOptionsFunctions) : Promise<INodePropertyOptions[]> {
|
||||
const rtv : INodePropertyOptions[] = [];
|
||||
const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call(this,'GET', 'workspaces');
|
||||
if(undefined !== workspaces) {
|
||||
async listWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const rtv: INodePropertyOptions[] = [];
|
||||
const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call(this, 'GET', 'workspaces');
|
||||
if (undefined !== workspaces) {
|
||||
workspaces.forEach(value => {
|
||||
rtv.push(
|
||||
{
|
||||
name: value.name,
|
||||
value: value.id,
|
||||
});
|
||||
{
|
||||
name: value.name,
|
||||
value: value.id,
|
||||
});
|
||||
});
|
||||
}
|
||||
return rtv;
|
||||
@@ -89,7 +89,7 @@ export class ClockifyTrigger implements INodeType {
|
||||
async poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const triggerField = this.getNodeParameter('watchField') as EntryTypeEnum;
|
||||
const workspaceId = this.getNodeParameter('workspaceId');
|
||||
const workspaceId = this.getNodeParameter('workspaceId');
|
||||
|
||||
if (!webhookData.userId) {
|
||||
// Cache the user-id that we do not have to request it every time
|
||||
@@ -97,12 +97,12 @@ export class ClockifyTrigger implements INodeType {
|
||||
webhookData.userId = userInfo.id;
|
||||
}
|
||||
|
||||
const qs : IDataObject = {};
|
||||
const qs: IDataObject = {};
|
||||
let resource: string;
|
||||
let result = null;
|
||||
|
||||
switch (triggerField) {
|
||||
case EntryTypeEnum.NEW_TIME_ENTRY :
|
||||
case EntryTypeEnum.NEW_TIME_ENTRY:
|
||||
default:
|
||||
const workflowTimezone = this.getTimezone();
|
||||
resource = `workspaces/${workspaceId}/user/${webhookData.userId}/time-entries`;
|
||||
@@ -110,10 +110,10 @@ export class ClockifyTrigger implements INodeType {
|
||||
qs.end = moment().tz(workflowTimezone).format('YYYY-MM-DDTHH:mm:ss') + 'Z';
|
||||
qs.hydrated = true;
|
||||
qs['in-progress'] = false;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
result = await clockifyApiRequest.call(this, 'GET', resource, {}, qs );
|
||||
result = await clockifyApiRequest.call(this, 'GET', resource, {}, qs);
|
||||
webhookData.lastTimeChecked = qs.end;
|
||||
|
||||
if (Array.isArray(result) && result.length !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user