@kumologica/sdk 3.0.7 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -308,11 +308,11 @@ RED.sidebar.kumohub = (function () {
308
308
  }
309
309
  if (params.account) {
310
310
  $('#kumohub-fn-workspace').val(params.workspace || params.account);
311
- fillStages('#kumohub-fn-workspace').val();
311
+ fillStages(params.workspace || params.account);
312
312
  }
313
313
  if (params.workspace) {
314
314
  $('#kumohub-fn-workspace').val(params.workspace);
315
- fillStages('#kumohub-fn-workspace').val();
315
+ fillStages(params.workspace);
316
316
  }
317
317
 
318
318
  if (params.stage) {
@@ -395,8 +395,12 @@ RED.sidebar.kumohub = (function () {
395
395
  //dropdown.append($('<option></option>').val("UNDEFINED").text("Undefined"));
396
396
  return;
397
397
  }
398
- let ws = workspaces.find(w => w.name === fnWorkspace);
399
-
398
+ let ws;
399
+
400
+ if (workspaces) {
401
+ ws = workspaces.find(w => w.name === fnWorkspace);
402
+ }
403
+
400
404
  if (ws) {
401
405
  dropdown.empty();
402
406
  if (ws.stages && ws.stages.length > 0) {
@@ -421,8 +425,12 @@ RED.sidebar.kumohub = (function () {
421
425
  //dropdown.append($('<option></option>').val("UNDEFINED").text("Undefined"));
422
426
  return;
423
427
  }
424
- let ws = workspaces.find(w => w.name === workspace);
425
-
428
+ let ws;
429
+
430
+ if (workspaces) {
431
+ ws = workspaces.find(w => w.name === workspace);
432
+ }
433
+
426
434
  if (ws) {
427
435
  let st = ws.stages.find(s => s.name === stage);
428
436
  if (st && st.policies) {
@@ -1,4 +1,8 @@
1
1
  RED.view = (function () {
2
+ let drag = false;
3
+ let dragging = false;
4
+ let draggingPos = { top: 0, left: 0, x: 0, y: 0 };
5
+
2
6
  var space_width = 5000,
3
7
  space_height = 5000,
4
8
  lineCurveScale = 0.75,
@@ -70,7 +74,7 @@ RED.view = (function () {
70
74
  .attr('width', space_width)
71
75
  .attr('height', space_height)
72
76
  .attr('pointer-events', 'all')
73
- .style('cursor', 'crosshair')
77
+ // .style('cursor', 'crosshair')
74
78
  .on('mousedown', function () {
75
79
  focusView();
76
80
  })
@@ -532,6 +536,65 @@ RED.view = (function () {
532
536
  }
533
537
  });
534
538
 
539
+ // Handle dragging the workspace
540
+ $('#chart')
541
+ .keydown(function(e){
542
+ if(e.keyCode == 32) {
543
+ e.preventDefault();
544
+ if (!drag) {
545
+ drag = true;
546
+ $('#chart').attr('style','cursor: grab !important')
547
+ }
548
+ }
549
+ })
550
+ .keyup(function(e){
551
+ if(e.keyCode == 32 && drag){
552
+ e.preventDefault();
553
+ drag = false;
554
+ dragging = false;
555
+ $('#chart').attr('style','cursor: default !important')
556
+ }
557
+ })
558
+ .on("mousedown", function(e) {
559
+ if (drag && !dragging) {
560
+ e.preventDefault();
561
+
562
+ $('#chart').attr('style','cursor: grabbing !important')
563
+ dragging = true;
564
+ draggingPos = {
565
+ // The current scroll
566
+ left: $('#chart').scrollLeft(),
567
+ top: $('#chart').scrollTop(),
568
+ x: e.clientX,
569
+ y: e.clientY
570
+ }
571
+ }
572
+ })
573
+
574
+ .on("mouseup", function(e) {
575
+ if (drag && dragging){
576
+ e.preventDefault();
577
+ dragging = false;
578
+ // console.log('Dragging off')
579
+ $('#chart').attr('style','cursor: grab !important')
580
+ }
581
+
582
+ })
583
+
584
+ .on("mousemove", function(e) {
585
+ if (drag && dragging){
586
+ e.preventDefault();
587
+
588
+ // How far the mouse has been moved
589
+ const dx = e.clientX - draggingPos.x;
590
+ const dy = e.clientY - draggingPos.y;
591
+
592
+ $("#chart").scrollLeft(draggingPos.left - dx);
593
+ $("#chart").scrollTop(draggingPos.top - dy);
594
+ }
595
+ });
596
+
597
+
535
598
  // Handle nodes dragged from the palette
536
599
  $('#chart').droppable({
537
600
  accept: '.palette_node',
@@ -1257,7 +1320,7 @@ RED.view = (function () {
1257
1320
  // console.log('[view] Create a lasso....d3.event.ctrlKey = ', d3.event.ctrlKey);
1258
1321
 
1259
1322
  if (mouse_mode === 0 && !(d3.event.metaKey || d3.event.ctrlKey)) {
1260
- if (!touchStartTime) {
1323
+ if (!touchStartTime && !drag) {
1261
1324
 
1262
1325
  point = d3.mouse(this);
1263
1326
  lasso = vis