diff --git a/pkg/expr/expr.go b/pkg/expr/expr.go index 3f346889f52af08e87a431caecf1513768fc12c1..1969b58c6bec892b05f8eff38eec86f3d4099e01 100644 --- a/pkg/expr/expr.go +++ b/pkg/expr/expr.go @@ -31,11 +31,6 @@ func Eval(ctx context.Context, input string, env map[string]interface{}) (interf } for k, v := range env { - if mapper, ok := v.(Mapper); ok { - e[k] = mapper.ToMap() - continue - } - e[k] = v } @@ -83,8 +78,4 @@ func IsExpression(input string) bool { } return false -} - -type Mapper interface { - ToMap() map[string]interface{} } \ No newline at end of file diff --git a/pkg/extension/schema.go b/pkg/extension/schema.go index 6b38a6d37a43b11fad1221ec947f5d0666313e93..501de9a247c3ba4240dc50ba641d7e2c56a1d2fc 100644 --- a/pkg/extension/schema.go +++ b/pkg/extension/schema.go @@ -25,7 +25,7 @@ func NewActionsCollection(spaceID, envID string) *collections.Collection { "extension", field.String().SetTitle("Расширение (Deprecated)"), "name", field.String().SetTitle("Название").SetTextSearch(true), "description", field.String().SetTitle("Описание"), - "icon", field.String().SetTitle("Название РёРєРѕРЅРєРё"), + "icon", field.String().SetTitle("Название РёРєРѕРЅРєРё").WithUI(&field.UI{Widget: "Icon"}), "image", references.Field([]string{"media"}).SetTitle("Рзображение").WithUI(&field.UI{Widget: "Media"}), "kind", field.Number( field.NumberFormatInt, @@ -126,7 +126,7 @@ func NewExtensionsCollection(spaceID, envID string) *collections.Collection { ).SetTitle("Состояние").WithUI(&field.UI{Widget: "Select"}), ) - //UI + // UI sch.Field.UI.ListView = &field.View{Options: map[string]interface{}{ "fields": []interface{}{"id", "title", "extension_state", "updated_at", "updated_by"}, "sort": []interface{}{"title"}, diff --git a/pkg/files/file.go b/pkg/files/file.go index fc12151b69655ecef0a8f6309c54e02e65fc76f0..5700309d4e180d8a242eccc87bf8ed4581ff39bd 100644 --- a/pkg/files/file.go +++ b/pkg/files/file.go @@ -16,12 +16,12 @@ const ( // File - описание файла РІ системе хранения perxis type File struct { - ID string `mapstructure:"id,omitempty" json:"id"` // Уникальный идентификатор файла РІ хранилище - Name string `mapstructure:"name,omitempty" json:"name" bson:"name,omitempty"` // РРјСЏ файла - Size int `mapstructure:"size,omitempty" json:"size" bson:"size,omitempty"` // Размер файла - MimeType string `mapstructure:"mimeType,omitempty" json:"mimeType" bson:"mimeType,omitempty"` // Mime-type файла - URL string `mapstructure:"url,omitempty" json:"url" bson:"url,omitempty"` // Адрес для загрузки файла - Key string `mapstructure:"key,omitempty" json:"key" bson:"key,omitempty"` // Ключ для хранения файла РІ хранилище + ID string `mapstructure:"id,omitempty" json:"id" expr:"id"` // Уникальный идентификатор файла РІ хранилище + Name string `mapstructure:"name,omitempty" json:"name" bson:"name,omitempty" expr:"name"` // РРјСЏ файла + Size int `mapstructure:"size,omitempty" json:"size" bson:"size,omitempty" expr:"size"` // Размер файла + MimeType string `mapstructure:"mimeType,omitempty" json:"mimeType" bson:"mimeType,omitempty" expr:"mime_type"` // Mime-type файла + URL string `mapstructure:"url,omitempty" json:"url" bson:"url,omitempty" expr:"url"` // Адрес для загрузки файла + Key string `mapstructure:"key,omitempty" json:"key" bson:"key,omitempty" expr:"key"` // Ключ для хранения файла РІ хранилище File fs.File `mapstructure:"-" json:"-" bson:"-"` // Файл для загрузки(РёР· файловой системы) } @@ -47,17 +47,6 @@ func (f *File) SetURLWithTemplate(t *template.Template) error { return nil } -func (f File) ToMap() map[string]interface{} { - return map[string]interface{}{ - "id": f.ID, - "name": f.Name, - "size": f.Size, - "mime_type": f.MimeType, - "url": f.URL, - "key": f.Key, - } -} - func NewFile(name, mimeType string, size int, temp bool) *File { i := id.GenerateNewID() if temp { diff --git a/pkg/files/uploader.go b/pkg/files/uploader.go index 5b03f62a8007c85a64bdaa3ce8961f4d28ceaef3..a26b4cea1ea9fba0411380579f138f8a1a455ec9 100644 --- a/pkg/files/uploader.go +++ b/pkg/files/uploader.go @@ -33,6 +33,7 @@ func (u *uploader) Upload(src io.Reader, upload *Upload) error { if err != nil { return err } + resp.Body.Close() if resp.StatusCode != http.StatusOK { return errors.New("upload request failed: " + resp.Status) diff --git a/pkg/references/reference.go b/pkg/references/reference.go index b1b56953f98131dfebf69c41c3ff53299ff09384..171ded420c3fd5601cac9ad9f74ad69883f964ea 100644 --- a/pkg/references/reference.go +++ b/pkg/references/reference.go @@ -7,9 +7,9 @@ import ( ) type Reference struct { - ID string `json:"id" bson:"id" mapstructure:"id"` - CollectionID string `json:"collection_id" bson:"collection_id" mapstructure:"collection_id"` - Disabled bool `json:"disabled,omitempty" bson:"disabled,omitempty" mapstructure:"disabled"` + ID string `json:"id" bson:"id" mapstructure:"id" expr:"id"` + CollectionID string `json:"collection_id" bson:"collection_id" mapstructure:"collection_id" expr:"collection_id"` + Disabled bool `json:"disabled,omitempty" bson:"disabled,omitempty" mapstructure:"disabled" expr:"disabled"` } func (r *Reference) MarshalBSON() ([]byte, error) { @@ -25,13 +25,6 @@ func (r *Reference) MarshalBSON() ([]byte, error) { return bson.Marshal(d) } -func (r *Reference) ToMap() map[string]interface{} { - return map[string]interface{}{ - "collection_id": r.CollectionID, - "id": r.ID, - } -} - func ReferenceFromPB(refPB *pb.Reference) *Reference { if refPB == nil { return nil