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
94a7e9b1
Commit
94a7e9b1
authored
Jan 22, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
poc(panel): experimental panel stuff
parent
0796b2c0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
45 deletions
+80
-45
public/app/features/panel/panel_ctrl.ts
+21
-0
public/app/features/panel/panel_directive.js
+4
-3
public/app/features/panel/panel_loader.ts
+40
-7
public/app/partials/dashboard.html
+4
-3
public/app/plugins/panel/test/module.html
+4
-0
public/app/plugins/panel/test/module.ts
+7
-32
No files found.
public/app/features/panel/panel_ctrl.ts
0 → 100644
View file @
94a7e9b1
///<reference path="../../headers/common.d.ts" />
import
PanelMeta
from
'./panel_meta2'
;
export
class
PanelCtrl
{
panelMeta
:
any
;
panel
:
any
;
row
:
any
;
dashboard
:
any
;
constructor
(
private
$scope
)
{
this
.
panelMeta
=
new
PanelMeta
({
panelName
:
'Table'
,
editIcon
:
"fa fa-table"
,
fullscreen
:
true
,
metricsEditor
:
true
,
});
}
}
public/app/features/panel/panel_directive.js
View file @
94a7e9b1
...
...
@@ -15,9 +15,10 @@ function (angular, $) {
scope
:
{
ctrl
:
"="
},
link
:
function
(
scope
,
elem
)
{
var
panelContainer
=
elem
.
find
(
'.panel-container'
);
scope
.
$watchGroup
([
'fullscreen'
,
'height'
,
'panel.height'
,
'row.height'
],
function
()
{
panelContainer
.
css
({
minHeight
:
scope
.
height
||
scope
.
panel
.
height
||
scope
.
row
.
height
,
display
:
'block'
});
elem
.
toggleClass
(
'panel-fullscreen'
,
scope
.
fullscreen
?
true
:
false
);
var
ctrl
=
scope
.
ctrl
;
scope
.
$watchGroup
([
'ctrl.fullscreen'
,
'ctrl.height'
,
'ctrl.panel.height'
,
'ctrl.row.height'
],
function
()
{
panelContainer
.
css
({
minHeight
:
ctrl
.
height
||
ctrl
.
panel
.
height
||
ctrl
.
row
.
height
,
display
:
'block'
});
elem
.
toggleClass
(
'panel-fullscreen'
,
ctrl
.
fullscreen
?
true
:
false
);
});
}
};
...
...
public/app/features/panel/panel_loader.ts
View file @
94a7e9b1
...
...
@@ -8,34 +8,67 @@ import {unknownPanelDirective} from '../../plugins/panel/unknown/module';
var
directiveModule
=
angular
.
module
(
'grafana.directives'
);
/** @ngInject */
function
panelLoader
(
$compile
,
dynamicDirectiveSrv
)
{
function
panelLoader
(
$compile
,
dynamicDirectiveSrv
,
$http
,
$q
)
{
return
{
restrict
:
'E'
,
scope
:
{
dashboard
:
"="
,
row
:
"="
,
panel
:
"="
},
link
:
function
(
scope
,
elem
,
attrs
)
{
function
addDirective
(
name
,
component
)
{
if
(
!
component
.
registered
)
{
directiveModule
.
component
(
attrs
.
$normalize
(
name
),
component
);
component
.
registered
=
true
;
function
getTemplate
(
component
)
{
if
(
component
.
template
)
{
return
$q
.
when
(
component
.
template
);
}
return
$http
.
get
(
component
.
templateUrl
).
then
(
res
=>
{
return
res
.
data
;
});
}
function
addPanelAndCompile
(
name
)
{
var
child
=
angular
.
element
(
document
.
createElement
(
name
));
child
.
attr
(
'dashboard'
,
'dashboard'
);
child
.
attr
(
'panel'
,
'panel'
);
child
.
attr
(
'row'
,
'row'
);
$compile
(
child
)(
scope
);
elem
.
empty
();
elem
.
append
(
child
);
}
function
addPanel
(
name
,
directive
)
{
if
(
!
directive
.
registered
)
{
getTemplate
(
directive
).
then
(
template
=>
{
directive
.
templateUrl
=
null
;
directive
.
template
=
`<grafana-panel ctrl="ctrl">
${
template
}
</grafana-panel>`
;
directive
.
controllerAs
=
'ctrl'
;
directive
.
bindToController
=
true
;
directive
.
scope
=
{
dashboard
:
"="
,
panel
:
"="
,
row
:
"="
};
directiveModule
.
directive
(
attrs
.
$normalize
(
name
),
function
()
{
return
directive
;
});
directive
.
registered
=
true
;
addPanelAndCompile
(
name
);
});
}
addPanelAndCompile
(
name
);
}
var
panelElemName
=
'panel-directive-'
+
scope
.
panel
.
type
;
let
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
if
(
!
panelInfo
)
{
add
Directive
(
panelElemName
,
unknownPanelDirective
);
add
Panel
(
panelElemName
,
unknownPanelDirective
);
}
System
.
import
(
panelInfo
.
module
).
then
(
function
(
panelModule
)
{
add
Directive
(
panelElemName
,
panelModule
.
component
);
add
Panel
(
panelElemName
,
panelModule
.
panel
);
}).
catch
(
err
=>
{
console
.
log
(
'Panel err: '
,
err
);
});
...
...
public/app/partials/dashboard.html
View file @
94a7e9b1
...
...
@@ -79,9 +79,10 @@
<div
class=
"row-text pointer"
ng-click=
"toggleRow(row)"
ng-if=
"row.showTitle"
ng-bind=
"row.title | interpolateTemplateVars:this"
>
</div>
<div
ng-repeat=
"(name, panel) in row.panels track by panel.id"
class=
"panel"
ui-draggable=
"!dashboardViewState.fullscreen"
drag=
"panel.id"
ui-on-Drop=
"onDrop($data, row, panel)"
drag-handle-class=
"drag-handle"
panel-width
>
<panel-loader
class=
"panel-margin"
></panel-loader>
<div
ng-repeat=
"panel in row.panels track by panel.id"
class=
"panel"
ui-draggable=
"!dashboardViewState.fullscreen"
drag=
"panel.id"
ui-on-drop=
"onDrop($data, row, panel)"
drag-handle-class=
"drag-handle"
panel-width
>
<panel-loader
class=
"panel-margin"
dashboard=
"dashboard"
row=
"row"
panel=
"panel"
>
</panel-loader>
</div>
<div
panel-drop-zone
class=
"panel panel-drop-zone"
ui-on-drop=
"onDrop($data, row)"
data-drop=
"true"
>
...
...
public/app/plugins/panel/test/module.html
0 → 100644
View file @
94a7e9b1
<h2
class=
"text-center"
>
Test panel!
panel.id: {{ctrl.panel.id}}
</h2>
public/app/plugins/panel/test/module.ts
View file @
94a7e9b1
///<reference path="../../../headers/common.d.ts" />
import
PanelMeta
from
'app/features/panel/panel_meta2'
;
class
PanelBaseCtrl
{
panelMeta
:
any
;
panel
:
any
;
dashboard
:
any
;
constructor
(
private
$scope
)
{
this
.
panelMeta
=
new
PanelMeta
({
panelName
:
'Table'
,
editIcon
:
"fa fa-table"
,
fullscreen
:
true
,
metricsEditor
:
true
,
});
}
}
class
TestPanelCtrl
extends
PanelBaseCtrl
{
import
{
PanelCtrl
}
from
'../../../features/panel/panel_ctrl'
;
class
TestPanelCtrl
extends
PanelCtrl
{
constructor
(
$scope
)
{
super
(
$scope
);
}
}
var
testPanelComponent
=
{
template
:
`
<grafana-panel ctrl="ctrl">
<div class="text-center" style="padding-top: 2rem">
<h2>Test Panel</h2>
</div>
</grafana-panel>
`
,
var
panel
=
{
templateUrl
:
`app/plugins/panel/test/module.html`
,
controller
:
TestPanelCtrl
,
controllerAs
:
'ctrl'
,
bindings
:
{
dashboard
:
"="
,
panel
:
"="
,
link
:
function
(
scope
,
elem
)
{
console
.
log
(
'panel link'
);
}
};
export
{
PanelBaseCtrl
,
TestPanelCtrl
,
testPanelComponent
as
component
,
panel
,
}
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