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
2dbb3709
Commit
2dbb3709
authored
Jun 26, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on resize handle, drag to resize panels & rows
parent
906e70e5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
3 deletions
+78
-3
public/app/features/dashboard/rowCtrl.js
+2
-2
public/app/features/panel/panelDirective.js
+61
-1
public/app/features/panel/partials/panel.html
+1
-0
public/css/less/panel.less
+10
-0
public/vendor/angular-native-dragdrop/draganddrop.js
+4
-0
No files found.
public/app/features/dashboard/rowCtrl.js
View file @
2dbb3709
...
...
@@ -98,7 +98,7 @@ function (angular, app, _, config) {
};
$scope
.
updatePanelSpan
=
function
(
panel
,
span
)
{
panel
.
span
=
Math
.
min
(
Math
.
max
(
panel
.
span
+
span
,
1
),
12
);
panel
.
span
=
Math
.
min
(
Math
.
max
(
Math
.
floor
(
panel
.
span
+
span
)
,
1
),
12
);
};
$scope
.
replacePanel
=
function
(
newPanel
,
oldPanel
)
{
...
...
@@ -121,7 +121,7 @@ function (angular, app, _, config) {
module
.
directive
(
'rowHeight'
,
function
()
{
return
function
(
scope
,
element
)
{
scope
.
$watchGroup
([
'row.collapse'
,
'row.height'
],
function
()
{
element
[
0
].
style
.
minHeight
=
scope
.
row
.
collapse
?
'5px'
:
scope
.
row
.
height
;
element
.
css
({
minHeight
:
scope
.
row
.
collapse
?
'5px'
:
scope
.
row
.
height
})
;
});
};
});
...
...
public/app/features/panel/panelDirective.js
View file @
2dbb3709
...
...
@@ -22,7 +22,8 @@ function (angular, $, config) {
});
}
};
}).
directive
(
'grafanaPanel'
,
function
()
{
})
.
directive
(
'grafanaPanel'
,
function
()
{
return
{
restrict
:
'E'
,
templateUrl
:
'app/features/panel/partials/panel.html'
,
...
...
@@ -36,5 +37,64 @@ function (angular, $, config) {
});
}
};
})
.
directive
(
'panelResizer'
,
function
(
$rootScope
)
{
return
{
restrict
:
'E'
,
template
:
'<span class="resize-panel-handle"></span>'
,
link
:
function
(
scope
,
elem
)
{
var
resizing
=
false
;
var
handleOffset
;
var
originalHeight
;
var
originalWidth
;
var
maxWidth
;
function
dragStartHandler
(
e
)
{
e
.
preventDefault
();
console
.
log
(
'start'
);
resizing
=
true
;
handleOffset
=
$
(
e
.
target
).
offset
();
originalHeight
=
parseInt
(
scope
.
row
.
height
);
originalWidth
=
scope
.
panel
.
span
;
maxWidth
=
$
(
document
).
width
();
$
(
'body'
).
on
(
'mousemove'
,
moveHandler
);
$
(
'body'
).
on
(
'mouseup'
,
dragEndHandler
);
}
function
moveHandler
(
e
)
{
scope
.
row
.
height
=
originalHeight
+
(
e
.
pageY
-
handleOffset
.
top
);
scope
.
panel
.
span
=
originalWidth
+
(((
e
.
pageX
-
handleOffset
.
left
)
/
maxWidth
)
*
12
);
var
rowSpan
=
scope
.
dashboard
.
rowSpan
(
scope
.
row
);
if
(
Math
.
floor
(
rowSpan
)
<
14
)
{
scope
.
row
.
panels
[
scope
.
row
.
panels
.
length
-
1
].
span
=
scope
.
row
.
panels
[
scope
.
row
.
panels
.
length
-
1
].
span
-
(
rowSpan
-
12
);
}
scope
.
$apply
(
function
()
{
scope
.
$broadcast
(
'render'
);
});
}
function
dragEndHandler
()
{
console
.
log
(
'end'
);
scope
.
$apply
(
function
()
{
$rootScope
.
$broadcast
(
'render'
);
});
$
(
'body'
).
off
(
'mousemove'
,
moveHandler
);
$
(
'body'
).
off
(
'mouseup'
,
dragEndHandler
);
}
elem
.
on
(
'mousedown'
,
dragStartHandler
);
scope
.
$on
(
"$destroy"
,
function
()
{
elem
.
off
(
'mousedown'
,
dragStartHandler
);
});
}
};
});
});
public/app/features/panel/partials/panel.html
View file @
2dbb3709
...
...
@@ -16,6 +16,7 @@
<div
class=
"panel-content"
>
<ng-transclude></ng-transclude>
</div>
<panel-resizer></panel-resizer>
</div>
<div
class=
"panel-full-edit"
ng-if=
"editMode"
>
...
...
public/css/less/panel.less
View file @
2dbb3709
...
...
@@ -203,3 +203,13 @@
top: 0;
right: 0;
}
.resize-panel-handle {
cursor: se-resize;
position: absolute;
bottom: 0;
right: 0;
width: 15px;
height: 15px;
display: block;
}
public/vendor/angular-native-dragdrop/draganddrop.js
View file @
2dbb3709
...
...
@@ -75,6 +75,10 @@
function
dragstartHandler
(
e
)
{
var
isDragAllowed
=
!
isDragHandleUsed
||
dragTarget
.
classList
.
contains
(
dragHandleClass
);
if
(
dragTarget
.
classList
.
contains
(
"resize-panel-handle"
))
{
return
;
}
if
(
isDragAllowed
)
{
var
sendChannel
=
attrs
.
dragChannel
||
'defaultchannel'
;
var
dragData
=
''
;
...
...
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