From 9938af6a3b0c7ec36f6922aef02b181431785d06 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Sat, 25 Mar 2023 17:09:23 +0000 Subject: [PATCH] added 'schedules' page, allowing quick enabling/disabling of schedule filters --- models/filter.go | 28 ++++++++------ web/templates/base.html | 8 ++-- web/templates/schedules.html | 49 ++++++++++++++++++++++++ web/web.go | 73 ++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 web/templates/schedules.html diff --git a/models/filter.go b/models/filter.go index 21ed39e..9d8d6ae 100644 --- a/models/filter.go +++ b/models/filter.go @@ -3,23 +3,27 @@ package models import ( "fmt" "html" + + "github.com/robfig/cron/v3" ) type FilterID uint type FilterType string type Filter struct { - ID FilterID `form:"filter_id" yaml:"filter_id" json:"filter_id"` - WatchID WatchID `form:"filter_watch_id" gorm:"index" yaml:"filter_watch_id" json:"filter_watch_id" binding:"required"` - Name string `form:"filter_name" gorm:"index" yaml:"filter_name" json:"filter_name" binding:"required" validate:"min=1"` - X int `form:"x" yaml:"x" json:"x" validate:"default=0"` - Y int `form:"y" yaml:"y" json:"y" validate:"default=0"` - Type FilterType `form:"filter_type" yaml:"filter_type" json:"filter_type" binding:"required" validate:"oneof=url xpath json css replace match substring math store condition cron"` - Var1 string `form:"var1" yaml:"var1" json:"var1" binding:"required"` - Var2 *string `form:"var2" yaml:"var2" json:"var2"` - Parents []*Filter `gorm:"-:all"` - Children []*Filter `gorm:"-:all"` - Results []string `gorm:"-:all"` - Logs []string `gorm:"-:all"` + ID FilterID `form:"filter_id" yaml:"filter_id" json:"filter_id"` + WatchID WatchID `form:"filter_watch_id" gorm:"index" yaml:"filter_watch_id" json:"filter_watch_id" binding:"required"` + Name string `form:"filter_name" gorm:"index" yaml:"filter_name" json:"filter_name" binding:"required" validate:"min=1"` + X int `form:"x" yaml:"x" json:"x" validate:"default=0"` + Y int `form:"y" yaml:"y" json:"y" validate:"default=0"` + Type FilterType `form:"filter_type" yaml:"filter_type" json:"filter_type" binding:"required" validate:"oneof=url xpath json css replace match substring math store condition cron"` + Var1 string `form:"var1" yaml:"var1" json:"var1" binding:"required"` + Var2 *string `form:"var2" yaml:"var2" json:"var2"` + Parents []*Filter `gorm:"-:all"` + Children []*Filter `gorm:"-:all"` + Results []string `gorm:"-:all"` + Logs []string `gorm:"-:all"` + CronEntry *cron.Entry `gorm:"-:all"` + Enabled string `gorm:"-:all"` // lazy fix for not being able to pointer deref in golang template.... } func (filter *Filter) Log(v ...any) { diff --git a/web/templates/base.html b/web/templates/base.html index 58cd63f..f0bc029 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -18,15 +18,12 @@