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
10df9dc8
Commit
10df9dc8
authored
Mar 22, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(plugins): finished app navigation enhancements, closes #4434
parent
7f79024e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
36 deletions
+43
-36
pkg/api/dtos/plugins.go
+12
-11
pkg/api/index.go
+6
-12
pkg/api/plugins.go
+9
-8
pkg/plugins/app_plugin.go
+12
-3
pkg/plugins/models.go
+2
-1
public/app/features/plugins/partials/plugin_page.html
+1
-1
public/app/features/plugins/plugin_page_ctrl.ts
+1
-0
No files found.
pkg/api/dtos/plugins.go
View file @
10df9dc8
...
...
@@ -3,17 +3,18 @@ package dtos
import
"github.com/grafana/grafana/pkg/plugins"
type
PluginSetting
struct
{
Name
string
`json:"name"`
Type
string
`json:"type"`
Id
string
`json:"id"`
Enabled
bool
`json:"enabled"`
Pinned
bool
`json:"pinned"`
Module
string
`json:"module"`
BaseUrl
string
`json:"baseUrl"`
Info
*
plugins
.
PluginInfo
`json:"info"`
Includes
[]
*
plugins
.
PluginInclude
`json:"includes"`
Dependencies
*
plugins
.
PluginDependencies
`json:"dependencies"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
Name
string
`json:"name"`
Type
string
`json:"type"`
Id
string
`json:"id"`
Enabled
bool
`json:"enabled"`
Pinned
bool
`json:"pinned"`
Module
string
`json:"module"`
BaseUrl
string
`json:"baseUrl"`
Info
*
plugins
.
PluginInfo
`json:"info"`
Includes
[]
*
plugins
.
PluginInclude
`json:"includes"`
Dependencies
*
plugins
.
PluginDependencies
`json:"dependencies"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
DefaultNavUrl
string
`json:"defaultNavUrl"`
}
type
PluginListItem
struct
{
...
...
pkg/api/index.go
View file @
10df9dc8
...
...
@@ -90,7 +90,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
if
plugin
.
Pinned
{
appLink
:=
&
dtos
.
NavLink
{
Text
:
plugin
.
Name
,
Url
:
setting
.
AppSubUrl
+
"/plugins/"
+
plugin
.
Id
+
"/edit"
,
Url
:
plugin
.
DefaultNavUrl
,
Img
:
plugin
.
Info
.
Logos
.
Small
,
}
...
...
@@ -100,9 +100,6 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
Url
:
setting
.
AppSubUrl
+
"/plugins/"
+
plugin
.
Id
+
"/page/"
+
include
.
Slug
,
Text
:
include
.
Name
,
}
if
include
.
DefaultNav
{
appLink
.
Url
=
link
.
Url
}
appLink
.
Children
=
append
(
appLink
.
Children
,
link
)
}
if
include
.
Type
==
"dashboard"
&&
include
.
AddToNav
{
...
...
@@ -110,16 +107,13 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
Url
:
setting
.
AppSubUrl
+
"/dashboard/db/"
+
include
.
Slug
,
Text
:
include
.
Name
,
}
if
include
.
DefaultNav
{
appLink
.
Url
=
link
.
Url
}
appLink
.
Children
=
append
(
appLink
.
Children
,
link
)
}
}
if
c
.
OrgRole
==
m
.
ROLE_ADMIN
{
appLink
.
Children
=
append
(
appLink
.
Children
,
&
dtos
.
NavLink
{
Divider
:
true
})
appLink
.
Children
=
append
(
appLink
.
Children
,
&
dtos
.
NavLink
{
Text
:
"Config"
,
Icon
:
"fa fa-cog"
,
Url
:
setting
.
AppSubUrl
+
"/plugins/"
+
plugin
.
Id
+
"/edit"
})
appLink
.
Children
=
append
(
appLink
.
Children
,
&
dtos
.
NavLink
{
Text
:
"
Plugin
Config"
,
Icon
:
"fa fa-cog"
,
Url
:
setting
.
AppSubUrl
+
"/plugins/"
+
plugin
.
Id
+
"/edit"
})
}
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
appLink
)
...
...
@@ -132,10 +126,10 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
Icon
:
"fa fa-fw fa-cogs"
,
Url
:
setting
.
AppSubUrl
+
"/admin"
,
Children
:
[]
*
dtos
.
NavLink
{
{
Text
:
"Global Users"
,
Icon
:
"fa fa-fw fa-cogs"
,
Url
:
setting
.
AppSubUrl
+
"/admin/users"
},
{
Text
:
"Global Orgs"
,
Icon
:
"fa fa-fw fa-cogs"
,
Url
:
setting
.
AppSubUrl
+
"/admin/orgs"
},
{
Text
:
"Server Settings"
,
Icon
:
"fa fa-fw fa-cogs"
,
Url
:
setting
.
AppSubUrl
+
"/admin/settings"
},
{
Text
:
"Server Stats"
,
Icon
:
"fa-fw fa-cogs"
,
Url
:
setting
.
AppSubUrl
+
"/admin/stats"
},
{
Text
:
"Global Users"
,
Url
:
setting
.
AppSubUrl
+
"/admin/users"
},
{
Text
:
"Global Orgs"
,
Url
:
setting
.
AppSubUrl
+
"/admin/orgs"
},
{
Text
:
"Server Settings"
,
Url
:
setting
.
AppSubUrl
+
"/admin/settings"
},
{
Text
:
"Server Stats"
,
Url
:
setting
.
AppSubUrl
+
"/admin/stats"
},
},
})
}
...
...
pkg/api/plugins.go
View file @
10df9dc8
...
...
@@ -72,14 +72,15 @@ func GetPluginSettingById(c *middleware.Context) Response {
}
else
{
dto
:=
&
dtos
.
PluginSetting
{
Type
:
def
.
Type
,
Id
:
def
.
Id
,
Name
:
def
.
Name
,
Info
:
&
def
.
Info
,
Dependencies
:
&
def
.
Dependencies
,
Includes
:
def
.
Includes
,
BaseUrl
:
def
.
BaseUrl
,
Module
:
def
.
Module
,
Type
:
def
.
Type
,
Id
:
def
.
Id
,
Name
:
def
.
Name
,
Info
:
&
def
.
Info
,
Dependencies
:
&
def
.
Dependencies
,
Includes
:
def
.
Includes
,
BaseUrl
:
def
.
BaseUrl
,
Module
:
def
.
Module
,
DefaultNavUrl
:
def
.
DefaultNavUrl
,
}
query
:=
m
.
GetPluginSettingByIdQuery
{
PluginId
:
pluginId
,
OrgId
:
c
.
OrgId
}
...
...
pkg/plugins/app_plugin.go
View file @
10df9dc8
...
...
@@ -6,6 +6,7 @@ import (
"github.com/gosimple/slug"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
type
AppPluginCss
struct
{
...
...
@@ -75,10 +76,18 @@ func (app *AppPlugin) initApp() {
}
}
app
.
DefaultNavUrl
=
setting
.
AppSubUrl
+
"/plugins/"
+
app
.
Id
+
"/edit"
// slugify pages
for
_
,
page
:=
range
app
.
Includes
{
if
page
.
Slug
==
""
{
page
.
Slug
=
slug
.
Make
(
page
.
Name
)
for
_
,
include
:=
range
app
.
Includes
{
if
include
.
Slug
==
""
{
include
.
Slug
=
slug
.
Make
(
include
.
Name
)
}
if
include
.
Type
==
"page"
&&
include
.
DefaultNav
{
app
.
DefaultNavUrl
=
setting
.
AppSubUrl
+
"/plugins/"
+
app
.
Id
+
"/page/"
+
include
.
Slug
}
if
include
.
Type
==
"dashboard"
&&
include
.
DefaultNav
{
app
.
DefaultNavUrl
=
setting
.
AppSubUrl
+
"/dashboard/db/"
+
include
.
Slug
}
}
}
pkg/plugins/models.go
View file @
10df9dc8
...
...
@@ -42,6 +42,7 @@ type PluginBase struct {
IncludedInAppId
string
`json:"-"`
PluginDir
string
`json:"-"`
DefaultNavUrl
string
`json:"-"`
// cache for readme file contents
Readme
[]
byte
`json:"-"`
...
...
@@ -80,7 +81,7 @@ type PluginInclude struct {
Type
string
`json:"type"`
Component
string
`json:"component"`
Role
models
.
RoleType
`json:"role"`
AddToNav
bool
`json:"
A
ddToNav"`
AddToNav
bool
`json:"
a
ddToNav"`
DefaultNav
bool
`json:"defaultNav"`
Slug
string
`json:"slug"`
...
...
public/app/features/plugins/partials/plugin_page.html
View file @
10df9dc8
<navbar
icon=
"icon-gf icon-gf-apps"
title=
"{{ctrl.appModel.name}}"
title-url=
"
plugins/{{ctrl.pluginId}}/edit
"
>
<navbar
icon=
"icon-gf icon-gf-apps"
title=
"{{ctrl.appModel.name}}"
title-url=
"
{{ctrl.appModel.defaultNavUrl}}
"
>
</navbar>
<div
class=
"page-container"
>
...
...
public/app/features/plugins/plugin_page_ctrl.ts
View file @
10df9dc8
...
...
@@ -15,6 +15,7 @@ export class AppPageCtrl {
this
.
backendSrv
.
get
(
`/api/plugins/
${
this
.
pluginId
}
/settings`
).
then
(
app
=>
{
this
.
appModel
=
app
;
this
.
page
=
_
.
findWhere
(
app
.
includes
,
{
slug
:
this
.
$routeParams
.
slug
});
if
(
!
this
.
page
)
{
this
.
$rootScope
.
appEvent
(
'alert-error'
,
[
'App Page Not Found'
,
''
]);
}
...
...
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