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
a867dc06
Commit
a867dc06
authored
Oct 09, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tech: got angular component to load inside react grid
parent
63bf2a02
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
10 deletions
+55
-10
public/app/features/dashboard/all.js
+1
-0
public/app/features/dashboard/dashboard_ctrl.ts
+5
-2
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
+8
-3
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+5
-0
public/app/features/dashboard/dashgrid/PanelLoader.ts
+33
-0
public/app/features/dashboard/dashgrid/dashboard_plugin.ts
+0
-3
public/app/features/plugins/plugin_component.ts
+1
-1
public/app/partials/dashboard.html
+2
-1
No files found.
public/app/features/dashboard/all.js
View file @
a867dc06
...
@@ -24,6 +24,7 @@ define([
...
@@ -24,6 +24,7 @@ define([
'./ad_hoc_filters'
,
'./ad_hoc_filters'
,
'./repeat_option/repeat_option'
,
'./repeat_option/repeat_option'
,
'./dashgrid/DashboardGrid'
,
'./dashgrid/DashboardGrid'
,
'./dashgrid/PanelLoader'
,
'./acl/acl'
,
'./acl/acl'
,
'./folder_picker/picker'
,
'./folder_picker/picker'
,
'./folder_modal/folder'
'./folder_modal/folder'
...
...
public/app/features/dashboard/dashboard_ctrl.ts
View file @
a867dc06
///<reference path="../../headers/common.d.ts" />
import
config
from
'app/core/config'
;
import
config
from
'app/core/config'
;
import
angular
from
'angular'
;
import
angular
from
'angular'
;
...
@@ -19,6 +17,7 @@ export class DashboardCtrl {
...
@@ -19,6 +17,7 @@ export class DashboardCtrl {
unsavedChangesSrv
,
unsavedChangesSrv
,
dynamicDashboardSrv
,
dynamicDashboardSrv
,
dashboardViewStateSrv
,
dashboardViewStateSrv
,
panelLoader
,
contextSrv
,
contextSrv
,
alertSrv
,
alertSrv
,
$timeout
)
{
$timeout
)
{
...
@@ -131,6 +130,10 @@ export class DashboardCtrl {
...
@@ -131,6 +130,10 @@ export class DashboardCtrl {
$scope
.
dashboard
.
meta
.
folderId
=
folder
.
id
;
$scope
.
dashboard
.
meta
.
folderId
=
folder
.
id
;
$scope
.
dashboard
.
meta
.
folderTitle
=
folder
.
title
;
$scope
.
dashboard
.
meta
.
folderTitle
=
folder
.
title
;
};
};
$scope
.
getPanelLoader
=
function
()
{
return
panelLoader
;
};
}
}
init
(
dashboard
)
{
init
(
dashboard
)
{
...
...
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
View file @
a867dc06
...
@@ -3,9 +3,10 @@ import coreModule from 'app/core/core_module';
...
@@ -3,9 +3,10 @@ import coreModule from 'app/core/core_module';
import
ReactGridLayout
from
'react-grid-layout'
;
import
ReactGridLayout
from
'react-grid-layout'
;
import
{
DashboardModel
}
from
'../model'
;
import
{
DashboardModel
}
from
'../model'
;
import
{
DashboardPanel
}
from
'./DashboardPanel'
;
import
{
DashboardPanel
}
from
'./DashboardPanel'
;
import
{
PanelLoader
}
from
'./PanelLoader'
;
import
sizeMe
from
'react-sizeme'
;
import
sizeMe
from
'react-sizeme'
;
const
COLUMN_COUNT
=
24
;
const
COLUMN_COUNT
=
12
;
const
ROW_HEIGHT
=
30
;
const
ROW_HEIGHT
=
30
;
function
GridWrapper
({
size
,
layout
,
onLayoutChange
,
children
})
{
function
GridWrapper
({
size
,
layout
,
onLayoutChange
,
children
})
{
...
@@ -37,6 +38,7 @@ const SizedReactLayoutGrid = sizeMe({monitorWidth: true})(GridWrapper);
...
@@ -37,6 +38,7 @@ const SizedReactLayoutGrid = sizeMe({monitorWidth: true})(GridWrapper);
export
interface
DashboardGridProps
{
export
interface
DashboardGridProps
{
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
getPanelLoader
:
()
=>
PanelLoader
;
}
}
export
class
DashboardGrid
extends
React
.
Component
<
DashboardGridProps
,
any
>
{
export
class
DashboardGrid
extends
React
.
Component
<
DashboardGridProps
,
any
>
{
...
@@ -69,7 +71,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
...
@@ -69,7 +71,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
for
(
let
panel
of
this
.
props
.
dashboard
.
panels
)
{
for
(
let
panel
of
this
.
props
.
dashboard
.
panels
)
{
panelElements
.
push
(
panelElements
.
push
(
<
div
key=
{
panel
.
id
.
toString
()
}
className=
"panel"
>
<
div
key=
{
panel
.
id
.
toString
()
}
className=
"panel"
>
<
DashboardPanel
panel=
{
panel
}
/>
<
DashboardPanel
panel=
{
panel
}
getPanelLoader=
{
this
.
props
.
getPanelLoader
}
dashboard=
{
this
.
props
.
dashboard
}
/>
</
div
>,
</
div
>,
);
);
}
}
...
@@ -86,5 +88,8 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
...
@@ -86,5 +88,8 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
}
}
coreModule
.
directive
(
'dashboardGrid'
,
function
(
reactDirective
)
{
coreModule
.
directive
(
'dashboardGrid'
,
function
(
reactDirective
)
{
return
reactDirective
(
DashboardGrid
,
[[
'dashboard'
,
{
watchDepth
:
'reference'
}]]);
return
reactDirective
(
DashboardGrid
,
[
[
'dashboard'
,
{
watchDepth
:
'reference'
}],
[
'getPanelLoader'
,
{
watchDepth
:
'reference'
,
wrapApply
:
false
}],
]);
});
});
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
a867dc06
import
React
from
'react'
;
import
React
from
'react'
;
import
{
PanelLoader
}
from
'./PanelLoader'
;
export
interface
DashboardPanelProps
{
export
interface
DashboardPanelProps
{
panel
:
any
;
panel
:
any
;
dashboard
:
any
;
getPanelLoader
:
()
=>
PanelLoader
;
}
}
export
class
DashboardPanel
extends
React
.
Component
<
DashboardPanelProps
,
any
>
{
export
class
DashboardPanel
extends
React
.
Component
<
DashboardPanelProps
,
any
>
{
...
@@ -13,6 +16,8 @@ export class DashboardPanel extends React.Component<DashboardPanelProps, any> {
...
@@ -13,6 +16,8 @@ export class DashboardPanel extends React.Component<DashboardPanelProps, any> {
}
}
componentDidMount
()
{
componentDidMount
()
{
var
loader
=
this
.
props
.
getPanelLoader
();
loader
.
load
(
this
.
element
,
this
.
props
.
panel
,
this
.
props
.
dashboard
);
}
}
render
()
{
render
()
{
...
...
public/app/features/dashboard/dashgrid/PanelLoader.ts
0 → 100644
View file @
a867dc06
import
angular
from
'angular'
;
import
coreModule
from
'app/core/core_module'
;
export
interface
AttachedPanel
{
destroy
();
}
export
class
PanelLoader
{
/** @ngInject */
constructor
(
private
$compile
,
private
$rootScope
)
{
}
load
(
elem
,
panel
,
dashboard
):
AttachedPanel
{
var
template
=
'<plugin-component type="panel"></plugin-component>'
;
var
panelScope
=
this
.
$rootScope
.
$new
();
panelScope
.
panel
=
panel
;
panelScope
.
dashboard
=
dashboard
;
const
compiledElem
=
this
.
$compile
(
template
)(
panelScope
);
const
rootNode
=
angular
.
element
(
elem
);
rootNode
.
append
(
compiledElem
);
return
{
destroy
:
()
=>
{
panelScope
.
$destroy
();
compiledElem
.
remove
();
}
};
}
}
coreModule
.
service
(
'panelLoader'
,
PanelLoader
);
public/app/features/dashboard/dashgrid/dashboard_plugin.ts
deleted
100644 → 0
View file @
63bf2a02
import
coreModule
from
'app/core/core'
;
public/app/features/plugins/plugin_component.ts
View file @
a867dc06
...
@@ -68,7 +68,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
...
@@ -68,7 +68,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
var
componentInfo
:
any
=
{
var
componentInfo
:
any
=
{
name
:
'panel-plugin-'
+
scope
.
panel
.
type
,
name
:
'panel-plugin-'
+
scope
.
panel
.
type
,
bindings
:
{
dashboard
:
"="
,
panel
:
"="
,
row
:
"="
},
bindings
:
{
dashboard
:
"="
,
panel
:
"="
,
row
:
"="
},
attrs
:
{
dashboard
:
"
ctrl.dashboard"
,
panel
:
"panel"
,
row
:
"ctrl.row
"
},
attrs
:
{
dashboard
:
"
dashboard"
,
panel
:
"panel
"
},
};
};
let
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
let
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
...
...
public/app/partials/dashboard.html
View file @
a867dc06
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
<dashboard-submenu
ng-if=
"dashboard.meta.submenuEnabled"
dashboard=
"dashboard"
></dashboard-submenu>
<dashboard-submenu
ng-if=
"dashboard.meta.submenuEnabled"
dashboard=
"dashboard"
></dashboard-submenu>
<!-- <dash-grid dashboard="dashboard"></dash-grid> -->
<!-- <dash-grid dashboard="dashboard"></dash-grid> -->
<dashboard-grid
dashboard=
"dashboard"
></dashboard-grid>
<dashboard-grid
dashboard=
"dashboard"
get-panel-loader=
"getPanelLoader"
>
</dashboard-grid>
</div>
</div>
</div>
</div>
...
...
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