Комментирование, правки кода, исправление модальных окон

This commit is contained in:
XeRo 2026-01-15 17:55:52 +05:00
parent 2e8eee135e
commit 300afb5d26
8 changed files with 299 additions and 618 deletions

View file

@ -155,6 +155,7 @@ func ComputeValue(computeExpr string, app *types.PackageApplication) (interface{
return result, nil
}
// Recompute производит перерасчет всех полей
func Recompute(app *types.PackageApplication) {
for i := range app.Sections {
section := &app.Sections[i]
@ -162,7 +163,8 @@ func Recompute(app *types.PackageApplication) {
field := &section.Fields[j]
if field.FieldType == "compute" && field.Compute != "" {
if field.Variable != nil {
continue //?почему мы пропускаем
// todo почему мы пропускаем?
continue
}
value, err := ComputeValue(field.Compute, app)
if err != nil {
@ -174,8 +176,10 @@ func Recompute(app *types.PackageApplication) {
}
}
// DefineExprCustomFunctions возвращает собственные функции expr
func DefineExprCustomFunctions() []expr.Option {
return []expr.Option{
//вычисляет значение по заданному регулярному выражению
expr.Function("regex",
func(args ...interface{}) (interface{}, error) {
if len(args) != 3 {
@ -191,6 +195,7 @@ func DefineExprCustomFunctions() []expr.Option {
return re.ReplaceAllString(input, repl), nil
}, new(func(string, string, string) string),
),
//проверяет совпадение переданного значения и указанного регулярного выражения
expr.Function("regex_match",
func(args ...interface{}) (interface{}, error) {
if len(args) != 2 {
@ -207,6 +212,7 @@ func DefineExprCustomFunctions() []expr.Option {
}, new(func(string, string) bool),
),
//возвращает собственный текст ошибки
expr.Function("error",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -216,6 +222,7 @@ func DefineExprCustomFunctions() []expr.Option {
},
new(func(string) error),
),
//возвращает тело ответа по указанному адресу
expr.Function("http_get",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -232,6 +239,7 @@ func DefineExprCustomFunctions() []expr.Option {
},
new(func(string) string),
),
//возвращает результат выполнения команды из оболочки
expr.Function("shell",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -250,6 +258,7 @@ func DefineExprCustomFunctions() []expr.Option {
},
new(func(string) error),
),
//возвращает значение указанной переменной из env
expr.Function("env",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -258,6 +267,7 @@ func DefineExprCustomFunctions() []expr.Option {
return os.Getenv(fmt.Sprintf("%v", args[0])), nil
}, new(func(string) error),
),
//проверяет наличие файла в системе
expr.Function("file_exists",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -268,6 +278,7 @@ func DefineExprCustomFunctions() []expr.Option {
return err == nil, nil
}, new(func(string) bool),
),
//проверяет наличие директории в системе
expr.Function("dir_exists",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -284,6 +295,7 @@ func DefineExprCustomFunctions() []expr.Option {
return false, nil
}, new(func(string) bool),
),
//проверяет доступность порта
expr.Function("port_free",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -294,6 +306,7 @@ func DefineExprCustomFunctions() []expr.Option {
return cmd.Run() != nil, nil
}, new(func(string) error),
),
//проверяет наличие пользователя в системе
expr.Function("user_exists",
func(args ...interface{}) (interface{}, error) {
if len(args) == 0 {
@ -307,6 +320,7 @@ func DefineExprCustomFunctions() []expr.Option {
}
}
// SpecialValueHandle получаем необычные значения полей
func SpecialValueHandle(special string) interface{} {
specialValue := strings.Split(special, "code:")[1]
switch specialValue {