First functioning version with server calls.

This commit is contained in:
Joe Tretter
2020-03-09 10:49:19 -05:00
parent 9fbcf07cb5
commit 34ff5ec68f
5 changed files with 194 additions and 31 deletions

View File

@@ -29,18 +29,26 @@ let beforeShowDay=(theDate)=>{
let isoDate=theDate.toISOString().substr(0,10);
console.log("BeforeShow",isoDate,theDate);
if (!filterContext.availableDates.dates[isoDate]) {
let isDateFound=false;
for (let i=0;i<filterContext.availableDates.length;i++){
if (filterContext.availableDates[i].Date===theDate.toISOString().substr(0,10)){
isDateFound=true;
break;
};
}
if (!isDateFound) {
return {enabled:false, tooltip:"No data"};
}
}
let fetchSymbols=()=>{
$.ajax({
url:"https://netsquat.ddns.kawomi.com/wc/raw/tosym"
$.get({
url:"http://localhost:3000/getSymbols"
}).done(response=>{
let allSymbols=JSON.parse(response);
let allSymbols=response;
console.log(allSymbols);
refreshSymbolList(allSymbols.symbols);
refreshSymbolList(allSymbols);
});
}
@@ -54,8 +62,8 @@ let symbolChanged=_=>{
$("#datePicker").datepicker({beforeShowDay:beforeShowDay})
.on('changeDate', (e)=>{
console.log("DatePicker changed date",e.date);
filterContext.selectedDate=e.date.toISOString().substr(0,10);
showTimesForDay(filterContext.selectedDate);
filterContext.theDate=e.date.toISOString().substr(0,10);
showTimesForDay(filterContext.theDate);
});
});
}
@@ -68,29 +76,37 @@ let timeChanged=()=>{
let requestOptionChain=()=>{
$.ajax({
url:"https://netsquat.ddns.kawomi.com/wc/raw/spy"
url:"http://localhost:3000/getOptionChain?Date=" + filterContext.theDate + "&Symbol=" + filterContext.theSymbol + "&Time="+filterContext.selectedTime
}).done(response=>{
dta=JSON.parse(response);
dta=JSON.parse(response[0].Data);
console.log("received",dta);
displayOptionChain();
});
}
let showTimesForDay=(theDate)=>{
let lbTime=$("#lbTime");
lbTime.empty();
allTimes = filterContext.availableDates.dates[theDate];
for (let i=0;i<allTimes.length;i++){
theTime=allTimes[i];
lbTime.append($(`<option>${theTime}</option>`))
}
let showTimesForDay=()=>{
return $.ajax({
url:"http://localhost:3000/getTimes?Date=" + filterContext.theDate + "&Symbol=" + filterContext.theSymbol
}).done(response=>{
let availableTimes=response;
console.log(availableTimes);
let lbTime=$("#lbTime");
lbTime.empty();
allTimes = availableTimes;
for (let i=0;i<allTimes.length;i++){
theTime=allTimes[i].Time;
lbTime.append($(`<option>${theTime}</option>`))
}
});
}
let getAvailDatesForSymbol=(theSymbol)=>{
return $.ajax({
url:"https://netsquat.ddns.kawomi.com/wc/raw/availDates"
url:"http://localhost:3000/getDates"
}).done(response=>{
let availableDates=JSON.parse(response);
let availableDates=response;
console.log(availableDates);
filterContext.availableDates=availableDates;
});
@@ -100,7 +116,7 @@ let refreshSymbolList=(allSymbols)=>{
let lbSymbol=$("#lbSymbol");
lbSymbol.empty();
for (let i=0;i<allSymbols.length;i++){
theSymbol=allSymbols[i];
theSymbol=allSymbols[i].Symbol;
console.log(theSymbol);
lbSymbol.append($(`<option>${theSymbol}</option>`))
}