Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
67ec9edc
Unverified
Commit
67ec9edc
authored
Feb 28, 2020
by
Carl Bergquist
Committed by
GitHub
Feb 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: avoid alias for models in plugins (#22483)
parent
f2f2722b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
37 deletions
+37
-37
pkg/api/dtos/invite.go
+2
-2
pkg/plugins/dashboard_importer.go
+5
-5
pkg/plugins/dashboard_importer_test.go
+2
-2
pkg/plugins/dashboards.go
+5
-5
pkg/plugins/dashboards_test.go
+6
-6
pkg/plugins/dashboards_updater.go
+9
-9
pkg/plugins/models.go
+3
-3
pkg/plugins/queries.go
+5
-5
No files found.
pkg/api/dtos/invite.go
View file @
67ec9edc
package
dtos
import
m
"github.com/grafana/grafana/pkg/models"
import
"github.com/grafana/grafana/pkg/models"
type
AddInviteForm
struct
{
LoginOrEmail
string
`json:"loginOrEmail" binding:"Required"`
Name
string
`json:"name"`
Role
m
.
RoleType
`json:"role" binding:"Required"`
Role
m
odels
.
RoleType
`json:"role" binding:"Required"`
SendEmail
bool
`json:"sendEmail"`
}
...
...
pkg/plugins/dashboard_importer.go
View file @
67ec9edc
...
...
@@ -7,7 +7,7 @@ import (
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboards"
)
...
...
@@ -19,7 +19,7 @@ type ImportDashboardCommand struct {
FolderId
int64
OrgId
int64
User
*
m
.
SignedInUser
User
*
m
odels
.
SignedInUser
PluginId
string
Result
*
PluginDashboardInfoDTO
}
...
...
@@ -44,7 +44,7 @@ func init() {
}
func
ImportDashboard
(
cmd
*
ImportDashboardCommand
)
error
{
var
dashboard
*
m
.
Dashboard
var
dashboard
*
m
odels
.
Dashboard
var
err
error
if
cmd
.
PluginId
!=
""
{
...
...
@@ -52,7 +52,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error {
return
err
}
}
else
{
dashboard
=
m
.
NewDashboardFromJson
(
cmd
.
Dashboard
)
dashboard
=
m
odels
.
NewDashboardFromJson
(
cmd
.
Dashboard
)
}
evaluator
:=
&
DashTemplateEvaluator
{
...
...
@@ -65,7 +65,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error {
return
err
}
saveCmd
:=
m
.
SaveDashboardCommand
{
saveCmd
:=
m
odels
.
SaveDashboardCommand
{
Dashboard
:
generatedDash
,
OrgId
:
cmd
.
OrgId
,
UserId
:
cmd
.
User
.
UserId
,
...
...
pkg/plugins/dashboard_importer_test.go
View file @
67ec9edc
...
...
@@ -5,7 +5,7 @@ import (
"testing"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/setting"
.
"github.com/smartystreets/goconvey/convey"
...
...
@@ -22,7 +22,7 @@ func TestDashboardImport(t *testing.T) {
PluginId
:
"test-app"
,
Path
:
"dashboards/connections.json"
,
OrgId
:
1
,
User
:
&
m
.
SignedInUser
{
UserId
:
1
,
OrgRole
:
m
.
ROLE_ADMIN
},
User
:
&
m
odels
.
SignedInUser
{
UserId
:
1
,
OrgRole
:
models
.
ROLE_ADMIN
},
Inputs
:
[]
ImportDashboardInput
{
{
Name
:
"*"
,
Type
:
"datasource"
,
Value
:
"graphite"
},
},
...
...
pkg/plugins/dashboards.go
View file @
67ec9edc
...
...
@@ -6,7 +6,7 @@ import (
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
)
type
PluginDashboardInfoDTO
struct
{
...
...
@@ -35,7 +35,7 @@ func GetPluginDashboards(orgId int64, pluginId string) ([]*PluginDashboardInfoDT
result
:=
make
([]
*
PluginDashboardInfoDTO
,
0
)
// load current dashboards
query
:=
m
.
GetDashboardsByPluginIdQuery
{
OrgId
:
orgId
,
PluginId
:
pluginId
}
query
:=
m
odels
.
GetDashboardsByPluginIdQuery
{
OrgId
:
orgId
,
PluginId
:
pluginId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -48,7 +48,7 @@ func GetPluginDashboards(orgId int64, pluginId string) ([]*PluginDashboardInfoDT
}
res
:=
&
PluginDashboardInfoDTO
{}
var
dashboard
*
m
.
Dashboard
var
dashboard
*
m
odels
.
Dashboard
var
err
error
if
dashboard
,
err
=
loadPluginDashboard
(
plugin
.
Id
,
include
.
Path
);
err
!=
nil
{
...
...
@@ -89,7 +89,7 @@ func GetPluginDashboards(orgId int64, pluginId string) ([]*PluginDashboardInfoDT
return
result
,
nil
}
func
loadPluginDashboard
(
pluginId
,
path
string
)
(
*
m
.
Dashboard
,
error
)
{
func
loadPluginDashboard
(
pluginId
,
path
string
)
(
*
m
odels
.
Dashboard
,
error
)
{
plugin
,
exists
:=
Plugins
[
pluginId
]
if
!
exists
{
...
...
@@ -109,5 +109,5 @@ func loadPluginDashboard(pluginId, path string) (*m.Dashboard, error) {
return
nil
,
err
}
return
m
.
NewDashboardFromJson
(
data
),
nil
return
m
odels
.
NewDashboardFromJson
(
data
),
nil
}
pkg/plugins/dashboards_test.go
View file @
67ec9edc
...
...
@@ -5,7 +5,7 @@ import (
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
.
"github.com/smartystreets/goconvey/convey"
"gopkg.in/ini.v1"
...
...
@@ -22,23 +22,23 @@ func TestPluginDashboards(t *testing.T) {
err
=
pm
.
Init
()
So
(
err
,
ShouldBeNil
)
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetDashboardQuery
)
error
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
odels
.
GetDashboardQuery
)
error
{
if
query
.
Slug
==
"nginx-connections"
{
dash
:=
m
.
NewDashboard
(
"Nginx Connections"
)
dash
:=
m
odels
.
NewDashboard
(
"Nginx Connections"
)
dash
.
Data
.
Set
(
"revision"
,
"1.1"
)
query
.
Result
=
dash
return
nil
}
return
m
.
ErrDashboardNotFound
return
m
odels
.
ErrDashboardNotFound
})
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetDashboardsByPluginIdQuery
)
error
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
odels
.
GetDashboardsByPluginIdQuery
)
error
{
var
data
=
simplejson
.
New
()
data
.
Set
(
"title"
,
"Nginx Connections"
)
data
.
Set
(
"revision"
,
22
)
query
.
Result
=
[]
*
m
.
Dashboard
{
query
.
Result
=
[]
*
m
odels
.
Dashboard
{
{
Slug
:
"nginx-connections"
,
Data
:
data
},
}
return
nil
...
...
pkg/plugins/dashboards_updater.go
View file @
67ec9edc
...
...
@@ -2,7 +2,7 @@ package plugins
import
(
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
)
func
init
()
{
...
...
@@ -12,7 +12,7 @@ func init() {
func
(
pm
*
PluginManager
)
updateAppDashboards
()
{
pm
.
log
.
Debug
(
"Looking for App Dashboard Updates"
)
query
:=
m
.
GetPluginSettingsQuery
{
OrgId
:
0
}
query
:=
m
odels
.
GetPluginSettingsQuery
{
OrgId
:
0
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
plog
.
Error
(
"Failed to get all plugin settings"
,
"error"
,
err
)
...
...
@@ -44,7 +44,7 @@ func autoUpdateAppDashboard(pluginDashInfo *PluginDashboardInfoDTO, orgId int64)
PluginId
:
pluginDashInfo
.
PluginId
,
Overwrite
:
true
,
Dashboard
:
dash
.
Data
,
User
:
&
m
.
SignedInUser
{
UserId
:
0
,
OrgRole
:
m
.
ROLE_ADMIN
},
User
:
&
m
odels
.
SignedInUser
{
UserId
:
0
,
OrgRole
:
models
.
ROLE_ADMIN
},
Path
:
pluginDashInfo
.
Path
,
}
...
...
@@ -68,7 +68,7 @@ func syncPluginDashboards(pluginDef *PluginBase, orgId int64) {
if
dash
.
Removed
{
plog
.
Info
(
"Deleting plugin dashboard"
,
"pluginId"
,
pluginDef
.
Id
,
"dashboard"
,
dash
.
Slug
)
deleteCmd
:=
m
.
DeleteDashboardCommand
{
OrgId
:
orgId
,
Id
:
dash
.
DashboardId
}
deleteCmd
:=
m
odels
.
DeleteDashboardCommand
{
OrgId
:
orgId
,
Id
:
dash
.
DashboardId
}
if
err
:=
bus
.
Dispatch
(
&
deleteCmd
);
err
!=
nil
{
plog
.
Error
(
"Failed to auto update app dashboard"
,
"pluginId"
,
pluginDef
.
Id
,
"error"
,
err
)
return
...
...
@@ -87,14 +87,14 @@ func syncPluginDashboards(pluginDef *PluginBase, orgId int64) {
}
// update version in plugin_setting table to mark that we have processed the update
query
:=
m
.
GetPluginSettingByIdQuery
{
PluginId
:
pluginDef
.
Id
,
OrgId
:
orgId
}
query
:=
m
odels
.
GetPluginSettingByIdQuery
{
PluginId
:
pluginDef
.
Id
,
OrgId
:
orgId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
plog
.
Error
(
"Failed to read plugin setting by id"
,
"error"
,
err
)
return
}
appSetting
:=
query
.
Result
cmd
:=
m
.
UpdatePluginSettingVersionCmd
{
cmd
:=
m
odels
.
UpdatePluginSettingVersionCmd
{
OrgId
:
appSetting
.
OrgId
,
PluginId
:
appSetting
.
PluginId
,
PluginVersion
:
pluginDef
.
Info
.
Version
,
...
...
@@ -105,19 +105,19 @@ func syncPluginDashboards(pluginDef *PluginBase, orgId int64) {
}
}
func
handlePluginStateChanged
(
event
*
m
.
PluginStateChangedEvent
)
error
{
func
handlePluginStateChanged
(
event
*
m
odels
.
PluginStateChangedEvent
)
error
{
plog
.
Info
(
"Plugin state changed"
,
"pluginId"
,
event
.
PluginId
,
"enabled"
,
event
.
Enabled
)
if
event
.
Enabled
{
syncPluginDashboards
(
Plugins
[
event
.
PluginId
],
event
.
OrgId
)
}
else
{
query
:=
m
.
GetDashboardsByPluginIdQuery
{
PluginId
:
event
.
PluginId
,
OrgId
:
event
.
OrgId
}
query
:=
m
odels
.
GetDashboardsByPluginIdQuery
{
PluginId
:
event
.
PluginId
,
OrgId
:
event
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
err
}
for
_
,
dash
:=
range
query
.
Result
{
deleteCmd
:=
m
.
DeleteDashboardCommand
{
OrgId
:
dash
.
OrgId
,
Id
:
dash
.
Id
}
deleteCmd
:=
m
odels
.
DeleteDashboardCommand
{
OrgId
:
dash
.
OrgId
,
Id
:
dash
.
Id
}
plog
.
Info
(
"Deleting plugin dashboard"
,
"pluginId"
,
event
.
PluginId
,
"dashboard"
,
dash
.
Slug
)
...
...
pkg/plugins/models.go
View file @
67ec9edc
...
...
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/setting"
)
...
...
@@ -78,7 +78,7 @@ func (pb *PluginBase) registerPlugin(pluginDir string) error {
for
_
,
include
:=
range
pb
.
Includes
{
if
include
.
Role
==
""
{
include
.
Role
=
m
.
ROLE_VIEWER
include
.
Role
=
m
odels
.
ROLE_VIEWER
}
}
...
...
@@ -97,7 +97,7 @@ type PluginInclude struct {
Path
string
`json:"path"`
Type
string
`json:"type"`
Component
string
`json:"component"`
Role
m
.
RoleType
`json:"role"`
Role
m
odels
.
RoleType
`json:"role"`
AddToNav
bool
`json:"addToNav"`
DefaultNav
bool
`json:"defaultNav"`
Slug
string
`json:"slug"`
...
...
pkg/plugins/queries.go
View file @
67ec9edc
...
...
@@ -2,17 +2,17 @@ package plugins
import
(
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
)
func
GetPluginSettings
(
orgId
int64
)
(
map
[
string
]
*
m
.
PluginSettingInfoDTO
,
error
)
{
query
:=
m
.
GetPluginSettingsQuery
{
OrgId
:
orgId
}
func
GetPluginSettings
(
orgId
int64
)
(
map
[
string
]
*
m
odels
.
PluginSettingInfoDTO
,
error
)
{
query
:=
m
odels
.
GetPluginSettingsQuery
{
OrgId
:
orgId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
nil
,
err
}
pluginMap
:=
make
(
map
[
string
]
*
m
.
PluginSettingInfoDTO
)
pluginMap
:=
make
(
map
[
string
]
*
m
odels
.
PluginSettingInfoDTO
)
for
_
,
plug
:=
range
query
.
Result
{
pluginMap
[
plug
.
PluginId
]
=
plug
}
...
...
@@ -24,7 +24,7 @@ func GetPluginSettings(orgId int64) (map[string]*m.PluginSettingInfoDTO, error)
}
// default to enabled true
opt
:=
&
m
.
PluginSettingInfoDTO
{
opt
:=
&
m
odels
.
PluginSettingInfoDTO
{
PluginId
:
pluginDef
.
Id
,
OrgId
:
orgId
,
Enabled
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment