Marthee commited on
Commit
c4936a9
·
verified ·
1 Parent(s): 12894ac

Update templates/proposed-GUI.html

Browse files
Files changed (1) hide show
  1. templates/proposed-GUI.html +129 -117
templates/proposed-GUI.html CHANGED
@@ -1411,9 +1411,9 @@ function ImgSide(imgdata, spreadsheetLink, pdfLink) {
1411
  var buttonContainer = document.createElement('div');
1412
  buttonContainer.style.display = 'flex';
1413
  buttonContainer.style.marginTop = '10px';
1414
-
1415
  var legendbutton = document.createElement("button");
1416
- legendbutton.id = 'measureADRbutton2';
1417
  legendbutton.innerText = 'Legend and Data created';
1418
  legendbutton.style.backgroundColor = 'rgb(5, 43, 235)';
1419
 
@@ -1427,9 +1427,9 @@ function ImgSide(imgdata, spreadsheetLink, pdfLink) {
1427
  legendbutton.addEventListener('click', function () {
1428
  window.open(spreadsheetLink);
1429
  });
1430
-
1431
  var imgbutton = document.createElement("button");
1432
- imgbutton.id = 'measureADRbutton2';
1433
  imgbutton.innerText = 'Click to view as PDF';
1434
  imgbutton.style.backgroundColor = 'rgb(255,0,255)';
1435
 
@@ -1443,15 +1443,40 @@ function ImgSide(imgdata, spreadsheetLink, pdfLink) {
1443
  imgbutton.addEventListener('click', function () {
1444
  window.open(pdfLink);
1445
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1446
 
 
1447
  buttonContainer.appendChild(legendbutton);
1448
  buttonContainer.appendChild(imgbutton);
 
 
1449
 
1450
  imgContainer.appendChild(imgcanvas);
1451
  imgContainer.appendChild(buttonContainer);
1452
 
1453
  backimg.appendChild(imgContainer);
1454
- }
1455
  function updatepreview(pdfname){
1456
  console.log('pdfpath',pdfname)
1457
 
@@ -1696,128 +1721,115 @@ function getData(form) {
1696
  var flag=0;
1697
  pdfpath=[];
1698
  pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs'])
1699
- var rightsideids=[];
1700
-
1701
- if (formvalues['selectprojs'].startsWith('1.0') || formvalues['selectprojs'].startsWith('3.2') || formvalues['selectprojs'].startsWith('2.8') || formvalues['selectprojs'].startsWith('3.3') )
1702
- {// Set the interval in milliseconds
1703
- const interval = 6000;
1704
- const initialDelay = 0;
1705
- console.log('Starting first AJAX request...');
1706
- let delrows1=''; // Define delrows1 in a broader scope
1707
- let delrows2=''; // Define delrows1 in a broader scope
1708
 
 
1709
 
1710
- // First AJAX request
1711
- $.ajax({
1712
- type: "POST",
1713
- url: "/_submission",
1714
- // set content type header to use Flask response.get_json()
1715
- contentType: "application/json",
1716
- // convert data/object to JSON to send
1717
- data: JSON.stringify({
1718
- dict1: JSON.stringify(list1),
1719
- spreadsheetId: spreadsheetId,
1720
- pdfpathpath: JSON.stringify(pdfpath),
1721
- path: Object.fromEntries(formData)['measureselectname']
1722
- }),
1723
- dataType: "json",
1724
- // handle response
1725
- success: function(data1) {
1726
- delrows1 = data1[0];
1727
- console.log('First AJAX response received:', JSON.stringify(delrows1));
 
 
 
 
1728
 
1729
- },
1730
- error: function(err) {
1731
- PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1732
- ShowPopUp();
1733
- }
1734
- })
 
 
 
 
 
 
 
 
 
 
 
 
1735
 
1736
-
1737
- // Function to handle the delay
1738
- const delay = ms => new Promise(res => setTimeout(res, ms));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1739
 
1740
- // Function to perform AJAX requests and compare data
1741
- async function fetchAndCompareData() {
1742
- try {
1743
 
1744
- // Second AJAX request
1745
- let data11 = await $.ajax({
1746
- type: "POST",
1747
- url: "/_submission",
1748
- contentType: "application/json",
1749
- data: JSON.stringify({
1750
- dict1: JSON.stringify(list1),
1751
- spreadsheetId: spreadsheetId,
1752
- pdfpathpath: JSON.stringify(pdfpath),
1753
- path: Object.fromEntries(formData)['measureselectname']
1754
- }),
1755
- dataType: "json"
1756
- });
1757
 
1758
- delrows2 = data11[0];
1759
- console.log('Second AJAX response received:', JSON.stringify(delrows2));
1760
-
1761
- // Compare the data
1762
- if (JSON.stringify(delrows1) === JSON.stringify(delrows2))
1763
- console.log('same')
1764
- else{
1765
- console.log('Differences found:', delrows1, delrows2);
1766
- if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) {
1767
- delrows1=delrows2
1768
- document.getElementById("loading").hidden = false;
1769
- document.getElementById("loading").style.marginTop='20%'
1770
- document.getElementById("loading").style.marginLeft='75%'
1771
-
1772
- updatepreview([pdfpath,Object.fromEntries(formData)['measureselectname']])
1773
-
1774
- // document.getElementsByClassName('imgContainer')[0].src=''
1775
-
1776
- await $.ajax({
1777
- type: "POST",
1778
- url: "/deletemarkupsroute",
1779
- contentType: "application/json",
1780
- data: JSON.stringify({
1781
- dict: JSON.stringify(SimilarAreaDictionary),
1782
- deletedrows: delrows2,
1783
- path: Object.fromEntries(formData)['measureselectname'],
1784
- spreadsheetId: spreadsheetId,
1785
- areaPermArr: JSON.stringify(data[7]),
1786
- section: Object.fromEntries(formData)['selectprojs'],
1787
- pdfpathpath: JSON.stringify(pdfpath)
1788
- }),
1789
- dataType: "json",
1790
- });
1791
 
1792
- console.log('Markups updated');
1793
-
1794
- }
1795
- }
1796
-
1797
- // Wait for the delay
1798
- console.log(`Waiting for ${interval} ms...`);
1799
- await delay(interval);
1800
- console.log('Delay complete. Starting second AJAX request...');
1801
-
1802
- } catch (err) {
1803
- console.error('Error occurred:', err);
1804
- PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1805
- ShowPopUp();
1806
- } finally {
1807
- // Ensure the function is called again after the interval, whether an error occurred or not
1808
- setTimeout(fetchAndCompareData, interval);
1809
  }
 
1810
  }
1811
 
1812
- // Initial call to the function after the initial delay
1813
- setTimeout(fetchAndCompareData, initialDelay);
1814
-
1815
- }
1816
-
1817
-
1818
-
1819
-
1820
- /////////////////////////
1821
  });
1822
  }
1823
  // trial for 2.1 - tameem's code--- delete and deploy in the above if statement
@@ -1867,7 +1879,7 @@ setTimeout(fetchAndCompareData, initialDelay);
1867
  });
1868
 
1869
  var legendbutton= document.createElement("button");
1870
- legendbutton.id='measureADRbutton2';
1871
  legendbutton.innerText='Legend and Data created';
1872
  legendbutton.style.backgroundColor='rgb(5, 43, 235)';
1873
  legendbutton.addEventListener('mouseover',function(){
 
1411
  var buttonContainer = document.createElement('div');
1412
  buttonContainer.style.display = 'flex';
1413
  buttonContainer.style.marginTop = '10px';
1414
+ ///////////////////////////////////////////////////////////////
1415
  var legendbutton = document.createElement("button");
1416
+ legendbutton.className = 'measureADRbutton2';
1417
  legendbutton.innerText = 'Legend and Data created';
1418
  legendbutton.style.backgroundColor = 'rgb(5, 43, 235)';
1419
 
 
1427
  legendbutton.addEventListener('click', function () {
1428
  window.open(spreadsheetLink);
1429
  });
1430
+ //////////////////////////////////////////////////////////////
1431
  var imgbutton = document.createElement("button");
1432
+ imgbutton.className = 'measureADRbutton2';
1433
  imgbutton.innerText = 'Click to view as PDF';
1434
  imgbutton.style.backgroundColor = 'rgb(255,0,255)';
1435
 
 
1443
  imgbutton.addEventListener('click', function () {
1444
  window.open(pdfLink);
1445
  });
1446
+ /////////////////////////////////////////////////////////////
1447
+ var refreshpdfmarkups = document.createElement("button");
1448
+ refreshpdfmarkups.className = 'measureADRbutton2';
1449
+ refreshpdfmarkups.id='refreshpdfmarkups'
1450
+ refreshpdfmarkups.style.backgroundColor = 'rgb(255,80,255)';
1451
+ refreshpdfmarkups.style.padding = '10px 20px';
1452
+
1453
+ // Create the icon element
1454
+ const icon = document.createElement('i');
1455
+ icon.className = 'fa fa-refresh'; // Add Font Awesome classes
1456
+ icon.setAttribute('aria-hidden', 'true'); // Add accessibility attribute
1457
+
1458
+ // Set button text and append the icon
1459
+ // refreshpdfmarkups.textContent = ' Refresh';
1460
+ refreshpdfmarkups.prepend(icon); // Add icon before the text
1461
+
1462
+ refreshpdfmarkups.addEventListener('mouseover', function () {
1463
+ refreshpdfmarkups.style.boxShadow = '0 0 8px 2px rgb(255,80,255)';
1464
+ });
1465
+ refreshpdfmarkups.addEventListener('mouseout', function () {
1466
+ refreshpdfmarkups.style.boxShadow = 'none';
1467
+ });
1468
 
1469
+ ////////////////////////////////////////////////////////////
1470
  buttonContainer.appendChild(legendbutton);
1471
  buttonContainer.appendChild(imgbutton);
1472
+ buttonContainer.appendChild(refreshpdfmarkups);
1473
+
1474
 
1475
  imgContainer.appendChild(imgcanvas);
1476
  imgContainer.appendChild(buttonContainer);
1477
 
1478
  backimg.appendChild(imgContainer);
1479
+ }
1480
  function updatepreview(pdfname){
1481
  console.log('pdfpath',pdfname)
1482
 
 
1721
  var flag=0;
1722
  pdfpath=[];
1723
  pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs'])
1724
+ if (formvalues['selectprojs'].startsWith('1.0') || formvalues['selectprojs'].startsWith('3.2') || formvalues['selectprojs'].startsWith('2.8') || formvalues['selectprojs'].startsWith('3.3')) {
1725
+ const interval = 6000; // Interval in milliseconds
1726
+ let delrows1 = ''; // Initial data storage
1727
+ let delrows2 = ''; // Updated data storage
 
 
 
 
 
1728
 
1729
+ console.log('Starting first AJAX request...');
1730
 
1731
+ // First AJAX request
1732
+ $.ajax({
1733
+ type: "POST",
1734
+ url: "/_submission",
1735
+ contentType: "application/json",
1736
+ data: JSON.stringify({
1737
+ dict1: JSON.stringify(list1),
1738
+ spreadsheetId: spreadsheetId,
1739
+ pdfpathpath: JSON.stringify(pdfpath),
1740
+ path: Object.fromEntries(formData)['measureselectname']
1741
+ }),
1742
+ dataType: "json",
1743
+ success: function (data1) {
1744
+ delrows1 = data1[0];
1745
+ console.log('First AJAX response received:', JSON.stringify(delrows1));
1746
+ },
1747
+ error: function (err) {
1748
+ console.error('Error occurred during first AJAX call:', err);
1749
+ PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1750
+ ShowPopUp();
1751
+ }
1752
+ });
1753
 
1754
+ // Function to perform AJAX requests and compare data
1755
+ async function fetchAndCompareData() {
1756
+ try {
1757
+ console.log('Fetching data...');
1758
+
1759
+ // Second AJAX request
1760
+ const data11 = await $.ajax({
1761
+ type: "POST",
1762
+ url: "/_submission",
1763
+ contentType: "application/json",
1764
+ data: JSON.stringify({
1765
+ dict1: JSON.stringify(list1),
1766
+ spreadsheetId: spreadsheetId,
1767
+ pdfpathpath: JSON.stringify(pdfpath),
1768
+ path: Object.fromEntries(formData)['measureselectname']
1769
+ }),
1770
+ dataType: "json"
1771
+ });
1772
 
1773
+ delrows2 = data11[0];
1774
+ console.log('Second AJAX response received:', JSON.stringify(delrows2));
1775
+
1776
+ // Compare data
1777
+ if (JSON.stringify(delrows1) === JSON.stringify(delrows2)) {
1778
+ console.log('Data is the same');
1779
+ } else {
1780
+ console.log('Differences found:', delrows1, delrows2);
1781
+ if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) {
1782
+ delrows1 = delrows2;
1783
+ document.getElementById("loading").hidden = false;
1784
+ document.getElementById("loading").style.marginTop = '20%';
1785
+ document.getElementById("loading").style.marginLeft = '65%';
1786
+
1787
+ updatepreview([pdfpath, Object.fromEntries(formData)['measureselectname']]);
1788
+
1789
+ await $.ajax({
1790
+ type: "POST",
1791
+ url: "/deletemarkupsroute",
1792
+ contentType: "application/json",
1793
+ data: JSON.stringify({
1794
+ dict: JSON.stringify(SimilarAreaDictionary),
1795
+ deletedrows: delrows2,
1796
+ path: Object.fromEntries(formData)['measureselectname'],
1797
+ spreadsheetId: spreadsheetId,
1798
+ areaPermArr: JSON.stringify(data[7]),
1799
+ section: Object.fromEntries(formData)['selectprojs'],
1800
+ pdfpathpath: JSON.stringify(pdfpath)
1801
+ }),
1802
+ dataType: "json"
1803
+ });
1804
 
1805
+ console.log('Markups updated');
1806
+ }
1807
+ }
1808
 
1809
+ } catch (err) {
1810
+ console.error('Error occurred during fetchAndCompareData:', err);
1811
+ PopupElement.textContent = 'Error occurred. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
1812
+ ShowPopUp();
1813
+ } finally {
1814
+ // Always continue fetching data every 6 seconds
1815
+ console.log(`Waiting for ${interval} ms before next fetch...`);
1816
+ setTimeout(fetchAndCompareData, interval); // Continue the interval
1817
+ }
1818
+ }
 
 
 
1819
 
1820
+ // Initial interval-based call
1821
+ setTimeout(fetchAndCompareData, interval);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1822
 
1823
+ // Button click event listener
1824
+ document.addEventListener("click", function (event) {
1825
+ if (event.target && event.target.id === "refreshpdfmarkups") {
1826
+ console.log('Button clicked. Fetching data immediately...');
1827
+ fetchAndCompareData();
 
 
 
 
 
 
 
 
 
 
 
 
1828
  }
1829
+ });
1830
  }
1831
 
1832
+ /////////////////////////
 
 
 
 
 
 
 
 
1833
  });
1834
  }
1835
  // trial for 2.1 - tameem's code--- delete and deploy in the above if statement
 
1879
  });
1880
 
1881
  var legendbutton= document.createElement("button");
1882
+ legendbutton.className='measureADRbutton2';
1883
  legendbutton.innerText='Legend and Data created';
1884
  legendbutton.style.backgroundColor='rgb(5, 43, 235)';
1885
  legendbutton.addEventListener('mouseover',function(){