Commit 5b6fb3b1 by Torkel Ödegaard

feat(alerting): level handle progress

parent ec640bd5
...@@ -6,18 +6,24 @@ import _ from 'lodash'; ...@@ -6,18 +6,24 @@ import _ from 'lodash';
var options = {}; var options = {};
function getHandleTemplate(type, op, value) { function getHandleInnerHtml(type, op, value) {
if (op === '>') { op = '>'; } if (op === '>') { op = '>'; }
if (op === '<') { op = '&lt;'; } if (op === '<') { op = '&lt;'; }
return ` return `
<div class="alert-handle-line">
</div>
<div class="alert-handle">
<i class="icon-gf icon-gf-${type} alert-icon-${type}"></i>
${op} ${value}
</div>`;
}
function getFullHandleHtml(type, op, value) {
var innerTemplate = getHandleInnerHtml(type, op, value);
return `
<div class="alert-handle-wrapper alert-handle-wrapper--${type}"> <div class="alert-handle-wrapper alert-handle-wrapper--${type}">
<div class="alert-handle-line"> ${innerTemplate}
</div>
<div class="alert-handle">
<i class="icon-gf icon-gf-${type} alert-icon-${type}"></i>
${op} ${value}
</div>
</div> </div>
`; `;
} }
...@@ -32,14 +38,12 @@ function dragEndHandler() { ...@@ -32,14 +38,12 @@ function dragEndHandler() {
console.log('drag end'); console.log('drag end');
} }
var past;
function drawAlertHandles(plot) { function drawAlertHandles(plot) {
var options = plot.getOptions(); var options = plot.getOptions();
var $placeholder = plot.getPlaceholder(); var $placeholder = plot.getPlaceholder();
if (!options.alerting.editing) { if (!options.alerting.editing) {
$placeholder.find(".alert-handle").remove(); $placeholder.find(".alert-handle-wrapper").remove();
return; return;
} }
...@@ -55,16 +59,15 @@ function drawAlertHandles(plot) { ...@@ -55,16 +59,15 @@ function drawAlertHandles(plot) {
} }
if ($handle.length === 0) { if ($handle.length === 0) {
console.log('not found'); console.log('creating handle');
$handle = $(getHandleTemplate(type, model.op, model.level)); $handle = $(getFullHandleHtml(type, model.op, model.level));
$handle.attr('draggable', true); $handle.attr('draggable', true);
$handle.bind('dragend', dragEndHandler); $handle.bind('dragend', dragEndHandler);
$handle.bind('dragstart', dragStartHandler); $handle.bind('dragstart', dragStartHandler);
$placeholder.append($handle); $placeholder.append($handle);
console.log('registering drag events');
} else { } else {
console.log('reusing!'); console.log('reusing handle!');
$handle.html(getHandleTemplate(type, model.op, model.level)); $handle.html(getHandleInnerHtml(type, model.op, model.level));
} }
var levelCanvasPos = plot.p2c({x: 0, y: model.level}); var levelCanvasPos = plot.p2c({x: 0, y: model.level});
......
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
user-select: none; user-select: none;
&--warn { &--warn {
right: -111px; right: -222px;
width: 238px; width: 238px;
.alert-handle-line { .alert-handle-line {
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
} }
&--critical { &--critical {
right: -54px; right: -105px;
width: 123px; width: 123px;
.alert-handle-line { .alert-handle-line {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment