Marthee commited on
Commit
c484f5f
·
verified ·
1 Parent(s): 1e41198

Update templates/proposed-GUI.html

Browse files
Files changed (1) hide show
  1. templates/proposed-GUI.html +94 -175
templates/proposed-GUI.html CHANGED
@@ -1228,6 +1228,8 @@ var ratioPunit=1;
1228
  value=document.getElementById('selectunitP').value
1229
  if (value=='mm'){
1230
  ratioPunit=1000;
 
 
1231
  }
1232
  else
1233
  ratioPunit=1;
@@ -1437,6 +1439,8 @@ function getData(form) {
1437
  spreadsheetId=data[3];
1438
  spreadsheetURL=data[4];
1439
  list1= data[5]
 
 
1440
  }
1441
  if (formvalues['selectprojs'].startsWith('2.2'))
1442
  {
@@ -1535,199 +1539,114 @@ function getData(form) {
1535
  pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs'])
1536
  var rightsideids=[];
1537
 
1538
- if (formvalues['selectprojs'].startsWith('1.0') )// || formvalues['selectprojs'].startsWith('3.2') )
1539
- {
1540
- // Set the interval in milliseconds
1541
- const interval = 10000;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1542
 
 
1543
  // Function to handle the delay
1544
  const delay = ms => new Promise(res => setTimeout(res, ms));
1545
 
1546
  // Function to perform AJAX requests and compare data
1547
- function fetchAndCompareData() {
1548
- // First AJAX request
1549
- $.ajax({
1550
- type: "POST",
1551
- url: "/_submission",
1552
- contentType: "application/json",
1553
- data: JSON.stringify({
1554
- dict1: JSON.stringify(list1),
1555
- spreadsheetId: spreadsheetId,
1556
- pdfpathpath: JSON.stringify(pdfpath),
1557
- path: Object.fromEntries(formData)['measureselectname']
1558
- }),
1559
- dataType: "json",
1560
- success: function(data1) {
1561
- // if (data1.length > 0) {
1562
- const delrows1 = data1[0];
1563
- if(data1.length >0)
1564
- {
1565
- // Wait for the delay
1566
- delay(10000);
1567
 
1568
- // Second AJAX request
1569
- $.ajax({
 
 
 
 
 
 
 
 
 
1570
  type: "POST",
1571
- url: "/_submission",
1572
  contentType: "application/json",
1573
  data: JSON.stringify({
1574
- dict1: JSON.stringify(list1),
 
 
1575
  spreadsheetId: spreadsheetId,
1576
- pdfpathpath: JSON.stringify(pdfpath),
1577
- path: Object.fromEntries(formData)['measureselectname']
 
1578
  }),
1579
  dataType: "json",
1580
- success: function(data11) {
1581
-
1582
- const delrows2 = data11[0];
1583
- console.log('rowssssss',delrows1,delrows2)
1584
- if (JSON.stringify(delrows1) === JSON.stringify(delrows2)) {
1585
- console.log('same');
1586
- } else {
1587
- console.log('differences found', delrows1);
1588
- if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) {
1589
- $.ajax({
1590
- type: "POST",
1591
- url: "/deletemarkupsroute",
1592
- contentType: "application/json",
1593
- data: JSON.stringify({
1594
- dict: JSON.stringify(SimilarAreaDictionary),
1595
- deletedrows: delrows1,
1596
- path: Object.fromEntries(formData)['measureselectname'],
1597
- spreadsheetId: spreadsheetId,
1598
- areaPermArr: JSON.stringify(data[7]),
1599
- section: Object.fromEntries(formData)['selectprojs'],
1600
- pdfpathpath: JSON.stringify(pdfpath)
1601
- }),
1602
- dataType: "json",
1603
- success: function(response) {
1604
- console.log('Markups updated');
1605
- delay(5000)
1606
- },
1607
- error: function(err) {
1608
- PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1609
- ShowPopUp();
1610
- }
1611
- });
1612
- }
1613
- }
1614
- },
1615
- error: function(err) {
1616
- PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1617
- ShowPopUp();
1618
- }
1619
  });
 
 
 
1620
  }
1621
- },
1622
- error: function(err) {
1623
- PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1624
- ShowPopUp();
1625
- }
1626
- });
 
 
 
 
 
 
 
 
 
1627
  }
1628
 
1629
- // Set the interval to call the function
1630
- setInterval(fetchAndCompareData, interval);
1631
 
1632
- }
1633
 
1634
- // interval= setInterval( function() {
1635
-
1636
- // const delay = ms => new Promise(res => setTimeout(res, ms));
1637
- // delay(3000)
1638
-
1639
- // $.ajax({
1640
- // type: "POST",
1641
- // url: "/_submission",
1642
- // // set content type header to use Flask response.get_json()
1643
- // contentType: "application/json",
1644
- // // convert data/object to JSON to send
1645
- // data: JSON.stringify({dict1: JSON.stringify(list1),
1646
- // spreadsheetId:spreadsheetId,
1647
- // pdfpathpath:JSON.stringify(pdfpath),
1648
- // path:Object.fromEntries(formData)['measureselectname']}),
1649
- // // expect JSON data in return (e.g. Flask jsonify)
1650
- // dataType: "json",
1651
- // // handle response
1652
- // success: function(data1){
1653
-
1654
- // if(data1.length >0){
1655
- // delrows1=data1[0];
1656
- // // console.log(data1, delrows1,delrows2)
1657
- // // console.log(typeof delrows1)
1658
- // // console.log(typeof delrows2)
1659
- // if (JSON.stringify(delrows1)=== JSON.stringify(delrows2))
1660
- // {
1661
- // console.log('same')
1662
- // }
1663
- // else{
1664
- // // if (data1[0]==1){
1665
- // // return data1[0];
1666
- // flag=1
1667
- // console.log('jjjj')
1668
- // if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) {
1669
- // console.log('kkkkk')
1670
- // $.ajax({
1671
- // type: "POST",
1672
- // url: "/deletemarkupsroute",
1673
- // // set content type header to use Flask response.get_json()
1674
- // contentType: "application/json",
1675
- // // convert data/object to JSON to send
1676
- // data: JSON.stringify({ dict: JSON.stringify(SimilarAreaDictionary),
1677
- // deletedrows: JSON.stringify(delrows1),
1678
- // path:Object.fromEntries(formData)['measureselectname'],
1679
- // spreadsheetId:spreadsheetId,
1680
- // areaPermArr: JSON.stringify(data[7]),
1681
- // section: Object.fromEntries(formData)['selectprojs'],
1682
- // pdfpathpath:JSON.stringify(pdfpath),}),
1683
- // // expect JSON data in return (e.g. Flask jsonify)
1684
- // dataType: "json",
1685
- // // handle response
1686
- // success: function(response) {
1687
- // console.log(data2)
1688
- // },
1689
- // error: function(err) {
1690
- // PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1691
- // ShowPopUp();
1692
- // }
1693
- // })
1694
-
1695
- // }
1696
- // }
1697
- // }
1698
- // },
1699
- // error: function(err) {
1700
- // PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1701
- // ShowPopUp();
1702
- // }
1703
- // })
1704
-
1705
- // delay(4000);
1706
-
1707
-
1708
- // $.ajax({
1709
- // type: "POST",
1710
- // url: "/_submission",
1711
- // // set content type header to use Flask response.get_json()
1712
- // contentType: "application/json",
1713
- // // convert data/object to JSON to send
1714
- // data: JSON.stringify({dict1: JSON.stringify(list1),
1715
- // spreadsheetId:spreadsheetId,
1716
- // pdfpathpath:JSON.stringify(pdfpath),
1717
- // path:Object.fromEntries(formData)['measureselectname']}),
1718
- // // expect JSON data in return (e.g. Flask jsonify)
1719
- // dataType: "json",
1720
- // // handle response
1721
- // success: function(data11) {
1722
- // delrows2=data11[0];
1723
- // },
1724
- // error: function(err) {
1725
- // PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1726
- // ShowPopUp();
1727
- // }
1728
- // })
1729
-
1730
- // },7000)
1731
 
1732
 
1733
 
 
1228
  value=document.getElementById('selectunitP').value
1229
  if (value=='mm'){
1230
  ratioPunit=1000;
1231
+ // if (projsec.value.startsWith('3.2'))
1232
+ // ratioPunit=100;
1233
  }
1234
  else
1235
  ratioPunit=1;
 
1439
  spreadsheetId=data[3];
1440
  spreadsheetURL=data[4];
1441
  list1= data[5]
1442
+
1443
+
1444
  }
1445
  if (formvalues['selectprojs'].startsWith('2.2'))
1446
  {
 
1539
  pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs'])
1540
  var rightsideids=[];
1541
 
1542
+ if (formvalues['selectprojs'].startsWith('1.0') || formvalues['selectprojs'].startsWith('3.2') )
1543
+ {// Set the interval in milliseconds
1544
+ const interval = 30000;
1545
+ const initialDelay = 0;
1546
+ console.log('Starting first AJAX request...');
1547
+ let delrows1=0; // Define delrows1 in a broader scope
1548
+ let delrows2=0; // Define delrows1 in a broader scope
1549
+
1550
+
1551
+ // First AJAX request
1552
+ $.ajax({
1553
+ type: "POST",
1554
+ url: "/_submission",
1555
+ // set content type header to use Flask response.get_json()
1556
+ contentType: "application/json",
1557
+ // convert data/object to JSON to send
1558
+ data: JSON.stringify({
1559
+ dict1: JSON.stringify(list1),
1560
+ spreadsheetId: spreadsheetId,
1561
+ pdfpathpath: JSON.stringify(pdfpath),
1562
+ path: Object.fromEntries(formData)['measureselectname']
1563
+ }),
1564
+ dataType: "json",
1565
+ // handle response
1566
+ success: function(data1) {
1567
+ delrows1 = data1[0];
1568
+ console.log('First AJAX response received:', JSON.stringify(delrows1));
1569
+
1570
+ },
1571
+ error: function(err) {
1572
+ PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1573
+ ShowPopUp();
1574
+ }
1575
+ })
1576
 
1577
+
1578
  // Function to handle the delay
1579
  const delay = ms => new Promise(res => setTimeout(res, ms));
1580
 
1581
  // Function to perform AJAX requests and compare data
1582
+ async function fetchAndCompareData() {
1583
+ try {
1584
+
1585
+ // Second AJAX request
1586
+ let data11 = await $.ajax({
1587
+ type: "POST",
1588
+ url: "/_submission",
1589
+ contentType: "application/json",
1590
+ data: JSON.stringify({
1591
+ dict1: JSON.stringify(list1),
1592
+ spreadsheetId: spreadsheetId,
1593
+ pdfpathpath: JSON.stringify(pdfpath),
1594
+ path: Object.fromEntries(formData)['measureselectname']
1595
+ }),
1596
+ dataType: "json"
1597
+ });
 
 
 
 
1598
 
1599
+ delrows2 = data11[0];
1600
+ console.log('Second AJAX response received:', JSON.stringify(delrows2));
1601
+
1602
+ // Compare the data
1603
+ if (JSON.stringify(delrows1) === JSON.stringify(delrows2))
1604
+ console.log('same')
1605
+ else{
1606
+ console.log('Differences found:', delrows1, delrows2);
1607
+ if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) {
1608
+ delrows1=delrows2
1609
+ await $.ajax({
1610
  type: "POST",
1611
+ url: "/deletemarkupsroute",
1612
  contentType: "application/json",
1613
  data: JSON.stringify({
1614
+ dict: JSON.stringify(SimilarAreaDictionary),
1615
+ deletedrows: delrows2,
1616
+ path: Object.fromEntries(formData)['measureselectname'],
1617
  spreadsheetId: spreadsheetId,
1618
+ areaPermArr: JSON.stringify(data[7]),
1619
+ section: Object.fromEntries(formData)['selectprojs'],
1620
+ pdfpathpath: JSON.stringify(pdfpath)
1621
  }),
1622
  dataType: "json",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1623
  });
1624
+
1625
+ console.log('Markups updated');
1626
+
1627
  }
1628
+ }
1629
+
1630
+ // Wait for the delay
1631
+ console.log(`Waiting for ${interval} ms...`);
1632
+ await delay(interval);
1633
+ console.log('Delay complete. Starting second AJAX request...');
1634
+
1635
+ } catch (err) {
1636
+ console.error('Error occurred:', err);
1637
+ PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1638
+ ShowPopUp();
1639
+ } finally {
1640
+ // Ensure the function is called again after the interval, whether an error occurred or not
1641
+ setTimeout(fetchAndCompareData, interval);
1642
+ }
1643
  }
1644
 
1645
+ // Initial call to the function after the initial delay
1646
+ setTimeout(fetchAndCompareData, initialDelay);
1647
 
1648
+ }
1649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
 
1651
 
1652