WIP rules as js functions
Schema: added rule table. added more default groups

Also fixed a small bug in watch controller.
Merge branch 'Rules-for-measuring-groups' into staging