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
1c5f9027
Commit
1c5f9027
authored
Jan 17, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dashboard import feature
parent
a0036179
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
183 additions
and
15 deletions
+183
-15
src/app/features/account/datasourcesCtrl.js
+7
-0
src/app/features/account/importCtrl.js
+78
-0
src/app/features/account/partials/collaborators.html
+5
-5
src/app/features/account/partials/datasources.html
+10
-1
src/app/features/account/partials/import.html
+59
-0
src/app/features/admin/partials/accounts.html
+7
-5
src/app/features/all.js
+1
-0
src/app/features/annotations/partials/editor.html
+2
-2
src/app/features/elasticsearch/datasource.js
+1
-1
src/app/features/influxdb/datasource.js
+1
-1
src/app/partials/sidemenu.html
+4
-0
src/app/routes/backend/all.js
+4
-0
src/app/services/datasourceSrv.js
+4
-0
No files found.
src/app/features/account/datasourcesCtrl.js
View file @
1c5f9027
...
...
@@ -15,6 +15,13 @@ function (angular) {
access
:
'proxy'
};
$scope
.
types
=
[
{
name
:
'Graphite'
,
type
:
'graphite'
},
{
name
:
'InfluxDB'
,
type
:
'influxdb'
},
{
name
:
'Elasticsearch'
,
type
:
'elasticsearch'
},
{
name
:
'OpenTSDB'
,
type
:
'opentsdb'
},
];
$scope
.
init
=
function
()
{
$scope
.
reset
();
$scope
.
editor
=
{
index
:
0
};
...
...
src/app/features/account/importCtrl.js
0 → 100644
View file @
1c5f9027
define
([
'angular'
,
'lodash'
,
],
function
(
angular
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'ImportCtrl'
,
function
(
$scope
,
$http
,
backendSrv
,
datasourceSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
datasources
=
[];
$scope
.
sourceName
=
'grafana'
;
$scope
.
destName
=
'grafana'
;
$scope
.
imported
=
[];
$scope
.
dashboards
=
[];
$scope
.
infoText
=
''
;
$scope
.
importing
=
false
;
_
.
each
(
datasourceSrv
.
getAll
(),
function
(
ds
)
{
if
(
ds
.
type
===
'influxdb'
||
ds
.
type
===
'elasticsearch'
)
{
$scope
.
sourceName
=
ds
.
name
;
$scope
.
datasources
.
push
(
ds
.
name
);
}
else
if
(
ds
.
type
===
'grafana'
)
{
$scope
.
datasources
.
push
(
ds
.
name
);
}
});
};
$scope
.
startImport
=
function
()
{
$scope
.
sourceDs
=
datasourceSrv
.
get
(
$scope
.
sourceName
);
$scope
.
destDs
=
datasourceSrv
.
get
(
$scope
.
destName
);
$scope
.
sourceDs
.
searchDashboards
(
'title:'
).
then
(
function
(
results
)
{
$scope
.
dashboards
=
results
.
dashboards
;
if
(
$scope
.
dashboards
.
length
===
0
)
{
$scope
.
infoText
=
'No dashboards found'
;
return
;
}
$scope
.
importing
=
true
;
$scope
.
imported
=
[];
$scope
.
next
();
});
};
$scope
.
next
=
function
()
{
if
(
$scope
.
dashboards
.
length
===
0
)
{
$scope
.
infoText
=
"Done! Imported "
+
$scope
.
imported
.
length
+
" dashboards"
;
}
var
dash
=
$scope
.
dashboards
.
shift
();
if
(
!
dash
.
title
)
{
console
.
log
(
dash
);
return
;
}
var
infoObj
=
{
name
:
dash
.
title
,
info
:
'Importing...'
};
$scope
.
imported
.
push
(
infoObj
);
$scope
.
infoText
=
"Importing "
+
$scope
.
imported
.
length
+
'/'
+
(
$scope
.
imported
.
length
+
$scope
.
dashboards
.
length
);
$scope
.
sourceDs
.
getDashboard
(
dash
.
id
).
then
(
function
(
loadedDash
)
{
$scope
.
destDs
.
saveDashboard
(
loadedDash
).
then
(
function
()
{
infoObj
.
info
=
"Done!"
;
$scope
.
next
();
},
function
(
err
)
{
infoObj
.
info
=
"Error: "
+
err
;
$scope
.
next
();
});
});
};
$scope
.
init
();
});
});
src/app/features/account/partials/collaborators.html
View file @
1c5f9027
...
...
@@ -17,20 +17,20 @@
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 160px"
>
<strong>
Username or E
mail
</strong>
<strong>
username or e
mail
</strong>
</li>
<li>
<input
type=
"text"
ng-model=
"collaborator.login
OrE
mail"
required
class=
"input-xlarge tight-form-input"
placeholder=
"collaborator@email.com"
>
<input
type=
"text"
ng-model=
"collaborator.login
ore
mail"
required
class=
"input-xlarge tight-form-input"
placeholder=
"collaborator@email.com"
>
</li>
<li
class=
"tight-form-item"
>
R
ole
r
ole
</li>
<li>
<select
type=
"text"
ng-model=
"collaborator.role"
class=
"input-small tight-form-input"
ng-options=
"f for f in ['
Viewer', 'Editor', 'A
dmin']"
>
<select
type=
"text"
ng-model=
"collaborator.role"
class=
"input-small tight-form-input"
ng-options=
"f for f in ['
viewer', 'editor', 'a
dmin']"
>
</select>
</li>
<li>
<button
class=
"btn btn-success tight-form-btn"
ng-click=
"add
Collaborator()"
>
A
dd
</button>
<button
class=
"btn btn-success tight-form-btn"
ng-click=
"add
collaborator()"
>
a
dd
</button>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
src/app/features/account/partials/datasources.html
View file @
1c5f9027
...
...
@@ -70,7 +70,7 @@
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Type
</label>
<select
class=
"input-medium"
ng-model=
"current.type"
ng-options=
"f
for f in ['graphite', 'influxdb', 'opentsdb']
"
ng-change=
"typeChanged()"
></select>
<select
class=
"input-medium"
ng-model=
"current.type"
ng-options=
"f
.type as f.name for f in types
"
ng-change=
"typeChanged()"
></select>
</div>
<editor-opt-bool
text=
"Mark as default"
model=
"current.isDefault"
change=
"render()"
></editor-opt-bool>
</div>
...
...
@@ -103,6 +103,15 @@
</div>
</div>
</div>
<div
class=
"editor-row"
ng-if=
"current.type === 'elasticsearch'"
>
<div
class=
"section"
>
<h5>
Elastic search details
</h5>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Index name
</label>
<input
type=
"text"
class=
"input-large"
required
ng-model=
'current.database'
placeholder=
""
></input>
</div>
</div>
</div>
</div>
<div
class=
"dashboard-editor-footer"
style=
"margin-top: 20px"
>
...
...
src/app/features/account/partials/import.html
0 → 100644
View file @
1c5f9027
<div
ng-include=
"'app/partials/navbar.html'"
ng-init=
"pageTitle='Import'"
></div>
<div
class=
"dashboard-edit-view"
style=
"min-height: 500px"
>
<div
class=
"dashboard-editor-header"
>
<div
class=
"dashboard-editor-title"
>
<i
class=
"fa fa-th-large"
></i>
Import Dashboards
</div>
</div>
<div
class=
"dashboard-editor-body"
>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 160px"
>
<strong>
Dashboard source
</strong>
</li>
<li>
<select
type=
"text"
ng-model=
"sourceName"
class=
"input-small tight-form-input"
ng-options=
"f for f in datasources"
>
</select>
</li>
<li
class=
"tight-form-item"
style=
"width: 160px"
>
<strong>
Destination
</strong>
</li>
<li>
<select
type=
"text"
ng-model=
"destName"
class=
"input-small tight-form-input"
ng-options=
"f for f in datasources"
>
</select>
</li>
<li>
<button
class=
"btn btn-success tight-form-btn"
ng-click=
"startImport()"
>
Import
</button>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
</div>
</div>
<div
class=
"editor-row"
ng-if=
"importing"
>
<section
class=
"section"
>
<h5>
{{infoText}}
</h5>
<div
class=
"editor-row row"
>
<table
class=
"grafana-options-table span5"
>
<tr
ng-repeat=
"dash in imported"
>
<td>
{{dash.name}}
</td>
<td>
{{dash.info}}
</td>
</tr>
</table>
</div>
</section>
</div>
</div>
</div>
src/app/features/admin/partials/accounts.html
View file @
1c5f9027
<div
ng-include=
"'app/partials/navbar.html'"
ng-init=
"pageTitle='Accounts'"
></div>
<div
ng-include=
"'app/partials/navbar.html'"
ng-init=
"pageTitle='A
dmin > A
ccounts'"
></div>
<div
class=
"dashboard-edit-view"
style=
"min-height: 500px"
>
<div
class=
"row-fluid"
>
<div
class=
"span8"
>
<div
class=
"dashboard-editor-body"
>
<div
class=
"editor-row row"
>
<div
class=
"section span6"
>
<table
class=
"grafana-options-table"
>
<tr>
<th
style=
"text-align:left"
>
Id
</th>
...
...
@@ -21,12 +22,12 @@
<td>
{{account.name}}
</td>
<td>
{{account.isAdmin}}
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"edit(variable)"
class=
"btn btn-success
"
>
<a
ng-click=
"edit(variable)"
class=
"btn btn-success btn-small
"
>
<i
class=
"fa fa-edit"
></i>
Edit
</a>
<a
ng-click=
"edit(variable)"
class=
"btn btn-danger
"
>
<a
ng-click=
"edit(variable)"
class=
"btn btn-danger btn-small
"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
...
...
@@ -34,4 +35,5 @@
</table>
</div>
</div>
</div>
</div>
src/app/features/all.js
View file @
1c5f9027
...
...
@@ -11,6 +11,7 @@ define([
'./account/collaboratorsCtrl'
,
'./account/datasourcesCtrl'
,
'./account/apiKeysCtrl'
,
'./account/importCtrl'
,
'./admin/accountsCtrl'
,
'./grafanaDatasource/datasource'
,
],
function
()
{});
src/app/features/annotations/partials/editor.html
View file @
1c5f9027
...
...
@@ -26,7 +26,7 @@
{{annotation.name}}
</td>
<td
style=
"width: 1%"
>
<a
ng-click=
"edit(annotation)"
class=
"btn btn-success btn-
mini
"
>
<a
ng-click=
"edit(annotation)"
class=
"btn btn-success btn-
small
"
>
<i
class=
"fa fa-edit"
></i>
Edit
</a>
...
...
@@ -34,7 +34,7 @@
<td
style=
"width: 1%"
><i
ng-click=
"_.move(annotations,$index,$index-1)"
ng-hide=
"$first"
class=
"pointer fa fa-arrow-up"
></i></td>
<td
style=
"width: 1%"
><i
ng-click=
"_.move(annotations,$index,$index+1)"
ng-hide=
"$last"
class=
"pointer fa fa-arrow-down"
></i></td>
<td
style=
"width: 1%"
>
<a
ng-click=
"removeAnnotation(annotation)"
class=
"btn btn-danger btn-
mini
"
>
<a
ng-click=
"removeAnnotation(annotation)"
class=
"btn btn-danger btn-
small
"
>
<i
class=
"fa fa-remove"
></i>
</a>
</td>
...
...
src/app/features/elasticsearch/datasource.js
View file @
1c5f9027
...
...
@@ -13,7 +13,7 @@ function (angular, _, config, kbn, moment) {
module
.
factory
(
'ElasticDatasource'
,
function
(
$q
,
$http
,
templateSrv
)
{
function
ElasticDatasource
(
datasource
)
{
this
.
type
=
'elastic'
;
this
.
type
=
'elastic
search
'
;
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
url
=
datasource
.
url
;
this
.
name
=
datasource
.
name
;
...
...
src/app/features/influxdb/datasource.js
View file @
1c5f9027
...
...
@@ -15,7 +15,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
module
.
factory
(
'InfluxDatasource'
,
function
(
$q
,
$http
,
templateSrv
)
{
function
InfluxDatasource
(
datasource
)
{
this
.
type
=
'influx
DB
'
;
this
.
type
=
'influx
db
'
;
this
.
urls
=
datasource
.
urls
;
this
.
username
=
datasource
.
username
;
this
.
password
=
datasource
.
password
;
...
...
src/app/partials/sidemenu.html
View file @
1c5f9027
...
...
@@ -26,6 +26,10 @@
<a
class=
"pro-sidemenu-link"
href=
"account/apikeys"
>
<i
class=
"fa fa-key"
></i>
API Keys
</a>
<a
class=
"pro-sidemenu-link"
href=
"account/import"
>
<i
class=
"fa fa-download"
></i>
Import
</a>
<a
class=
"pro-sidemenu-link"
href=
"admin/accounts"
ng-if=
"grafana.user.isGrafanaAdmin"
>
<i
class=
"fa fa-institution"
></i>
Admin
</a>
...
...
src/app/routes/backend/all.js
View file @
1c5f9027
...
...
@@ -42,6 +42,10 @@ define([
templateUrl
:
'app/features/account/partials/apikeys.html'
,
controller
:
'ApiKeysCtrl'
,
})
.
when
(
'/account/import'
,
{
templateUrl
:
'app/features/account/partials/import.html'
,
controller
:
'ImportCtrl'
,
})
.
when
(
'/account'
,
{
templateUrl
:
'app/features/account/partials/account.html'
,
controller
:
'AccountCtrl'
,
...
...
src/app/services/datasourceSrv.js
View file @
1c5f9027
...
...
@@ -82,6 +82,10 @@ function (angular, _, config) {
return
this
.
default
;
};
this
.
getAll
=
function
()
{
return
datasources
;
};
this
.
getAnnotationSources
=
function
()
{
return
annotationSources
;
};
...
...
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