12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- /* Authors : Carlos C. Corrada-Bravo
- David J. Ortiz-Rivera
-
- Organization : Centro de Desarrollo y Consultoria Computacional
- Project : OPASO Material Registry
- File : menu.js
- Description : Generate user menu */
-
- /* fetch authorized labs */
- $(document).ready(menu);
-
- /* menu() - generate user menu */
- function menu(){
- /* query server */
- $.post("/scripts/opaso",{query: 2},function(data){
- // console.log(data);
- /* extract response */
- let response = JSON.parse(data);
- let status = response["status"];
-
- /* handle by status */
- switch(status){
- case "success": /* on success, generate menu */
- /* extract authorized laboratories */
- let auth = response["authorized"];
- let r = element_gen("div",{class: "lab-row"});
-
- /* generate laboratory links */
- for(var lab in auth){
- /* generate elements */
- let room = element_gen("div",{class: "lab-room",text: auth[lab]["lab_room"]});
- let p = `(${auth[lab]["access_level"].charAt()})`;
- let privileges = element_gen("p",{class: "privileges-indicator",text: p});
-
- /* set lab link */
- let href = `/laboratory?lab_id=${auth[lab]["lab_id"]}`;
- let link = element_gen("a",{class: "lab-link",href: href,childs:{room,privileges}});
- let w = element_gen("div",{class: "col-lg-3 laboratory-wrapper"});
-
- w.append(link);
- r.append(w);
- }
- $(".laboratories").append(r);
-
- /* display menu */
- $(".processing").hide();
- setTimeout(function(){
- $(".main-wrapper").show();
- },250);
- break;
-
- case "expired": /* on expired, redirect to index */
- window.location.href = "/?error=session_expired";
- break;
-
- default: /* on error, display message */
- set_alert(status,response["message"]);
- break;
- }
- });
- }
|