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
3d15ee6d
Commit
3d15ee6d
authored
Dec 18, 2015
by
woodsaj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow app menu items to be selectivly pinned to the left nav menu
parent
48cf56b6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
54 deletions
+73
-54
pkg/api/app_plugin.go
+10
-8
pkg/api/dtos/app_plugin.go
+5
-4
pkg/api/index.go
+23
-20
pkg/models/app_plugin.go
+10
-8
pkg/plugins/models.go
+1
-0
pkg/plugins/plugins.go
+8
-7
pkg/services/sqlstore/app_plugin.go
+9
-6
pkg/services/sqlstore/migrations/app_plugin.go
+1
-0
public/app/features/org/appEditCtrl.js
+1
-1
public/app/features/org/partials/appEdit.html
+5
-0
No files found.
pkg/api/app_plugin.go
View file @
3d15ee6d
...
...
@@ -18,10 +18,11 @@ func GetAppPlugins(c *middleware.Context) Response {
installedAppsMap
:=
make
(
map
[
string
]
*
dtos
.
AppPlugin
)
for
t
,
a
:=
range
plugins
.
Apps
{
installedAppsMap
[
t
]
=
&
dtos
.
AppPlugin
{
Type
:
a
.
Type
,
Enabled
:
a
.
Enabled
,
Module
:
a
.
Module
,
JsonData
:
make
(
map
[
string
]
interface
{}),
Type
:
a
.
Type
,
Enabled
:
a
.
Enabled
,
PinNavLinks
:
a
.
PinNavLinks
,
Module
:
a
.
Module
,
JsonData
:
make
(
map
[
string
]
interface
{}),
}
}
...
...
@@ -31,10 +32,11 @@ func GetAppPlugins(c *middleware.Context) Response {
for
_
,
b
:=
range
query
.
Result
{
if
def
,
ok
:=
installedAppsMap
[
b
.
Type
];
ok
{
result
=
append
(
result
,
&
dtos
.
AppPlugin
{
Type
:
b
.
Type
,
Enabled
:
b
.
Enabled
,
Module
:
def
.
Module
,
JsonData
:
b
.
JsonData
,
Type
:
b
.
Type
,
Enabled
:
b
.
Enabled
,
PinNavLinks
:
b
.
PinNavLinks
,
Module
:
def
.
Module
,
JsonData
:
b
.
JsonData
,
})
seenApps
[
b
.
Type
]
=
true
}
...
...
pkg/api/dtos/app_plugin.go
View file @
3d15ee6d
package
dtos
type
AppPlugin
struct
{
Type
string
`json:"type"`
Enabled
bool
`json:"enabled"`
Module
string
`json:"module"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
Type
string
`json:"type"`
Enabled
bool
`json:"enabled"`
PinNavLinks
bool
`json:"pin_nav_links"`
Module
string
`json:"module"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
}
pkg/api/index.go
View file @
3d15ee6d
...
...
@@ -69,28 +69,31 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
for
_
,
css
:=
range
plugin
.
Css
{
data
.
PluginCss
=
append
(
data
.
PluginCss
,
&
dtos
.
PluginCss
{
Light
:
css
.
Light
,
Dark
:
css
.
Dark
})
}
for
_
,
item
:=
range
plugin
.
MainNavLinks
{
// only show menu items for the specified roles.
var
validRoles
[]
m
.
RoleType
if
string
(
item
.
ReqRole
)
==
""
||
item
.
ReqRole
==
m
.
ROLE_VIEWER
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
,
m
.
ROLE_EDITOR
,
m
.
ROLE_VIEWER
}
}
else
if
item
.
ReqRole
==
m
.
ROLE_EDITOR
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
,
m
.
ROLE_EDITOR
}
}
else
if
item
.
ReqRole
==
m
.
ROLE_ADMIN
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
}
}
ok
:=
true
if
len
(
validRoles
)
>
0
{
ok
=
false
for
_
,
role
:=
range
validRoles
{
if
role
==
c
.
OrgRole
{
ok
=
true
break
if
plugin
.
PinNavLinks
{
for
_
,
item
:=
range
plugin
.
MainNavLinks
{
// only show menu items for the specified roles.
var
validRoles
[]
m
.
RoleType
if
string
(
item
.
ReqRole
)
==
""
||
item
.
ReqRole
==
m
.
ROLE_VIEWER
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
,
m
.
ROLE_EDITOR
,
m
.
ROLE_VIEWER
}
}
else
if
item
.
ReqRole
==
m
.
ROLE_EDITOR
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
,
m
.
ROLE_EDITOR
}
}
else
if
item
.
ReqRole
==
m
.
ROLE_ADMIN
{
validRoles
=
[]
m
.
RoleType
{
m
.
ROLE_ADMIN
}
}
ok
:=
true
if
len
(
validRoles
)
>
0
{
ok
=
false
for
_
,
role
:=
range
validRoles
{
if
role
==
c
.
OrgRole
{
ok
=
true
break
}
}
}
}
if
ok
{
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
&
dtos
.
NavLink
{
Text
:
item
.
Text
,
Href
:
item
.
Href
,
Icon
:
item
.
Icon
})
if
ok
{
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
&
dtos
.
NavLink
{
Text
:
item
.
Text
,
Href
:
item
.
Href
,
Icon
:
item
.
Icon
})
}
}
}
}
...
...
pkg/models/app_plugin.go
View file @
3d15ee6d
...
...
@@ -3,11 +3,12 @@ package models
import
"time"
type
AppPlugin
struct
{
Id
int64
Type
string
OrgId
int64
Enabled
bool
JsonData
map
[
string
]
interface
{}
Id
int64
Type
string
OrgId
int64
Enabled
bool
PinNavLinks
bool
JsonData
map
[
string
]
interface
{}
Created
time
.
Time
Updated
time
.
Time
...
...
@@ -18,9 +19,10 @@ type AppPlugin struct {
// Also acts as api DTO
type
UpdateAppPluginCmd
struct
{
Type
string
`json:"type" binding:"Required"`
Enabled
bool
`json:"enabled"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
Type
string
`json:"type" binding:"Required"`
Enabled
bool
`json:"enabled"`
PinNavLinks
bool
`json:"pin_nav_links"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
Id
int64
`json:"-"`
OrgId
int64
`json:"-"`
...
...
pkg/plugins/models.go
View file @
3d15ee6d
...
...
@@ -71,6 +71,7 @@ type AppPlugin struct {
Js
[]
*
AppPluginJs
`json:"js"`
Css
[]
*
AppPluginCss
`json:"css"`
MainNavLinks
[]
*
AppPluginNavLink
`json:"mainNavLinks"`
PinNavLinks
bool
`json:"pinNavLinks"`
StaticRootConfig
*
StaticRootConfig
`json:"staticRoot"`
}
...
...
pkg/plugins/plugins.go
View file @
3d15ee6d
...
...
@@ -203,17 +203,18 @@ func GetEnabledPlugins(orgApps []*models.AppPlugin) EnabledPlugins {
seenPanels
:=
make
(
map
[
string
]
bool
)
seenApi
:=
make
(
map
[
string
]
bool
)
for
appType
,
a
pp
:=
range
Apps
{
// start with enabled set to the default state listed in the json config.
enabled
:=
app
.
Enabled
for
appType
,
installedA
pp
:=
range
Apps
{
var
app
AppPlugin
app
=
*
installedApp
// check if the app is stored in the DB for this org and if so, use the
//
enabled
state stored there.
// state stored there.
if
b
,
ok
:=
orgAppsMap
[
appType
];
ok
{
enabled
=
b
.
Enabled
app
.
Enabled
=
b
.
Enabled
app
.
PinNavLinks
=
b
.
PinNavLinks
}
if
e
nabled
{
if
app
.
E
nabled
{
for
_
,
d
:=
range
app
.
DatasourcePlugins
{
if
ds
,
ok
:=
DataSources
[
d
];
ok
{
enabledPlugins
.
DataSourcePlugins
[
d
]
=
ds
...
...
@@ -235,7 +236,7 @@ func GetEnabledPlugins(orgApps []*models.AppPlugin) EnabledPlugins {
}
}
}
enabledPlugins
.
AppPlugins
=
append
(
enabledPlugins
.
AppPlugins
,
app
)
enabledPlugins
.
AppPlugins
=
append
(
enabledPlugins
.
AppPlugins
,
&
app
)
}
}
...
...
pkg/services/sqlstore/app_plugin.go
View file @
3d15ee6d
...
...
@@ -25,20 +25,23 @@ func UpdateAppPlugin(cmd *m.UpdateAppPluginCmd) error {
exists
,
err
:=
sess
.
Where
(
"org_id=? and type=?"
,
cmd
.
OrgId
,
cmd
.
Type
)
.
Get
(
&
app
)
sess
.
UseBool
(
"enabled"
)
sess
.
UseBool
(
"pin_nav_links"
)
if
!
exists
{
app
=
m
.
AppPlugin
{
Type
:
cmd
.
Type
,
OrgId
:
cmd
.
OrgId
,
Enabled
:
cmd
.
Enabled
,
JsonData
:
cmd
.
JsonData
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
Type
:
cmd
.
Type
,
OrgId
:
cmd
.
OrgId
,
Enabled
:
cmd
.
Enabled
,
PinNavLinks
:
cmd
.
PinNavLinks
,
JsonData
:
cmd
.
JsonData
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
_
,
err
=
sess
.
Insert
(
&
app
)
return
err
}
else
{
app
.
Enabled
=
cmd
.
Enabled
app
.
JsonData
=
cmd
.
JsonData
app
.
PinNavLinks
=
cmd
.
PinNavLinks
_
,
err
=
sess
.
Id
(
app
.
Id
)
.
Update
(
&
app
)
return
err
}
...
...
pkg/services/sqlstore/migrations/app_plugin.go
View file @
3d15ee6d
...
...
@@ -11,6 +11,7 @@ func addAppPluginMigration(mg *Migrator) {
{
Name
:
"org_id"
,
Type
:
DB_BigInt
,
Nullable
:
true
},
{
Name
:
"type"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
{
Name
:
"enabled"
,
Type
:
DB_Bool
,
Nullable
:
false
},
{
Name
:
"pin_nav_links"
,
Type
:
DB_Bool
,
Nullable
:
false
},
{
Name
:
"json_data"
,
Type
:
DB_Text
,
Nullable
:
true
},
{
Name
:
"created"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
{
Name
:
"updated"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
...
...
public/app/features/org/appEditCtrl.js
View file @
3d15ee6d
...
...
@@ -26,7 +26,7 @@ function (angular, _, config) {
$scope
.
_update
=
function
()
{
appSrv
.
update
(
$scope
.
current
).
then
(
function
()
{
window
.
location
.
href
=
config
.
appSubUrl
+
"
plugin
s"
;
window
.
location
.
href
=
config
.
appSubUrl
+
"
org/app
s"
;
});
};
...
...
public/app/features/org/partials/appEdit.html
View file @
3d15ee6d
...
...
@@ -26,6 +26,11 @@
<input
class=
"cr1"
id=
"current.enabled"
type=
"checkbox"
ng-model=
"current.enabled"
ng-checked=
"current.enabled"
>
<label
for=
"current.enabled"
class=
"cr1"
></label>
</li>
<li
class=
"tight-form-item"
>
Pin To Menu
<input
class=
"cr1"
id=
"current.pin_nav_links"
type=
"checkbox"
ng-model=
"current.pin_nav_links"
ng-checked=
"current.pin_nav_links"
>
<label
for=
"current.pin_nav_links"
class=
"cr1"
></label>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
...
...
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