diff --git a/static/index.html b/static/index.html index 07726e37..933fb02d 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@ /* TODO: move into own file. run tests? */ function receivedMessage(msg) { console.log("new message!", msg); - // TODO: + // TODO: // 1. build a sub element id= sessionDate (need to store that field still?) if el w/id doesn't exist // 2. append to that element instead of directly to "sequences". then we can later hide finished sequences @@ -17,17 +17,57 @@ add_new_series(data['content']) } } + +function mktable(data){ + const keys = [ + "SequenceType", "PED_major", "TR", "TE", "Matrix", + "PixelResol", "BWP", "BWPPE", "FA", "TA", + "FoV", "Shims"] + + let table = ""; + /*Object.entries(data['input']).map( + ([k,v]) => ``) + + */ + let rows = ["", "", ""] + for(const k of keys){ + conf_css = ((k in data['errors'])?"no-conform":"conform") + rows[0] += ``;; + rows[1] += ``; + rows[2] += ``; + } + console.log(rows); + table += `${rows[0]}` + + `${rows[1]}` + + `${rows[2]}`; + table += "
${k}${v}${data['template'][k]}
inputtemplate${k}${data['input'][k]}${data['template'][k]}
"; + return(table) +} + +/* what to do with type=="new" data: a dicom from a new sequence */ function add_new_series(data) { let el = document.createElement("li"); el.className = data['conforms']?'conform':'no-conform'; dcm_in = data['input']; errors = data['errors']; - identity = `${dcm_in['Project']}/${dcm_in['SequenceName']} @ ${dcm_in['SeriesNumber']}`; - note = Object.keys(errors).length==0?'💯':JSON.stringify(errors); + let summary = `${dcm_in['SeriesNumber']} ${dcm_in['Project']}/${dcm_in['SequenceName']}`; + //JSON.stringify(errors); + for(k of Object.keys(errors)){ + summary += `
${k} should be ${errors[k]['expect']} but have ${errors[k]['have']}` + } + + const details_status = data['conforms']?'':'open'; + let note = `
${summary}` + + note += "
" + mktable(data) + "
"; + console.log("...note:", note); - el.textContent = `${identity}: ${note}`; + el.innerHTML=note; + // TODO: per scanner tab let seq = document.getElementById("sequences"); + // clear waiting if(seq.innerHTML == "waiting for scanner"){ seq.innerHTML = "" @@ -35,10 +75,18 @@ seq.prepend(el); //appendChild(el); } +/* connects socket to main dispatcher `recievedMessages` */ function update_via_ws() { const ws = new WebSocket("ws://127.0.0.1:5000/"); ws.addEventListener('message', receivedMessage); } + +function simdata(){ + let data = document.getElementById("debug"); + data = JSON.parse(data.value) + add_new_series(data) +} + window.onload = update_via_ws; @@ -48,5 +96,30 @@
+ + diff --git a/static/main.css b/static/main.css index b942a3b4..c300c12f 100644 --- a/static/main.css +++ b/static/main.css @@ -1,6 +1,6 @@ html { - max-width: 70ch; - padding: 3em 1em; + /*max-width: 70ch;*/ + padding: 1em 2em; margin: auto; line-height: 1.75; font-size: 1.25em; @@ -8,3 +8,13 @@ html { .conform { background: lightgreen; } .no-conform { background: pink; } + +li { + margin: 1em 0 1em 0; /* top and bottom padding */ + list-style: none; +} +details>table {font-size: smaller;} +td.no-conform { background: red} +th.no-conform { background: red} +td.conform { background: gray; font-size: .5em;} +th.conform { background: lightgreen; font-size: .5em;}