A mobile interface for the OpenSprinkler irrigation device. Designed to allow manual control, program management (preview, add, edit, and delete), initiation of a run-once program, viewing graphical and tabulated representations of log data, viewing device status, adjusting rain delay, and changing of OpenSprinkler settings.
Huge refactor! please review carefully, please test locally and give feedback/input!
This is an attempt to clean up and slightly modernize the code base to make it easier to work on, test and potentially facilitate a migration to a modern frontend framework in the future. The main.js file is unwieldly at nearly 14000 lines, which makes it difficult to understand & work on, lags the IDE and prevents auto generation of unit tests (AI tools will fail to generate sufficient unit tests due to the size).
IMO the monolith main.js needs be broken down into smaller pieces, separating concerns whenever possible, then backfilling unit tests for functionality. This will set the stage for the looming future task of migrating the project to a modern frontend framework with ES6 functionality and a build tool like Parcel (or webpack). Given the current lack of unit tests, it seems dangerous to attempt any such migration (or major feature branch) right now.
💡 This PR aims to:
create es5 style "modules" or "namespaces" to organize code and split files (using the OSApp object namespace)
move all existing global variables into dedicated namespaces (example OSApp.currentSession, OSApp.Constants, etc)
rename existing global variables to be more descriptive whenever possible
attempt to separate immutable constant values from state/session variables (session, site, weather, ui state, etc)
create a /www/js/modules folder to house cleaned/refactored files
move vendor js (jquery, jqm, datatables, etc) to the /www/vendor-js folder to bypass styling/linting checks
reconfigure grunt jshint and jscs tasks to look at all /www/js/**/.js files
slightly change the grunt-jscs style rules to prevent massive edits due to line length
reconfigure some grunt tasks (bump, add bump-version)
❓ What other scripts/commands need updating to include the new js files for build/deploy steps?
increment version to 2.4.3
🦾 What I need help with
Review code for typos/bugs
Give your input on naming conventions and patterns
Check pr out locally and test with your OS devices
Report any console errors or other bugs that show up
🚨 Changes Proposed
Huge refactor! please review carefully, please test locally and give feedback/input!
This is an attempt to clean up and slightly modernize the code base to make it easier to work on, test and potentially facilitate a migration to a modern frontend framework in the future. The
main.js
file is unwieldly at nearly 14000 lines, which makes it difficult to understand & work on, lags the IDE and prevents auto generation of unit tests (AI tools will fail to generate sufficient unit tests due to the size).IMO the monolith
main.js
needs be broken down into smaller pieces, separating concerns whenever possible, then backfilling unit tests for functionality. This will set the stage for the looming future task of migrating the project to a modern frontend framework with ES6 functionality and a build tool like Parcel (or webpack). Given the current lack of unit tests, it seems dangerous to attempt any such migration (or major feature branch) right now.💡 This PR aims to:
OSApp
object namespace)OSApp.currentSession
,OSApp.Constants
, etc)/www/js/modules
folder to house cleaned/refactored files/www/js/**/.js
filesgrunt-jscs
style rules to prevent massive edits due to line length🦾 What I need help with
🎥 Demo Video or Screenshots
https://streamable.com/i0hy9c
🔢 Final line counts for js files: