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

@xabi08yt/iutgradignanhpscheduler

v1.0.8

Published

Helper to help getting schedules from ical or other source

Downloads

83

Readme

Scheduler

Fetch and process your lessons of the day / week / month from any external sources !

  • Built-in calendar like navigation (Move in time a cursor).

  • Can be implemented with any kind of calendar source (Ical, Json, etc..)

  • Prebuilt modules for hyperplanning / ade / celcat.

Authors : @alexboin, @celian-rib Maintainer : @Xabi08YT


Usage

Here's an example of basic usage :

Get all events of January 17 from an hyperplanning source.

import { HyperplanningScheduler } from "scheduler";

const scheduler = new HyperplanningScheduler("F28486A74D71A7B44CD0B88D32986A91");

scheduler
    .setDate("2022-01-17")
    .getEvents()
    .then(console.log);

API

Types & Interfaces :

Event :

export interface Event {
  id: string;
  subject: string;
  description: string[];
  dateStart: Date;
  dateEnd: Date;
  locations: string[];
}

(Built-in custom event type) Lesson :

You can make your own interface that the scheduler will work with

export interface Lesson extends Event {
    groups: string[];
    type?: string;
    teachers: string[];
}

SchedulerMode :

type SchedulerMode = "day" | "week" | "month";

Methods :

Navigation mode :

| Method | Description | Return | | ------------------------ | ------------------------------- | --------------- | | setMode(SchedulerMode) | Set the current navigation mode | Scheduler | | getMode() | Get the current navigation mode | SchedulerMode |

Cursor navigation :

| Method | Description | Return | | ----------------- | ---------------------------------------------------------------------------------------------- | ----------- | | setDate(Date) | Set the cursor on the given date (Change the mode to day) | Scheduler | | move(number) | Move the cursor depending on the given number of steps and the current navigation mode | Scheduler | | next() | Move the cursor to the next day | week | month, according to the current navigation mode | Scheduler | | nextDay() | Move to the next day (Set the navigation mode to day) | Scheduler | | nextWeek() | Move to the next week (Set the navigation mode to week) | Scheduler | | nextMonth() | Move to the next month (Set the navigation mode to month) | Scheduler | | previous() | Move the cursor to the previous day | week | month, according to the current navigation mode | Scheduler | | previousDay() | Move to the previous day (Set the navigation mode to day) | Scheduler | | previousWeek() | Move to the previous week (Set the navigation mode to week) | Scheduler | | previousMonth() | Move to the previous month (Set the navigation mode to month) | Scheduler |

Other :

| Method | Description | Return | | ----------------------- | ------------------------------------------------------------------ | ---------------------------- | | getEvents() | All fetched events that are related to the current cursor and mode | Promise<Event[]> | | getCurrentDateRange() | The current date range that the scheduler is focusing on | { start: Date, end: Date } | | clearCache() | clear the cache content | Scheduler | | debug() | print current attributes values | undefined |


Prevent CORS policy issues

The scheduler instance has to fetch ical data from external source, causing CORS issue if you'r using node in a browser environment.

In order to you the scheduler you'll have to make your own proxy redirecting the requests to the right urls.

Examples :

Scheduler config and netlify toml config for proxying requests

1) Hyplerplanning :

  • Proxy url template :

    • /api/scheduler/hyperplanning/:schedulerId/:dateParameter
  • Implementation :

    • private scheduler = new HyperplanningScheduler(
          "F28486A74D71A7B44CD0B88D32986A91",
          { proxyUrl: "/api/scheduler/hyperplanning/:schedulerId/:dateParameter" }
      );
    • [[redirects]]
        from = "/api/scheduler/hyperplanning/:schedulerId/:dateParameter"
        to = "https://hyperplanning.iut.u-bordeaux.fr/Telechargements/ical/Edt.ics?version=2021.0.1.3&idICal=:schedulerId&param=:dateParameter"
        status = 200

2) Ade :

  • Proxy url template :

    • /api/scheduler/ade/:schedulerId/:dateParameter
  • Implementation :

    • private scheduler2 = new AdeScheduler("7214", {
          proxyUrl: "/api/scheduler/ade/:schedulerId/:dateParameter",
      });
    • [[redirects]]
        from = "/api/scheduler/ade/:schedulerId/:dateParameter"
        to = "https://ade.bordeaux-inp.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=:schedulerId&projectId=1&calType=ical&:dateParameter"
        status = 200

3) Celcat :

  • Proxy url template :

    • /api/scheduler/celcat
    • Celcat service is using a method post (The parameters are not in the url )

  • Implementation :

    • private scheduler3 = new CelcatScheduler("CP100A2", {
          proxyUrl: "/api/scheduler/celcat",
      });
    • [[redirects]]
        from = "/api/scheduler/celcat"
        to = "https://celcat.u-bordeaux.fr/Calendar/Home/GetCalendarData"
        status = 200

Custom Scheduler from you own source

import { Scheduler, Event } from "scheduler";

export interface CustomInterface extends Event {
	myValue: string;
}

export default class CustomScheduler extends Scheduler<CustomInterface> {
	
	minDate = "2010-01-01";
	maxDate: "2030-12-31";

	protected fetchSource(): Promise<string> {
		// Fetch the data from your custom source
		// Return the fetched data as string
		throw new Error("Method not implemented.");
	}
	
	protected parseEvents(data: string): CustomInterface[] {
		// Parse here the fetched data to construct
		// the final result
		throw new Error("Method not implemented.");
	}
}