Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nilesh-tawari committed Oct 5, 2017
1 parent 1c0e5ce commit fbf37f0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 45 deletions.
16 changes: 12 additions & 4 deletions chronqc/chronqc_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ def myQuery(Runname, Panel, status, chartid,startdate,enddate,annotation):
print("Enter")
todate = date.today().strftime('%Y-%m-%d')
annotation = '{0} : {1}'.format(todate, annotation)
mycursor.execute("UPDATE Run_Annotations SET Annotation = Annotation || '<br>' || ? , Status = ?, GraphID = ?, Date1 = ?, Date2 = ? WHERE Run = ? and Panel = ?;", (annotation.decode('utf8'),status,chartid,startdate,enddate,Runname,Panel))
try:
mycursor.execute("UPDATE Run_Annotations SET Annotation = Annotation || '<br>' || ? , Status = ?, GraphID = ?, Date1 = ?, Date2 = ? WHERE Run = ? and Panel = ?;", (annotation,status,chartid,startdate,enddate,Runname,Panel))
except:
mycursor.execute("UPDATE Run_Annotations SET Annotation = Annotation || '<br>' || ? , Status = ?, GraphID = ?, Date1 = ?, Date2 = ? WHERE Run = ? and Panel = ?;", (annotation.decode("utf-8"),status,chartid,startdate,enddate,Runname,Panel))
connection.commit()
print(mycursor.rowcount, " rows")
if mycursor.rowcount == 0:
mycursor.execute("Insert into Run_Annotations (Annotation, Run, Panel, Status, GraphID, Date1, Date2) values(?,?,?,?,?,?,?);", (annotation.decode('utf8'), Runname, Panel, status,chartid,startdate,enddate))
try:
mycursor.execute("Insert into Run_Annotations (Annotation, Run, Panel, Status, GraphID, Date1, Date2) values(?,?,?,?,?,?,?);", (annotation, Runname, Panel, status,chartid,startdate,enddate))
except:
mycursor.execute("Insert into Run_Annotations (Annotation, Run, Panel, Status, GraphID, Date1, Date2) values(?,?,?,?,?,?,?);", (annotation.decode("utf-8"), Runname, Panel, status,chartid,startdate,enddate))
connection.commit()
return

Expand All @@ -73,8 +79,10 @@ def myQuery(Runname, Panel, status, chartid,startdate,enddate,annotation):

@route('/datedataQuery/<Date>/<Panel>/<Notes>')
def myDateQuery(Date, Panel, Notes):
mycursor.execute('''INSERT INTO Date_Annotations (Annotated_date, Notes, Panel)
VALUES (?,?,?);''', (Date, Notes,Panel))
try:
mycursor.execute('''INSERT INTO Date_Annotations (Annotated_date, Notes, Panel) VALUES (?,?,?);''', (Date, Notes,Panel))
except:
mycursor.execute('''INSERT INTO Date_Annotations (Annotated_date, Notes, Panel) VALUES (?,?,?);''', (Date, Notes.decode("utf-8"),Panel))
connection.commit()
return

Expand Down
60 changes: 19 additions & 41 deletions chronqc/templates/base_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -551,23 +551,6 @@ <h4 class="modal-title">Invalid Date!</h4>
</div>
</div>

<div id="ann_added" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Annotation added!</h4>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>


<div class="modal fade" id="myModalHorizontal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Expand Down Expand Up @@ -754,20 +737,20 @@ <h1>Summary Table</h1>
csv += formatRows($rows.map(grabRow)) + '"';

// Data URI
var csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
var csvData = 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodeURIComponent(csv);

// For IE (tested 10+)
if (window.navigator.msSaveOrOpenBlob) {
var blob = new Blob([decodeURIComponent(encodeURI(csv))], {
type: "text/csv;charset=utf-8;"
type: "data:text/csv;charset=utf-8,%EF%BB%BF"
});
navigator.msSaveBlob(blob, filename);
} else {
jQuery(this)
.attr({
'download': filename
,'href': csvData
//,'target' : '_blank' //if you want it to open in a new window
,'target' : '_blank' //if you want it to open in a new window
});
}

Expand All @@ -791,31 +774,21 @@ <h1>Summary Table</h1>
return $cols.map(grabCol)
.get().join(tmpColDelim);
}
// Grab and format a column from the table
function grabCol(j,col){
var $col = jQuery(col);
if (jQuery(col).prop("tagName")=="TD"){
jQuery(col).find("br").replaceWith("; ");
jQuery(col).find("br").replaceWith("<br>\n ");
}
var $text = jQuery(col).text();
return $text.replace('"', '""'); // escape double quotes
return $text.replace('"', '""');

}
}


// This must be a hyperlink

jQuery("#exporttocsv").on('click', function(event) {
// CSV

var args = [jQuery('#SummaryTable>table'), 'Chronqc_' + panelname + '_Summary_Table.csv'];
exportTableToCSV.apply(this, args);

// If CSV, don't do event.preventDefault() or return false
// We actually need this to be a typical hyperlink
});


var scrolling = null;

function scroll_up() {
Expand Down Expand Up @@ -1286,6 +1259,13 @@ <h1>Summary Table</h1>
}
}
}

function stateChange(newState) {
setTimeout(function(){
if(newState == -1){window.location.reload(true);}
}, 250);
}

////////////////////////////////////////////////////////////////////////////////////////
// Multiple column bar chart
function multiColumnBarPlotter(e) {
Expand Down Expand Up @@ -1348,9 +1328,9 @@ <h1>Summary Table</h1>

function toDateDate(dateStr) {
dateStr = dateStr.replace(/\//g, '-').replace(/\./g, '-').replace(/,/g, '-')
console.log(dateStr)
const [year, month, day] = dateStr.split("-")
if (( year == undefined || year < 1000 || year > 3000) || (month== undefined||month < 1 || month >12) || ( day==undefined || day < 00 || day > 31 )) {
var date = new Date(dateStr)
if (date=="Invalid Date" || ( year == undefined || year < 1000 || year > 3000) || (month== undefined||month < 1 || month >12) || ( day==undefined || day < 00 || day > 31 )) {
p = "Please valid date in YYYY-MM-DD format"
$j(".modal .modal-body #invaliddatemodalp").html( p );
$j('#invaliddatemodal').modal("show");
Expand Down Expand Up @@ -1384,10 +1364,11 @@ <h1>Summary Table</h1>
annotation = annotation.replace(/\\/g, '&slashbackback');
annotation = annotation.replace(/\//g, '&backslash');
$j.get("http://localhost:8000/dataQuery/" + runname + "/" + panelname + "/" + dbstatus + "/" + chartid + "/" + startdate + "/" + enddate + "/" + annotation, function(result) {})
$j('#ann_added').modal("show");
/*$j('#ann_added').modal("show");
$j('#ann_added').on('hidden.bs.modal', function () {
window.location.reload(true);
})
})*/
state = stateChange(-1)

}
}
Expand Down Expand Up @@ -1478,10 +1459,7 @@ <h1>Summary Table</h1>
Notes = Notes.replace(/\//g, 'backslash');
Notes = Notes.replace(/\\/g, 'slashbackback');
$j.get("http://localhost:8000/datedataQuery/" + Date + "/" + panelname + "/" + Notes, function(result) {})
$j('#ann_added').modal("show");
$j('#ann_added').on('hidden.bs.modal', function () {
window.location.reload(true);
})
state = stateChange(-1)
}
}

Expand Down

0 comments on commit fbf37f0

Please sign in to comment.