TimeOff.Management Documentation

repository·master·Indexed 21 days ago

https://github.com/timeoff-management/timeoff-management-application

Absence management software for small and medium size businesses. This web application supports custom leave types, various views (Calendar, Team, List), and third-party integrations with Google Calendar and MS Outlook. It is built with Node.js, Express.js, and SQLite, featuring a REST API, session management via Passport.js, and optional Redis session storage.

Tokens
8.7K
Snippets
31
Records
42
Agent score
76%

What's inside TimeOff.Management

  1. Run application tests

    master

    The project includes a test suite to verify main user paths. To run tests, you must have Chrome and Chrome driver installed in your path. Ensure the application is running with default settings before executing tests.

    To run tests in the background, use USE_CHROME=1 npm test. If you want to visually observe the browser executing the interactions, prefix the command with SHOW_CHROME=1.

    USE_CHROME=1 npm test
  2. Use Redis as storage for Sessions

    master

    By default, the application uses its primary database (the Sessions table) to store session data. You can switch this storage mechanism to Redis to improve performance or offload session management.

    To enable Redis session storage, you must ensure the application version is at least 1.4.0 and update the config/app.json file.

    // Example configuration in config/app.json
    {
      "sessionStore": {
        "useRedis": true,
        "redisConnectionConfiguration": {
          "host": "your-redis-host",
          "port": 6379
        }
      }
    }
  3. Update an existing TimeOff.Management instance

    master

    If you are running an existing instance and need to patch it with a new version from the master branch, use the following sequence to fetch updates, install new dependencies, and migrate the database:

    1. Fetch and pull the latest code.
    2. Install dependencies.
    3. Run the database update script.
    4. Restart the application.
    git fetch
    git pull origin master
    npm install
    npm run-script db-update
    npm start
  4. Amend predefined leave type colors

    master

    To change the colors of the existing predefined options in the leave type color picker, follow these steps:

    1. Open scss/main.scss.
    2. Locate the classes named leave_type_color_1 (or similar numeric suffixes).
    3. Update the background property within these classes to your desired color.
    4. Compile the changes by running the following command:
      npm run compile-sass
    5. Commit your changes to git.
    npm run compile-sass
  5. Add new colors to the leave type color picker

    master

    If the existing color set is insufficient, you can add new color options by modifying both the template and the styles:

    1. Update the Template: Open views/partials/options_for_color_picker.hbs and add a new list item using the following format, where X is the next available integer (e.g., if leave_type_color_5 is the highest, use 6):
      <li><a href="#" class="btn btd-default leave_type_color_X" data-tom-color-picker-css-class="leave_type_color_X">Color X</a></li>
    2. Update the Styles: Open scss/main.scss and define the new class leave_type_color_X with your chosen color.
    3. Compile: Run the following command to generate the CSS file:
      npm run compile-sass
    4. Commit: Save your changes to git.
    <li><a href="#" class="btn btd-default leave_type_color_X" data-tom-color-picker-css-class="leave_type_color_X">Color X</a></li>
    npm run compile-sass
  6. Install TimeOff.Management via self-hosting

    master

    To host the application on your own infrastructure, ensure you have Node.js (>=4.0.0) and SQLite installed. Follow these steps to clone, install dependencies, and start the server:

    1. Clone the repository.
    2. Navigate to the directory.
    3. Install npm packages.
    4. Start the application.

    Once started, the application is accessible at http://localhost:3000/.

    git clone https://github.com/timeoff-management/application.git timeoff-management
    cd timeoff-management
    npm install
    npm start
  7. Application Entrypoint and Express Configuration

    master

    The app.js file serves as the main entrypoint for the TimeOff.Management application, configuring an Express.js server. It sets up the Handlebars view engine, database model access, session management, and authentication via Passport.js.

    Key configuration details:

    • View Engine: Uses Handlebars (.hbs) with a main layout and custom helpers from ./lib/view/helpers.
    • Database: The database model is attached to the application object via app.set('db_model', ...), allowing access to the Sequelize instance.
    • Authentication: Uses Passport.js for session-based authentication. It requires createSessionMiddleware configured with the Sequelize database instance.
    • Middleware: Includes standard middleware for body parsing, cookies, static files, and custom middleware for injecting session/user data into template locals.
    var app = express();
    
    // View engine setup
    var handlebars = require('express-handlebars').create({
      defaultLayout : 'main',
      extname       : '.hbs',
      helpers       : require('./lib/view/helpers')(),
    });
    
    app.engine('.hbs', handlebars.engine);
    app.set('view engine', '.hbs');
    
    // Database model access
    app.set('db_model', require('./lib/model/db'));
    
    module.exports = app;
  8. Configure Local (Email/Password) authentication

    master

    The system supports two modes of local authentication via LocalStrategy:

    1. LDAP Authentication: If the user's company has ldap_auth_enabled set to true, the system attempts to authenticate the user against the configured LDAP server.
    2. Standard Password Authentication: If LDAP is not enabled, the system validates the password using the user object's is_my_password(password) method.

    Upon successful authentication, the user is automatically activated via user.maybe_activate() and their session details are reloaded.