Commit a59f076a by Daniel Bawag

WG-36 - Added User ID in output files' names

parent c021d691
...@@ -31,6 +31,7 @@ function validateForm() { ...@@ -31,6 +31,7 @@ function validateForm() {
for (let i = 0; i < credObj.length; i++) { for (let i = 0; i < credObj.length; i++) {
// console.log(credObj[i].username + " " + credObj[i].password); // console.log(credObj[i].username + " " + credObj[i].password);
if ((un == credObj[i].username) && (pw == credObj[i].password)) { if ((un == credObj[i].username) && (pw == credObj[i].password)) {
sessionStorage.setItem('user_id', un);
window.location = "index.html"; window.location = "index.html";
return false; return false;
} }
......
...@@ -23,7 +23,7 @@ function WriteForm(e,metrics) ...@@ -23,7 +23,7 @@ function WriteForm(e,metrics)
XML.Close(); XML.Close();
var final_xml=XML.ToString().replace(/</g,"\n<").replace(/&lt;/g,"\<").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/\n<\//g,"</").replace(/<\/xml>/g,"\n</xml>"); var final_xml=XML.ToString().replace(/</g,"\n<").replace(/&lt;/g,"\<").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/\n<\//g,"</").replace(/<\/xml>/g,"\n</xml>");
var myFile = new File([final_xml], "UserID" + "_" + File_Name + ".xml", {type: "text/plain;charset=utf-8"}); var myFile = new File([final_xml], sessionStorage.getItem('user_id') + "_" + File_Name + ".xml", {type: "text/plain;charset=utf-8"});
// saveAs(myFile); // saveAs(myFile);
let formData = new FormData(); let formData = new FormData();
formData.append("file", myFile); formData.append("file", myFile);
......
...@@ -101,14 +101,14 @@ const saveMetrics = (metrics) => { ...@@ -101,14 +101,14 @@ const saveMetrics = (metrics) => {
let last = rows[size]; let last = rows[size];
let avg = last[last.length - 1]; let avg = last[last.length - 1];
let newAvg = (avg + metrics.rate) / (size + 1); let newAvg = ((avg * size) + metrics.rate) / (size + 1);
rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, newAvg]); rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, newAvg]);
} }
var myFile = new File( var myFile = new File(
[(rows.map(e => e.join(",")).join("\n"))], [(rows.map(e => e.join(",")).join("\n"))],
'UserID' + '_Metrics_' + (new Date()).toISOString().slice(0,10).replace(/-/g,"") + ".csv", sessionStorage.getItem('user_id') + '_Metrics_' + (new Date()).toISOString().slice(0,10).replace(/-/g,"") + ".csv",
{type: "text/plain;charset=utf-8"} {type: "text/plain;charset=utf-8"}
); );
let formData = new FormData(); let formData = new FormData();
......
...@@ -36,6 +36,7 @@ endButton.addEventListener("click", function(){ ...@@ -36,6 +36,7 @@ endButton.addEventListener("click", function(){
//clear localStorage //clear localStorage
localStorage.clear(); localStorage.clear();
sessionStorage.clear();
//if form is submitted or fields are blank, delete database //if form is submitted or fields are blank, delete database
if(submitted || checkForm(form)){ if(submitted || checkForm(form)){
......
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