ethanpartida / MMM-MyStudyLife

Module to display info from the website MyStudyLife
MIT License
10 stars 1 forks source link

Displays "loading" only on Magic Mirror^2 #9

Closed Oleson-Cybersec closed 2 years ago

Oleson-Cybersec commented 2 years ago

Hello @ethanpartida , I downloaded your repsoitory with git clone https://github.com/ethanpartida/MMM-MyStudyLife within ~/MagicMirror/modules --> cd MMM-MyStudyLife --> npm install. After I added this code to my config.js file within my modules: [ section:

Config.js below:

    {
        module: "MMM-MyStudyLife",  // Not sure why, this module doesn't work for me as of posting
        position: "bottom_right",
        config: {
            code: "AAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Real code redacted
            // Login to your MyStudyLife.com, then go to your dashboard --> *Press F12* --> *Click on Console* --> 
            // *Click right of the ">>"* --> Input: "localStorage" to see your key right of " _: ", Should look similar to the code above
            showSchedule: true,
            showExams: true,
            showTasks: true,
            classes: {
                "English 101": [1,3],       // See doucmentation online
                "Computing": [1],
                "Intro to Networking": [3],
                "Statistics": [4],
                "Psychology 102": [6]
                        }
               }
    },

Then I went within the MMM-MyStudyLife directory to nano MMM-MyStudyLife.js to edit the content inside:

Module.register("MMM-MyStudyLife", {
    defaults: {
        url: "https://api.mystudylife.com/v6.1/data",
        interval: 1000000,
        code: "AAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Real code redacted
        loaded: ' ',
        color: true,
        showSchedule: true,
        showExams: true,
        showTasks: true,
        totNumOfTasks: 10, //max number of tasks displayed
        totNumOfExams: 5, //max number of exams displayed
        includeExamSub: false, //Include subject of exam in name
        militaryTime: true, //24 hour time
        averageScheduleHeight: 600, //pixels
        minClassHeight: 15, //% of schedule pixels
        maxClassHeight: 50, //% of schedule pixels
        classFontScale: 1,
        taskFontScale: 1,
        examFontScale: 1,
        useTerms: false, // use terms or not, if not it will default to yearly schedules
        useCycles: false, //cycle based schedule
        //Ignore these if not using cycle schedule
        offset: 0, //offset to adjust cycle position
        daysOff: [0,6], //days in which there is no school, they dont count towards cycle rotation
        cycleLength: 2, //Length of cycle
        classes: {},
        colorCode: {
ethanpartida commented 2 years ago

Hi,

Sorry for the late response. Thanks for including your config in the error request. I tried to replicate your error by building a schedule with your same classes but was unable to get the 'loading' screen. I've added an extra check to avoid errors onto the main branch. Please try updating your version and see if that helps.

If you are still receiving the loading screen, please reply with a screenshot of the mirror in dev mode. You can access this by the command npm run start dev.

Best, Ethan

Oleson-Cybersec commented 2 years ago

So I used git reset --hard && git pull to update the branch (I think). I restarted my MM and it still shows loading. Here are the results of the logs. npm run start dev

npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2021-10-23T22_01_51_769Z-debug.log

tail -n 25 ~/.npm/_logs/2021-10-23T22_01_51_769Z-debug.log

26 timing npm:load Completed in 82ms
27 timing command:run-script Completed in 37ms
28 verbose stack Error: Missing script: "start"
28 verbose stack
28 verbose stack Did you mean one of these?
28 verbose stack     npm star # Mark your favorite packages
28 verbose stack     npm stars # View packages marked as favorites
28 verbose stack
28 verbose stack To see a list of scripts, run:
28 verbose stack   npm run
28 verbose stack     at RunScript.run (/usr/lib/node_modules/npm/lib/run-script.js:105:13)
29 verbose cwd /home/JO_pi/MagicMirror/modules/MMM-MyStudyLife
30 verbose Linux 5.10.63-v7l+
31 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "start" "dev"
32 verbose node v14.18.1
33 verbose npm  v8.1.0
34 error Missing script: "start"
34 error
34 error Did you mean one of these?
34 error     npm star # Mark your favorite packages
34 error     npm stars # View packages marked as favorites
34 error
34 error To see a list of scripts, run:
34 error   npm run
35 verbose exit 1

Module within my ~/MagicMirror/config/config.js

                {
                        module: "MMM-MyStudyLife",
                        position: "bottom_right",
                        config: {
                                code: "AAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Real code redacted
                                showSchedule: true,
                                showExams: true,
                                showTasks: true,
                                classes: {
                                        "English 101": [1,3],
                                        "Computing": [1],
                                        "Intro to Networking": [3],
                                        "Statistics": [4],
                                        "Psychology 102": [6]
                                        }
                                }
                },

Lastly, I left the ~/MagicMirror/modules/MMM-MyStudyLife.js untouched as I reset the file to its default settings on your published GitHub. Let me know if I need to change anything in there

Oleson-Cybersec commented 2 years ago

Am I supposed to change anything in the ~/MagicMirror/modules/MMM-MyStudyLife.js like adding in the localStorage._ code, and not sure what the loaded token is for. This is my current one, let me know if I need to change any values inside! Thank you in advance :)

Module.register("MMM-MyStudyLife", {
    defaults: {
        url: "https://api.mystudylife.com/v6.1/data",
        interval: 1000000,
        code: ' ',
        loaded: ' ',
        color: true,
        showSchedule: true,
        showExams: true,
        showTasks: true,
        totNumOfTasks: 6, //max number of tasks displayed
        totNumOfExams: 5, //max number of exams displayed
        includeExamSub: true, //Include subject of exam in name
        militaryTime: true, //24 hour time
        averageScheduleHeight: 600, //pixels
        minClassHeight: 15, //% of schedule pixels
        maxClassHeight: 50, //% of schedule pixels
        classFontScale: 1,
        taskFontScale: 1,
        examFontScale: 1,
        useTerms: true, // use terms or not, if not it will default to yearly schedules
        useCycles: false, //cycle based schedule
        //Ignore these if not using cycle schedule
        offset: 0, //offset to adjust cycle position
        daysOff: [0,6], //days in which there is no school, they dont count towards cycle rotation
        cycleLength: 2, //Length of cycle
        classes: {},
        colorCode: {
            '0': {'h': "#049372", 'b': "#113b31"},
            '1':{'h': "#fd5645", 'b': "#5d1f19"},
            '2':{'h': "#f89406", 'b': "#4c3310"},
            '3':{'h': "#3a539b", 'b': "#242832"},
            '4':{'h': "#dc44b4", 'b': "#41253a"},
            '5':{'h': "#e3be0d", 'b': "#4c451f"},
            '6':{'h': "#95a5a6", 'b': "#343c3c"},
            '7':{'h': "#1098a5", 'b': "#1c3d40"},
            '8':{'h': "#7d59b6", 'b': "#342d3e"},
            '9':{'h': "#38acfa", 'b': "#182c3a"},
            '10':{'h': "#34495e", 'b': "#222e39"},
            '11':{'h': "#2574a9", 'b': "#0e2b3f"},
            '12':{'h': "#c0392b", 'b': "#412320"},
            '13':{'h': "#00634c", 'b': "#0e2f28"},
            '14':{'h': "#674172", 'b': "#2e2032"}
        },
    },
    start: function () {
        this.loaded = true; //OG false
        this.datas = ' ';
        this.currentTerm;
        this.currentYear;
        this.date;
        this.cycleDay=this.config.offset;
        this.storedDate=new Date();
        this.updateData(this);
    },
    getStyles: function() {
        return ["styles1.css", "font-awesome.css"];
    },
    updateData: function(self) {
        self.date= new Date();
        self.sendSocketNotification('load', {'url':self.config.url, 'code':self.config.code});
        setTimeout(self.updateData, self.config.interval, self);
    },
    getDom: function() {
        var wrapper = document.createElement('div');
        wrapper.className = "myStudyWrapper";
        if (!this.loaded){
            wrapper.innerHTML = "loading";
            return wrapper;
        }
        else {
            console.log("Loading successful");
            if(this.config.showSchedule) {
                wrapper.appendChild(this.makeSchedule());
            }
            var leftWrapper = document.createElement('div');
            leftWrapper.className = "leftWrapper";
            if(this.config.showTasks) {
                leftWrapper.appendChild(this.makeTasks());
            }
            if(this.config.showExams) {
                leftWrapper.appendChild(this.makeExams());
            }
            wrapper.appendChild(leftWrapper);
            return wrapper;
        }
    },
ethanpartida commented 2 years ago

What command do you use to start the mirror? Adding 'dev' to the end of that command should open a console with some text on the rightside. Otherwise "Ctrl+Shit+i" inside of the mirror should open the same console.

Best, Ethan On Oct 23, 2021, 5:11 PM -0500, Jordan O. @.***>, wrote:

So I used git reset --hard && git pull to update the branch (I think). I restarted my MM and it still shows loading. Here are the results of the logs. npm run start dev npm ERR! Missing script: "start" npm ERR! npm ERR! Did you mean one of these? npm ERR! npm star # Mark your favorite packages npm ERR! npm stars # View packages marked as favorites npm ERR! npm ERR! To see a list of scripts, run: npm ERR! npm run

npm ERR! A complete log of this run can be found in: npm ERR! /home/pi/.npm/_logs/2021-10-23T22_01_51_769Z-debug.log tail -n 25 ~/.npm/_logs/2021-10-23T22_01_51_769Z-debug.log 26 timing npm:load Completed in 82ms 27 timing command:run-script Completed in 37ms 28 verbose stack Error: Missing script: "start" 28 verbose stack 28 verbose stack Did you mean one of these? 28 verbose stack npm star # Mark your favorite packages 28 verbose stack npm stars # View packages marked as favorites 28 verbose stack 28 verbose stack To see a list of scripts, run: 28 verbose stack npm run 28 verbose stack at RunScript.run (/usr/lib/node_modules/npm/lib/run-script.js:105:13) 29 verbose cwd /home/JO_pi/MagicMirror/modules/MMM-MyStudyLife 30 verbose Linux 5.10.63-v7l+ 31 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "start" "dev" 32 verbose node v14.18.1 33 verbose npm v8.1.0 34 error Missing script: "start" 34 error 34 error Did you mean one of these? 34 error npm star # Mark your favorite packages 34 error npm stars # View packages marked as favorites 34 error 34 error To see a list of scripts, run: 34 error npm run 35 verbose exit 1 Module within my ~/MagicMirror/config/config.js { module: "MMM-MyStudyLife", position: "bottom_right", config: { code: "AAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Real code redacted showSchedule: true, showExams: true, showTasks: true, classes: { "English 101": [1,3], "Computing": [1], "Intro to Networking": [3], "Statistics": [4], "Psychology 102": [6] } } }, Lastly, I left the ~/MagicMirror/modules/MMM-MyStudyLife.js untouched as I reset the file to its default settings on your published GitHub. Let me know if I need to change anything in there — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

ethanpartida commented 2 years ago

Only the config should need be changed for the application to work, it would actually help my bugfixing if you left the .js file unchanged. Try running npm start dev in the terminal (when you are at the MagicMirror folder).

Oleson-Cybersec commented 2 years ago

My mmstart.sh script:

#!/bin/bash
cd ~/MagicMirror
node serveronly & sleep 30
xinit ~/chromium_start.sh

My chromium_start.sh script:

#!/bin/sh
unclutter &
xset -dpms # disable DPMS (Energy Star) features.
xset s off # disable screen saver
xset s noblank # don’t blank the video device
matchbox-window-manager &
chromium-browser --incognito --kiosk http://localhost:8080/

I used pm2 to run them, and have node v14.18.1 downloaded to install everything using git clone REPO_URL then npm install inside that new directory.

Oleson-Cybersec commented 2 years ago

Only the config should need be changed for the application to work, it would actually help my bugfixing if you left the .js file unchanged. Try running npm start dev in the terminal (when you are at the MagicMirror folder).

I'll remodify everything back to how it was and start again

Oleson-Cybersec commented 2 years ago

This is from my console within the Ctl + Shift + I command you had me put in:

MMM-MyStudyLife.js:78 Loading successful
MMM-MyStudyLife.js:355 sorting classes
TypeError: classes is not iterable
    at Class.sortClasses (MMM-MyStudyLife.js:356)
    at Class.makeSchedule (MMM-MyStudyLife.js:216)
    at Class.getDom (MMM-MyStudyLife.js:80)
    at main.js:113
    at new Promise (<anonymous>)
    at updateDom (main.js:111)
    at main.js:53
    at Array.forEach (<anonymous>)
    at createDomObjects (main.js:20)
    at Object.modulesStarted (main.js:502)
MMM-MyStudyLife.js:356 Uncaught (in promise) TypeError: classes is not iterable
    at Class.sortClasses (MMM-MyStudyLife.js:356)
    at Class.makeSchedule (MMM-MyStudyLife.js:216)
    at Class.getDom (MMM-MyStudyLife.js:80)
    at main.js:113
    at new Promise (<anonymous>)
    at updateDom (main.js:111)
    at main.js:53
    at Array.forEach (<anonymous>)
    at createDomObjects (main.js:20)
    at Object.modulesStarted (main.js:502)
5
weather.js:149 New weather information available.
localhost/:1 Refused to apply style from 'http://localhost:8080/css/custom.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
weather.js:149 New weather information available.
Oleson-Cybersec commented 2 years ago

After returning the MMM-MyStudyLife.js back, I restarted it and got this from the results using the ctl shift I

Load script: modules/MMM-MyStudyLife/MMM-MyStudyLife.js
module.js:509 Module registered: MMM-MyStudyLife
loader.js:155 Bootstrapping module: MMM-MyStudyLife
loader.js:160 Scripts loaded for: MMM-MyStudyLife
loader.js:203 Load stylesheet: modules/MMM-MyStudyLife/styles1.css
loader.js:244 File already loaded: font-awesome.css
loader.js:162 Styles loaded for: MMM-MyStudyLife
loader.js:164 Translations loaded for: MMM-MyStudyLife
ethanpartida commented 2 years ago

Ah this is good! Let me try to bugfix and I will get back to you.

Best, Ethan On Oct 23, 2021, 6:09 PM -0500, Jordan O. @.***>, wrote:

After returning the MMM-MyStudyLife.js back, I restarted it and got this from the results using the ctl shift I Load script: modules/MMM-MyStudyLife/MMM-MyStudyLife.js module.js:509 Module registered: MMM-MyStudyLife loader.js:155 Bootstrapping module: MMM-MyStudyLife loader.js:160 Scripts loaded for: MMM-MyStudyLife loader.js:203 Load stylesheet: modules/MMM-MyStudyLife/styles1.css loader.js:244 File already loaded: font-awesome.css loader.js:162 Styles loaded for: MMM-MyStudyLife loader.js:164 Translations loaded for: MMM-MyStudyLife — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Oleson-Cybersec commented 2 years ago

I got this from running npm start dev, within ~/MagicMirror

initial message from MMM-MyStudyLife

[23.10.2021 19:09.20.073] [LOG]   Module helper loaded: currentweather
[23.10.2021 19:09.20.075] [LOG]   No helper found for module: weather.
[23.10.2021 19:09.20.637] [LOG]   Initializing new module helper ...
[23.10.2021 19:09.20.638] [LOG]   Module helper loaded: MMM-MyStudyLife

Towards the bottom before launching applications

[23.10.2021 19:09.20.798] [LOG]   Connecting socket for: MMM-MyStudyLife
[23.10.2021 19:09.20.799] [LOG]   Sockets connected & modules started ...
[23.10.2021 19:09.21.162] [ERROR] Whoops! There was an uncaught exception...
[23.10.2021 19:09.21.173] [ERROR] Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
    at Server.setupListenHandle [as _listen2] (net.js:1318:16)
    at listenInCluster (net.js:1366:12)
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1503:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:8)
Oleson-Cybersec commented 2 years ago

Thanks for getting back to me Ethan, I really appreciate it! I barely learned the syntax for js so I'm very grateful. I'm trying to get all my class schedules and assignments right in front of me. Can't wait to have this displayed on my monitor

ethanpartida commented 2 years ago

I was unable to figure out why you're receiving that error but I included a message which should give me some more details in a recent patch. Try updating your branch and sending me the console log again. It should hopefully be something along the lines of

MMM-MyStudyLife.js:78 Loading successful
MMM-MyStudyLife.js:355 sorting classes
DATA AND INFO
TypeError: classes is not iterable