<%@ LANGUAGE="JSCRIPT" %><% // // 23-Dec-08 rbd New DB caching hack // 20-Jan-11 rbd GEM:571 - Set our parent iframe's height. // 22-Jan-10 rbd GEM:571 - Do this when receiving POST responses as well. // Make IE fudge distance a manifest constant. Increase IE // fudge to 18. Add manifest constant for extra display dist. // Fix deletion, iframe name changed. // 06-Feb-12 rbd GEM:296 - Enhance for creating new Projects. // 12-Apr-12 rbd GEM:842 - Fix new project for single user case // 22-Jan-14 rbd GEM:1083 No more DBRelay hack :-) // 13-Nov-14 rbd GEM:342 change behavior for pause/resume of projects, also // found code for GEM:1245 in here, and it has been removed. // 22-Mar-15 rbd GEM:1318 Default new Project contact info to Observer/User // if the latter already exists. // 17-Jan-19 rbd GEM:1660 Modern DOCTYPE and HTML declarations // 18-Jan-19 rbd GEM:1663 Modernize alerting with SweetAlert. // 19-Jan-19 rbd GEM:1664 Fix validation, needed an additional call on chained validations. // 07-Feb-18 rbd GEM:1766 Change usage of => to equivalent function() syntax for IE11 // 24-Feb-21 rbd GEM:1746 Add "Are you sure?" to all mass operation buttons. // var DB = Scheduler.Database; var formid = Request.Form("id").Item; // "Item" gets the string from the object var R; var newProject = "no"; if(formid == "NPR") { var cU = DB.Users; var eU = new Enumerator(cU); var uFound = false; for(; !eU.atEnd(); eU.moveNext()) { var dbU = eU.item(); if(dbU.Name == User.Name) { DB.CurrentUser = dbU.ID; // Found existing user match uFound = true; break; // Done! } } if(!uFound) { // Need to create new user dbU = DB.AddNewUser(); dbU.Name = User.Name; dbU.Update(); DB.CurrentUser = dbU.ID; } R = DB.AddNewProject(); R.Name = "New Project " + R.ID; // Uniquify name R.ContactName = User.Name; // Add special ACP linkage info if(User.Name != "Observatory Operator") { R.ContactName += " [ACP " + User.Username + "]"; if(User.WantsCompress) R.ContactName += "#"; } if (uFound) { R.ContactEmail = dbU.Email; // Existing user, start with that contact info R.ContactOrganization = dbU.Organization; } else { R.ContactEmail = "your@email.here"; } R.Update(); newProject = "yes"; DB.CurrentUser = 0; // RESTORE TO ALL USERS! } else { R = DB.Project(Request.Form("id")); // Existing Project } Response.ExpiresAbsolute = new Date("Jan 1, 2000").getVarDate(); // Expire even with clocdk offsets Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); if(Request.ServerVariables("REQUEST_METHOD").toLowerCase() != "post") { // === GET === %> Project

This project belongs to <%= R.User.Name %>

Project Name:
Description:
Observers:
External ID:
Contact Name:
Contact Mail:
Contact Org:


  Pause   Resume   Delete   Save Changes



  Resubmit All Plans   Resubmit Failed Plans   Disable All Plans

<% } else { // === POST === var np = 0; try { DB.BeginTransaction(); // Preserve database integrity! switch(Request.Form("op").Item.toLowerCase()) { case "pause": R.Disabled = true; R.Update(); Response.Write("Project successfully paused"); // WARN: "paused" is used in rUpdatePauseResume() above break; case "resume": R.Disabled = false; R.Update(); Response.Write("Project successfully resumed"); break; case "delete": DB.DeleteProject(R); Response.Write("Deleted"); break; case "displans": // Disable all Plans if(R.Plans.Count === 0) { Response.Write("No plans in this Project"); } else { var eR = new Enumerator(R.Plans); for(; !eR.atEnd(); eR.moveNext()) { var P = eR.item(); if(P.Status != 2) // Do not disable running plans! (typ) P.Disable(); // Don't UpdateStatus(), this does Refresh()!! (typ) } Response.Write("All plans successfully disabled"); } break; case "resubplans": // Resubmit all plans if(R.Plans.Count === 0) { Response.Write("No plans in this Project"); } else { var eR = new Enumerator(R.Plans); for(; !eR.atEnd(); eR.moveNext()) { var P = eR.item(); if(P.Status != 2) // 2 = running P.Resubmit(); } Response.Write("All plans successfully resubmitted"); } break; case "resubfailedplans": // Resubmit failed plans if(R.Plans.Count === 0) { Response.Write("No plans in this Project"); } else { var eR = new Enumerator(R.Plans); for(; !eR.atEnd(); eR.moveNext()) { var P = eR.item(); if(P.Status == 4) { // 4 = failed P.Resubmit(); np += 1; } } if (np === 0) Response.Write("No failed plans to process"); else Response.Write(np + " failed plan(s) successfully resubmitted"); } break; case "update": R.Name = Request.Form("rName"); R.Description = Request.Form("rDesc"); R.Observers = Request.Form("rObs"); R.ExternalID = Request.Form("rExtID"); R.ContactName = Request.Form("rContName"); R.ContactEMail = Request.Form("rContMail"); R.ContactOrganization = Request.Form("rContOrg"); R.Update(); Response.Write("Project successfully updated."); break; default: break; } DB.CommitTransaction(); } catch(ex) { DB.RollbackTransaction(); Response.Write(ex.Description); } } %>