@Richtw what position did you put it in?
Read the statement by Michael Teeuw here.
Posts made by sdetweil
-
RE: Internet-Monitor display issue
-
RE: MagicMirror (vers:2.27) : split Error - 07May2024
@nkc my upgrade script?
can you examine your config.js and look for any module
that does NOT have that exact spelling
all lowercase
module
-
RE: MagicMirror 2.27 Error - modules failing - not displaying output - 7May2024
@nkc and it ran ok after that?
and then how did you get your modules installed?
you didn’t try to upgrade w my upgrade script?
-
RE: Show calendar based on IP Address accessed
@Spinster ok, here is the final
in calendar.js
add these variables
updateOnFetch: true, useIPAddress: false // add config var }, timerHandle:null, // add this ourIPAddress:null, // add this requiresVersion: "2.1.0",
change this
// Override start method. start () {
to
this// Override start method. startup () {
add this code
let ip_match = false; if(this.config.useIPAddress){ const client_ip_for_this_calendar = this.getCalendarProperty(calendar.url, "ipaddress", null) if(this.ourIPAddress) ip_match = client_ip_for_this_calendar.includes(this.ourIPAddress) } if(this.config.useIPAddress == false || ip_match==true) this.addCalendar(calendar.url, calendar.auth, calendarConfig); // old original line
and add this routine somewhere
notificationReceived(notification,payload){ if(notification === 'ALL_MODULES_STARTED'){ // if we are using ip address checking if(this.config.useIPAddress){ // loop thru all the modules let m = MM.getModules().withClass("getip"); if(m.length){ // if getip is configured and not disabled if((m[0].disabled== undefined || (m[0].disabled != undefined && m[0].disabled == false)) ){ // start a timer to wait for getip to finish this.timerHandle = setInterval(()=>{ // get its dom content let client_ip = document.getElementById("getip_address") // if we found id if(client_ip !== null){ // stop the timer clearInterval(this.timerHandle) // save our IP address, only need to look it up once this.ourIPAddress=client_ip.innerText // call startup this.startup() } }, 500) } } // thru the loop, didn't start a timer, module not found if(this.timerHandle === null){ // didn't find getip // module not found, can't do this later either this.config.useIPAddress = false; this.startup() } } // use default else this.startup() } else if (notification === "FETCH_CALENDAR") { this.sendSocketNotification(notification, { url: payload.url, id: this.identifier+(this.ourIPAddress?'_'+this.ourIPAddress:'') }); } },
and in the socketNotificationReceived routine
change thissocketNotificationReceived (notification, payload) { if (notification === "FETCH_CALENDAR") { this.sendSocketNotification(notification, { url: payload.url, id: this.identifier }); } if (this.identifier !== payload.id) { return; }
to this
socketNotificationReceived (notification, payload) { if (this.identifier+(this.ourIPAddress?'_'+this.ourIPAddress:'') !== payload.id) { return; }
and in the addCalendar routine
change thisid: this.identifier,
to this
id: this.identifier+(this.ourIPAddress?'_'+this.ourIPAddress:''),
to use
add the getip module to config.js, anywhere
add property to calendar above the calendars list (but still inside the config:{}{ section)useIPAddress:true,
in any cal url block you want to be sensitive to IP address add property
ipaddress:"xxx yyy zzz", // space separated list of client ipaddresses this calendar can be displayed on
andhow
-
RE: Show calendar based on IP Address accessed
@Spinster yes you need both
I am away from my system for another couple hours
will collapse to one post then
-
RE: Show calendar based on IP Address accessed
@Spinster yes, the two pieces together
ipaddress:“…”
at each cal url block… only does one ipaddress per url -
RE: Show calendar based on IP Address accessed
@MMRIZE said in Show calendar based on IP Address accessed:
My code is just small injection that does filtering out calendars by condition on socketNotificationReceived. No additional fetching is needed.
AFTER fetching… so throw away data, which we fetched , knowing we wouldn’t use it…