From 708833b7025b2a00db2e890067e74b74697604b0 Mon Sep 17 00:00:00 2001 From: Piyush Chauhan <42397980+pyshx@users.noreply.github.com> Date: Tue, 5 Sep 2023 07:21:51 +0530 Subject: [PATCH] chore(server): handle visibility for nls layer (#661) --- server/gql/newlayer.graphql | 1 + server/internal/adapter/gql/generated.go | 11 ++++++++++- server/internal/adapter/gql/gqlmodel/models_gen.go | 1 + .../adapter/gql/resolver_mutation_nlslayer.go | 1 + server/internal/usecase/interactor/nlslayer.go | 1 + server/internal/usecase/interfaces/nlslayer.go | 1 + server/pkg/nlslayer/nlslayerops/intializer.go | 7 +++++++ 7 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/gql/newlayer.graphql b/server/gql/newlayer.graphql index 615427e00d..7ac67e1482 100644 --- a/server/gql/newlayer.graphql +++ b/server/gql/newlayer.graphql @@ -44,6 +44,7 @@ input AddNLSLayerSimpleInput { sceneId: ID! config: JSON index: Int + visible: Boolean } input RemoveNLSLayerInput { diff --git a/server/internal/adapter/gql/generated.go b/server/internal/adapter/gql/generated.go index 5297c8272a..72f4aa0600 100644 --- a/server/internal/adapter/gql/generated.go +++ b/server/internal/adapter/gql/generated.go @@ -8309,6 +8309,7 @@ input AddNLSLayerSimpleInput { sceneId: ID! config: JSON index: Int + visible: Boolean } input RemoveNLSLayerInput { @@ -53887,7 +53888,7 @@ func (ec *executionContext) unmarshalInputAddNLSLayerSimpleInput(ctx context.Con asMap[k] = v } - fieldsInOrder := [...]string{"layerType", "title", "sceneId", "config", "index"} + fieldsInOrder := [...]string{"layerType", "title", "sceneId", "config", "index", "visible"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -53934,6 +53935,14 @@ func (ec *executionContext) unmarshalInputAddNLSLayerSimpleInput(ctx context.Con if err != nil { return it, err } + case "visible": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("visible")) + it.Visible, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } } } diff --git a/server/internal/adapter/gql/gqlmodel/models_gen.go b/server/internal/adapter/gql/gqlmodel/models_gen.go index a32456dce5..0f073ac237 100644 --- a/server/internal/adapter/gql/gqlmodel/models_gen.go +++ b/server/internal/adapter/gql/gqlmodel/models_gen.go @@ -118,6 +118,7 @@ type AddNLSLayerSimpleInput struct { SceneID ID `json:"sceneId"` Config JSON `json:"config"` Index *int `json:"index"` + Visible *bool `json:"visible"` } type AddNLSLayerSimplePayload struct { diff --git a/server/internal/adapter/gql/resolver_mutation_nlslayer.go b/server/internal/adapter/gql/resolver_mutation_nlslayer.go index 3ec25994ac..430a5f20bd 100644 --- a/server/internal/adapter/gql/resolver_mutation_nlslayer.go +++ b/server/internal/adapter/gql/resolver_mutation_nlslayer.go @@ -21,6 +21,7 @@ func (r *mutationResolver) AddNLSLayerSimple(ctx context.Context, input gqlmodel Index: input.Index, LayerType: gqlmodel.ToNLSLayerType(input.LayerType), Config: gqlmodel.ToNLSConfig(input.Config), + Visible: input.Visible, } layer, err := usecases(ctx).NLSLayer.AddLayerSimple(ctx, inp, getOperator(ctx)) diff --git a/server/internal/usecase/interactor/nlslayer.go b/server/internal/usecase/interactor/nlslayer.go index 98fcc3a1f2..334ac7187d 100644 --- a/server/internal/usecase/interactor/nlslayer.go +++ b/server/internal/usecase/interactor/nlslayer.go @@ -70,6 +70,7 @@ func (i *NLSLayer) AddLayerSimple(ctx context.Context, inp interfaces.AddNLSLaye LayerType: inp.LayerType, Index: inp.Index, Title: inp.Title, + Visible: inp.Visible, }.Initialize() if err != nil { return nil, err diff --git a/server/internal/usecase/interfaces/nlslayer.go b/server/internal/usecase/interfaces/nlslayer.go index d4bb5517ec..e1bce1f762 100644 --- a/server/internal/usecase/interfaces/nlslayer.go +++ b/server/internal/usecase/interfaces/nlslayer.go @@ -15,6 +15,7 @@ type AddNLSLayerSimpleInput struct { Index *int LayerType nlslayer.LayerType Config *nlslayer.Config + Visible *bool } type UpdateNLSLayerInput struct { diff --git a/server/pkg/nlslayer/nlslayerops/intializer.go b/server/pkg/nlslayer/nlslayerops/intializer.go index 8ee8c6114a..b0e88a0e5c 100644 --- a/server/pkg/nlslayer/nlslayerops/intializer.go +++ b/server/pkg/nlslayer/nlslayerops/intializer.go @@ -11,6 +11,7 @@ type LayerSimple struct { Config *nlslayer.Config Index *int Title string + Visible *bool } func (i LayerSimple) Initialize() (*nlslayer.NLSLayerSimple, error) { @@ -21,6 +22,12 @@ func (i LayerSimple) Initialize() (*nlslayer.NLSLayerSimple, error) { builder.Config(i.Config) } + if i.Visible != nil { + builder.IsVisible(*i.Visible) + } else { + builder.IsVisible(true) + } + var layerSimple *nlslayer.NLSLayerSimple if i.LayerType.IsValidLayerType() {