Commit af278978 authored by Porter Libby's avatar Porter Libby
Browse files

change query caching

parent 9b7ce3d3
......@@ -128,3 +128,6 @@ label
-moz-osx-font-smoothing: grayscale;
cursor: pointer;
}
.esri-coordinate-conversion{
width: 300px;
}
......@@ -80,15 +80,7 @@ require(["esri/Map", "esri/views/SceneView", "esri/views/MapView", "esri/Graphic
// DATA //
// Arrays (hold on the the db information that gets fetched)
tripnames = [];
tripids = [];
sitenames = [];
siteids = [];
sectornames = [];
sectorids = [];
var query_selection = [null,null,null,null,null];
selected_trip = null;
selected_site = null;
......@@ -100,12 +92,14 @@ function getTrips(){
type: 'GET',
url: '/trips',
success: function(response) {
var tripnames = [];
var tripids = [];
for(x = 0; x < response.length; x++){
tripids.push(response[x].tripid);
tripnames.push(response[x].tripname);
}
console.info('TRIPS');
console.table(tripnames);
console.table(response);
renderTrips(tripnames, tripids);
},
error: function(xhr, status, err) {
......@@ -121,18 +115,20 @@ function getSites(trip_id){
var container = document.getElementById('sectors');
container.innerHTML = "";
selected_trip = trip_id;
query_selection[0] = trip_id;
$.ajax({
type: 'GET',
url: '/sites',
data: {id: trip_id},
success: function(response) {
var sitenames = [];
var siteids = [];
for(x = 0; x < response.length; x++){
sitenames.push(response[x].sitename);
siteids.push(response[x].siteid);
}
console.info('SITES');
console.table(sitenames);
console.table(response);
renderSites(sitenames, siteids);
},
error: function(xhr, status, err) {
......@@ -141,21 +137,24 @@ function getSites(trip_id){
});
}
function getSectors(site_id, trip_id){
function getSectors(site_id){
sectornames = [];
sectorids = [];
selected_site = site_id;
query_selection[1] = site_id;
$.ajax({
type: 'GET',
url: '/sectors',
data: {siteid: site_id, tripid: trip_id},
data: {siteid: site_id, tripid: query_selection[0]},
success: function(response) {
var sectornames = [];
var sectorids = [];
for(x = 0; x < response.length; x++){
sectornames.push(response[x].sectorname);
sectorids.push(response[x].sectorid);
}
console.info('SECTORS');
console.table(sectornames);
console.table(response);
renderSectors(sectornames, sectorids);
},
error: function(xhr, status, err) {
......
......@@ -22,6 +22,7 @@ const pool = new Pool({
})
const getTrips = (request, response) => {
console.info("SELECT tripName, tripID from fieldday_trip;");
pool.query("SELECT tripName, tripID from fieldday_trip;", (error, results) => {
if (error) {
throw error
......@@ -30,6 +31,7 @@ const getTrips = (request, response) => {
})
}
const getSites = (request, response) => {
console.info('SELECT siteName, siteID from fieldday_site where tripid='+ (request.query.id) + ';');
pool.query('SELECT siteName, siteID from fieldday_site where tripid='+ (request.query.id) + ';', (error, results) => {
if (error) {
throw error
......@@ -38,6 +40,7 @@ const getSites = (request, response) => {
})
}
const getSectors = (request, response) => {
console.info('SELECT sectorname, sectorid from fieldday_sector where tripid='+ (request.query.tripid) + ' and siteid=' + (request.query.siteid) + ';');
pool.query('SELECT sectorname, sectorid from fieldday_sector where tripid='+ (request.query.tripid) + ' and siteid=' + (request.query.siteid) + ';', (error, results) => {
if (error) {
throw error
......
......@@ -4,12 +4,13 @@
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Datavis 2.0</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" href="https://js.arcgis.com/4.12/esri/css/main.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://js.arcgis.com/4.12/"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
<div id='mapView'>
......
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