Fix some linting problems
This commit is contained in:
+11
-10
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
@@ -96,7 +97,7 @@ type CreateExploreMapResponse struct {
|
||||
// 500: internalServerError
|
||||
func (hs *HTTPServer) listExploreMaps(c *contextmodel.ReqContext) response.Response {
|
||||
query := &exploremap.GetExploreMapsQuery{
|
||||
OrgID: c.SignedInUser.GetOrgID(),
|
||||
OrgID: c.GetOrgID(),
|
||||
Limit: c.QueryInt("limit"),
|
||||
}
|
||||
|
||||
@@ -126,12 +127,12 @@ func (hs *HTTPServer) getExploreMap(c *contextmodel.ReqContext) response.Respons
|
||||
uid := web.Params(c.Req)[":uid"]
|
||||
query := &exploremap.GetExploreMapByUIDQuery{
|
||||
UID: uid,
|
||||
OrgID: c.SignedInUser.GetOrgID(),
|
||||
OrgID: c.GetOrgID(),
|
||||
}
|
||||
|
||||
m, err := hs.exploreMapService.Get(c.Req.Context(), query)
|
||||
if err != nil {
|
||||
if err == exploremap.ErrExploreMapNotFound {
|
||||
if errors.Is(err, exploremap.ErrExploreMapNotFound) {
|
||||
return response.Error(http.StatusNotFound, "Explore map not found", err)
|
||||
}
|
||||
return response.Error(http.StatusInternalServerError, "Failed to get explore map", err)
|
||||
@@ -155,8 +156,8 @@ func (hs *HTTPServer) createExploreMap(c *contextmodel.ReqContext) response.Resp
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
|
||||
cmd.OrgID = c.SignedInUser.GetOrgID()
|
||||
cmd.CreatedBy = c.SignedInUser.UserID
|
||||
cmd.OrgID = c.GetOrgID()
|
||||
cmd.CreatedBy = c.UserID
|
||||
|
||||
m, err := hs.exploreMapService.Create(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
@@ -184,12 +185,12 @@ func (hs *HTTPServer) updateExploreMap(c *contextmodel.ReqContext) response.Resp
|
||||
}
|
||||
|
||||
cmd.UID = uid
|
||||
cmd.OrgID = c.SignedInUser.GetOrgID()
|
||||
cmd.UpdatedBy = c.SignedInUser.UserID
|
||||
cmd.OrgID = c.GetOrgID()
|
||||
cmd.UpdatedBy = c.UserID
|
||||
|
||||
m, err := hs.exploreMapService.Update(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
if err == exploremap.ErrExploreMapNotFound {
|
||||
if errors.Is(err, exploremap.ErrExploreMapNotFound) {
|
||||
return response.Error(http.StatusNotFound, "Explore map not found", err)
|
||||
}
|
||||
return response.Error(http.StatusInternalServerError, "Failed to update explore map", err)
|
||||
@@ -212,12 +213,12 @@ func (hs *HTTPServer) deleteExploreMap(c *contextmodel.ReqContext) response.Resp
|
||||
uid := web.Params(c.Req)[":uid"]
|
||||
cmd := &exploremap.DeleteExploreMapCommand{
|
||||
UID: uid,
|
||||
OrgID: c.SignedInUser.GetOrgID(),
|
||||
OrgID: c.GetOrgID(),
|
||||
}
|
||||
|
||||
err := hs.exploreMapService.Delete(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
if err == exploremap.ErrExploreMapNotFound {
|
||||
if errors.Is(err, exploremap.ErrExploreMapNotFound) {
|
||||
return response.Error(http.StatusNotFound, "Explore map not found", err)
|
||||
}
|
||||
return response.Error(http.StatusInternalServerError, "Failed to delete explore map", err)
|
||||
|
||||
@@ -64,6 +64,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/datasources/guardian"
|
||||
"github.com/grafana/grafana/pkg/services/encryption"
|
||||
"github.com/grafana/grafana/pkg/services/exploremap"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/hooks"
|
||||
@@ -80,7 +81,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/playlist"
|
||||
"github.com/grafana/grafana/pkg/services/exploremap"
|
||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/managedplugins"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginassets"
|
||||
|
||||
+1
-1
@@ -91,6 +91,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/dsquerierclient"
|
||||
"github.com/grafana/grafana/pkg/services/encryption"
|
||||
encryptionservice "github.com/grafana/grafana/pkg/services/encryption/service"
|
||||
"github.com/grafana/grafana/pkg/services/exploremap/exploremapimpl"
|
||||
"github.com/grafana/grafana/pkg/services/extsvcauth"
|
||||
extsvcreg "github.com/grafana/grafana/pkg/services/extsvcauth/registry"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
@@ -120,7 +121,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/oauthtoken/oauthtokentest"
|
||||
"github.com/grafana/grafana/pkg/services/org/orgimpl"
|
||||
"github.com/grafana/grafana/pkg/services/playlist/playlistimpl"
|
||||
"github.com/grafana/grafana/pkg/services/exploremap/exploremapimpl"
|
||||
"github.com/grafana/grafana/pkg/services/plugindashboards"
|
||||
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration"
|
||||
|
||||
@@ -66,8 +66,8 @@ func (h *ExploreMapChannelHandler) OnSubscribe(ctx context.Context, user identit
|
||||
type messageType string
|
||||
|
||||
const (
|
||||
MessageTypeCursorUpdate messageType = "cursor_update"
|
||||
MessageTypeCursorLeave messageType = "cursor_leave"
|
||||
MessageTypeCursorUpdate messageType = "cursor_update"
|
||||
MessageTypeCursorLeave messageType = "cursor_leave"
|
||||
MessageTypeViewportUpdate messageType = "viewport_update"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package realtime
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -26,7 +27,6 @@ type OperationHub struct {
|
||||
liveService *live.GrafanaLive
|
||||
store Store
|
||||
states *StateCache
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// StateCache holds in-memory CRDT states for active maps
|
||||
@@ -124,8 +124,14 @@ func (h *OperationHub) applyOperation(state *MapState, op crdt.Operation) error
|
||||
}
|
||||
}
|
||||
|
||||
// Other operation types don't need special handling in the hub
|
||||
// They're applied at the client level
|
||||
case crdt.OpUpdatePanelPosition,
|
||||
crdt.OpUpdatePanelSize,
|
||||
crdt.OpUpdatePanelZIndex,
|
||||
crdt.OpUpdatePanelExplore,
|
||||
crdt.OpAddComment,
|
||||
crdt.OpRemoveComment:
|
||||
// These operation types don't need special handling in the hub
|
||||
// They're applied at the client level
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -199,7 +205,7 @@ func (h *OperationHub) snapshotAll(ctx context.Context) {
|
||||
for _, uid := range mapUIDs {
|
||||
if err := h.SnapshotState(ctx, uid); err != nil {
|
||||
// Ignore "not found" errors - map may have been deleted or not yet created
|
||||
if err != exploremap.ErrExploreMapNotFound {
|
||||
if !errors.Is(err, exploremap.ErrExploreMapNotFound) {
|
||||
logger.Warn("Failed to snapshot state", "error", err, "mapUid", uid)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user