npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

toxic-schedule

v1.1.3

Published

Angular 6 module, rendering time slots for appointments.

Downloads

14

Readme

Toxic Schedule component

Angular 6 module, rendering time slots for appointments.

Install

npm install --save toxic-schedule

Usage

  1. Import ToxicScheduleModule in your project
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";

import { AppComponent } from "./app.component";
import { ToxicScheduleModule } from "toxic-schedule";

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule, 
    ToxicScheduleModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}
  1. Use the following HTML
<lib-toxic-schedule 
    [interval]="15" 
    [startTime]="startTime" 
    [endTime]="endTime" 
    [reservedSlots]="reservedSlots"
    [sectors]="sectors"
    (slotSelected)="getSelectedTime($event)">
</lib-toxic-schedule>
  • interval - number, slot intervals in minutes
  • startTime - Date object, representing the schedule start time
  • endTime - Date object, representing the schedule end time
  • reservedSlots - list of predefined time slots, which should be displayed in the schedule
  • sectors - list of sector names (vertical columns). Must match the values from TimeSlot's sector property.
  • slotSelected - event, which will be emittted when a slot is selected. TimeSlot model will be passed, eigther empty or one of the preselected.

TimeSlot model

const timeSlot = new TimeSlot(startTime, endTime, sector, [description, [params, [id]]]);
  • startTime - Slot start date/time. Date, string or milliseconds.
  • endTime - Slot start date/time. Date, string or milliseconds.
  • sector - Sector name, string.
  • description - Optional, plain text description for this time slot.
  • params - Optional, any params you might need to pass over.
  • id - Optional, slot id, if you have assigned one.

Demo

  1. Clone the project and install its dependencies
git clone https://github.com/vmanchev/toxic-schedule.git
cd toxic-schedule
npm install
  1. Run the application
ng serve
  1. Open your browser and navigate to http://localhost:3000

  2. Play with it - change the data from src/app/app.component.ts file.

Screenshots can be found in the github repo.

Features

  • multiple sectors (e.g. all doctors in the clinic);
  • customizable slot intervals;
  • customizable start and end date/time;
  • display reserved slots

How it works

You'll get a nice schedule with sectors (columns) and time slots (rows). When the user clicks on any slot, slotSelected event will be dispatched. Use your own handler function to capture the selected TimeSlot object.

The minimum required setup data would be:

  • slots interval in minites
  • at least one sector
  • start date/time
  • end date/time

In addition, you can provide a list of TimeSlot objects, which will be used as reserved slots. These will be displayed over the main grid of time slots, with different background, and the value from TimeSlot's description property will be displayed.

Responsive layout

For small screens (below 576px in width), only one sector at a time will be displayed. All sectors are accessible via a dropdown. When the user selects a new sector, the related TimeSlot grid will be displayed along with the reserved slots, if any.

For bigger screens (576px and above), all sectors will be displayed.

Sample data

The following sample data was used to build the above screenshots:

    this.interval = 15;
    this.startTime = new Date('2018-09-20T10:00:00.000');
    this.endTime = new Date('2018-09-20T13:00:00.000');

    this.sectors = [
      'Anakin Skywalker',
      'Chewbacca',
      'Han Solo',
      'Leia Organa'
    ];

    this.reservedSlots = [
      new TimeSlot(
        '2018-09-20T10:30:00',
        '2018-09-20T10:45:00',
        'Anakin Skywalker',
        'Dentist',
        1
      ),
      new TimeSlot(
        '2018-09-20T10:45:00',
        '2018-09-20T11:00:00',
        'Anakin Skywalker',
        'Meeting with Joe',
        2
      ),
      new TimeSlot(
        '2018-09-20T11:30:00',
        '2018-09-20T12:00:00',
        'Anakin Skywalker',
        'Call Adam',
        3
      ),
      new TimeSlot(
        '2018-09-20T10:00:00',
        '2018-09-20T10:30:00',
        'Chewbacca',
        'Board meeting',
        4
      ),
      new TimeSlot(
        '2018-09-20T10:45:00',
        '2018-09-20T11:15:00',
        'Han Solo',
        'Dentist',
        5
      ),
      new TimeSlot(
        '2018-09-20T11:45:00',
        '2018-09-20T12:30:00',
        'Leia Organa',
        'Kinds/Lunch',
        6
      )
    ];

Build the library

Run ng build toxic-schedule and find the output inside the dist/toxic-schedule folder.