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
eb2abe80
Commit
eb2abe80
authored
Jul 13, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted $q to Promise migration in datasource_srv
parent
390090da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
public/app/features/plugins/datasource_srv.ts
+10
-6
public/app/features/plugins/specs/datasource_srv.jest.ts
+1
-1
No files found.
public/app/features/plugins/datasource_srv.ts
View file @
eb2abe80
...
...
@@ -7,7 +7,7 @@ export class DatasourceSrv {
datasources
:
any
;
/** @ngInject */
constructor
(
private
$injector
,
private
$rootScope
,
private
templateSrv
)
{
constructor
(
private
$
q
,
private
$
injector
,
private
$rootScope
,
private
templateSrv
)
{
this
.
init
();
}
...
...
@@ -27,7 +27,7 @@ export class DatasourceSrv {
}
if
(
this
.
datasources
[
name
])
{
return
Promise
.
resolve
(
this
.
datasources
[
name
]);
return
this
.
$q
.
when
(
this
.
datasources
[
name
]);
}
return
this
.
loadDatasource
(
name
);
...
...
@@ -36,16 +36,18 @@ export class DatasourceSrv {
loadDatasource
(
name
)
{
const
dsConfig
=
config
.
datasources
[
name
];
if
(
!
dsConfig
)
{
return
Promise
.
reject
({
message
:
'Datasource named '
+
name
+
' was not found'
});
return
this
.
$q
.
reject
({
message
:
'Datasource named '
+
name
+
' was not found'
});
}
const
deferred
=
this
.
$q
.
defer
();
const
pluginDef
=
dsConfig
.
meta
;
return
importPluginModule
(
pluginDef
.
module
)
importPluginModule
(
pluginDef
.
module
)
.
then
(
plugin
=>
{
// check if its in cache now
if
(
this
.
datasources
[
name
])
{
return
this
.
datasources
[
name
];
deferred
.
resolve
(
this
.
datasources
[
name
]);
return
;
}
// plugin module needs to export a constructor function named Datasource
...
...
@@ -57,11 +59,13 @@ export class DatasourceSrv {
instance
.
meta
=
pluginDef
;
instance
.
name
=
name
;
this
.
datasources
[
name
]
=
instance
;
return
instance
;
deferred
.
resolve
(
instance
)
;
})
.
catch
(
err
=>
{
this
.
$rootScope
.
appEvent
(
'alert-error'
,
[
dsConfig
.
name
+
' plugin failed'
,
err
.
toString
()]);
});
return
deferred
.
promise
;
}
getAll
()
{
...
...
public/app/features/plugins/specs/datasource_srv.jest.ts
View file @
eb2abe80
...
...
@@ -16,7 +16,7 @@ const templateSrv = {
};
describe
(
'datasource_srv'
,
function
()
{
let
_datasourceSrv
=
new
DatasourceSrv
({},
{},
templateSrv
);
let
_datasourceSrv
=
new
DatasourceSrv
({},
{},
{},
templateSrv
);
describe
(
'when loading explore sources'
,
()
=>
{
beforeEach
(()
=>
{
...
...
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