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
e5970e83
Commit
e5970e83
authored
Feb 26, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dashlist): list last x viewed dashboards
closes #3896
parent
83662b51
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
12 deletions
+84
-12
public/app/features/dashboard/all.js
+1
-0
public/app/features/dashboard/dashboardLoaderSrv.js
+17
-8
public/app/features/dashboard/impressions.js
+7
-0
public/app/features/dashboard/impressions2.ts
+41
-0
public/app/plugins/panel/dashlist/module.html
+1
-1
public/app/plugins/panel/dashlist/module.ts
+15
-1
public/dashboards/home.json
+2
-2
No files found.
public/app/features/dashboard/all.js
View file @
e5970e83
...
...
@@ -16,4 +16,5 @@ define([
'./graphiteImportCtrl'
,
'./dynamicDashboardSrv'
,
'./importCtrl'
,
'./impressions'
,
],
function
()
{});
public/app/features/dashboard/dashboardLoaderSrv.js
View file @
e5970e83
...
...
@@ -5,8 +5,9 @@ define([
'jquery'
,
'app/core/utils/kbn'
,
'app/core/utils/datemath'
,
'./impressions'
,
],
function
(
angular
,
moment
,
_
,
$
,
kbn
,
dateMath
)
{
function
(
angular
,
moment
,
_
,
$
,
kbn
,
dateMath
,
impressions
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
...
...
@@ -24,19 +25,27 @@ function (angular, moment, _, $, kbn, dateMath) {
};
this
.
loadDashboard
=
function
(
type
,
slug
)
{
if
(
type
===
'script'
)
{
return
this
.
_loadScriptedDashboard
(
slug
);
}
var
promise
;
if
(
type
===
'snapshot'
)
{
return
backendSrv
.
get
(
'/api/snapshots/'
+
$routeParams
.
slug
).
catch
(
function
()
{
if
(
type
===
'script'
)
{
promise
=
this
.
_loadScriptedDashboard
(
slug
);
}
else
if
(
type
===
'snapshot'
)
{
promise
=
backendSrv
.
get
(
'/api/snapshots/'
+
$routeParams
.
slug
).
catch
(
function
()
{
return
{
meta
:{
isSnapshot
:
true
,
canSave
:
false
,
canEdit
:
false
},
dashboard
:
{
title
:
'Snapshot not found'
}};
});
}
else
{
promise
=
backendSrv
.
getDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
)
.
catch
(
function
()
{
return
self
.
_dashboardLoadFailed
(
"Not found"
);
});
}
return
backendSrv
.
getDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
).
catch
(
function
()
{
return
self
.
_dashboardLoadFailed
(
"Not found"
);
promise
.
then
(
function
(
result
)
{
impressions
.
addImpression
(
slug
);
return
result
;
});
return
promise
;
};
this
.
_loadScriptedDashboard
=
function
(
file
)
{
...
...
public/app/features/dashboard/impressions.js
0 → 100644
View file @
e5970e83
define
([
'./impressions2'
],
function
(
impressions
)
{
'use strict'
;
// backward compatability hack;
return
impressions
.
impressions
;
});
public/app/features/dashboard/impressions2.ts
0 → 100644
View file @
e5970e83
///<reference path="../../headers/common.d.ts" />
import
store
from
'app/core/store'
;
import
_
from
'lodash'
;
export
class
Impressions
{
constructor
()
{}
addImpression
(
slug
)
{
var
impressions
=
[];
if
(
store
.
exists
(
"dashboard_impressions"
))
{
impressions
=
JSON
.
parse
(
store
.
get
(
"dashboard_impressions"
));
if
(
!
_
.
isArray
(
impressions
))
{
impressions
=
[];
}
}
var
exists
=
impressions
.
indexOf
(
slug
);
if
(
exists
>=
0
)
{
impressions
.
splice
(
exists
,
1
);
}
impressions
.
unshift
(
slug
);
if
(
impressions
.
length
>
20
)
{
impressions
.
shift
();
}
store
.
set
(
"dashboard_impressions"
,
JSON
.
stringify
(
impressions
));
}
getImpressions
()
{
var
k
=
store
.
get
(
"dashboard_impressions"
);
return
JSON
.
parse
(
k
);
}
}
var
impressions
=
new
Impressions
();
export
{
impressions
};
public/app/plugins/panel/dashlist/module.html
View file @
e5970e83
...
...
@@ -5,7 +5,7 @@
{{dash.title}}
</span>
<span
class=
"dashlist-star"
>
<i
class=
"fa"
ng-class=
"{'fa-star': dash.isStarred, 'fa-star-o':
!dash.isStarred
}"
></i>
<i
class=
"fa"
ng-class=
"{'fa-star': dash.isStarred, 'fa-star-o':
dash.isStarred === false
}"
></i>
</span>
</a>
</div>
...
...
public/app/plugins/panel/dashlist/module.ts
View file @
e5970e83
...
...
@@ -3,6 +3,7 @@
import
_
from
'lodash'
;
import
config
from
'app/core/config'
;
import
{
PanelCtrl
}
from
'app/plugins/sdk'
;
import
{
impressions
}
from
'app/features/dashboard/impressions2'
;
// Set and populate defaults
var
panelDefaults
=
{
...
...
@@ -31,7 +32,7 @@ class DashListCtrl extends PanelCtrl {
initEditMode
()
{
super
.
initEditMode
();
this
.
modes
=
[
'starred'
,
'search'
];
this
.
modes
=
[
'starred'
,
'search'
,
'last viewed'
];
this
.
icon
=
"fa fa-star"
;
this
.
addEditorTab
(
'Options'
,
()
=>
{
return
{
templateUrl
:
'public/app/plugins/panel/dashlist/editor.html'
};
...
...
@@ -41,6 +42,19 @@ class DashListCtrl extends PanelCtrl {
refresh
()
{
var
params
:
any
=
{
limit
:
this
.
panel
.
limit
};
if
(
this
.
panel
.
mode
===
'last viewed'
)
{
var
dashListNames
=
_
.
first
(
impressions
.
getImpressions
(),
this
.
panel
.
limit
).
map
((
dashboard
)
=>
{
return
{
title
:
dashboard
,
uri
:
'db/'
+
dashboard
};
});
this
.
dashList
=
dashListNames
;
this
.
renderingCompleted
();
return
;
}
if
(
this
.
panel
.
mode
===
'starred'
)
{
params
.
starred
=
"true"
;
}
else
{
...
...
public/dashboards/home.json
View file @
e5970e83
...
...
@@ -47,11 +47,11 @@
{
"id"
:
3
,
"limit"
:
10
,
"mode"
:
"
search
"
,
"mode"
:
"
last viewed
"
,
"query"
:
""
,
"span"
:
6
,
"tags"
:
[],
"title"
:
"
D
ashboards"
,
"title"
:
"
Last 10 viewed d
ashboards"
,
"type"
:
"dashlist"
}
],
...
...
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