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
0796b2c0
Commit
0796b2c0
authored
Jan 21, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
poc(panel as isolated compoennts): experimental panel stuff
parent
7b4fe824
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
35 deletions
+55
-35
public/app/features/panel/panel_directive.js
+1
-1
public/app/features/panel/panel_loader.ts
+30
-14
public/app/features/panel/panel_menu.js
+7
-7
public/app/plugins/panel/test/module.ts
+17
-13
No files found.
public/app/features/panel/panel_directive.js
View file @
0796b2c0
...
...
@@ -12,9 +12,9 @@ function (angular, $) {
restrict
:
'E'
,
templateUrl
:
'app/features/panel/partials/panel.html'
,
transclude
:
true
,
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
);
...
...
public/app/features/panel/panel_loader.ts
View file @
0796b2c0
...
...
@@ -5,26 +5,42 @@ import config from 'app/core/config';
import
{
unknownPanelDirective
}
from
'../../plugins/panel/unknown/module'
;
var
directiveModule
=
angular
.
module
(
'grafana.directives'
);
/** @ngInject */
function
panelLoader
(
$parse
,
dynamicDirectiveSrv
)
{
return
dynamicDirectiveSrv
.
create
({
directive
:
scope
=>
{
function
panelLoader
(
$compile
,
dynamicDirectiveSrv
)
{
return
{
restrict
:
'E'
,
link
:
function
(
scope
,
elem
,
attrs
)
{
function
addDirective
(
name
,
component
)
{
if
(
!
component
.
registered
)
{
directiveModule
.
component
(
attrs
.
$normalize
(
name
),
component
);
component
.
registered
=
true
;
}
var
child
=
angular
.
element
(
document
.
createElement
(
name
));
child
.
attr
(
'dashboard'
,
'dashboard'
);
child
.
attr
(
'panel'
,
'panel'
);
$compile
(
child
)(
scope
);
elem
.
empty
();
elem
.
append
(
child
);
}
var
panelElemName
=
'panel-directive-'
+
scope
.
panel
.
type
;
let
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
if
(
!
panelInfo
)
{
return
Promise
.
resolve
({
name
:
'panel-directive-'
+
scope
.
panel
.
type
,
fn
:
unknownPanelDirective
});
addDirective
(
panelElemName
,
unknownPanelDirective
);
}
return
System
.
import
(
panelInfo
.
module
).
then
(
function
(
panelModule
)
{
return
{
name
:
'panel-directive-'
+
scope
.
panel
.
type
,
fn
:
panelModule
.
panel
,
};
System
.
import
(
panelInfo
.
module
).
then
(
function
(
panelModule
)
{
addDirective
(
panelElemName
,
panelModule
.
component
);
}).
catch
(
err
=>
{
console
.
log
(
'Panel err: '
,
err
);
});
}
,
}
)
;
}
};
}
angular
.
module
(
'grafana.directives'
).
directive
(
'panelLoader'
,
panelLoader
);
public/app/features/panel/panel_menu.js
View file @
0796b2c0
...
...
@@ -11,16 +11,16 @@ function (angular, $, _) {
.
directive
(
'panelMenu'
,
function
(
$compile
,
linkSrv
)
{
var
linkTemplate
=
'<span class="panel-title drag-handle pointer">'
+
'<span class="panel-title-text drag-handle">{{
panel.title | interpolateTemplateVars:this
}}</span>'
+
'<span class="panel-title-text drag-handle">{{
ctrl.panel.title
}}</span>'
+
'<span class="panel-links-btn"><i class="fa fa-external-link"></i></span>'
+
'<span class="panel-time-info" ng-show="panelMeta.timeInfo"><i class="fa fa-clock-o"></i> {{panelMeta.timeInfo}}</span>'
+
'<span class="panel-time-info" ng-show="
ctrl.
panelMeta.timeInfo"><i class="fa fa-clock-o"></i> {{panelMeta.timeInfo}}</span>'
+
'</span>'
;
function
createExternalLinkMenu
(
$scope
)
{
var
template
=
'<div class="panel-menu small">'
;
template
+=
'<div class="panel-menu-row">'
;
if
(
$scope
.
panel
.
links
)
{
if
(
$scope
.
ctrl
.
panel
.
links
)
{
_
.
each
(
$scope
.
panel
.
links
,
function
(
link
)
{
var
info
=
linkSrv
.
getPanelLinkAnchorInfo
(
link
,
$scope
.
panel
.
scopedVars
);
template
+=
'<a class="panel-menu-link" href="'
+
info
.
href
+
'" target="'
+
info
.
target
+
'">'
+
info
.
title
+
'</a>'
;
...
...
@@ -31,7 +31,7 @@ function (angular, $, _) {
function
createMenuTemplate
(
$scope
)
{
var
template
=
'<div class="panel-menu small">'
;
if
(
$scope
.
dashboardM
eta
.
canEdit
)
{
if
(
$scope
.
ctrl
.
dashboard
.
m
eta
.
canEdit
)
{
template
+=
'<div class="panel-menu-inner">'
;
template
+=
'<div class="panel-menu-row">'
;
template
+=
'<a class="panel-menu-icon pull-left" ng-click="updateColumnSpan(-1)"><i class="fa fa-minus"></i></a>'
;
...
...
@@ -44,9 +44,9 @@ function (angular, $, _) {
template
+=
'<div class="panel-menu-row">'
;
template
+=
'<a class="panel-menu-link" gf-dropdown="extendedMenu"><i class="fa fa-bars"></i></a>'
;
_
.
each
(
$scope
.
panelMeta
.
menu
,
function
(
item
)
{
_
.
each
(
$scope
.
ctrl
.
panelMeta
.
menu
,
function
(
item
)
{
// skip edit actions if not editor
if
(
item
.
role
===
'Editor'
&&
!
$scope
.
dashboardM
eta
.
canEdit
)
{
if
(
item
.
role
===
'Editor'
&&
!
$scope
.
ctrl
.
dashboard
.
m
eta
.
canEdit
)
{
return
;
}
...
...
@@ -64,7 +64,7 @@ function (angular, $, _) {
}
function
getExtendedMenu
(
$scope
)
{
return
angular
.
copy
(
$scope
.
panelMeta
.
extendedMenu
);
return
angular
.
copy
(
$scope
.
ctrl
.
panelMeta
.
extendedMenu
);
}
return
{
...
...
public/app/plugins/panel/test/module.ts
View file @
0796b2c0
...
...
@@ -3,14 +3,17 @@
import
PanelMeta
from
'app/features/panel/panel_meta2'
;
class
PanelBaseCtrl
{
panelMeta
:
any
;
panel
:
any
;
dashboard
:
any
;
constructor
(
private
$scope
)
{
$scope
.
panelMeta
=
new
PanelMeta
({
this
.
panelMeta
=
new
PanelMeta
({
panelName
:
'Table'
,
editIcon
:
"fa fa-table"
,
fullscreen
:
true
,
metricsEditor
:
true
,
});
$scope
.
testProp
=
"hello"
;
}
}
...
...
@@ -18,26 +21,27 @@ class TestPanelCtrl extends PanelBaseCtrl {
constructor
(
$scope
)
{
super
(
$scope
);
$scope
.
panelMeta
.
panelName
=
"Test"
;
}
}
function
testPanelDirective
()
{
return
{
restrict
:
'E'
,
template
:
`
<grafana-panel>
var
testPanelComponent
=
{
template
:
`
<grafana-panel ctrl="ctrl">
<div class="text-center" style="padding-top: 2rem">
<h2>Test Panel
, {{testProp}}
</h2>
<h2>Test Panel</h2>
</div>
</grafana-panel>
`
,
controller
:
TestPanelCtrl
};
}
controller
:
TestPanelCtrl
,
controllerAs
:
'ctrl'
,
bindings
:
{
dashboard
:
"="
,
panel
:
"="
,
}
};
export
{
PanelBaseCtrl
,
TestPanelCtrl
,
testPanel
Directive
as
panel
testPanel
Component
as
component
,
}
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