LucaVivona commited on
Commit
16543f4
1 Parent(s): 9aeb710

🤏 Draggable Bottom To Resize Node

Browse files
backend/src/resources/__pycache__/module.cpython-39.pyc CHANGED
Binary files a/backend/src/resources/__pycache__/module.cpython-39.pyc and b/backend/src/resources/__pycache__/module.cpython-39.pyc differ
 
docker-compose.yml CHANGED
@@ -24,5 +24,4 @@ services:
24
  volumes:
25
  - './frontend/src:/app/src'
26
  - './frontend/public:/app/public'
27
- command: "npm start"
28
-
 
24
  volumes:
25
  - './frontend/src:/app/src'
26
  - './frontend/public:/app/public'
27
+ command: "npm start"
 
frontend/src/components/Navagation/navbar.js CHANGED
@@ -20,7 +20,6 @@ export default class Navbar extends Component{
20
  mode : false,
21
  modal : false,
22
  error : false
23
-
24
  }
25
  }
26
 
 
20
  mode : false,
21
  modal : false,
22
  error : false
 
23
  }
24
  }
25
 
frontend/src/components/Nodes/Custom.js CHANGED
@@ -68,15 +68,15 @@ export default class CustomNodeIframe extends React.Component {
68
 
69
  }
70
 
71
- // (Experimental) resize nodes by dragging
72
- // initial = (e) => {
73
- // this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height , size : this.state.size, iframe : this.state.iframe, initial_pos : e.clientY, initial_size : this.myRef.current.offsetHeight })
74
- // }
75
 
76
- // resize = (e) => {
77
- // this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height, size : this.state.size, iframe : this.state.iframe, initial_pos : this.state.initial_pos, initial_size : this.state.initial_size})
78
- // this.myRef.current.style.height = `${parseInt(this.state.initial_size) + parseInt(e.clientY - this.state.initial_pos)}px`
79
- // }
80
 
81
  Counter(focus, size){
82
  return (<div className="custom-number-input h-10 w-32 dark:text-white text-black ">
@@ -125,12 +125,12 @@ export default class CustomNodeIframe extends React.Component {
125
  className=" -z-10 container h-full p-2 flex-grow space-iframe overflow-scroll "
126
  sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"></iframe>
127
  </div>
128
- {// (Experimental) Do not uncomment
129
- /* <div className={`absolute bottom-0 w-full h-10 bg-transparent border-1 shadow-2xl rounded-xl z-10 cursor-ns-resize`}
130
  draggable
131
  onDragStart={(e) => { this.initial(e)}}
132
  onDrag={(e) => { this.resize(e)}}
133
- ></div> */}
134
  </>
135
  </>)
136
  }
 
68
 
69
  }
70
 
71
+ //(Experimental) resize nodes by dragging
72
+ initial = (e) => {
73
+ this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height , size : this.state.size, iframe : this.state.iframe, initial_pos : e.clientY, initial_size : this.myRef.current.offsetHeight })
74
+ }
75
 
76
+ resize = (e) => {
77
+ this.setState({id : this.state.id, reachable : this.state.reachable, selected : this.state.selected, data : this.state.data, width : this.state.width, height : this.state.height, size : this.state.size, iframe : this.state.iframe, initial_pos : this.state.initial_pos, initial_size : this.state.initial_size})
78
+ this.myRef.current.style.height = `${parseInt(this.state.initial_size) + parseInt(e.clientY - this.state.initial_pos)}px`
79
+ }
80
 
81
  Counter(focus, size){
82
  return (<div className="custom-number-input h-10 w-32 dark:text-white text-black ">
 
125
  className=" -z-10 container h-full p-2 flex-grow space-iframe overflow-scroll "
126
  sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"></iframe>
127
  </div>
128
+ {/* (Experimental) Do not uncomment */}
129
+ <div className={`absolute bottom-0 w-full h-10 bg-transparent border-1 shadow-2xl rounded-xl z-10 cursor-ns-resize`}
130
  draggable
131
  onDragStart={(e) => { this.initial(e)}}
132
  onDrag={(e) => { this.resize(e)}}
133
+ ></div>
134
  </>
135
  </>)
136
  }
frontend/src/components/ReactFlow/ReactFlowEnv.js CHANGED
@@ -44,28 +44,30 @@ export default function ReactEnviorment() {
44
  const onDrop = useCallback(
45
  (event) => {
46
  event.preventDefault();
47
- console.log(event.dataTransfer.getData('application/reactflow'))
48
- const reactFlowBounds = reactFlowWrapper.current.getBoundingClientRect();
49
- const type = event.dataTransfer.getData('application/reactflow');
50
- const item = JSON.parse(event.dataTransfer.getData('application/item'));
51
- const colour = event.dataTransfer.getData('application/colour');
52
- // check if the dropped element is valid
53
- if (typeof type === 'undefined' || !type) {
54
- return;
55
- }
56
-
57
- const position = reactFlowInstance.project({
58
- x: event.clientX - reactFlowBounds.left,
59
- y: event.clientY - reactFlowBounds.top,
60
- });
61
- const newNode = {
62
- id: `${item.name}-${nodes.length}`,
63
- type,
64
- position,
65
- dragHandle : `#draggable`,
66
- data: { label: `${item.name}`, host : `${item.host}`, colour : `${colour}`, delete : deleteNode },
67
- };
68
- setNodes((nds) => nds.concat(newNode));
 
 
69
  },
70
  [reactFlowInstance, nodes]);
71
 
 
44
  const onDrop = useCallback(
45
  (event) => {
46
  event.preventDefault();
47
+
48
+ if(event.dataTransfer.getData('application/reactflow') !== ""){
49
+ const reactFlowBounds = reactFlowWrapper.current.getBoundingClientRect();
50
+ const type = event.dataTransfer.getData('application/reactflow');
51
+ const item = JSON.parse(event.dataTransfer.getData('application/item'));
52
+ const colour = event.dataTransfer.getData('application/colour');
53
+ // check if the dropped element is valid
54
+ if (typeof type === 'undefined' || !type) {
55
+ return;
56
+ }
57
+
58
+ const position = reactFlowInstance.project({
59
+ x: event.clientX - reactFlowBounds.left,
60
+ y: event.clientY - reactFlowBounds.top,
61
+ });
62
+ const newNode = {
63
+ id: `${item.name}-${nodes.length}`,
64
+ type,
65
+ position,
66
+ dragHandle : `#draggable`,
67
+ data: { label: `${item.name}`, host : `${item.host}`, colour : `${colour}`, delete : deleteNode },
68
+ };
69
+ setNodes((nds) => nds.concat(newNode));
70
+ }
71
  },
72
  [reactFlowInstance, nodes]);
73
 
frontend/src/css/dist/output.css CHANGED
@@ -583,10 +583,6 @@ video {
583
  }
584
  }
585
 
586
- .fixed {
587
- position: fixed;
588
- }
589
-
590
  .absolute {
591
  position: absolute;
592
  }
@@ -600,10 +596,6 @@ video {
600
  bottom: 0px;
601
  }
602
 
603
- .left-\[39\.15\%\] {
604
- left: 39.15%;
605
- }
606
-
607
  .-right-3 {
608
  right: -0.75rem;
609
  }
@@ -632,22 +624,6 @@ video {
632
  right: 1.25rem;
633
  }
634
 
635
- .left-\[50\%\] {
636
- left: 50%;
637
- }
638
-
639
- .right-\[50\%\] {
640
- right: 50%;
641
- }
642
-
643
- .right-\[45\%\] {
644
- right: 45%;
645
- }
646
-
647
- .right-\[39\.1\%\] {
648
- right: 39.1%;
649
- }
650
-
651
  .-z-20 {
652
  z-index: -20;
653
  }
@@ -668,26 +644,6 @@ video {
668
  z-index: 50;
669
  }
670
 
671
- .-z-0 {
672
- z-index: 0;
673
- }
674
-
675
- .z-30 {
676
- z-index: 30;
677
- }
678
-
679
- .-z-40 {
680
- z-index: -40;
681
- }
682
-
683
- .z-\[100\] {
684
- z-index: 100;
685
- }
686
-
687
- .z-\[\] {
688
- z-index: ;
689
- }
690
-
691
  .float-left {
692
  float: left;
693
  }
@@ -700,25 +656,14 @@ video {
700
  margin: 0px;
701
  }
702
 
703
- .my-auto {
704
- margin-top: auto;
705
- margin-bottom: auto;
706
- }
707
-
708
- .my-5 {
709
- margin-top: 1.25rem;
710
- margin-bottom: 1.25rem;
711
- }
712
-
713
- .mx-auto {
714
- margin-left: auto;
715
- margin-right: auto;
716
- }
717
-
718
  .mt-4 {
719
  margin-top: 1rem;
720
  }
721
 
 
 
 
 
722
  .ml-auto {
723
  margin-left: auto;
724
  }
@@ -739,46 +684,6 @@ video {
739
  margin-top: -0.75rem;
740
  }
741
 
742
- .-mr-6 {
743
- margin-right: -1.5rem;
744
- }
745
-
746
- .mb-4 {
747
- margin-bottom: 1rem;
748
- }
749
-
750
- .mb-10 {
751
- margin-bottom: 2.5rem;
752
- }
753
-
754
- .mr-10 {
755
- margin-right: 2.5rem;
756
- }
757
-
758
- .ml-10 {
759
- margin-left: 2.5rem;
760
- }
761
-
762
- .ml-60 {
763
- margin-left: 15rem;
764
- }
765
-
766
- .mb-1 {
767
- margin-bottom: 0.25rem;
768
- }
769
-
770
- .mb-2 {
771
- margin-bottom: 0.5rem;
772
- }
773
-
774
- .-mb-2 {
775
- margin-bottom: -0.5rem;
776
- }
777
-
778
- .-mt-2 {
779
- margin-top: -0.5rem;
780
- }
781
-
782
  .block {
783
  display: block;
784
  }
@@ -791,10 +696,6 @@ video {
791
  display: inline-flex;
792
  }
793
 
794
- .table {
795
- display: table;
796
- }
797
-
798
  .hidden {
799
  display: none;
800
  }
@@ -1052,11 +953,6 @@ video {
1052
  background-color: rgb(254 169 89 / var(--tw-bg-opacity));
1053
  }
1054
 
1055
- .bg-black {
1056
- --tw-bg-opacity: 1;
1057
- background-color: rgb(0 0 0 / var(--tw-bg-opacity));
1058
- }
1059
-
1060
  .bg-gradient-to-bl {
1061
  background-image: linear-gradient(to bottom left, var(--tw-gradient-stops));
1062
  }
@@ -1282,16 +1178,6 @@ video {
1282
  padding-right: 1.5rem;
1283
  }
1284
 
1285
- .px-4 {
1286
- padding-left: 1rem;
1287
- padding-right: 1rem;
1288
- }
1289
-
1290
- .px-9 {
1291
- padding-left: 2.25rem;
1292
- padding-right: 2.25rem;
1293
- }
1294
-
1295
  .pt-8 {
1296
  padding-top: 2rem;
1297
  }
@@ -1324,10 +1210,6 @@ video {
1324
  padding-top: 0.5rem;
1325
  }
1326
 
1327
- .pl-10 {
1328
- padding-left: 2.5rem;
1329
- }
1330
-
1331
  .text-center {
1332
  text-align: center;
1333
  }
@@ -1341,9 +1223,9 @@ video {
1341
  line-height: 2.5rem;
1342
  }
1343
 
1344
- .text-base {
1345
- font-size: 1rem;
1346
- line-height: 1.5rem;
1347
  }
1348
 
1349
  .text-3xl {
@@ -1361,11 +1243,6 @@ video {
1361
  line-height: 2rem;
1362
  }
1363
 
1364
- .text-xl {
1365
- font-size: 1.25rem;
1366
- line-height: 1.75rem;
1367
- }
1368
-
1369
  .font-bold {
1370
  font-weight: 700;
1371
  }
@@ -1374,10 +1251,6 @@ video {
1374
  font-weight: 600;
1375
  }
1376
 
1377
- .font-extrabold {
1378
- font-weight: 800;
1379
- }
1380
-
1381
  .leading-tight {
1382
  line-height: 1.25;
1383
  }
@@ -1387,14 +1260,14 @@ video {
1387
  color: rgb(255 255 255 / var(--tw-text-opacity));
1388
  }
1389
 
1390
- .text-black {
1391
  --tw-text-opacity: 1;
1392
- color: rgb(0 0 0 / var(--tw-text-opacity));
1393
  }
1394
 
1395
- .text-blue-50 {
1396
  --tw-text-opacity: 1;
1397
- color: rgb(239 246 255 / var(--tw-text-opacity));
1398
  }
1399
 
1400
  .underline {
@@ -1402,10 +1275,6 @@ video {
1402
  text-decoration-line: underline;
1403
  }
1404
 
1405
- .opacity-70 {
1406
- opacity: 0.7;
1407
- }
1408
-
1409
  .opacity-60 {
1410
  opacity: 0.6;
1411
  }
@@ -1570,51 +1439,17 @@ video {
1570
  }
1571
 
1572
  @media (min-width: 640px) {
1573
- .sm\:left-\[38\.5\%\] {
1574
- left: 38.5%;
1575
- }
1576
-
1577
- .sm\:left-\[50\%\] {
1578
- left: 50%;
1579
- }
1580
-
1581
- .sm\:left-\[70\%\] {
1582
- left: 70%;
1583
- }
1584
-
1585
- .sm\:right-\[\%\] {
1586
- right: %;
1587
- }
1588
-
1589
  .sm\:w-60 {
1590
  width: 15rem;
1591
  }
1592
 
1593
- .sm\:pl-5 {
1594
- padding-left: 1.25rem;
1595
- }
1596
-
1597
  .sm\:text-sm {
1598
  font-size: 0.875rem;
1599
  line-height: 1.25rem;
1600
  }
1601
  }
1602
 
1603
- @media (min-width: 768px) {
1604
- .md\:left-\[39\.15\%\] {
1605
- left: 39.15%;
1606
- }
1607
-
1608
- .md\:right-\[\%\] {
1609
- right: %;
1610
- }
1611
- }
1612
-
1613
  @media (min-width: 1024px) {
1614
- .lg\:left-\[40\%\] {
1615
- left: 40%;
1616
- }
1617
-
1618
  .lg\:w-72 {
1619
  width: 18rem;
1620
  }
 
583
  }
584
  }
585
 
 
 
 
 
586
  .absolute {
587
  position: absolute;
588
  }
 
596
  bottom: 0px;
597
  }
598
 
 
 
 
 
599
  .-right-3 {
600
  right: -0.75rem;
601
  }
 
624
  right: 1.25rem;
625
  }
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  .-z-20 {
628
  z-index: -20;
629
  }
 
644
  z-index: 50;
645
  }
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  .float-left {
648
  float: left;
649
  }
 
656
  margin: 0px;
657
  }
658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
  .mt-4 {
660
  margin-top: 1rem;
661
  }
662
 
663
+ .-mt-2 {
664
+ margin-top: -0.5rem;
665
+ }
666
+
667
  .ml-auto {
668
  margin-left: auto;
669
  }
 
684
  margin-top: -0.75rem;
685
  }
686
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687
  .block {
688
  display: block;
689
  }
 
696
  display: inline-flex;
697
  }
698
 
 
 
 
 
699
  .hidden {
700
  display: none;
701
  }
 
953
  background-color: rgb(254 169 89 / var(--tw-bg-opacity));
954
  }
955
 
 
 
 
 
 
956
  .bg-gradient-to-bl {
957
  background-image: linear-gradient(to bottom left, var(--tw-gradient-stops));
958
  }
 
1178
  padding-right: 1.5rem;
1179
  }
1180
 
 
 
 
 
 
 
 
 
 
 
1181
  .pt-8 {
1182
  padding-top: 2rem;
1183
  }
 
1210
  padding-top: 0.5rem;
1211
  }
1212
 
 
 
 
 
1213
  .text-center {
1214
  text-align: center;
1215
  }
 
1223
  line-height: 2.5rem;
1224
  }
1225
 
1226
+ .text-xl {
1227
+ font-size: 1.25rem;
1228
+ line-height: 1.75rem;
1229
  }
1230
 
1231
  .text-3xl {
 
1243
  line-height: 2rem;
1244
  }
1245
 
 
 
 
 
 
1246
  .font-bold {
1247
  font-weight: 700;
1248
  }
 
1251
  font-weight: 600;
1252
  }
1253
 
 
 
 
 
1254
  .leading-tight {
1255
  line-height: 1.25;
1256
  }
 
1260
  color: rgb(255 255 255 / var(--tw-text-opacity));
1261
  }
1262
 
1263
+ .text-blue-50 {
1264
  --tw-text-opacity: 1;
1265
+ color: rgb(239 246 255 / var(--tw-text-opacity));
1266
  }
1267
 
1268
+ .text-black {
1269
  --tw-text-opacity: 1;
1270
+ color: rgb(0 0 0 / var(--tw-text-opacity));
1271
  }
1272
 
1273
  .underline {
 
1275
  text-decoration-line: underline;
1276
  }
1277
 
 
 
 
 
1278
  .opacity-60 {
1279
  opacity: 0.6;
1280
  }
 
1439
  }
1440
 
1441
  @media (min-width: 640px) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1442
  .sm\:w-60 {
1443
  width: 15rem;
1444
  }
1445
 
 
 
 
 
1446
  .sm\:text-sm {
1447
  font-size: 0.875rem;
1448
  line-height: 1.25rem;
1449
  }
1450
  }
1451
 
 
 
 
 
 
 
 
 
 
 
1452
  @media (min-width: 1024px) {
 
 
 
 
1453
  .lg\:w-72 {
1454
  width: 18rem;
1455
  }