Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple instances in Calendar #1109

Closed
rgstephens opened this issue Dec 30, 2017 · 9 comments
Closed

Support multiple instances in Calendar #1109

rgstephens opened this issue Dec 30, 2017 · 9 comments

Comments

@rgstephens
Copy link

I'd like to create multiple calendars (a "Today's Calendar" with certain types of calendar items and a "Group Calendar" with upcoming events associated with a group of people, etc.). I've added a new instance configuration option so you can create multiple calendar instances each have a unique instance id. For example:

    {
      module: "calendar",
      header: "Today's Calendar",
      position: "top_left",
      config: {
        instance: "today",
        maximumNumberOfDays: 1,
        calendars: [
          {
            symbol: "cutlery ",
            url:
              "http://diningroomschedule.com"
          },
          {
            symbol: "male ",
            url:
              "https://mensevents.com"
          },
          {
            symbol: "female ",
            url:
              "https://womensevents.com"
          }
        ]
      }
    },
    {
      module: "calendar",
      header: "Group Calendar",
      position: "top_left",
      config: {
        instance: "bmoor",
        timeFormat: "absolute",
        getRelative: 0,
        urgency: 2,
        fadePoint: 0.7,
        dateFormat: "ddd, MMM do",
        excludedEvents: ["Breakfast", "Lunch"],
        calendars: [
          {
            symbol: "futbol-o ",
            maximumEntries: 2,
            url: "http://www.trumba.com/calendars/seattle-seahawks-schedule.ics"
          },
          {
            symbol: "futbol-o ",
            maximumEntries: 2,
            url: "http://collegefootballcalendar.net/cal/264"
          }
        ]
      }
    },

@MichMich
Copy link
Collaborator

I fail to understand what the issue is. Why does it need an "instance" identifier? You can just add multiple calendar modules to your config? Could you elaborate?

@rgstephens
Copy link
Author

If I create two calendars, options for the first calendar are over-ridden by the second. For example, if my first calendar specifies maximumNumberOfDays: 2 and the second calendar doesn't include that option the maximumNumberOfDays for the first calendar is not limited to the two day maximum. Using the instance setting, the parameters are kept separate.

I've duplicated the issue with the excludedEvents option.

What led me to create this option was this discussion on the forum. One of the users in this discussion states that most modules don't support multi-instance and that they share node_helper.

@MichMich
Copy link
Collaborator

This is more of a bug than a missing feature. The calendar URL's aren't shared between multiple instances either. So any other configuration like maximumNumberOfDays should remain separate as well. The best approach is to let the frontend module handle the usage of the configuration. The node helper shouldn't do much more than fetching the data. Adding an "instance" configuration to solve it is a workaround which makes it unnecessary complicated.

Making the necessary changes is a pretty far-reaching task. But I think it's better to solve this in a clean way than to use quick and dirty solutions.

If it's really an issue for your calendar. You can always fork the calendar module and create & use your own version.

Of course, an PR which solves the issue is more than welcome. I will therefor leave this Issue open. I'll close the current PR for now.

One minor hint if you do want to make your own fork: you can always use the module's identifier in stead of an "instance" configuration. the this.identifier is unique for every instance of a module. This removes the need for the user to configure an instance name.

@rgstephens
Copy link
Author

@MichMich Thanks for the pointers.

@bolish
Copy link

bolish commented Jan 21, 2019

Hi @rgstephens @MichMich

I'm facing the excat same issue and can't figure it out myself because of lack of skills.
Did finally one of you made the improvement?

If not, @rgstephens, could you please guide me step by step so I can't implement the workaround you discussed above (this.identifier) to get that solved?

Regards

@rgstephens
Copy link
Author

@bolish It's been a while since I worked on this. I can't give you step by step but here's a link to my modified calendar.js and a sample calendar config.

@bolish
Copy link

bolish commented Jan 21, 2019

thanks @rgstephens but I can't manage to get it work...
Whatever method I use (and I tried A LOT), maximumNumberOfDays is always overwritting the previous module instance...
Really hope there could be a fix soon...

@sdetweil
Copy link
Collaborator

sdetweil commented Sep 1, 2019

the easiest way to support mu;ltiple instances of the same module is on each sendSocketNotification to add the module identifier to the structure sent.
and in the node helper send that identifier back as part of any sendsocketNotification payload.
the module.js checks the identifier, and if not matching, ignores the notification ..

the node helper also has to save the config data sent down by identifier (or limit the use to just api data and response)...

if multiple instances are running, (multiple module: mod_name in config.js) any sendsocketNotification from the node_helper WILL got to ALL instances...

see my https://github.com/sdetweil/NewBusTimes repo which supports multiple module: in config.js

@stale
Copy link

stale bot commented Oct 31, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 31, 2019
@stale stale bot closed this as completed Nov 7, 2019
MichMich added a commit that referenced this issue Jun 2, 2020
Fix #1109 - multiple calendar instances with different config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants