Skip to content

Commit 57cbefd

Browse files
committed
working on empty space / dropzone ghost panel
1 parent d98191a commit 57cbefd

File tree

5 files changed

+61
-17
lines changed

5 files changed

+61
-17
lines changed

public/app/features/dashboard/model.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class DashboardModel {
1818
style: any;
1919
timezone: any;
2020
editable: any;
21-
hideControls: any;
2221
sharedCrosshair: any;
2322
rows: any;
2423
time: any;
@@ -51,7 +50,6 @@ export class DashboardModel {
5150
this.style = data.style || "dark";
5251
this.timezone = data.timezone || '';
5352
this.editable = data.editable !== false;
54-
this.hideControls = data.hideControls || false;
5553
this.sharedCrosshair = data.sharedCrosshair || false;
5654
this.rows = data.rows || [];
5755
this.time = data.time || { from: 'now-6h', to: 'now' };
@@ -72,7 +70,6 @@ export class DashboardModel {
7270
}
7371

7472
private initMeta(meta) {
75-
console.log(meta);
7673
meta = meta || {};
7774

7875
meta.canShare = meta.canShare !== false;
@@ -84,7 +81,6 @@ export class DashboardModel {
8481
meta.canEdit = false;
8582
meta.canDelete = false;
8683
meta.canSave = false;
87-
this.hideControls = true;
8884
}
8985

9086
this.meta = meta;

public/app/features/dashboard/row/row.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
</div>
6060

6161
<div panel-drop-zone class="panel panel-drop-zone" ui-on-drop="ctrl.onDrop($data)" data-drop="true">
62-
<div class="panel-container" style="background: transparent">
63-
<div style="text-align: center">
64-
<em>Drop here</em>
62+
<div class="panel-margin">
63+
<div class="panel-container">
64+
<div class="panel-drop-zone-text"></div>
6565
</div>
6666
</div>
6767
</div>

public/app/features/dashboard/row/row.ts

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function rowDirective($rootScope) {
106106
},
107107
link: function(scope, element) {
108108
scope.$watchGroup(['ctrl.row.collapse', 'ctrl.row.height'], function() {
109-
element.css({minHeight: scope.ctrl.row.collapse ? '5px' : scope.ctrl.row.height});
109+
element.find('.panels-wrapper').css({minHeight: scope.ctrl.row.collapse ? '5px' : scope.ctrl.row.height});
110110
});
111111

112112
$rootScope.onAppEvent('panel-fullscreen-enter', function(evt, info) {
@@ -167,20 +167,61 @@ coreModule.directive('panelWidth', function($rootScope) {
167167

168168
coreModule.directive('panelDropZone', function($timeout) {
169169
return function(scope, element) {
170-
scope.$on("ANGULAR_DRAG_START", function() {
171-
$timeout(function() {
172-
var dropZoneSpan = 12 - scope.ctrl.dashboard.rowSpan(scope.ctrl.row);
170+
var row = scope.ctrl.row;
171+
var indrag = false;
172+
var textEl = element.find('.panel-drop-zone-text');
173+
174+
function showPanel(span, text) {
175+
element.find('.panel-container').css('height', row.height);
176+
element[0].style.width = ((span / 1.2) * 10) + '%';
177+
textEl.text(text);
178+
element.show();
179+
}
180+
181+
function hidePanel() {
182+
element.hide();
183+
// element.removeClass('panel-drop-zone--empty');
184+
}
173185

174-
if (dropZoneSpan > 0) {
175-
element.find('.panel-container').css('height', scope.ctrl.row.height);
176-
element[0].style.width = ((dropZoneSpan / 1.2) * 10) + '%';
177-
element.show();
186+
function updateState() {
187+
if (scope.ctrl.dashboard.editMode) {
188+
if (row.panels.length === 0 && indrag === false) {
189+
return showPanel(12, 'Empty Space');
178190
}
179-
});
191+
192+
var dropZoneSpan = 12 - scope.ctrl.dashboard.rowSpan(scope.ctrl.row);
193+
if (dropZoneSpan > 1) {
194+
if (indrag) {
195+
return showPanel(dropZoneSpan, 'Drop Here');
196+
} else {
197+
return showPanel(dropZoneSpan, 'Empty Space');
198+
}
199+
}
200+
}
201+
202+
if (indrag === true) {
203+
return showPanel(dropZoneSpan, 'Drop Here');
204+
}
205+
206+
hidePanel();
207+
}
208+
209+
scope.$watchGroup(['ctrl.row.panels.length', 'ctrl.dashboard.editMode', 'ctrl.row.span'], updateState);
210+
211+
scope.$on("ANGULAR_DRAG_START", function() {
212+
indrag = true;
213+
updateState();
214+
// $timeout(function() {
215+
// var dropZoneSpan = 12 - scope.ctrl.dashboard.rowSpan(scope.ctrl.row);
216+
// if (dropZoneSpan > 0) {
217+
// showPanel(dropZoneSpan, 'Panel Drop Zone');
218+
// }
219+
// });
180220
});
181221

182222
scope.$on("ANGULAR_DRAG_END", function() {
183-
element.hide();
223+
indrag = false;
224+
updateState();
184225
});
185226
};
186227
});

public/img/angle_gradient_rev.png

-54.8 KB
Loading

public/sass/pages/_dashboard.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ div.flot-text {
165165
display: none;
166166
.panel-container {
167167
border: 1px solid $dark-3;
168+
display: flex;
169+
justify-content: center;
170+
flex-direction: column;
171+
text-align: center;
172+
color: $text-muted;
173+
font-weight: bold;
174+
background: repeating-linear-gradient(-128deg, #111, #111 10px, #191919 10px, #222 20px);
168175
}
169176
}
170177

0 commit comments

Comments
 (0)