1.1.1 • Published 2 years ago

whms v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

WHMS

npm version license

A package that simplifies the work hour management system (get/post) process.

new

  1. add id to UploadConfig.
  2. fix upload function error handling

Installing

Using npm:

$ npm install whms

Example

note: CommonJS usage

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

const whms = require("whms").default;

// whms.<method> will now provide autocomplete and parameter typings

Upload Work Reocrd List to database

import whms from "whms";

whms.upload({
  id: 69,
  employeeAccount: "John Doe",
  projectCode: "C000",
  content: "This is a content",
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"],
}).then((response) => {
  console.log(response);
});

Get data from work hour management system

import whms from 'whms';

whms.get({
  method: "getProjects",
  data: {}
});

whms.get({
  method: "getAvalibleProjects",
  data: {}
});

whms.get({
  method: "getProjectsByCondition",
  data: {
    projectCodeSearch: "",
    projectNameSearch: "",
    projectShowAll: false
  }
});

whms.get({
  method: "getWorkRecord",
  data: {
    workRecordEmployeeId: 69,
    workRecordCreateDate: new Date().getTime() // Unix time
  }
});

whms.get({
  method: "getEmployees",
  data: {
    employeeShowDisabled: true
  }
});

whms.get({
  method: "getEmployeesByCondition"
  data: {
    employeeIdSearch: "",
    employeeNameSearch: ""
  }
});

Post data to work hour management system

import whms from "whms";

whms.post({
  method: "addWorkRecord",
  data: {
    workRecordList: [], // Array<WorkRecord> length should be 8
  },
});

Generate Work Record List

import whms, { Employee, WorkRecord } from "whms";

const employee: Employee = {
  id: 69,
  code: "",
  name: "John Doe",
  account: "johndoe",
  password: "password",
  tel: "123-45678",
  ext: "234",
  email: "johndoe@example.com",
  enabled: true,
};

const wrList: WorkRecord[] = whms.generateWorkReocrd({
  employee: employee, // employee object
  projectId: 10, // project index
  content: "This is a content.",
  createDate: 0, // unix time
});
console.log(wrList.length); // print 8

Upload Config

{
  id: 69,
  employeeAccount: "johndoe", // [optional] `employeeaccount` is your account not usernmae
  projectCode: "C000",
  content: "This is a content",

  // date format: "yyyy-MM-dd" or "yyyy/MM/dd"
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"]
}
1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago