mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
⚡ Minor improvements to Clockify-Node
This commit is contained in:
parent
3a73493aeb
commit
a25229ace9
|
@ -3,12 +3,12 @@ import {
|
|||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
|
@ -30,13 +30,13 @@ import {
|
|||
} from './ProjectInterfaces';
|
||||
|
||||
import {
|
||||
projectOperations,
|
||||
projectFields,
|
||||
projectOperations,
|
||||
} from './ProjectDescription';
|
||||
|
||||
import {
|
||||
tagOperations,
|
||||
tagFields,
|
||||
tagOperations,
|
||||
} from './TagDescription';
|
||||
|
||||
import {
|
||||
|
@ -45,7 +45,6 @@ import {
|
|||
} from './TimeEntryDescription';
|
||||
|
||||
import * as moment from 'moment-timezone';
|
||||
import { boardColumnFields } from '../MondayCom/BoardColumnDescription';
|
||||
|
||||
export class Clockify implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
@ -359,14 +358,12 @@ export class Clockify implements INodeType {
|
|||
body,
|
||||
qs
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'tag') {
|
||||
|
||||
if (operation === 'add') {
|
||||
if (operation === 'create') {
|
||||
|
||||
const workspaceId = this.getNodeParameter('workspaceId', i) as string;
|
||||
|
||||
|
@ -456,8 +453,6 @@ export class Clockify implements INodeType {
|
|||
body,
|
||||
qs
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -573,8 +568,6 @@ export class Clockify implements INodeType {
|
|||
body,
|
||||
qs
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface IMembershipDto {
|
|||
|
||||
export interface ITagDto {
|
||||
id: string;
|
||||
name: any;
|
||||
name: any; // tslint:disable-line:no-any
|
||||
workspaceId: string;
|
||||
archived: boolean;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {IHourlyRateDto, IMembershipDto} from "./CommonDtos";
|
||||
import { INodeExecutionData } from "n8n-workflow";
|
||||
import { IHourlyRateDto, IMembershipDto } from './CommonDtos';
|
||||
|
||||
enum EstimateEnum {
|
||||
AUTO = "AUTO",
|
||||
|
@ -11,7 +10,7 @@ interface IEstimateDto {
|
|||
type: EstimateEnum;
|
||||
}
|
||||
|
||||
export interface IProjectDto{
|
||||
export interface IProjectDto {
|
||||
archived: boolean;
|
||||
billable: boolean;
|
||||
clientId: string;
|
||||
|
|
|
@ -16,9 +16,9 @@ export const tagOperations = [
|
|||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Add a tag',
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a tag',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
|
@ -59,7 +59,7 @@ export const tagFields = [
|
|||
'tag',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {ITimeIntervalDto} from "./CommonDtos";
|
||||
import { ITimeIntervalDto } from './CommonDtos';
|
||||
|
||||
interface ITimeEntriesDurationRequest {
|
||||
start: string;
|
||||
|
@ -18,7 +18,7 @@ export interface ITimeEntryRequest {
|
|||
timeInterval: ITimeEntriesDurationRequest;
|
||||
workspaceId: string;
|
||||
isLocked: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITimeEntryDto {
|
||||
billable: boolean;
|
||||
|
@ -32,4 +32,3 @@ export interface ITimeEntryDto {
|
|||
userId: string;
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ export interface IUserDto {
|
|||
defaultWorkspace: string;
|
||||
email: string;
|
||||
id: string;
|
||||
memberships: IMembershipDto [];
|
||||
memberships: IMembershipDto[];
|
||||
name: string;
|
||||
profilePicture: string;
|
||||
settings: IUserSettingsDto;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { IHourlyRateDto, IMembershipDto } from './CommonDtos';
|
||||
|
||||
enum AdminOnlyPagesEnum {
|
||||
PROJECT ='PROJECT',
|
||||
PROJECT = 'PROJECT',
|
||||
TEAM = 'TEAM',
|
||||
REPORTS = 'REPORTS',
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ export interface IWorkspaceDto {
|
|||
hourlyRate: IHourlyRateDto;
|
||||
id: string;
|
||||
imageUrl: string;
|
||||
memberships: IMembershipDto[];
|
||||
memberships: IMembershipDto[];
|
||||
name: string;
|
||||
workspaceSettings: IWorkspaceSettingsDto;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue