Commit 1490f0bf authored by Porter Libby's avatar Porter Libby
Browse files

more function to query permalinks

parent e9e724b3
......@@ -28,7 +28,7 @@ app.get('/streamings', q.getStreamings);
// LISTEN
app.listen(process.env.PORT || 3000, function(){
app.listen(process.env.PORT || 4000, function(){
console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});
......@@ -137,6 +137,24 @@ label
-webkit-text-fill-color: transparent;
font-size: 20px;
}
#prompt-text button{
color: black;
font-size: 20px;
background-color: rgba(0,0,0,0.5);
}
#prompt-text .button_enable{
color: black;
font-size: 20px;
background-color: rgba(0,0,0,0.0);
}
#prompt-text button:hover{
background-color: rgba(0,0,0,0.5);
}
#prompt-text .button_enable:hover{
color: black;
font-size: 20px;
background-color: rgba(0,0,0,0.2);
}
.lds-ellipsis {
display: inline-block;
......@@ -192,4 +210,4 @@ label
100% {
transform: translate(19px, 0);
}
}
\ No newline at end of file
}
......@@ -23,10 +23,12 @@ This is the entry point so that both of these options in the descision tree can
*/
function setReading(){
query_type = 0;
document.getElementById("button_permalink").classList.remove("button_enable");
getTrips(); // get top level of data and render to the next block on the form
}
function setStreaming(){
query_type = 1;
document.getElementById("button_permalink").classList.remove("button_enable");
getTrips(); // get top level of data and render to the next block on the form
}
/*
......@@ -52,6 +54,8 @@ function getTrips(){
document.getElementById('streamingdates').innerHTML = "";
document.getElementById('streaming').innerHTML = "";
document.getElementById('reading').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
$.ajax({
type: 'GET',
url: '/trips',
......@@ -84,6 +88,7 @@ function getSites(trip_id){
document.getElementById('streamingdates').innerHTML = "";
document.getElementById('streaming').innerHTML = "";
document.getElementById('reading').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#trips-ls','trips-button');
......@@ -120,6 +125,7 @@ function getSectors(site_id){
document.getElementById('streamingdates').innerHTML = "";
document.getElementById('streaming').innerHTML = "";
document.getElementById('reading').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#sites-ls','sites-button');
......@@ -150,6 +156,7 @@ function getSpots(sector_id){
document.getElementById('streamingplatform').innerHTML = "";
document.getElementById('streaming').innerHTML = "";
document.getElementById('reading').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#sectors-ls','sectors-button');
......@@ -175,6 +182,7 @@ function getSpots(sector_id){
function getReadings(spot_id){
document.getElementById('data-prompt').innerHTML = "Pick a set of data to visualize";
document.getElementById('reading').innerHTML = placeholderHTML;
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#spots-ls','spots-button');
......@@ -202,6 +210,7 @@ function getStreamingsPlatforms(sector_id){
document.getElementById('streamingplatform').innerHTML = placeholderHTML;
document.getElementById('streamingdates').innerHTML = "";
document.getElementById('streaming').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#sectors-ls','sectors-button');
......@@ -229,6 +238,7 @@ function getStreamingsDates(platformid){
document.getElementById('data-prompt').innerHTML = "Pick a set of data to visualize";
document.getElementById('streamingdates').innerHTML = placeholderHTML;
document.getElementById('streaming').innerHTML = "";
document.getElementById("button_permalink").classList.remove("button_enable");
togglediv('#streamingsplatforms-ls','streamingsplatforms-button');
query_selection[4] = platformid;
......@@ -256,6 +266,7 @@ function getStreamingsDates(platformid){
function getStreamings(date){
document.getElementById('data-prompt').innerHTML = "Loading your data selection...";
document.getElementById('streaming').innerHTML = placeholderHTML;
document.getElementById("button_permalink").classList.add("button_enable");
togglediv('#streamingsdates-ls','streamingsdates-button');
query_selection[5] = date;
......@@ -420,6 +431,7 @@ function divide(data_arr){
}
function loadQuery(params){
console.log('loading query');
document.getElementById("button_permalink").classList.remove("button_enable");
// mode, trip, site, sector, spot, platform, date
// /?1/26/1/1/ev1/2018-06-05
if (params.length == 7 && params[1] == 1){ // streaming query
......@@ -432,18 +444,30 @@ function loadQuery(params){
}
console.log(query_selection);
console.log(params);
document.getElementById('query_type').innerHTML = "<label><strong>Query loaded from permalink!</br><button onclick='removeQuery()'>Return to regular selection</button></strong></label>";
getStreamings(query_selection[5]);
}
function buildQuery(){
query_string = document.location.href.split('/?')[0];
query_string += "?" + "query"
query_string += "/" + query_type
if (query_type == 1){ // streaming
query_string += "/" + query_selection[0];
query_string += "/" + query_selection[1];
query_string += "/" + query_selection[2]; // skip spot
query_string += "/" + query_selection[4];
query_string += "/" + query_selection[5];
bt = document.getElementById("button_permalink")
if (bt.classList.contains("button_enable")){
query_string = document.location.href.split('/?')[0];
query_string += "?" + "query"
query_string += "/" + query_type
if (query_type == 1){ // streaming
query_string += "/" + query_selection[0];
query_string += "/" + query_selection[1];
query_string += "/" + query_selection[2]; // skip spot
query_string += "/" + query_selection[4];
query_string += "/" + query_selection[5];
}
console.log(query_string);
document.getElementById('permalink_out').innerHTML = query_string;
}else{
console.warn('Incomplete Query!')
}
console.log(query_string);
}
function removeQuery(){
current = document.location.href;
base = current.split('?')[0];
location.replace(base);
}
\ No newline at end of file
......@@ -45,7 +45,9 @@ function createGraph(dataset, title,color){
}
function addData(chart, label_arr, data, title_arr,color) {
console.warn('UPDATING CHART: this might take a minute!');
chart.destroy();
if (chart){
chart.destroy();
}
chart = new Chart(document.getElementById("line-chart"), {
type: 'scatter',
data: {},
......
......@@ -87,7 +87,7 @@
<div id='dataView'>
<div id='data'>
<div class='data-catagory'>
<div class='data-catagory' id='query_type'>
<div class='data-header' style='padding-bottom:15px;''>
<input class="data-radio form-radio" onchange="setReading();" type="radio" name="data-type" id="readings"/>
<label for="readings"><strong>Readings</strong></label>
......@@ -106,7 +106,11 @@
<div class='data-catagory' id='reading'></div>
<div id='data-prompt-box'>
<strong id='prompt-text'>
<span id='data-prompt'>Select a data type</span>
</br>
<button onclick='buildQuery()' id='button_permalink'>Create Permalink</button>
<span id='permalink_out'></span>
</strong>
</div>
</div>
......
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