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
16fc6e8b
Commit
16fc6e8b
authored
Apr 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work on editable false dashboards, #1834
parent
af277f56
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
16 deletions
+44
-16
public/app/features/dashboard/dashboardNavCtrl.js
+2
-0
public/app/features/dashboard/dashboardSrv.js
+2
-0
public/app/features/dashboard/partials/dashboardTopNav.html
+2
-2
public/app/routes/dashLoadControllers.js
+13
-4
public/app/services/contextSrv.js
+7
-8
public/test/specs/dashboardSrv-specs.js
+18
-2
No files found.
public/app/features/dashboard/dashboardNavCtrl.js
View file @
16fc6e8b
...
...
@@ -119,6 +119,8 @@ function (angular, _) {
$scope
.
saveDashboardAs
=
function
()
{
var
newScope
=
$rootScope
.
$new
();
newScope
.
clone
=
$scope
.
dashboard
.
getSaveModelClone
();
newScope
.
clone
.
editable
=
true
;
newScope
.
clone
.
hideControls
=
false
;
$scope
.
appEvent
(
'show-modal'
,
{
src
:
'./app/features/dashboard/partials/saveDashboardAs.html'
,
...
...
public/app/features/dashboard/dashboardSrv.js
View file @
16fc6e8b
...
...
@@ -66,6 +66,8 @@ function (angular, $, kbn, _, moment) {
if
(
!
this
.
editable
)
{
meta
.
canEdit
=
false
;
meta
.
canDelete
=
false
;
meta
.
canSave
=
false
;
this
.
hideControls
=
true
;
}
this
.
meta
=
meta
;
...
...
public/app/features/dashboard/partials/dashboardTopNav.html
View file @
16fc6e8b
...
...
@@ -27,7 +27,7 @@
<li
ng-show=
"dashboardMeta.canShare"
>
<a
class=
"pointer"
ng-click=
"shareDashboard()"
bs-tooltip=
"'Share dashboard'"
data-placement=
"bottom"
><i
class=
"fa fa-share-square-o"
></i></a>
</li>
<li
ng-show=
"dashboardMeta.can
Edit
"
>
<li
ng-show=
"dashboardMeta.can
Save
"
>
<a
ng-click=
"saveDashboard()"
bs-tooltip=
"'Save dashboard'"
data-placement=
"bottom"
><i
class=
"fa fa-save"
></i></a>
</li>
<li
class=
"dropdown"
>
...
...
@@ -38,7 +38,7 @@
<li
ng-if=
"dashboardMeta.canEdit"
><a
class=
"pointer"
ng-click=
"openEditView('templating');"
>
Templating
</a></li>
<li><a
class=
"pointer"
ng-click=
"exportDashboard();"
>
Export
</a></li>
<li><a
class=
"pointer"
ng-click=
"editJson();"
>
View JSON
</a></li>
<li
ng-if=
"
dashboardMeta.canSave
"
><a
class=
"pointer"
ng-click=
"saveDashboardAs();"
>
Save As...
</a></li>
<li
ng-if=
"
contextSrv.isEditor
"
><a
class=
"pointer"
ng-click=
"saveDashboardAs();"
>
Save As...
</a></li>
<li
ng-if=
"dashboardMeta.canDelete"
><a
class=
"pointer"
ng-click=
"deleteDashboard();"
>
Delete dashboard
</a></li>
</ul>
</li>
...
...
public/app/routes/dashLoadControllers.js
View file @
16fc6e8b
...
...
@@ -59,12 +59,15 @@ function (angular, _, kbn, moment, $) {
$location
.
path
(
''
);
return
;
}
$scope
.
initDashboard
({
meta
:
{},
model
:
window
.
grafanaImportDashboard
},
$scope
);
$scope
.
initDashboard
({
meta
:
{
canShare
:
false
,
canStar
:
false
},
model
:
window
.
grafanaImportDashboard
},
$scope
);
});
module
.
controller
(
'NewDashboardCtrl'
,
function
(
$scope
)
{
$scope
.
initDashboard
({
meta
:
{},
meta
:
{
canStar
:
false
,
canShare
:
false
},
model
:
{
title
:
"New dashboard"
,
rows
:
[{
height
:
'250px'
,
panels
:[]
}]
...
...
@@ -93,7 +96,10 @@ function (angular, _, kbn, moment, $) {
};
file_load
(
$routeParams
.
jsonFile
).
then
(
function
(
result
)
{
$scope
.
initDashboard
({
meta
:
{
fromFile
:
true
},
model
:
result
},
$scope
);
$scope
.
initDashboard
({
meta
:
{
canSave
:
false
,
canDelete
:
false
},
model
:
result
},
$scope
);
});
});
...
...
@@ -138,7 +144,10 @@ function (angular, _, kbn, moment, $) {
};
script_load
(
$routeParams
.
jsFile
).
then
(
function
(
result
)
{
$scope
.
initDashboard
({
meta
:
{
fromScript
:
true
,
canDelete
:
false
},
model
:
result
.
data
},
$scope
);
$scope
.
initDashboard
({
meta
:
{
fromScript
:
true
,
canDelete
:
false
,
canSave
:
false
},
model
:
result
.
data
},
$scope
);
});
});
...
...
public/app/services/contextSrv.js
View file @
16fc6e8b
...
...
@@ -18,13 +18,6 @@ function (angular, _, store, config) {
}
}
this
.
version
=
config
.
buildInfo
.
version
;
this
.
lightTheme
=
false
;
this
.
user
=
new
User
();
this
.
isSignedIn
=
this
.
user
.
isSignedIn
;
this
.
isGrafanaAdmin
=
this
.
user
.
isGrafanaAdmin
;
this
.
sidemenu
=
store
.
getBool
(
'grafana.sidemenu'
);
// events
$rootScope
.
$on
(
'toggle-sidemenu'
,
function
()
{
self
.
toggleSideMenu
();
...
...
@@ -47,6 +40,12 @@ function (angular, _, store, config) {
},
50
);
};
this
.
version
=
config
.
buildInfo
.
version
;
this
.
lightTheme
=
false
;
this
.
user
=
new
User
();
this
.
isSignedIn
=
this
.
user
.
isSignedIn
;
this
.
isGrafanaAdmin
=
this
.
user
.
isGrafanaAdmin
;
this
.
sidemenu
=
store
.
getBool
(
'grafana.sidemenu'
);
this
.
isEditor
=
this
.
hasRole
(
'Editor'
)
||
this
.
hasRole
(
'Admin'
);
});
});
public/test/specs/dashboardSrv-specs.js
View file @
16fc6e8b
...
...
@@ -185,10 +185,26 @@ define([
expect
(
model
.
annotations
.
list
.
length
).
to
.
be
(
0
);
expect
(
model
.
templating
.
list
.
length
).
to
.
be
(
0
);
});
});
});
describe
(
'Given editable false dashboard'
,
function
()
{
var
model
;
beforeEach
(
function
()
{
model
=
_dashboardSrv
.
create
({
editable
:
false
,
});
});
it
(
'Should set meta canEdit and canSave to false'
,
function
()
{
expect
(
model
.
meta
.
canSave
).
to
.
be
(
false
);
expect
(
model
.
meta
.
canEdit
).
to
.
be
(
false
);
});
it
(
'getSaveModelClone should remove meta'
,
function
()
{
var
clone
=
model
.
getSaveModelClone
();
expect
(
clone
.
meta
).
to
.
be
(
undefined
);
});
});
});
});
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