light modification
This commit is contained in:
parent
e741a95cdb
commit
5c2980fb36
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
type AbstractResource struct {
|
type AbstractResource struct {
|
||||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||||
|
Type string `json:"type,omitempty" bson:"type,omitempty"` // Type is the type of the resource
|
||||||
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"` // Logo is the logo of the resource
|
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"` // Logo is the logo of the resource
|
||||||
Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource
|
Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource
|
||||||
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
|
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
|
||||||
@ -85,6 +86,7 @@ func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.AP
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *AbstractIntanciatedResource[T]) Trim() {
|
func (d *AbstractIntanciatedResource[T]) Trim() {
|
||||||
|
d.Type = d.GetType()
|
||||||
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
|
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
|
||||||
for _, instance := range d.Instances {
|
for _, instance := range d.Instances {
|
||||||
instance.ClearPeerGroups()
|
instance.ClearPeerGroups()
|
||||||
|
@ -2,7 +2,6 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
"cloud.o-forge.io/core/oc-lib/logs"
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
@ -83,9 +82,6 @@ func (wfa *resourceMongoAccessor[T]) Search(filters *dbs.Filters, search string,
|
|||||||
return utils.GenericSearch[T](filters, search, wfa.getResourceFilter(search),
|
return utils.GenericSearch[T](filters, search, wfa.getResourceFilter(search),
|
||||||
func(d utils.DBObject) utils.ShallowDBObject {
|
func(d utils.DBObject) utils.ShallowDBObject {
|
||||||
d.(T).SetAllowedInstances(wfa.Request)
|
d.(T).SetAllowedInstances(wfa.Request)
|
||||||
if strings.Contains(d.(T).GetType(), search) && search != "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err == nil && len(resources) > 0 {
|
if err == nil && len(resources) > 0 {
|
||||||
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
||||||
}
|
}
|
||||||
@ -100,6 +96,7 @@ func (abs *resourceMongoAccessor[T]) getResourceFilter(search string) *dbs.Filte
|
|||||||
return &dbs.Filters{
|
return &dbs.Filters{
|
||||||
Or: map[string][]dbs.Filter{ // filter by like name, short_description, description, owner, url if no filters are provided
|
Or: map[string][]dbs.Filter{ // filter by like name, short_description, description, owner, url if no filters are provided
|
||||||
"abstractintanciatedresource.abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
"abstractintanciatedresource.abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
|
"abstractintanciatedresource.abstractresource.abstractobject.type": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
"abstractintanciatedresource.abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
|
"abstractintanciatedresource.abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
"abstractintanciatedresource.abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
|
"abstractintanciatedresource.abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
"abstractintanciatedresource.abstractresource.owners.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
"abstractintanciatedresource.abstractresource.owners.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
|
Loading…
Reference in New Issue
Block a user