fixed last bit of math filtertype

This commit is contained in:
BroodjeAap 2022-09-29 17:11:14 +00:00
parent 9baa980df6
commit 9945cba323
4 changed files with 23 additions and 15 deletions

View file

@ -12,7 +12,7 @@ type Filter struct {
Name string `form:"filter_name" yaml:"filter_name" json:"filter_name" binding:"required" validate:"min=1"` 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"` X int `form:"x" yaml:"x" json:"x" validate:"default=0"`
Y int `form:"y" yaml:"y" json:"y" 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"` Var1 string `form:"var1" yaml:"var1" json:"var1" binding:"required"`
Var2 *string `form:"var2" yaml:"var2" json:"var2"` Var2 *string `form:"var2" yaml:"var2" json:"var2"`
Var3 *string `form:"var3" yaml:"var3" json:"var3"` Var3 *string `form:"var3" yaml:"var3" json:"var3"`

View file

@ -72,22 +72,28 @@ func getFilterResult(filter *Filter) {
{ {
getFilterResultSubstring(filter) getFilterResultSubstring(filter)
} }
case filter.Type == "min": case filter.Type == "math":
{ {
getFilterResultMin(filter) switch {
} case filter.Var1 == "min":
case filter.Type == "max": {
{ getFilterResultMin(filter)
getFilterResultMax(filter) }
} case filter.Var1 == "max":
case filter.Type == "average": {
{ getFilterResultMax(filter)
getFilterResultAverage(filter) }
} case filter.Var1 == "average":
case filter.Type == "count": {
{ getFilterResultAverage(filter)
getFilterResultCount(filter) }
case filter.Var1 == "count":
{
getFilterResultCount(filter)
}
}
} }
default: default:
log.Println("getFilterResult called with filter.Type == ", filter.Type) log.Println("getFilterResult called with filter.Type == ", filter.Type)
} }

View file

@ -279,6 +279,7 @@ function onTypeChange(node) {
} }
case "math": { case "math": {
var mathSelect = document.createElement("select"); var mathSelect = document.createElement("select");
mathSelect.name = "var1";
mathSelect.id = "var1Input"; mathSelect.id = "var1Input";
mathSelect.classList.add("form-control"); mathSelect.classList.add("form-control");
var mathOptionMin = document.createElement("option"); var mathOptionMin = document.createElement("option");

View file

@ -268,6 +268,7 @@ function onTypeChange(node: DiagramNode | null = null){
} }
case "math": { case "math": {
let mathSelect = document.createElement("select"); let mathSelect = document.createElement("select");
mathSelect.name = "var1";
mathSelect.id = "var1Input"; mathSelect.id = "var1Input";
mathSelect.classList.add("form-control"); mathSelect.classList.add("form-control");
let mathOptionMin = document.createElement("option"); let mathOptionMin = document.createElement("option");