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
0aa0ae0e
Commit
0aa0ae0e
authored
Oct 04, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
react-2-angular: added generic angular directive loader util that can be used from react
parent
019d0ee1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
public/app/core/components/grafana_app.ts
+5
-2
public/app/core/services/AngularLoader.ts
+42
-0
No files found.
public/app/core/components/grafana_app.ts
View file @
0aa0ae0e
...
...
@@ -10,6 +10,7 @@ import colors from 'app/core/utils/colors';
import
{
BackendSrv
,
setBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
DatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
import
{
configureStore
}
from
'app/store/configureStore'
;
import
{
AngularLoader
,
setAngularLoader
}
from
'app/core/services/AngularLoader'
;
export
class
GrafanaCtrl
{
/** @ngInject */
...
...
@@ -22,11 +23,13 @@ export class GrafanaCtrl {
contextSrv
,
bridgeSrv
,
backendSrv
:
BackendSrv
,
datasourceSrv
:
DatasourceSrv
datasourceSrv
:
DatasourceSrv
,
angularLoader
:
AngularLoader
)
{
// sets singleston instances for angular services so react components can access them
configureStore
(
);
setAngularLoader
(
angularLoader
);
setBackendSrv
(
backendSrv
);
configureStore
();
$scope
.
init
=
()
=>
{
$scope
.
contextSrv
=
contextSrv
;
...
...
public/app/core/services/AngularLoader.ts
0 → 100644
View file @
0aa0ae0e
import
angular
from
'angular'
;
import
coreModule
from
'app/core/core_module'
;
import
_
from
'lodash'
;
export
interface
AngularComponent
{
destroy
();
}
export
class
AngularLoader
{
/** @ngInject */
constructor
(
private
$compile
,
private
$rootScope
)
{}
load
(
elem
,
scopeProps
,
template
):
AngularComponent
{
const
scope
=
this
.
$rootScope
.
$new
();
_
.
assign
(
scope
,
scopeProps
);
const
compiledElem
=
this
.
$compile
(
template
)(
scope
);
const
rootNode
=
angular
.
element
(
elem
);
rootNode
.
append
(
compiledElem
);
return
{
destroy
:
()
=>
{
scope
.
$destroy
();
compiledElem
.
remove
();
},
};
}
}
coreModule
.
service
(
'angularLoader'
,
AngularLoader
);
let
angularLoaderInstance
:
AngularLoader
;
export
function
setAngularLoader
(
pl
:
AngularLoader
)
{
angularLoaderInstance
=
pl
;
}
// away to access it from react
export
function
getAngularLoader
():
AngularLoader
{
return
angularLoaderInstance
;
}
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