diff --git a/models.go b/models.go index 3d729fd..cef025d 100644 --- a/models.go +++ b/models.go @@ -12,7 +12,7 @@ type Filter struct { Name string `form:"filter_name" 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 string `form:"filter_type" yaml:"filter_type" json:"filter_type" binding:"required" validate:"oneof=url xpath json css replace match substring min max average count"` + Type string `form:"filter_type" yaml:"filter_type" json:"filter_type" binding:"required" validate:"oneof=url xpath json css replace match substring math"` Var1 string `form:"var1" yaml:"var1" json:"var1" binding:"required"` Var2 *string `form:"var2" yaml:"var2" json:"var2"` Var3 *string `form:"var3" yaml:"var3" json:"var3"` diff --git a/scraping.go b/scraping.go index 60aa5e2..e33aff9 100644 --- a/scraping.go +++ b/scraping.go @@ -72,22 +72,28 @@ func getFilterResult(filter *Filter) { { getFilterResultSubstring(filter) } - case filter.Type == "min": + case filter.Type == "math": { - getFilterResultMin(filter) - } - case filter.Type == "max": - { - getFilterResultMax(filter) - } - case filter.Type == "average": - { - getFilterResultAverage(filter) - } - case filter.Type == "count": - { - getFilterResultCount(filter) + switch { + case filter.Var1 == "min": + { + getFilterResultMin(filter) + } + case filter.Var1 == "max": + { + getFilterResultMax(filter) + } + case filter.Var1 == "average": + { + getFilterResultAverage(filter) + } + case filter.Var1 == "count": + { + getFilterResultCount(filter) + } + } } + default: log.Println("getFilterResult called with filter.Type == ", filter.Type) } diff --git a/static/edit.js b/static/edit.js index f95b430..a1831cd 100644 --- a/static/edit.js +++ b/static/edit.js @@ -279,6 +279,7 @@ function onTypeChange(node) { } case "math": { var mathSelect = document.createElement("select"); + mathSelect.name = "var1"; mathSelect.id = "var1Input"; mathSelect.classList.add("form-control"); var mathOptionMin = document.createElement("option"); diff --git a/static/edit.ts b/static/edit.ts index 81e1de9..2bd12db 100644 --- a/static/edit.ts +++ b/static/edit.ts @@ -268,6 +268,7 @@ function onTypeChange(node: DiagramNode | null = null){ } case "math": { let mathSelect = document.createElement("select"); + mathSelect.name = "var1"; mathSelect.id = "var1Input"; mathSelect.classList.add("form-control"); let mathOptionMin = document.createElement("option");